@vue/compat 3.3.6 → 3.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -354,117 +354,120 @@ function onScopeDispose(fn) {
354
354
  }
355
355
  }
356
356
 
357
- const createDep = (effects) => {
358
- const dep = new Set(effects);
359
- dep.w = 0;
360
- dep.n = 0;
361
- return dep;
362
- };
363
- const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
364
- const newTracked = (dep) => (dep.n & trackOpBit) > 0;
365
- const initDepMarkers = ({ deps }) => {
366
- if (deps.length) {
367
- for (let i = 0; i < deps.length; i++) {
368
- deps[i].w |= trackOpBit;
369
- }
370
- }
371
- };
372
- const finalizeDepMarkers = (effect) => {
373
- const { deps } = effect;
374
- if (deps.length) {
375
- let ptr = 0;
376
- for (let i = 0; i < deps.length; i++) {
377
- const dep = deps[i];
378
- if (wasTracked(dep) && !newTracked(dep)) {
379
- dep.delete(effect);
380
- } else {
381
- deps[ptr++] = dep;
382
- }
383
- dep.w &= ~trackOpBit;
384
- dep.n &= ~trackOpBit;
385
- }
386
- deps.length = ptr;
387
- }
388
- };
389
-
390
- const targetMap = /* @__PURE__ */ new WeakMap();
391
- let effectTrackDepth = 0;
392
- let trackOpBit = 1;
393
- const maxMarkerBits = 30;
394
357
  let activeEffect;
