@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
  **/
@@ -532,7 +532,7 @@ class ReactiveEffect {
532
532
  /**
533
533
  * @internal
534
534
  */
535
- this.nextEffect = void 0;
535
+ this.next = void 0;
536
536
  /**
537
537
  * @internal
538
538
  */
@@ -562,9 +562,7 @@ class ReactiveEffect {
562
562
  return;
563
563
  }
564
564
  if (!(this.flags & 8)) {
565
- this.flags |= 8;
566
- this.nextEffect = batchedEffect;
567
- batchedEffect = this;
565
+ batch(this);
568
566
  }
569
567
  }
570
568
  run() {
@@ -625,7 +623,12 @@ class ReactiveEffect {
625
623
  }
626
624
  }
627
625
  let batchDepth = 0;
628
- let batchedEffect;
626
+ let batchedSub;
627
+ function batch(sub) {
628
+ sub.flags |= 8;
629
+ sub.next = batchedSub;
630
+ batchedSub = sub;
631
+ }
629
632
  function startBatch() {
630
633
  batchDepth++;
631
634
  }
@@ -634,15 +637,16 @@ function endBatch() {
634
637
  return;
635
638
  }
636
639
  let error;
637
- while (batchedEffect) {
638
- let e = batchedEffect;
639
- batchedEffect = void 0;
640
+ while (batchedSub) {
641
+ let e = batchedSub;
642
+ batchedSub = void 0;
640
643
  while (e) {
641
- const next = e.nextEffect;
642
- e.nextEffect = void 0;
644
+ const next = e.next;
645
+ e.next = void 0;
643
646
  e.flags &= ~8;
644
647
  if (e.flags & 1) {
645
648
  try {
649
+ ;
646
650
  e.trigger();
647
651
  } catch (err) {
648
652
  if (!error) error = err;
@@ -682,7 +686,7 @@ function cleanupDeps(sub) {
682
686
  }
683
687
  function isDirty(sub) {
684
688
  for (let link = sub.deps; link; link = link.nextDep) {
685
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
689
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
686
690
  return true;
687
691
  }
688
692
  }
@@ -702,7 +706,7 @@ function refreshComputed(computed) {
702
706
  computed.globalVersion = globalVersion;
703
707
  const dep = computed.dep;
704
708
  computed.flags |= 2;
705
- if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
709
+ if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
706
710
  computed.flags &= ~2;
707
711
  return;
708
712
  }
@@ -727,7 +731,7 @@ function refreshComputed(computed) {
727
731
  computed.flags &= ~2;
728
732
  }
729
733
  }
730
- function removeSub(link) {
734
+ function removeSub(link, fromComputed = false) {
731
735
  const { dep, prevSub, nextSub } = link;
732
736
  if (prevSub) {
733
737
  prevSub.nextSub = nextSub;
@@ -740,10 +744,18 @@ function removeSub(link) {
740
744
  if (dep.subs === link) {
741
745
  dep.subs = prevSub;
742
746
  }
743
- if (!dep.subs && dep.computed) {
744
- dep.computed.flags &= ~4;
745
- for (let l = dep.computed.deps; l; l = l.nextDep) {
746
- removeSub(l);
747
+ if (dep.subsHead === link) {
748
+ dep.subsHead = nextSub;
749
+ }
750
+ if (!dep.subs) {
751
+ if (dep.computed) {
752
+ dep.computed.flags &= ~4;
753
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
754
+ removeSub(l, true);
755
+ }
756
+ } else if (dep.map && !fromComputed) {
757
+ dep.map.delete(dep.key);
758
+ if (!dep.map.size) targetMap.delete(dep.target);
747
759
  }
748
760
  }
749
761
  }
@@ -824,6 +836,12 @@ class Dep {
824
836
  * Doubly linked list representing the subscribing effects (tail)
825
837
  */
826
838
  this.subs = void 0;
839
+ /**
840
+ * For object property deps cleanup
841
+ */
842
+ this.target = void 0;
843
+ this.map = void 0;
844
+ this.key = void 0;
827
845
  {
828
846
  this.subsHead = void 0;
829
847
  }
@@ -897,7 +915,10 @@ class Dep {
897
915
  }
898
916
  }
899
917
  for (let link = this.subs; link; link = link.prevSub) {
900
- link.sub.notify();
918
+ if (link.sub.notify()) {
919
+ ;
920
+ link.sub.dep.notify();
921
+ }
901
922
  }
902
923
  } finally {
903
924
  endBatch();
@@ -941,6 +962,9 @@ function track(target, type, key) {
941
962
  let dep = depsMap.get(key);
942
963
  if (!dep) {
943
964
  depsMap.set(key, dep = new Dep());
965
+ dep.target = target;
966
+ dep.map = depsMap;
967
+ dep.key = key;
944
968
  }
945
969
  {
946
970
  dep.track({
@@ -1817,13 +1841,15 @@ class RefImpl {
1817
1841
  }
1818
1842
  }
1819
1843
  function triggerRef(ref2) {
1820
- {
1821
- ref2.dep.trigger({
1822
- target: ref2,
1823
- type: "set",
1824
- key: "value",
1825
- newValue: ref2._value
1826
- });
1844
+ if (ref2.dep) {
1845
+ {
1846
+ ref2.dep.trigger({
1847
+ target: ref2,
1848
+ type: "set",
1849
+ key: "value",
1850
+ newValue: ref2._value
1851
+ });
1852
+ }
1827
1853
  }
1828
1854
  }
1829
1855
  function unref(ref2) {
@@ -1966,8 +1992,10 @@ class ComputedRefImpl {
1966
1992
  */
1967
1993
  notify() {
1968
1994
  this.flags |= 16;
1969
- if (activeSub !== this) {
1970
- this.dep.notify();
1995
+ if (!(this.flags & 8) && // avoid infinite self recursion
1996
+ activeSub !== this) {
1997
+ batch(this);
1998
+ return true;
1971
1999
  }
1972
2000
  }
1973
2001
  get value() {
@@ -2115,20 +2143,12 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2115
2143
  remove(scope.effects, effect);
2116
2144
  }
2117
2145
  };
2118
- if (once) {
2119
- if (cb) {
2120
- const _cb = cb;
2121
- cb = (...args) => {
2122
- _cb(...args);
2123
- watchHandle();
2124
- };
2125
- } else {
2126
- const _getter = getter;
2127
- getter = () => {
2128
- _getter();
2129
- watchHandle();
2130
- };
2131
- }
2146
+ if (once && cb) {
2147
+ const _cb = cb;
2148
+ cb = (...args) => {
2149
+ _cb(...args);
2150
+ watchHandle();
2151
+ };
2132
2152
  }
2133
2153
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2134
2154
  const job = (immediateFirstRun) => {
@@ -2577,7 +2597,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
2577
2597
  cb.flags &= ~1;
2578
2598
  }
2579
2599
  cb();
2580
- cb.flags &= ~1;
2600
+ if (!(cb.flags & 4)) {
2601
+ cb.flags &= ~1;
2602
+ }
2581
2603
  }
2582
2604
  }
2583
2605
  }
@@ -2633,7 +2655,9 @@ function flushJobs(seen) {
2633
2655
  job.i,
2634
2656
  job.i ? 15 : 14
2635
2657
  );
2636
- job.flags &= ~1;
2658
+ if (!(job.flags & 4)) {
2659
+ job.flags &= ~1;
2660
+ }
2637
2661
  }
2638
2662
  }
2639
2663
  } finally {
@@ -4963,6 +4987,11 @@ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
4963
4987
  const id = requestIdleCallback(hydrate, { timeout });
4964
4988
  return () => cancelIdleCallback(id);
4965
4989
  };
4990
+ function elementIsVisibleInViewport(el) {
4991
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4992
+ const { innerHeight, innerWidth } = window;
4993
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4994
+ }
4966
4995
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4967
4996
  const ob = new IntersectionObserver((entries) => {
4968
4997
  for (const e of entries) {
@@ -4972,7 +5001,15 @@ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4972
5001
  break;
4973
5002
  }
4974
5003
  }, opts);
4975
- forEach((el) => ob.observe(el));
5004
+ forEach((el) => {
5005
+ if (!(el instanceof Element)) return;
5006
+ if (elementIsVisibleInViewport(el)) {
5007
+ hydrate();
5008
+ ob.disconnect();
5009
+ return false;
5010
+ }
5011
+ ob.observe(el);
5012
+ });
4976
5013
  return () => ob.disconnect();
4977
5014
  };
4978
5015
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -5017,7 +5054,10 @@ function forEachElement(node, cb) {
5017
5054
  let next = node.nextSibling;
5018
5055
  while (next) {
5019
5056
  if (next.nodeType === 1) {
5020
- cb(next);
5057
+ const result = cb(next);
5058
+ if (result === false) {
5059
+ break;
5060
+ }
5021
5061
  } else if (isComment(next)) {
5022
5062
  if (next.data === "]") {
5023
5063
  if (--depth === 0) break;
@@ -7110,7 +7150,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7110
7150
  return vm;
7111
7151
  }
7112
7152
  }
7113
- Vue.version = `2.6.14-compat:${"3.5.5"}`;
7153
+ Vue.version = `2.6.14-compat:${"3.5.7"}`;
7114
7154
  Vue.config = singletonApp.config;
7115
7155
  Vue.use = (plugin, ...options) => {
7116
7156
  if (plugin && isFunction(plugin.install)) {
@@ -9928,11 +9968,12 @@ function doWatch(source, cb, options = EMPTY_OBJ) {
9928
9968
  } else if (!cb || immediate) {
9929
9969
  baseWatchOptions.once = true;
9930
9970
  } else {
9931
- return {
9932
- stop: NOOP,
9933
- resume: NOOP,
9934
- pause: NOOP
9971
+ const watchStopHandle = () => {
9935
9972
  };
9973
+ watchStopHandle.stop = NOOP;
9974
+ watchStopHandle.resume = NOOP;
9975
+ watchStopHandle.pause = NOOP;
9976
+ return watchStopHandle;
9936
9977
  }
9937
9978
  }
9938
9979
  const instance = currentInstance;
@@ -12224,7 +12265,7 @@ function isMemoSame(cached, memo) {
12224
12265
  return true;
12225
12266
  }
12226
12267
 
12227
- const version = "3.5.5";
12268
+ const version = "3.5.7";
12228
12269
  const warn = warn$1 ;
12229
12270
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12230
12271
  const devtools = devtools$1 ;
@@ -12567,7 +12608,7 @@ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
12567
12608
  resolve();
12568
12609
  }
12569
12610
  };
12570
- if (explicitTimeout) {
12611
+ if (explicitTimeout != null) {
12571
12612
  return setTimeout(resolveIfNotStale, explicitTimeout);
12572
12613
  }
12573
12614
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
@@ -19421,7 +19462,7 @@ const transformModel$1 = (dir, node, context) => {
19421
19462
  );
19422
19463
  return createTransformProps();
19423
19464
  }
19424
- const rawExp = exp.loc.source;
19465
+ const rawExp = exp.loc.source.trim();
19425
19466
  const expString = exp.type === 4 ? exp.content : rawExp;
19426
19467
  const bindingType = context.bindingMetadata[rawExp];
19427
19468
  if (bindingType === "props" || bindingType === "props-aliased") {