@vue/reactivity 3.5.0-alpha.5 → 3.5.0-beta.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,5 +1,5 @@
1
1
  /**
2
- * @vue/reactivity v3.5.0-alpha.5
2
+ * @vue/reactivity v3.5.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -29,6 +29,7 @@ class EffectScope {
29
29
  * @internal
30
30
  */
31
31
  this.cleanups = [];
32
+ this._isPaused = false;
32
33
  this.parent = activeEffectScope;
33
34
  if (!detached && activeEffectScope) {
34
35
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
@@ -39,6 +40,37 @@ class EffectScope {
39
40
  get active() {
40
41
  return this._active;
41
42
  }
43
+ pause() {
44
+ if (this._active) {
45
+ this._isPaused = true;
46
+ if (this.scopes) {
47
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
48
+ this.scopes[i].pause();
49
+ }
50
+ }
51
+ for (let i = 0, l = this.effects.length; i < l; i++) {
52
+ this.effects[i].pause();
53
+ }
54
+ }
55
+ }
56
+ /**
57
+ * Resumes the effect scope, including all child scopes and effects.
58
+ */
59
+ resume() {
60
+ if (this._active) {
61
+ if (this._isPaused) {
62
+ this._isPaused = false;
63
+ if (this.scopes) {
64
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
65
+ this.scopes[i].resume();
66
+ }
67
+ }
68
+ for (let i = 0, l = this.effects.length; i < l; i++) {
69
+ this.effects[i].resume();
70
+ }
71
+ }
72
+ }
73
+ }
42
74
  run(fn) {
43
75
  if (this._active) {
44
76
  const currentEffectScope = activeEffectScope;
@@ -122,9 +154,10 @@ const EffectFlags = {
122
154
  "16": "DIRTY",
123
155
  "ALLOW_RECURSE": 32,
124
156
  "32": "ALLOW_RECURSE",
125
- "NO_BATCH": 64,
126
- "64": "NO_BATCH"
157
+ "PAUSED": 64,
158
+ "64": "PAUSED"
127
159
  };
160
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
128
161
  class ReactiveEffect {
129
162
  constructor(fn) {
130
163
  this.fn = fn;
@@ -153,6 +186,18 @@ class ReactiveEffect {
153
186
  activeEffectScope.effects.push(this);
154
187
  }
155
188
  }
189
+ pause() {
190
+ this.flags |= 64;
191
+ }
192
+ resume() {
193
+ if (this.flags & 64) {
194
+ this.flags &= ~64;
195
+ if (pausedQueueEffects.has(this)) {
196
+ pausedQueueEffects.delete(this);
197
+ this.trigger();
198
+ }
199
+ }
200
+ }
156
201
  /**
157
202
  * @internal
158
203
  */
@@ -160,9 +205,6 @@ class ReactiveEffect {
160
205
  if (this.flags & 2 && !(this.flags & 32)) {
161
206
  return;
162
207
  }
163
- if (this.flags & 64) {
164
- return this.trigger();
165
- }
166
208
  if (!(this.flags & 8)) {
167
209
  this.flags |= 8;
168
210
  this.nextEffect = batchedEffect;
@@ -206,7 +248,9 @@ class ReactiveEffect {
206
248
  }
207
249
  }
208
250
  trigger() {
209
- if (this.scheduler) {
251
+ if (this.flags & 64) {
252
+ pausedQueueEffects.add(this);
253
+ } else if (this.scheduler) {
210
254
  this.scheduler();
211
255
  } else {
212
256
  this.runIfDirty();
@@ -234,6 +278,7 @@ function endBatch() {
234
278
  batchDepth--;
235
279
  return;
236
280
  }
281
+ batchDepth--;
237
282
  let error;
238
283
  while (batchedEffect) {
239
284
  let e = batchedEffect;
@@ -252,7 +297,6 @@ function endBatch() {
252
297
  e = next;
253
298
  }
254
299
  }
255
- batchDepth--;
256
300
  if (error) throw error;
257
301
  }
258
302
  function prepareDeps(sub) {
@@ -539,9 +583,15 @@ function addSub(link) {
539
583
  link.dep.subs = link;
540
584
  }
541
585
  const targetMap = /* @__PURE__ */ new WeakMap();
542
- const ITERATE_KEY = Symbol("Object iterate" );
543
- const MAP_KEY_ITERATE_KEY = Symbol("Map keys iterate" );
544
- const ARRAY_ITERATE_KEY = Symbol("Array iterate" );
586
+ const ITERATE_KEY = Symbol(
587
+ "Object iterate"
588
+ );
589
+ const MAP_KEY_ITERATE_KEY = Symbol(
590
+ "Map keys iterate"
591
+ );
592
+ const ARRAY_ITERATE_KEY = Symbol(
593
+ "Array iterate"
594
+ );
545
595
  function track(target, type, key) {
546
596
  if (shouldTrack && activeSub) {
547
597
  let depsMap = targetMap.get(target);
@@ -662,26 +712,26 @@ const arrayInstrumentations = {
662
712
  });
663
713
  },
664
714
  every(fn, thisArg) {
665
- return apply(this, "every", fn, thisArg);
715
+ return apply(this, "every", fn, thisArg, void 0, arguments);
666
716
  },
667
717
  filter(fn, thisArg) {
668
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
718
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
669
719
  },
670
720
  find(fn, thisArg) {
671
- return apply(this, "find", fn, thisArg, toReactive);
721
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
672
722
  },
673
723
  findIndex(fn, thisArg) {
674
- return apply(this, "findIndex", fn, thisArg);
724
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
675
725
  },
676
726
  findLast(fn, thisArg) {
677
- return apply(this, "findLast", fn, thisArg, toReactive);
727
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
678
728
  },
679
729
  findLastIndex(fn, thisArg) {
680
- return apply(this, "findLastIndex", fn, thisArg);
730
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
681
731
  },
682
732
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
683
733
  forEach(fn, thisArg) {
684
- return apply(this, "forEach", fn, thisArg);
734
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
685
735
  },
686
736
  includes(...args) {
687
737
  return searchProxy(this, "includes", args);
@@ -697,7 +747,7 @@ const arrayInstrumentations = {
697
747
  return searchProxy(this, "lastIndexOf", args);
698
748
  },
699
749
  map(fn, thisArg) {
700
- return apply(this, "map", fn, thisArg);
750
+ return apply(this, "map", fn, thisArg, void 0, arguments);
701
751
  },
702
752
  pop() {
703
753
  return noTracking(this, "pop");
@@ -716,7 +766,7 @@ const arrayInstrumentations = {
716
766
  },
717
767
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
718
768
  some(fn, thisArg) {
719
- return apply(this, "some", fn, thisArg);
769
+ return apply(this, "some", fn, thisArg, void 0, arguments);
720
770
  },
721
771
  splice(...args) {
722
772
  return noTracking(this, "splice", args);
@@ -752,8 +802,13 @@ function iterator(self, method, wrapValue) {
752
802
  }
753
803
  return iter;
754
804
  }
755
- function apply(self, method, fn, thisArg, wrappedRetFn) {
805
+ const arrayProto = Array.prototype;
806
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
756
807
  const arr = shallowReadArray(self);
808
+ let methodFn;
809
+ if ((methodFn = arr[method]) !== arrayProto[method]) {
810
+ return methodFn.apply(arr, args);
811
+ }
757
812
  let needsWrap = false;
758
813
  let wrappedFn = fn;
759
814
  if (arr !== self) {
@@ -768,7 +823,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn) {
768
823
  };
769
824
  }
770
825
  }
771
- const result = arr[method](wrappedFn, thisArg);
826
+ const result = methodFn.call(arr, wrappedFn, thisArg);
772
827
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
773
828
  }
774
829
  function reduce(self, method, fn, args) {
@@ -831,7 +886,7 @@ class BaseReactiveHandler {
831
886
  return isShallow2;
832
887
  } else if (key === "__v_raw") {
833
888
  if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
834
- // this means the reciever is a user proxy of the reactive proxy
889
+ // this means the receiver is a user proxy of the reactive proxy
835
890
  Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
836
891
  return target;
837
892
  }
@@ -955,9 +1010,7 @@ class ReadonlyReactiveHandler extends BaseReactiveHandler {
955
1010
  }
956
1011
  const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
957
1012
  const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
958
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
959
- true
960
- );
1013
+ const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
961
1014
  const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
962
1015
 
963
1016
  const toShallow = (value) => value;
@@ -1452,13 +1505,14 @@ function proxyRefs(objectWithRefs) {
1452
1505
  class CustomRefImpl {
1453
1506
  constructor(factory) {
1454
1507
  this["__v_isRef"] = true;
1508
+ this._value = void 0;
1455
1509
  const dep = this.dep = new Dep();
1456
1510
  const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1457
1511
  this._get = get;
1458
1512
  this._set = set;
1459
1513
  }
1460
1514
  get value() {
1461
- return this._get();
1515
+ return this._value = this._get();
1462
1516
  }
1463
1517
  set value(newVal) {
1464
1518
  this._set(newVal);
@@ -1483,10 +1537,11 @@ class ObjectRefImpl {
1483
1537
  this._key = _key;
1484
1538
  this._defaultValue = _defaultValue;
1485
1539
  this["__v_isRef"] = true;
1540
+ this._value = void 0;
1486
1541
  }
1487
1542
  get value() {
1488
1543
  const val = this._object[this._key];
1489
- return val === void 0 ? this._defaultValue : val;
1544
+ return this._value = val === void 0 ? this._defaultValue : val;
1490
1545
  }
1491
1546
  set value(newVal) {
1492
1547
  this._object[this._key] = newVal;
@@ -1500,9 +1555,10 @@ class GetterRefImpl {
1500
1555
  this._getter = _getter;
1501
1556
  this["__v_isRef"] = true;
1502
1557
  this["__v_isReadonly"] = true;
1558
+ this._value = void 0;
1503
1559
  }
1504
1560
  get value() {
1505
- return this._getter();
1561
+ return this._value = this._getter();
1506
1562
  }
1507
1563
  }
1508
1564
  function toRef(source, key, defaultValue) {
@@ -1536,7 +1592,8 @@ class ComputedRefImpl {
1536
1592
  /**
1537
1593
  * @internal
1538
1594
  */
1539
- this["__v_isRef"] = true;
1595
+ this.__v_isRef = true;
1596
+ // TODO isolatedDeclarations "__v_isReadonly"
1540
1597
  // A computed is also a subscriber that tracks other deps
1541
1598
  /**
1542
1599
  * @internal
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/reactivity v3.5.0-alpha.5
2
+ * @vue/reactivity v3.5.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -25,6 +25,7 @@ class EffectScope {
25
25
  * @internal
26
26
  */
27
27
  this.cleanups = [];
28
+ this._isPaused = false;
28
29
  this.parent = activeEffectScope;
29
30
  if (!detached && activeEffectScope) {
30
31
  this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
@@ -35,6 +36,37 @@ class EffectScope {
35
36
  get active() {
36
37
  return this._active;
37
38
  }
39
+ pause() {
40
+ if (this._active) {
41
+ this._isPaused = true;
42
+ if (this.scopes) {
43
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
44
+ this.scopes[i].pause();
45
+ }
46
+ }
47
+ for (let i = 0, l = this.effects.length; i < l; i++) {
48
+ this.effects[i].pause();
49
+ }
50
+ }
51
+ }
52
+ /**
53
+ * Resumes the effect scope, including all child scopes and effects.
54
+ */
55
+ resume() {
56
+ if (this._active) {
57
+ if (this._isPaused) {
58
+ this._isPaused = false;
59
+ if (this.scopes) {
60
+ for (let i = 0, l = this.scopes.length; i < l; i++) {
61
+ this.scopes[i].resume();
62
+ }
63
+ }
64
+ for (let i = 0, l = this.effects.length; i < l; i++) {
65
+ this.effects[i].resume();
66
+ }
67
+ }
68
+ }
69
+ }
38
70
  run(fn) {
39
71
  if (this._active) {
40
72
  const currentEffectScope = activeEffectScope;
@@ -112,9 +144,10 @@ const EffectFlags = {
112
144
  "16": "DIRTY",
113
145
  "ALLOW_RECURSE": 32,
114
146
  "32": "ALLOW_RECURSE",
115
- "NO_BATCH": 64,
116
- "64": "NO_BATCH"
147
+ "PAUSED": 64,
148
+ "64": "PAUSED"
117
149
  };
150
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
118
151
  class ReactiveEffect {
119
152
  constructor(fn) {
120
153
  this.fn = fn;
@@ -143,6 +176,18 @@ class ReactiveEffect {
143
176
  activeEffectScope.effects.push(this);
144
177
  }
145
178
  }
179
+ pause() {
180
+ this.flags |= 64;
181
+ }
182
+ resume() {
183
+ if (this.flags & 64) {
184
+ this.flags &= ~64;
185
+ if (pausedQueueEffects.has(this)) {
186
+ pausedQueueEffects.delete(this);
187
+ this.trigger();
188
+ }
189
+ }
190
+ }
146
191
  /**
147
192
  * @internal
148
193
  */
@@ -150,9 +195,6 @@ class ReactiveEffect {
150
195
  if (this.flags & 2 && !(this.flags & 32)) {
151
196
  return;
152
197
  }
153
- if (this.flags & 64) {
154
- return this.trigger();
155
- }
156
198
  if (!(this.flags & 8)) {
157
199
  this.flags |= 8;
158
200
  this.nextEffect = batchedEffect;
@@ -191,7 +233,9 @@ class ReactiveEffect {
191
233
  }
192
234
  }
193
235
  trigger() {
194
- if (this.scheduler) {
236
+ if (this.flags & 64) {
237
+ pausedQueueEffects.add(this);
238
+ } else if (this.scheduler) {
195
239
  this.scheduler();
196
240
  } else {
197
241
  this.runIfDirty();
@@ -219,6 +263,7 @@ function endBatch() {
219
263
  batchDepth--;
220
264
  return;
221
265
  }
266
+ batchDepth--;
222
267
  let error;
223
268
  while (batchedEffect) {
224
269
  let e = batchedEffect;
@@ -237,7 +282,6 @@ function endBatch() {
237
282
  e = next;
238
283
  }
239
284
  }
240
- batchDepth--;
241
285
  if (error) throw error;
242
286
  }
243
287
  function prepareDeps(sub) {
@@ -491,9 +535,15 @@ function addSub(link) {
491
535
  link.dep.subs = link;
492
536
  }
493
537
  const targetMap = /* @__PURE__ */ new WeakMap();
494
- const ITERATE_KEY = Symbol("");
495
- const MAP_KEY_ITERATE_KEY = Symbol("");
496
- const ARRAY_ITERATE_KEY = Symbol("");
538
+ const ITERATE_KEY = Symbol(
539
+ ""
540
+ );
541
+ const MAP_KEY_ITERATE_KEY = Symbol(
542
+ ""
543
+ );
544
+ const ARRAY_ITERATE_KEY = Symbol(
545
+ ""
546
+ );
497
547
  function track(target, type, key) {
498
548
  if (shouldTrack && activeSub) {
499
549
  let depsMap = targetMap.get(target);
@@ -603,26 +653,26 @@ const arrayInstrumentations = {
603
653
  });
604
654
  },
605
655
  every(fn, thisArg) {
606
- return apply(this, "every", fn, thisArg);
656
+ return apply(this, "every", fn, thisArg, void 0, arguments);
607
657
  },
608
658
  filter(fn, thisArg) {
609
- return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
659
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
610
660
  },
611
661
  find(fn, thisArg) {
612
- return apply(this, "find", fn, thisArg, toReactive);
662
+ return apply(this, "find", fn, thisArg, toReactive, arguments);
613
663
  },
614
664
  findIndex(fn, thisArg) {
615
- return apply(this, "findIndex", fn, thisArg);
665
+ return apply(this, "findIndex", fn, thisArg, void 0, arguments);
616
666
  },
617
667
  findLast(fn, thisArg) {
618
- return apply(this, "findLast", fn, thisArg, toReactive);
668
+ return apply(this, "findLast", fn, thisArg, toReactive, arguments);
619
669
  },
620
670
  findLastIndex(fn, thisArg) {
621
- return apply(this, "findLastIndex", fn, thisArg);
671
+ return apply(this, "findLastIndex", fn, thisArg, void 0, arguments);
622
672
  },
623
673
  // flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
624
674
  forEach(fn, thisArg) {
625
- return apply(this, "forEach", fn, thisArg);
675
+ return apply(this, "forEach", fn, thisArg, void 0, arguments);
626
676
  },
627
677
  includes(...args) {
628
678
  return searchProxy(this, "includes", args);
@@ -638,7 +688,7 @@ const arrayInstrumentations = {
638
688
  return searchProxy(this, "lastIndexOf", args);
639
689
  },
640
690
  map(fn, thisArg) {
641
- return apply(this, "map", fn, thisArg);
691
+ return apply(this, "map", fn, thisArg, void 0, arguments);
642
692
  },
643
693
  pop() {
644
694
  return noTracking(this, "pop");
@@ -657,7 +707,7 @@ const arrayInstrumentations = {
657
707
  },
658
708
  // slice could use ARRAY_ITERATE but also seems to beg for range tracking
659
709
  some(fn, thisArg) {
660
- return apply(this, "some", fn, thisArg);
710
+ return apply(this, "some", fn, thisArg, void 0, arguments);
661
711
  },
662
712
  splice(...args) {
663
713
  return noTracking(this, "splice", args);
@@ -693,8 +743,13 @@ function iterator(self, method, wrapValue) {
693
743
  }
694
744
  return iter;
695
745
  }
696
- function apply(self, method, fn, thisArg, wrappedRetFn) {
746
+ const arrayProto = Array.prototype;
747
+ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
697
748
  const arr = shallowReadArray(self);
749
+ let methodFn;
750
+ if ((methodFn = arr[method]) !== arrayProto[method]) {
751
+ return methodFn.apply(arr, args);
752
+ }
698
753
  let needsWrap = false;
699
754
  let wrappedFn = fn;
700
755
  if (arr !== self) {
@@ -709,7 +764,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn) {
709
764
  };
710
765
  }
711
766
  }
712
- const result = arr[method](wrappedFn, thisArg);
767
+ const result = methodFn.call(arr, wrappedFn, thisArg);
713
768
  return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
714
769
  }
715
770
  function reduce(self, method, fn, args) {
@@ -772,7 +827,7 @@ class BaseReactiveHandler {
772
827
  return isShallow2;
773
828
  } else if (key === "__v_raw") {
774
829
  if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
775
- // this means the reciever is a user proxy of the reactive proxy
830
+ // this means the receiver is a user proxy of the reactive proxy
776
831
  Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
777
832
  return target;
778
833
  }
@@ -884,9 +939,7 @@ class ReadonlyReactiveHandler extends BaseReactiveHandler {
884
939
  }
885
940
  const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
886
941
  const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
887
- const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
888
- true
889
- );
942
+ const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
890
943
  const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
891
944
 
892
945
  const toShallow = (value) => value;
@@ -1338,13 +1391,14 @@ function proxyRefs(objectWithRefs) {
1338
1391
  class CustomRefImpl {
1339
1392
  constructor(factory) {
1340
1393
  this["__v_isRef"] = true;
1394
+ this._value = void 0;
1341
1395
  const dep = this.dep = new Dep();
1342
1396
  const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
1343
1397
  this._get = get;
1344
1398
  this._set = set;
1345
1399
  }
1346
1400
  get value() {
1347
- return this._get();
1401
+ return this._value = this._get();
1348
1402
  }
1349
1403
  set value(newVal) {
1350
1404
  this._set(newVal);
@@ -1366,10 +1420,11 @@ class ObjectRefImpl {
1366
1420
  this._key = _key;
1367
1421
  this._defaultValue = _defaultValue;
1368
1422
  this["__v_isRef"] = true;
1423
+ this._value = void 0;
1369
1424
  }
1370
1425
  get value() {
1371
1426
  const val = this._object[this._key];
1372
- return val === void 0 ? this._defaultValue : val;
1427
+ return this._value = val === void 0 ? this._defaultValue : val;
1373
1428
  }
1374
1429
  set value(newVal) {
1375
1430
  this._object[this._key] = newVal;
@@ -1383,9 +1438,10 @@ class GetterRefImpl {
1383
1438
  this._getter = _getter;
1384
1439
  this["__v_isRef"] = true;
1385
1440
  this["__v_isReadonly"] = true;
1441
+ this._value = void 0;
1386
1442
  }
1387
1443
  get value() {
1388
- return this._getter();
1444
+ return this._value = this._getter();
1389
1445
  }
1390
1446
  }
1391
1447
  function toRef(source, key, defaultValue) {
@@ -1419,7 +1475,8 @@ class ComputedRefImpl {
1419
1475
  /**
1420
1476
  * @internal
1421
1477
  */
1422
- this["__v_isRef"] = true;
1478
+ this.__v_isRef = true;
1479
+ // TODO isolatedDeclarations "__v_isReadonly"
1423
1480
  // A computed is also a subscriber that tracks other deps
1424
1481
  /**
1425
1482
  * @internal
@@ -22,8 +22,8 @@ export declare enum ReactiveFlags {
22
22
 
23
23
  export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T>;
24
24
  declare const ReactiveMarkerSymbol: unique symbol;
25
- export declare class ReactiveMarker {
26
- private [ReactiveMarkerSymbol]?;
25
+ export interface ReactiveMarker {
26
+ [ReactiveMarkerSymbol]?: void;
27
27
  }
28
28
  export type Reactive<T> = UnwrapNestedRefs<T> & (T extends readonly any[] ? ReactiveMarker : {});
29
29
  /**
@@ -278,7 +278,7 @@ export declare enum EffectFlags {
278
278
  NOTIFIED = 8,
279
279
  DIRTY = 16,
280
280
  ALLOW_RECURSE = 32,
281
- NO_BATCH = 64
281
+ PAUSED = 64
282
282
  }
283
283
  /**
284
284
  * Subscriber is a type that tracks (or subscribes to) a list of deps.
@@ -292,6 +292,8 @@ export declare class ReactiveEffect<T = any> implements Subscriber, ReactiveEffe
292
292
  onTrack?: (event: DebuggerEvent) => void;
293
293
  onTrigger?: (event: DebuggerEvent) => void;
294
294
  constructor(fn: () => T);
295
+ pause(): void;
296
+ resume(): void;
295
297
  run(): T;
296
298
  stop(): void;
297
299
  trigger(): void;
@@ -339,21 +341,25 @@ export declare function resetTracking(): void;
339
341
  export declare function onEffectCleanup(fn: () => void, failSilently?: boolean): void;
340
342
 
341
343
  declare const ComputedRefSymbol: unique symbol;
342
- export interface ComputedRef<T = any> extends WritableComputedRef<T> {
343
- readonly value: T;
344
+ declare const WritableComputedRefSymbol: unique symbol;
345
+ interface BaseComputedRef<T, S = T> extends Ref<T, S> {
344
346
  [ComputedRefSymbol]: true;
345
- }
346
- export interface WritableComputedRef<T> extends Ref<T> {
347
347
  /**
348
348
  * @deprecated computed no longer uses effect
349
349
  */
350
350
  effect: ComputedRefImpl;
351
351
  }
352
+ export interface ComputedRef<T = any> extends BaseComputedRef<T> {
353
+ readonly value: T;
354
+ }
355
+ export interface WritableComputedRef<T, S = T> extends BaseComputedRef<T, S> {
356
+ [WritableComputedRefSymbol]: true;
357
+ }
352
358
  export type ComputedGetter<T> = (oldValue?: T) => T;
353
359
  export type ComputedSetter<T> = (newValue: T) => void;
354
- export interface WritableComputedOptions<T> {
360
+ export interface WritableComputedOptions<T, S = T> {
355
361
  get: ComputedGetter<T>;
356
- set: ComputedSetter<T>;
362
+ set: ComputedSetter<S>;
357
363
  }
358
364
  /**
359
365
  * @private exported by @vue/reactivity for Vue core use, but not exported from
@@ -366,8 +372,8 @@ export declare class ComputedRefImpl<T = any> implements Subscriber {
366
372
  onTrack?: (event: DebuggerEvent) => void;
367
373
  onTrigger?: (event: DebuggerEvent) => void;
368
374
  constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined, isSSR: boolean);
369
- get value(): any;
370
- set value(newValue: any);
375
+ get value(): T;
376
+ set value(newValue: T);
371
377
  }
372
378
  /**
373
379
  * Takes a getter function and returns a readonly reactive ref object for the
@@ -403,7 +409,7 @@ export declare class ComputedRefImpl<T = any> implements Subscriber {
403
409
  * @see {@link https://vuejs.org/api/reactivity-core.html#computed}
404
410
  */
405
411
  export declare function computed<T>(getter: ComputedGetter<T>, debugOptions?: DebuggerOptions): ComputedRef<T>;
406
- export declare function computed<T>(options: WritableComputedOptions<T>, debugOptions?: DebuggerOptions): WritableComputedRef<T>;
412
+ export declare function computed<T, S = T>(options: WritableComputedOptions<T, S>, debugOptions?: DebuggerOptions): WritableComputedRef<T, S>;
407
413
 
408
414
  declare const RefSymbol: unique symbol;
409
415
  declare const RawSymbol: unique symbol;
@@ -431,7 +437,7 @@ export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
431
437
  * @param value - The object to wrap in the ref.
432
438
  * @see {@link https://vuejs.org/api/reactivity-core.html#ref}
433
439
  */
434
- export declare function ref<T>(value: T): Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
440
+ export declare function ref<T>(value: T): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
435
441
  export declare function ref<T = any>(): Ref<T | undefined>;
436
442
  declare const ShallowRefMarker: unique symbol;
437
443
  export type ShallowRef<T = any> = Ref<T> & {
@@ -482,8 +488,8 @@ export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
482
488
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
483
489
  */
484
490
  export declare function triggerRef(ref: Ref): void;
485
- export type MaybeRef<T = any> = T | Ref<T>;
486
- export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
491
+ export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
492
+ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
487
493
  /**
488
494
  * Returns the inner value if the argument is a ref, otherwise return the
489
495
  * argument itself. This is a sugar function for
@@ -500,7 +506,7 @@ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
500
506
  * @param ref - Ref or plain value to be converted into the plain value.
501
507
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
502
508
  */
503
- export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<T>): T;
509
+ export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
504
510
  /**
505
511
  * Normalizes values / refs / getters to values.
506
512
  * This is similar to {@link unref()}, except that it also normalizes getters.
@@ -517,7 +523,7 @@ export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<
517
523
  * @param source - A getter, an existing ref, or a non-function value.
518
524
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
519
525
  */
520
- export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T> | ShallowRef<T>): T;
526
+ export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
521
527
  /**
522
528
  * Returns a proxy for the given object that shallowly unwraps properties that
523
529
  * are refs. If the object already is reactive, it's returned as-is. If not, a
@@ -654,8 +660,14 @@ export declare function trigger(target: object, type: TriggerOpTypes, key?: unkn
654
660
 
655
661
  export declare class EffectScope {
656
662
  detached: boolean;
663
+ private _isPaused;
657
664
  constructor(detached?: boolean);
658
665
  get active(): boolean;
666
+ pause(): void;
667
+ /**
668
+ * Resumes the effect scope, including all child scopes and effects.
669
+ */
670
+ resume(): void;
659
671
  run<T>(fn: () => T): T | undefined;
660
672
  stop(fromParent?: boolean): void;
661
673
  }