395
- const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
396
- const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
397
358
  class ReactiveEffect {
398
- constructor(fn, scheduler = null, scope) {
359
+ constructor(fn, trigger, scheduler, scope) {
399
360
  this.fn = fn;
361
+ this.trigger = trigger;
400
362
  this.scheduler = scheduler;
401
363
  this.active = true;
402
364
  this.deps = [];
403
- this.parent = void 0;
365
+ /**
366
+ * @internal
367
+ */
368
+ this._dirtyLevel = 3;
369
+ /**
370
+ * @internal
371
+ */
372
+ this._trackId = 0;
373
+ /**
374
+ * @internal
375
+ */
376
+ this._runnings = 0;
377
+ /**
378
+ * @internal
379
+ */
380
+ this._queryings = 0;
381
+ /**
382
+ * @internal
383
+ */
384
+ this._depsLength = 0;
404
385
  recordEffectScope(this, scope);
405
386
  }
387
+ get dirty() {
388
+ if (this._dirtyLevel === 1) {
389
+ this._dirtyLevel = 0;
390
+ this._queryings++;
391
+ pauseTracking();
392
+ for (const dep of this.deps) {
393
+ if (dep.computed) {
394
+ triggerComputed(dep.computed);
395
+ if (this._dirtyLevel >= 2) {
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ resetTracking();
401
+ this._queryings--;
402
+ }
403
+ return this._dirtyLevel >= 2;
404
+ }
405
+ set dirty(v) {
406
+ this._dirtyLevel = v ? 3 : 0;
407
+ }
406
408
  run() {
409
+ this._dirtyLevel = 0;
407
410
  if (!this.active) {
408
411
  return this.fn();
409
412
  }
410
- let parent = activeEffect;
411
413
  let lastShouldTrack = shouldTrack;
412
- while (parent) {
413
- if (parent === this) {
414
- return;
415
- }
416
- parent = parent.parent;
417
- }
414
+ let lastEffect = activeEffect;
418
415
  try {
419
- this.parent = activeEffect;
420
- activeEffect = this;
421
416
  shouldTrack = true;
422
- trackOpBit = 1 << ++effectTrackDepth;
423
- if (effectTrackDepth <= maxMarkerBits) {
424
- initDepMarkers(this);
425
- } else {
426
- cleanupEffect(this);
427
- }
417
+ activeEffect = this;
418
+ this._runnings++;
419
+ preCleanupEffect(this);
428
420
  return this.fn();
429
421
  } finally {
430
- if (effectTrackDepth <= maxMarkerBits) {
431
- finalizeDepMarkers(this);
432
- }
433
- trackOpBit = 1 << --effectTrackDepth;
434
- activeEffect = this.parent;
422
+ postCleanupEffect(this);
423
+ this._runnings--;
424
+ activeEffect = lastEffect;
435
425
  shouldTrack = lastShouldTrack;
436
- this.parent = void 0;
437
- if (this.deferStop) {
438
- this.stop();
439
- }
440
426
  }
441
427
  }
442
428
  stop() {
443
- if (activeEffect === this) {
444
- this.deferStop = true;
445
- } else if (this.active) {
446
- cleanupEffect(this);
447
- if (this.onStop) {
448
- this.onStop();
449
- }
429
+ var _a;
430
+ if (this.active) {
431
+ preCleanupEffect(this);
432
+ postCleanupEffect(this);
433
+ (_a = this.onStop) == null ? void 0 : _a.call(this);
450
434
  this.active = false;
451
435
  }
452
436
  }
453
437
  }
454
- function cleanupEffect(effect2) {
455
- const { deps } = effect2;
456
- if (deps.length) {
457
- for (let i = 0; i < deps.length; i++) {
458
- deps[i].delete(effect2);
438
+ function triggerComputed(computed) {
439
+ return computed.value;
440
+ }
441
+ function preCleanupEffect(effect2) {
442
+ effect2._trackId++;
443
+ effect2._depsLength = 0;
444
+ }
445
+ function postCleanupEffect(effect2) {
446
+ if (effect2.deps && effect2.deps.length > effect2._depsLength) {
447
+ for (let i = effect2._depsLength; i < effect2.deps.length; i++) {
448
+ cleanupDepEffect(effect2.deps[i], effect2);
449
+ }
450
+ effect2.deps.length = effect2._depsLength;
451
+ }
452
+ }
453
+ function cleanupDepEffect(dep, effect2) {
454
+ const trackId = dep.get(effect2);
455
+ if (trackId !== void 0 && effect2._trackId !== trackId) {
456
+ dep.delete(effect2);
457
+ if (dep.size === 0) {
458
+ dep.cleanup();
459
459
  }
460
- deps.length = 0;
461
460
  }
462
461
  }
463
462
  function effect(fn, options) {
464
463
  if (fn.effect instanceof ReactiveEffect) {
465
464
  fn = fn.effect.fn;
466
465
  }
467
- const _effect = new ReactiveEffect(fn);
466
+ const _effect = new ReactiveEffect(fn, NOOP, () => {
467
+ if (_effect.dirty) {
468
+ _effect.run();
469
+ }
470
+ });
468
471
  if (options) {
469
472
  extend(_effect, options);
470
473
  if (options.scope)
@@ -481,6 +484,7 @@ function stop(runner) {
481
484
  runner.effect.stop();
482
485
  }
483
486
  let shouldTrack = true;
487
+ let pauseScheduleStack = 0;
484
488
  const trackStack = [];
485
489
  function pauseTracking() {
486
490
  trackStack.push(shouldTrack);
@@ -490,6 +494,68 @@ function resetTracking() {
490
494
  const last = trackStack.pop();
491
495
  shouldTrack = last === void 0 ? true : last;
492
496
  }
497
+ function pauseScheduling() {
498
+ pauseScheduleStack++;
499
+ }
500
+ function resetScheduling() {
501
+ pauseScheduleStack--;
502
+ while (!pauseScheduleStack && queueEffectSchedulers.length) {
503
+ queueEffectSchedulers.shift()();
504
+ }
505
+ }
506
+ function trackEffect(effect2, dep, debuggerEventExtraInfo) {
507
+ var _a;
508
+ if (dep.get(effect2) !== effect2._trackId) {
509
+ dep.set(effect2, effect2._trackId);
510
+ const oldDep = effect2.deps[effect2._depsLength];
511
+ if (oldDep !== dep) {
512
+ if (oldDep) {
513
+ cleanupDepEffect(oldDep, effect2);
514
+ }
515
+ effect2.deps[effect2._depsLength++] = dep;
516
+ } else {
517
+ effect2._depsLength++;
518
+ }
519
+ if (!!(process.env.NODE_ENV !== "production")) {
520
+ (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
521
+ }
522
+ }
523
+ }
524
+ const queueEffectSchedulers = [];
525
+ function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) {
526
+ var _a;
527
+ pauseScheduling();
528
+ for (const effect2 of dep.keys()) {
529
+ if (!effect2.allowRecurse && effect2._runnings) {
530
+ continue;
531
+ }
532
+ if (effect2._dirtyLevel < dirtyLevel && (!effect2._runnings || dirtyLevel !== 2)) {
533
+ const lastDirtyLevel = effect2._dirtyLevel;
534
+ effect2._dirtyLevel = dirtyLevel;
535
+ if (lastDirtyLevel === 0 && (!effect2._queryings || dirtyLevel !== 2)) {
536
+ if (!!(process.env.NODE_ENV !== "production")) {
537
+ (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
538
+ }
539
+ effect2.trigger();
540
+ if (effect2.scheduler) {
541
+ queueEffectSchedulers.push(effect2.scheduler);
542
+ }
543
+ }
544
+ }
545
+ }
546
+ resetScheduling();
547
+ }
548
+
549
+ const createDep = (cleanup, computed) => {
550
+ const dep = /* @__PURE__ */ new Map();
551
+ dep.cleanup = cleanup;
552
+ dep.computed = computed;
553
+ return dep;
554
+ };
555
+
556
+ const targetMap = /* @__PURE__ */ new WeakMap();
557
+ const ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
558
+ const MAP_KEY_ITERATE_KEY = Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
493
559
  function track(target, type, key) {
494
560
  if (shouldTrack && activeEffect) {
495
561
  let depsMap = targetMap.get(target);
@@ -498,35 +564,17 @@ function track(target, type, key) {
498
564
  }
499
565
  let dep = depsMap.get(key);
500
566
  if (!dep) {
501
- depsMap.set(key, dep = createDep());
502
- }
503
- const eventInfo = !!(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
- }
567
+ depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
568
+ }
569
+ trackEffect(
570
+ activeEffect,
571
+ dep,
572
+ !!(process.env.NODE_ENV !== "production") ? {
573
+ target,
574
+ type,
575
+ key
576
+ } : void 0
577
+ );
530
578
  }
531
579
  }
532
580
  function trigger(target, type, key, newValue, oldValue, oldTarget) {
@@ -540,7 +588,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
540
588
  } else if (key === "length" && isArray(target)) {
541
589
  const newLength = Number(newValue);
542
590
  depsMap.forEach((dep, key2) => {
543
- if (key2 === "length" || key2 >= newLength) {
591
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
544
592
  deps.push(dep);
545
593
  }
546
594
  });
@@ -574,53 +622,24 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
574
622
  break;
575
623
  }
576
624
  }
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();
625
+ pauseScheduling();
626
+ for (const dep of deps) {
627
+ if (dep) {
628
+ triggerEffects(
629
+ dep,
630
+ 3,
631
+ !!(process.env.NODE_ENV !== "production") ? {
632
+ target,
633
+ type,
634
+ key,
635
+ newValue,
636
+ oldValue,
637
+ oldTarget
638
+ } : void 0
639
+ );
622
640
  }
623
641
  }
642
+ resetScheduling();
624
643
  }
625
644
  function getDepFromReactive(object, key) {
626
645
  var _a;
@@ -651,7 +670,9 @@ function createArrayInstrumentations() {
651
670
  ["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
652
671
  instrumentations[key] = function(...args) {
653
672
  pauseTracking();
673
+ pauseScheduling();
654
674
  const res = toRaw(this)[key].apply(this, args);
675
+ resetScheduling();
655
676
  resetTracking();
656
677
  return res;
657
678
  };
@@ -1190,34 +1211,93 @@ function markRaw(value) {
1190
1211
  const toReactive = (value) => isObject(value) ? reactive(value) : value;
1191
1212
  const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1192
1213
 
1214
+ class ComputedRefImpl {
1215
+ constructor(getter, _setter, isReadonly, isSSR) {
1216
+ this._setter = _setter;
1217
+ this.dep = void 0;
1218
+ this.__v_isRef = true;
1219
+ this["__v_isReadonly"] = false;
1220
+ this.effect = new ReactiveEffect(getter, () => {
1221
+ triggerRefValue(this, 1);
1222
+ });
1223
+ this.effect.computed = this;
1224
+ this.effect.active = this._cacheable = !isSSR;
1225
+ this["__v_isReadonly"] = isReadonly;
1226
+ }
1227
+ get value() {
1228
+ const self = toRaw(this);
1229
+ trackRefValue(self);
1230
+ if (!self._cacheable || self.effect.dirty) {
1231
+ if (hasChanged(self._value, self._value = self.effect.run())) {
1232
+ triggerRefValue(self, 2);
1233
+ }
1234
+ }
1235
+ return self._value;
1236
+ }
1237
+ set value(newValue) {
1238
+ this._setter(newValue);
1239
+ }
1240
+ // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x
1241
+ get _dirty() {
1242
+ return this.effect.dirty;
1243
+ }
1244
+ set _dirty(v) {
1245
+ this.effect.dirty = v;
1246
+ }
1247
+ // #endregion
1248
+ }
1249
+ function computed$1(getterOrOptions, debugOptions, isSSR = false) {
1250
+ let getter;
1251
+ let setter;
1252
+ const onlyGetter = isFunction(getterOrOptions);
1253
+ if (onlyGetter) {
1254
+ getter = getterOrOptions;
1255
+ setter = !!(process.env.NODE_ENV !== "production") ? () => {
1256
+ console.warn("Write operation failed: computed value is readonly");
1257
+ } : NOOP;
1258
+ } else {
1259
+ getter = getterOrOptions.get;
1260
+ setter = getterOrOptions.set;
1261
+ }
1262
+ const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
1263
+ if (!!(process.env.NODE_ENV !== "production") && debugOptions && !isSSR) {
1264
+ cRef.effect.onTrack = debugOptions.onTrack;
1265
+ cRef.effect.onTrigger = debugOptions.onTrigger;
1266
+ }
1267
+ return cRef;
1268
+ }
1269
+
1193
1270
  function trackRefValue(ref2) {
1194
1271
  if (shouldTrack && activeEffect) {
1195
1272
  ref2 = toRaw(ref2);
1196
- if (!!(process.env.NODE_ENV !== "production")) {
1197
- trackEffects(ref2.dep || (ref2.dep = createDep()), {
1273
+ trackEffect(
1274
+ activeEffect,
1275
+ ref2.dep || (ref2.dep = createDep(
1276
+ () => ref2.dep = void 0,
1277
+ ref2 instanceof ComputedRefImpl ? ref2 : void 0
1278
+ )),
1279
+ !!(process.env.NODE_ENV !== "production") ? {
1198
1280
  target: ref2,
1199
1281
  type: "get",
1200
1282
  key: "value"
1201
- });
1202
- } else {
1203
- trackEffects(ref2.dep || (ref2.dep = createDep()));
1204
- }
1283
+ } : void 0
1284
+ );
1205
1285
  }
1206
1286
  }
1207
- function triggerRefValue(ref2, newVal) {
1287
+ function triggerRefValue(ref2, dirtyLevel = 3, newVal) {
1208
1288
  ref2 = toRaw(ref2);
1209
1289
  const dep = ref2.dep;
1210
1290
  if (dep) {
1211
- if (!!(process.env.NODE_ENV !== "production")) {
1212
- triggerEffects(dep, {
1291
+ triggerEffects(
1292
+ dep,
1293
+ dirtyLevel,
1294
+ !!(process.env.NODE_ENV !== "production") ? {
1213
1295
  target: ref2,
1214
1296
  type: "set",
1215
1297
  key: "value",
1216
1298
  newValue: newVal
1217
- });
1218
- } else {
1219
- triggerEffects(dep);
1220
- }
1299
+ } : void 0
1300
+ );
1221
1301
  }
1222
1302
  }
1223
1303
  function isRef(r) {
@@ -1253,12 +1333,12 @@ class RefImpl {
1253
1333
  if (hasChanged(newVal, this._rawValue)) {
1254
1334
  this._rawValue = newVal;
1255
1335
  this._value = useDirectValue ? newVal : toReactive(newVal);
1256
- triggerRefValue(this, newVal);
1336
+ triggerRefValue(this, 3, newVal);
1257
1337
  }
1258
1338
  }
1259
1339
  }
1260
1340
  function triggerRef(ref2) {
1261
- triggerRefValue(ref2, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1341
+ triggerRefValue(ref2, 3, !!(process.env.NODE_ENV !== "production") ? ref2.value : void 0);
1262
1342
  }
1263
1343
  function unref(ref2) {
1264
1344
  return isRef(ref2) ? ref2.value : ref2;
@@ -1356,57 +1436,6 @@ function propertyToRef(source, key, defaultValue) {
1356
1436
  return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
1357
1437
  }
1358
1438
 
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
1439
  const stack = [];
1411
1440
  function pushWarningContext(vnode) {
1412
1441
  stack.push(vnode);
@@ -1525,7 +1554,7 @@ function assertNumber(val, type) {
1525
1554
  }
1526
1555
  }
1527
1556
 
1528
- const ErrorTypeStrings = {
1557
+ const ErrorTypeStrings$1 = {
1529
1558
  ["sp"]: "serverPrefetch hook",
1530
1559
  ["bc"]: "beforeCreate hook",
1531
1560
  ["c"]: "created hook",
@@ -1586,7 +1615,7 @@ function handleError(err, instance, type, throwInDev = true) {
1586
1615
  if (instance) {
1587
1616
  let cur = instance.parent;
1588
1617
  const exposedInstance = instance.proxy;
1589
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : type;
1618
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings$1[type] : type;
1590
1619
  while (cur) {
1591
1620
  const errorCapturedHooks = cur.ec;
1592
1621
  if (errorCapturedHooks) {
@@ -1613,7 +1642,7 @@ function handleError(err, instance, type, throwInDev = true) {
1613
1642
  }
1614
1643
  function logError(err, type, contextVNode, throwInDev = true) {
1615
1644
  if (!!(process.env.NODE_ENV !== "production")) {
1616
- const info = ErrorTypeStrings[type];
1645
+ const info = ErrorTypeStrings$1[type];
1617
1646
  if (contextVNode) {
1618
1647
  pushWarningContext(contextVNode);
1619
1648
  }
@@ -1650,8 +1679,13 @@ function findInsertionIndex(id) {
1650
1679
  let end = queue.length;
1651
1680
  while (start < end) {
1652
1681
  const middle = start + end >>> 1;
1653
- const middleJobId = getId(queue[middle]);
1654
- middleJobId < id ? start = middle + 1 : end = middle;
1682
+ const middleJob = queue[middle];
1683
+ const middleJobId = getId(middleJob);
1684
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1685
+ start = middle + 1;
1686
+ } else {
1687
+ end = middle;
1688
+ }
1655
1689
  }
1656
1690
  return start;
1657
1691
  }
@@ -1838,6 +1872,7 @@ function rerender(id, newRender) {
1838
1872
  }
1839
1873
  instance.renderCache = [];
1840
1874
  isHmrUpdating = true;
1875
+ instance.effect.dirty = true;
1841
1876
  instance.update();
1842
1877
  isHmrUpdating = false;
1843
1878
  });
@@ -1865,6 +1900,7 @@ function reload(id, newComp) {
1865
1900
  instance.ceReload(newComp.styles);
1866
1901
  hmrDirtyComponents.delete(oldComp);
1867
1902
  } else if (instance.parent) {
1903
+ instance.parent.effect.dirty = true;
1868
1904
  queueJob(instance.parent.update);
1869
1905
  } else if (instance.appContext.reload) {
1870
1906
  instance.appContext.reload();
@@ -3242,14 +3278,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3242
3278
  parentComponent: parentComponent2,
3243
3279
  container: container2
3244
3280
  } = suspense;
3281
+ let delayEnter = false;
3245
3282
  if (suspense.isHydrating) {
3246
3283
  suspense.isHydrating = false;
3247
3284
  } else if (!resume) {
3248
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3285
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3249
3286
  if (delayEnter) {
3250
3287
  activeBranch.transition.afterLeave = () => {
3251
3288
  if (pendingId === suspense.pendingId) {
3252
3289
  move(pendingBranch, container2, anchor2, 0);
3290
+ queuePostFlushCb(effects);
3253
3291
  }
3254
3292
  };
3255
3293
  }
@@ -3275,7 +3313,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3275
3313
  }
3276
3314
  parent = parent.parent;
3277
3315
  }
3278
- if (!hasUnresolvedAncestor) {
3316
+ if (!hasUnresolvedAncestor && !delayEnter) {
3279
3317
  queuePostFlushCb(effects);
3280
3318
  }
3281
3319
  suspense.effects = [];
@@ -3561,8 +3599,15 @@ function watch(source, cb, options) {
3561
3599
  }
3562
3600
  return doWatch(source, cb, options);
3563
3601
  }
3564
- function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {
3602
+ function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = EMPTY_OBJ) {
3565
3603
  var _a;
3604
+ if (cb && once) {
3605
+ const _cb = cb;
3606
+ cb = (...args) => {
3607
+ _cb(...args);
3608
+ unwatch();
3609
+ };
3610
+ }
3566
3611
  if (!!(process.env.NODE_ENV !== "production") && !cb) {
3567
3612
  if (immediate !== void 0) {
3568
3613
  warn(
@@ -3574,6 +3619,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3574
3619
  `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
3575
3620
  );
3576
3621
  }
3622
+ if (once !== void 0) {
3623
+ warn(
3624
+ `watch() "once" option is only respected when using the watch(source, callback, options?) signature.`
3625
+ );
3626
+ }
3577
3627
  }
3578
3628
  const warnInvalidSource = (s) => {
3579
3629
  warn(
@@ -3670,7 +3720,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3670
3720
  }
3671
3721
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
3672
3722
  const job = () => {
3673
- if (!effect.active) {
3723
+ if (!effect.active || !effect.dirty) {
3674
3724
  return;
3675
3725
  }
3676
3726
  if (cb) {
@@ -3703,7 +3753,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3703
3753
  job.id = instance.uid;
3704
3754
  scheduler = () => queueJob(job);
3705
3755
  }
3706
- const effect = new ReactiveEffect(getter, scheduler);
3756
+ const effect = new ReactiveEffect(getter, NOOP, scheduler);
3757
+ const unwatch = () => {
3758
+ effect.stop();
3759
+ if (instance && instance.scope) {
3760
+ remove(instance.scope.effects, effect);
3761
+ }
3762
+ };
3707
3763
  if (!!(process.env.NODE_ENV !== "production")) {
3708
3764
  effect.onTrack = onTrack;
3709
3765
  effect.onTrigger = onTrigger;
@@ -3722,12 +3778,6 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3722
3778
  } else {
3723
3779
  effect.run();
3724
3780
  }
3725
- const unwatch = () => {
3726
- effect.stop();
3727
- if (instance && instance.scope) {
3728
- remove(instance.scope.effects, effect);
3729
- }
3730
- };
3731
3781
  if (ssrCleanup)
3732
3782
  ssrCleanup.push(unwatch);
3733
3783
  return unwatch;
@@ -3964,6 +4014,7 @@ const BaseTransitionImpl = {
3964
4014
  leavingHooks.afterLeave = () => {
3965
4015
  state.isLeaving = false;
3966
4016
  if (instance.update.active !== false) {
4017
+ instance.effect.dirty = true;
3967
4018
  instance.update();
3968
4019
  }
3969
4020
  };
@@ -4302,6 +4353,7 @@ function defineAsyncComponent(source) {
4302
4353
  load().then(() => {
4303
4354
  loaded.value = true;
4304
4355
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
4356
+ instance.parent.effect.dirty = true;
4305
4357
  queueJob(instance.parent.update);
4306
4358
  }
4307
4359
  }).catch((err) => {
@@ -4605,7 +4657,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4605
4657
  }
4606
4658
  return wrappedHook;
4607
4659
  } else if (!!(process.env.NODE_ENV !== "production")) {
4608
- const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
4660
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
4609
4661
  warn(
4610
4662
  `${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.` )
4611
4663
  );
@@ -5327,7 +5379,10 @@ const publicPropertiesMap = (
5327
5379
  $root: (i) => getPublicInstance(i.root),
5328
5380
  $emit: (i) => i.emit,
5329
5381
  $options: (i) => __VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type,
5330
- $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)),
5382
+ $forceUpdate: (i) => i.f || (i.f = () => {
5383
+ i.effect.dirty = true;
5384
+ queueJob(i.update);
5385
+ }),
5331
5386
  $nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
5332
5387
  $watch: (i) => __VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP
5333
5388
  })
@@ -6230,7 +6285,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6230
6285
  return vm;
6231
6286
  }
6232
6287
  }
6233
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6288
+ Vue.version = `2.6.14-compat:${"3.4.0-alpha.1"}`;
6234
6289
  Vue.config = singletonApp.config;
6235
6290
  Vue.use = (p, ...options) => {
6236
6291
  if (p && isFunction(p.install)) {
@@ -7563,7 +7618,14 @@ function createHydrationFunctions(rendererInternals) {
7563
7618
  break;
7564
7619
  case Comment:
7565
7620
  if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7566
- nextNode = onMismatch();
7621
+ if (node.tagName.toLowerCase() === "template") {
7622
+ const content = vnode.el.content.firstChild;
7623
+ replaceNode(content, node, parentComponent);
7624
+ vnode.el = node = content;
7625
+ nextNode = nextSibling(node);
7626
+ } else {
7627
+ nextNode = onMismatch();
7628
+ }
7567
7629
  } else {
7568
7630
  nextNode = nextSibling(node);
7569
7631
  }
@@ -7605,7 +7667,7 @@ function createHydrationFunctions(rendererInternals) {
7605
7667
  break;
7606
7668
  default:
7607
7669
  if (shapeFlag & 1) {
7608
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7670
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7609
7671
  nextNode = onMismatch();
7610
7672
  } else {
7611
7673
  nextNode = hydrateElement(
@@ -7620,6 +7682,13 @@ function createHydrationFunctions(rendererInternals) {
7620
7682
  } else if (shapeFlag & 6) {
7621
7683
  vnode.slotScopeIds = slotScopeIds;
7622
7684
  const container = parentNode(node);
7685
+ if (isFragmentStart) {
7686
+ nextNode = locateClosingAnchor(node);
7687
+ } else if (isComment(node) && node.data === "teleport start") {
7688
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7689
+ } else {
7690
+ nextNode = nextSibling(node);
7691
+ }
7623
7692
  mountComponent(
7624
7693
  vnode,
7625
7694
  container,
@@ -7629,10 +7698,6 @@ function createHydrationFunctions(rendererInternals) {
7629
7698
  isSVGContainer(container),
7630
7699
  optimized
7631
7700
  );
7632
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7633
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7634
- nextNode = nextSibling(nextNode);
7635
- }
7636
7701
  if (isAsyncWrapper(vnode)) {
7637
7702
  let subTree;
7638
7703
  if (isFragmentStart) {
@@ -7682,7 +7747,7 @@ function createHydrationFunctions(rendererInternals) {
7682
7747
  };
7683
7748
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7684
7749
  optimized = optimized || !!vnode.dynamicChildren;
7685
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7750
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7686
7751
  const forcePatchValue = type === "input" && dirs || type === "option";
7687
7752
  if (!!(process.env.NODE_ENV !== "production") || forcePatchValue || patchFlag !== -1) {
7688
7753
  if (dirs) {
@@ -7719,12 +7784,23 @@ function createHydrationFunctions(rendererInternals) {
7719
7784
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7720
7785
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7721
7786
  }
7787
+ let needCallTransitionHooks = false;
7788
+ if (isTemplateNode(el)) {
7789
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7790
+ const content = el.content.firstChild;
7791
+ if (needCallTransitionHooks) {
7792
+ transition.beforeEnter(content);
7793
+ }
7794
+ replaceNode(content, el, parentComponent);
7795
+ vnode.el = el = content;
7796
+ }
7722
7797
  if (dirs) {
7723
7798
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7724
7799
  }
7725
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7800
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7726
7801
  queueEffectWithSuspense(() => {
7727
7802
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7803
+ needCallTransitionHooks && transition.enter(el);
7728
7804
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7729
7805
  }, parentSuspense);
7730
7806
  }
@@ -7842,7 +7918,7 @@ function createHydrationFunctions(rendererInternals) {
7842
7918
  );
7843
7919
  vnode.el = null;
7844
7920
  if (isFragment) {
7845
- const end = locateClosingAsyncAnchor(node);
7921
+ const end = locateClosingAnchor(node);
7846
7922
  while (true) {
7847
7923
  const next2 = nextSibling(node);
7848
7924
  if (next2 && next2 !== end) {
@@ -7867,14 +7943,14 @@ function createHydrationFunctions(rendererInternals) {
7867
7943
  );
7868
7944
  return next;
7869
7945
  };
7870
- const locateClosingAsyncAnchor = (node) => {
7946
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7871
7947
  let match = 0;
7872
7948
  while (node) {
7873
7949
  node = nextSibling(node);
7874
7950
  if (node && isComment(node)) {
7875
- if (node.data === "[")
7951
+ if (node.data === open)
7876
7952
  match++;
7877
- if (node.data === "]") {
7953
+ if (node.data === close) {
7878
7954
  if (match === 0) {
7879
7955
  return nextSibling(node);
7880
7956
  } else {
@@ -7885,6 +7961,23 @@ function createHydrationFunctions(rendererInternals) {
7885
7961
  }
7886
7962
  return node;
7887
7963
  };
7964
+ const replaceNode = (newNode, oldNode, parentComponent) => {
7965
+ const parentNode2 = oldNode.parentNode;
7966
+ if (parentNode2) {
7967
+ parentNode2.replaceChild(newNode, oldNode);
7968
+ }
7969
+ let parent = parentComponent;
7970
+ while (parent) {
7971
+ if (parent.vnode.el === oldNode) {
7972
+ parent.vnode.el = newNode;
7973
+ parent.subTree.el = newNode;
7974
+ }
7975
+ parent = parent.parent;
7976
+ }
7977
+ };
7978
+ const isTemplateNode = (node) => {
7979
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
7980
+ };
7888
7981
  return [hydrate, hydrateNode];
7889
7982
  }
7890
7983
 
@@ -8235,7 +8328,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8235
8328
  if (dirs) {
8236
8329
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8237
8330
  }
8238
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8331
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8239
8332
  if (needCallTransitionHooks) {
8240
8333
  transition.beforeEnter(el);
8241
8334
  }
@@ -8635,6 +8728,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8635
8728
  } else {
8636
8729
  instance.next = n2;
8637
8730
  invalidateJob(instance.update);
8731
+ instance.effect.dirty = true;
8638
8732
  instance.update();
8639
8733
  }
8640
8734
  } else {
@@ -8828,11 +8922,16 @@ function baseCreateRenderer(options, createHydrationFns) {
8828
8922
  };
8829
8923
  const effect = instance.effect = new ReactiveEffect(
8830
8924
  componentUpdateFn,
8925
+ NOOP,
8831
8926
  () => queueJob(update),
8832
8927
  instance.scope
8833
8928
  // track it in component's effect scope
8834
8929
  );
8835
- const update = instance.update = () => effect.run();
8930
+ const update = instance.update = () => {
8931
+ if (effect.dirty) {
8932
+ effect.run();
8933
+ }
8934
+ };
8836
8935
  update.id = instance.uid;
8837
8936
  toggleRecurse(instance, true);
8838
8937
  if (!!(process.env.NODE_ENV !== "production")) {
@@ -9163,8 +9262,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9163
9262
  moveStaticNode(vnode, container, anchor);
9164
9263
  return;
9165
9264
  }
9166
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9167
- if (needTransition) {
9265
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9266
+ if (needTransition2) {
9168
9267
  if (moveType === 0) {
9169
9268
  transition.beforeEnter(el);
9170
9269
  hostInsert(el, container, anchor);
@@ -9393,6 +9492,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9393
9492
  function toggleRecurse({ effect, update }, allowed) {
9394
9493
  effect.allowRecurse = update.allowRecurse = allowed;
9395
9494
  }
9495
+ function needTransition(parentSuspense, transition) {
9496
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9497
+ }
9396
9498
  function traverseStaticChildren(n1, n2, shallow = false) {
9397
9499
  const ch1 = n1.children;
9398
9500
  const ch2 = n2.children;
@@ -10829,7 +10931,8 @@ function isMemoSame(cached, memo) {
10829
10931
  return true;
10830
10932
  }
10831
10933
 
10832
- const version = "3.3.6";
10934
+ const version = "3.4.0-alpha.1";
10935
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
10833
10936
  const _ssrUtils = {
10834
10937
  createComponentInstance,
10835
10938
  setupComponent,
@@ -12521,6 +12624,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12521
12624
  BaseTransitionPropsValidators: BaseTransitionPropsValidators,
12522
12625
  Comment: Comment,
12523
12626
  EffectScope: EffectScope,
12627
+ ErrorTypeStrings: ErrorTypeStrings,
12524
12628
  Fragment: Fragment,
12525
12629
  KeepAlive: KeepAlive,
12526
12630
  ReactiveEffect: ReactiveEffect,
@@ -12711,4 +12815,4 @@ var Vue$1 = Vue;
12711
12815
 
12712
12816
  const { configureCompat } = Vue$1;
12713
12817
 
12714
- 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 };
12818
+ 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 };