vue 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 v3.5.5
2
+ * vue v3.5.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -468,7 +468,7 @@ var Vue = (function (exports) {
468
468
  /**
469
469
  * @internal
470
470
  */
471
- this.nextEffect = void 0;
471
+ this.next = void 0;
472
472
  /**
473
473
  * @internal
474
474
  */
@@ -498,9 +498,7 @@ var Vue = (function (exports) {
498
498
  return;
499
499
  }
500
500
  if (!(this.flags & 8)) {
501
- this.flags |= 8;
502
- this.nextEffect = batchedEffect;
503
- batchedEffect = this;
501
+ batch(this);
504
502
  }
505
503
  }
506
504
  run() {
@@ -561,7 +559,12 @@ var Vue = (function (exports) {
561
559
  }
562
560
  }
563
561
  let batchDepth = 0;
564
- let batchedEffect;
562
+ let batchedSub;
563
+ function batch(sub) {
564
+ sub.flags |= 8;
565
+ sub.next = batchedSub;
566
+ batchedSub = sub;
567
+ }
565
568
  function startBatch() {
566
569
  batchDepth++;
567
570
  }
@@ -570,15 +573,16 @@ var Vue = (function (exports) {
570
573
  return;
571
574
  }
572
575
  let error;
573
- while (batchedEffect) {
574
- let e = batchedEffect;
575
- batchedEffect = void 0;
576
+ while (batchedSub) {
577
+ let e = batchedSub;
578
+ batchedSub = void 0;
576
579
  while (e) {
577
- const next = e.nextEffect;
578
- e.nextEffect = void 0;
580
+ const next = e.next;
581
+ e.next = void 0;
579
582
  e.flags &= ~8;
580
583
  if (e.flags & 1) {
581
584
  try {
585
+ ;
582
586
  e.trigger();
583
587
  } catch (err) {
584
588
  if (!error) error = err;
@@ -618,7 +622,7 @@ var Vue = (function (exports) {
618
622
  }
619
623
  function isDirty(sub) {
620
624
  for (let link = sub.deps; link; link = link.nextDep) {
621
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
625
+ if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
622
626
  return true;
623
627
  }
624
628
  }
@@ -638,7 +642,7 @@ var Vue = (function (exports) {
638
642
  computed.globalVersion = globalVersion;
639
643
  const dep = computed.dep;
640
644
  computed.flags |= 2;
641
- if (dep.version > 0 && !computed.isSSR && !isDirty(computed)) {
645
+ if (dep.version > 0 && !computed.isSSR && computed.deps && !isDirty(computed)) {
642
646
  computed.flags &= ~2;
643
647
  return;
644
648
  }
@@ -663,7 +667,7 @@ var Vue = (function (exports) {
663
667
  computed.flags &= ~2;
664
668
  }
665
669
  }
666
- function removeSub(link) {
670
+ function removeSub(link, fromComputed = false) {
667
671
  const { dep, prevSub, nextSub } = link;
668
672
  if (prevSub) {
669
673
  prevSub.nextSub = nextSub;
@@ -676,10 +680,18 @@ var Vue = (function (exports) {
676
680
  if (dep.subs === link) {
677
681
  dep.subs = prevSub;
678
682
  }
679
- if (!dep.subs && dep.computed) {
680
- dep.computed.flags &= ~4;
681
- for (let l = dep.computed.deps; l; l = l.nextDep) {
682
- removeSub(l);
683
+ if (dep.subsHead === link) {
684
+ dep.subsHead = nextSub;
685
+ }
686
+ if (!dep.subs) {
687
+ if (dep.computed) {
688
+ dep.computed.flags &= ~4;
689
+ for (let l = dep.computed.deps; l; l = l.nextDep) {
690
+ removeSub(l, true);
691
+ }
692
+ } else if (dep.map && !fromComputed) {
693
+ dep.map.delete(dep.key);
694
+ if (!dep.map.size) targetMap.delete(dep.target);
683
695
  }
684
696
  }
685
697
  }
@@ -760,6 +772,12 @@ var Vue = (function (exports) {
760
772
  * Doubly linked list representing the subscribing effects (tail)
761
773
  */
762
774
  this.subs = void 0;
775
+ /**
776
+ * For object property deps cleanup
777
+ */
778
+ this.target = void 0;
779
+ this.map = void 0;
780
+ this.key = void 0;
763
781
  {
764
782
  this.subsHead = void 0;
765
783
  }
@@ -833,7 +851,10 @@ var Vue = (function (exports) {
833
851
  }
834
852
  }
835
853
  for (let link = this.subs; link; link = link.prevSub) {
836
- link.sub.notify();
854
+ if (link.sub.notify()) {
855
+ ;
856
+ link.sub.dep.notify();
857
+ }
837
858
  }
838
859
  } finally {
839
860
  endBatch();
@@ -877,6 +898,9 @@ var Vue = (function (exports) {
877
898
  let dep = depsMap.get(key);
878
899
  if (!dep) {
879
900
  depsMap.set(key, dep = new Dep());
901
+ dep.target = target;
902
+ dep.map = depsMap;
903
+ dep.key = key;
880
904
  }
881
905
  {
882
906
  dep.track({
@@ -1753,13 +1777,15 @@ var Vue = (function (exports) {
1753
1777
  }
1754
1778
  }
1755
1779
  function triggerRef(ref2) {
1756
- {
1757
- ref2.dep.trigger({
1758
- target: ref2,
1759
- type: "set",
1760
- key: "value",
1761
- newValue: ref2._value
1762
- });
1780
+ if (ref2.dep) {
1781
+ {
1782
+ ref2.dep.trigger({
1783
+ target: ref2,
1784
+ type: "set",
1785
+ key: "value",
1786
+ newValue: ref2._value
1787
+ });
1788
+ }
1763
1789
  }
1764
1790
  }
1765
1791
  function unref(ref2) {
@@ -1902,8 +1928,10 @@ var Vue = (function (exports) {
1902
1928
  */
1903
1929
  notify() {
1904
1930
  this.flags |= 16;
1905
- if (activeSub !== this) {
1906
- this.dep.notify();
1931
+ if (!(this.flags & 8) && // avoid infinite self recursion
1932
+ activeSub !== this) {
1933
+ batch(this);
1934
+ return true;
1907
1935
  }
1908
1936
  }
1909
1937
  get value() {
@@ -2051,20 +2079,12 @@ var Vue = (function (exports) {
2051
2079
  remove(scope.effects, effect);
2052
2080
  }
2053
2081
  };
2054
- if (once) {
2055
- if (cb) {
2056
- const _cb = cb;
2057
- cb = (...args) => {
2058
- _cb(...args);
2059
- watchHandle();
2060
- };
2061
- } else {
2062
- const _getter = getter;
2063
- getter = () => {
2064
- _getter();
2065
- watchHandle();
2066
- };
2067
- }
2082
+ if (once && cb) {
2083
+ const _cb = cb;
2084
+ cb = (...args) => {
2085
+ _cb(...args);
2086
+ watchHandle();
2087
+ };
2068
2088
  }
2069
2089
  let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
2070
2090
  const job = (immediateFirstRun) => {
@@ -2513,7 +2533,9 @@ var Vue = (function (exports) {
2513
2533
  cb.flags &= ~1;
2514
2534
  }
2515
2535
  cb();
2516
- cb.flags &= ~1;
2536
+ if (!(cb.flags & 4)) {
2537
+ cb.flags &= ~1;
2538
+ }
2517
2539
  }
2518
2540
  }
2519
2541
  }
@@ -2569,7 +2591,9 @@ var Vue = (function (exports) {
2569
2591
  job.i,
2570
2592
  job.i ? 15 : 14
2571
2593
  );
2572
- job.flags &= ~1;
2594
+ if (!(job.flags & 4)) {
2595
+ job.flags &= ~1;
2596
+ }
2573
2597
  }
2574
2598
  }
2575
2599
  } finally {
@@ -4368,6 +4392,11 @@ Server rendered element contains fewer child nodes than client vdom.`
4368
4392
  const id = requestIdleCallback(hydrate, { timeout });
4369
4393
  return () => cancelIdleCallback(id);
4370
4394
  };
4395
+ function elementIsVisibleInViewport(el) {
4396
+ const { top, left, bottom, right } = el.getBoundingClientRect();
4397
+ const { innerHeight, innerWidth } = window;
4398
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
4399
+ }
4371
4400
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
4372
4401
  const ob = new IntersectionObserver((entries) => {
4373
4402
  for (const e of entries) {
@@ -4377,7 +4406,15 @@ Server rendered element contains fewer child nodes than client vdom.`
4377
4406
  break;
4378
4407
  }
4379
4408
  }, opts);
4380
- forEach((el) => ob.observe(el));
4409
+ forEach((el) => {
4410
+ if (!(el instanceof Element)) return;
4411
+ if (elementIsVisibleInViewport(el)) {
4412
+ hydrate();
4413
+ ob.disconnect();
4414
+ return false;
4415
+ }
4416
+ ob.observe(el);
4417
+ });
4381
4418
  return () => ob.disconnect();
4382
4419
  };
4383
4420
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -4422,7 +4459,10 @@ Server rendered element contains fewer child nodes than client vdom.`
4422
4459
  let next = node.nextSibling;
4423
4460
  while (next) {
4424
4461
  if (next.nodeType === 1) {
4425
- cb(next);
4462
+ const result = cb(next);
4463
+ if (result === false) {
4464
+ break;
4465
+ }
4426
4466
  } else if (isComment(next)) {
4427
4467
  if (next.data === "]") {
4428
4468
  if (--depth === 0) break;
@@ -10353,7 +10393,7 @@ Component that was made reactive: `,
10353
10393
  return true;
10354
10394
  }
10355
10395
 
10356
- const version = "3.5.5";
10396
+ const version = "3.5.7";
10357
10397
  const warn = warn$1 ;
10358
10398
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10359
10399
  const devtools = devtools$1 ;
@@ -10640,7 +10680,7 @@ Component that was made reactive: `,
10640
10680
  resolve();
10641
10681
  }
10642
10682
  };
10643
- if (explicitTimeout) {
10683
+ if (explicitTimeout != null) {
10644
10684
  return setTimeout(resolveIfNotStale, explicitTimeout);
10645
10685
  }
10646
10686
  const { type, timeout, propCount } = getTransitionInfo(el, expectedType);