@vue/compat 3.5.5 → 3.5.7

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,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.5
2
+ * @vue/compat v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -465,7 +465,7 @@ class ReactiveEffect {
465
465
  /**
466
466
  * @internal
467
467
  */
468
- this.nextEffect = void 0;
468
+ this.next = void 0;
469
469
  /**
470
470
  * @internal
471
471
  */
@@ -495,9 +495,7 @@ class ReactiveEffect {
495
495
  return;
496
496
  }
497
497
  if (!(this.flags & 8)) {
498
- this.flags |= 8;
499
- this.nextEffect = batchedEffect;
500
- batchedEffect = this;
498
+ batch(this);
501
499
  }
502
500
  }
503
501
  run() {
@@ -558,7 +556,12 @@ class ReactiveEffect {
558
556
  }
559
557
  }
560
558
  let batchDepth = 0;
561
- let batchedEffect;
559
+ let batchedSub;
560
+ function batch(sub) {
561
+ sub.flags |= 8;
562
+ sub.next = batchedSub;
563
+ batchedSub = sub;
564
+ }
562
565
  function startBatch() {
563
566
  batchDepth++;
564
567
  }
@@ -567,15 +570,16 @@ function endBatch() {
567
570
  return;
568
571
  }
569
572
  let error;
570
- while (batchedEffect) {
571
- let e = batchedEffect;
572
- batchedEffect = void 0;
573
+ while (batchedSub) {
574
+ let e = batchedSub;
575
+ batchedSub = void 0;
573
576
  while (e) {
574
- const next = e.nextEffect;
575
- e.nextEffect = void 0;
577
+ const next = e.next;
578
+ e.next = void 0;
576
579
  e.flags &= ~8;
577
580
  if (e.flags & 1) {
578
581
  try {
582
+ ;
579
583
  e.trigger();
580
584
  } catch (err) {
581
585
  if (!error) error = err;
@@ -615,7 +619,7 @@ function cleanupDeps(sub) {
615
619
  }
616
620
  function isDirty(sub) {
617
621
  for (let link = sub.deps; link; link = link.nextDep) {
618
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
622
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
619
623
  return true;
620
624
  }
621
625
  }
@@ -635,7 +639,7 @@ function refreshComputed(computed) {
635
639
  computed.globalVersion = globalVersion;
636
640
  const dep = computed.dep;
637
641
  computed.flags |= 2;
638
- if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
642
+ if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
639
643
  computed.flags &= ~2;
640
644
  return;
641
645
  }
@@ -660,7 +664,7 @@ function refreshComputed(computed) {
660
664
  computed.flags &= ~2;
661
665
  }
662
666
  }
663
- function removeSub(link) {
667
+ function removeSub(link, fromComputed = false) {
664
668
  const { dep, prevSub, nextSub } = link;
665
669
  if (prevSub) {
666
670
  prevSub.nextSub = nextSub;
@@ -673,10 +677,18 @@ function removeSub(link) {
673
677
  if (dep.subs === link) {
674
678
  dep.subs = prevSub;
675
679
  }
676
- if (!dep.subs && dep.computed) {
677
- dep.computed.flags &= ~4;
678
- for (let l = dep.computed.deps; l; l = l.nextDep) {
679
- removeSub(l);
680
+ if (dep.subsHead === link) {
681
+ dep.subsHead = nextSub;
682
+ }
683
+ if (!dep.subs) {
684
+ if (dep.computed) {
685
+ dep.computed.flags &= ~4;
686
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
687
+ removeSub(l, true);
688
+ }
689
+ } else if (dep.map && !fromComputed) {
690
+ dep.map.delete(dep.key);
691
+ if (!dep.map.size) targetMap.delete(dep.target);
680
692
  }
681
693
  }
682
694
  }
@@ -757,6 +769,12 @@ class Dep {
757
769
  * Doubly linked list representing the subscribing effects (tail)
758
770
  */
759
771
  this.subs = void 0;
772
+ /**
773
+ * For object property deps cleanup
774
+ */
775
+ this.target = void 0;
776
+ this.map = void 0;
777
+ this.key = void 0;
760
778
  {
761
779
  this.subsHead = void 0;
762
780
  }
@@ -830,7 +848,10 @@ class Dep {
830
848
  }
831
849
  }
832
850
  for (let link = this.subs; link; link = link.prevSub) {
833
- link.sub.notify();
851
+ if (link.sub.notify()) {
852
+ ;
853
+ link.sub.dep.notify();
854
+ }
834
855
  }
835
856
  } finally {
836
857
  endBatch();
@@ -874,6 +895,9 @@ function track(target, type, key) {
874
895
  let dep = depsMap.get(key);
875
896
  if (!dep) {
876
897
  depsMap.set(key, dep = new Dep());
898
+ dep.target = target;
899
+ dep.map = depsMap;
900
+ dep.key = key;
877
901
  }
878
902
  {
879
903
  dep.track({
@@ -1750,13 +1774,15 @@ class RefImpl {
1750
1774
  }
1751
1775
  }
1752
1776
  function triggerRef(ref2) {
1753
- {
1754
- ref2.dep.trigger({
1755
- target: ref2,
1756
- type: "set",
1757
- key: "value",
1758
- newValue: ref2._value
1759
- });
1777
+ if (ref2.dep) {
1778
+ {
1779
+ ref2.dep.trigger({
1780
+ target: ref2,
1781
+ type: "set",
1782
+ key: "value",
1783
+ newValue: ref2._value
1784
+ });
1785
+ }
1760
1786
  }
1761
1787
  }
1762
1788
  function unref(ref2) {
@@ -1899,8 +1925,10 @@ class ComputedRefImpl {
1899
1925
  */
1900
1926
  notify() {
1901
1927
  this.flags |= 16;
1902
- if (activeSub !== this) {
1903
- this.dep.notify();
1928
+ if (!(this.flags & 8) && // avoid infinite self recursion
1929
+ activeSub !== this) {
1930
+ batch(this);
1931
+ return true;
1904
1932
  }
1905
1933
  }
1906
1934
  get value() {
@@ -2048,20 +2076,12 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2048
2076
  remove(scope.effects, effect);
2049
2077
  }
2050
2078
  };
2051
- if (once) {
2052
- if (cb) {
2053
- const _cb = cb;
2054
- cb = (...args) => {
2055
- _cb(...args);
2056
- watchHandle();
2057
- };
2058
- } else {
2059
- const _getter = getter;
2060
- getter = () => {
2061
- _getter();
2062
- watchHandle();
2063
- };
2064
- }
2079
+ if (once && cb) {
2080
+ const _cb = cb;
2081
+ cb = (...args) => {
2082
+ _cb(...args);
2083
+ watchHandle();
2084
+ };
2065
2085
  }
2066
2086
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2067
2087
  const job = (immediateFirstRun) => {
@@ -2510,7 +2530,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
2510
2530
  cb.flags &= ~1;
2511
2531
  }
2512
2532
  cb();
2513
- cb.flags &= ~1;
2533
+ if (!(cb.flags & 4)) {
2534
+ cb.flags &= ~1;
2535
+ }
2514
2536
  }
2515
2537
  }
2516
2538
  }
@@ -2566,7 +2588,9 @@ function flushJobs(seen) {
2566
2588
  job.i,
2567
2589
  job.i ? 15 : 14
2568
2590
  );
2569
- job.flags &= ~1;
2591
+ if (!(job.flags & 4)) {
2592
+ job.flags &= ~1;
2593
+ }
2570
2594
  }
2571
2595
  }
2572
2596
  } finally {
@@ -4896,6 +4920,11 @@ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4896
4920
  const id = requestIdleCallback(hydrate, { timeout });
4897
4921
  return () => cancelIdleCallback(id);
4898
4922
  };
4923
+ function elementIsVisibleInViewport(el) {
4924
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4925
+ const { innerHeight, innerWidth } = window;
4926
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4927
+ }
4899
4928
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4900
4929
  const ob = new IntersectionObserver((entries) => {
4901
4930
  for (const e of entries) {
@@ -4905,7 +4934,15 @@ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4905
4934
  break;
4906
4935
  }
4907
4936
  }, opts);
4908
- forEach((el) => ob.observe(el));
4937
+ forEach((el) => {
4938
+ if (!(el instanceof Element)) return;
4939
+ if (elementIsVisibleInViewport(el)) {
4940
+ hydrate();
4941
+ ob.disconnect();
4942
+ return false;
4943
+ }
4944
+ ob.observe(el);
4945
+ });
4909
4946
  return () => ob.disconnect();
4910
4947
  };
4911
4948
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -4950,7 +4987,10 @@ function forEachElement(node, cb) {
4950
4987
  let next = node.nextSibling;
4951
4988
  while (next) {
4952
4989
  if (next.nodeType === 1) {
4953
- cb(next);
4990
+ const result = cb(next);
4991
+ if (result === false) {
4992
+ break;
4993
+ }
4954
4994
  } else if (isComment(next)) {
4955
4995
  if (next.data === "]") {
4956
4996
  if (--depth === 0) break;
@@ -7043,7 +7083,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7043
7083
  return vm;
7044
7084
  }
7045
7085
  }
7046
- Vue.version = `2.6.14-compat:${"3.5.5"}`;
7086
+ Vue.version = `2.6.14-compat:${"3.5.7"}`;
7047
7087
  Vue.config = singletonApp.config;
7048
7088
  Vue.use = (plugin, ...options) => {
7049
7089
  if (plugin && isFunction(plugin.install)) {
@@ -9861,11 +9901,12 @@ function doWatch(source, cb, options = EMPTY_OBJ) {
9861
9901
  } else if (!cb || immediate) {
9862
9902
  baseWatchOptions.once = true;
9863
9903
  } else {
9864
- return {
9865
- stop: NOOP,
9866
- resume: NOOP,
9867
- pause: NOOP
9904
+ const watchStopHandle = () => {
9868
9905
  };
9906
+ watchStopHandle.stop = NOOP;
9907
+ watchStopHandle.resume = NOOP;
9908
+ watchStopHandle.pause = NOOP;
9909
+ return watchStopHandle;
9869
9910
  }
9870
9911
  }
9871
9912
  const instance = currentInstance;
@@ -12157,7 +12198,7 @@ function isMemoSame(cached, memo) {
12157
12198
  return true;
12158
12199
  }
12159
12200
 
12160
- const version = "3.5.5";
12201
+ const version = "3.5.7";
12161
12202
  const warn = warn$1 ;
12162
12203
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12163
12204
  const devtools = devtools$1 ;
@@ -12500,7 +12541,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
12500
12541
  resolve();
12501
12542
  }
12502
12543
  };
12503
- if (explicitTimeout) {
12544
+ if (explicitTimeout != null) {
12504
12545
  return setTimeout(resolveIfNotStale, explicitTimeout);
12505
12546
  }
12506
12547
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);