@vue/reactivity 3.5.0-alpha.4 → 3.5.0-beta.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/reactivity v3.5.0-alpha.4
2
+ * @vue/reactivity v3.5.0-beta.1
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;
@@ -123,8 +155,11 @@ const EffectFlags = {
123
155
  "ALLOW_RECURSE": 32,
124
156
  "32": "ALLOW_RECURSE",
125
157
  "NO_BATCH": 64,
126
- "64": "NO_BATCH"
158
+ "64": "NO_BATCH",
159
+ "PAUSED": 128,
160
+ "128": "PAUSED"
127
161
  };
162
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
128
163
  class ReactiveEffect {
129
164
  constructor(fn) {
130
165
  this.fn = fn;
@@ -153,6 +188,18 @@ class ReactiveEffect {
153
188
  activeEffectScope.effects.push(this);
154
189
  }
155
190
  }
191
+ pause() {
192
+ this.flags |= 128;
193
+ }
194
+ resume() {
195
+ if (this.flags & 128) {
196
+ this.flags &= ~128;
197
+ if (pausedQueueEffects.has(this)) {
198
+ pausedQueueEffects.delete(this);
199
+ this.trigger();
200
+ }
201
+ }
202
+ }
156
203
  /**
157
204
  * @internal
158
205
  */
@@ -206,7 +253,9 @@ class ReactiveEffect {
206
253
  }
207
254
  }
208
255
  trigger() {
209
- if (this.scheduler) {
256
+ if (this.flags & 128) {
257
+ pausedQueueEffects.add(this);
258
+ } else if (this.scheduler) {
210
259
  this.scheduler();
211
260
  } else {
212
261
  this.runIfDirty();
@@ -539,9 +588,15 @@ function addSub(link) {
539
588
  link.dep.subs = link;
540
589
  }
541
590
  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" );
591
+ const ITERATE_KEY = Symbol(
592
+ "Object iterate"
593
+ );
594
+ const MAP_KEY_ITERATE_KEY = Symbol(
595
+ "Map keys iterate"
596
+ );
597
+ const ARRAY_ITERATE_KEY = Symbol(
598
+ "Array iterate"
599
+ );
545
600
  function track(target, type, key) {
546
601
  if (shouldTrack && activeSub) {
547
602
  let depsMap = targetMap.get(target);
@@ -665,19 +720,16 @@ const arrayInstrumentations = {
665
720
  return apply(this, "every", fn, thisArg);
666
721
  },
667
722
  filter(fn, thisArg) {
668
- const result = apply(this, "filter", fn, thisArg);
669
- return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
723
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
670
724
  },
671
725
  find(fn, thisArg) {
672
- const result = apply(this, "find", fn, thisArg);
673
- return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
726
+ return apply(this, "find", fn, thisArg, toReactive);
674
727
  },
675
728
  findIndex(fn, thisArg) {
676
729
  return apply(this, "findIndex", fn, thisArg);
677
730
  },
678
731
  findLast(fn, thisArg) {
679
- const result = apply(this, "findLast", fn, thisArg);
680
- return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
732
+ return apply(this, "findLast", fn, thisArg, toReactive);
681
733
  },
682
734
  findLastIndex(fn, thisArg) {
683
735
  return apply(this, "findLastIndex", fn, thisArg);
@@ -755,11 +807,13 @@ function iterator(self, method, wrapValue) {
755
807
  }
756
808
  return iter;
757
809
  }
758
- function apply(self, method, fn, thisArg) {
810
+ function apply(self, method, fn, thisArg, wrappedRetFn) {
759
811
  const arr = shallowReadArray(self);
812
+ let needsWrap = false;
760
813
  let wrappedFn = fn;
761
814
  if (arr !== self) {
762
- if (!isShallow(self)) {
815
+ needsWrap = !isShallow(self);
816
+ if (needsWrap) {
763
817
  wrappedFn = function(item, index) {
764
818
  return fn.call(this, toReactive(item), index, self);
765
819
  };
@@ -769,7 +823,8 @@ function apply(self, method, fn, thisArg) {
769
823
  };
770
824
  }
771
825
  }
772
- return arr[method](wrappedFn, thisArg);
826
+ const result = arr[method](wrappedFn, thisArg);
827
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
773
828
  }
774
829
  function reduce(self, method, fn, args) {
775
830
  const arr = shallowReadArray(self);
@@ -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.4
2
+ * @vue/reactivity v3.5.0-beta.1
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;
@@ -113,8 +145,11 @@ const EffectFlags = {
113
145
  "ALLOW_RECURSE": 32,
114
146
  "32": "ALLOW_RECURSE",
115
147
  "NO_BATCH": 64,
116
- "64": "NO_BATCH"
148
+ "64": "NO_BATCH",
149
+ "PAUSED": 128,
150
+ "128": "PAUSED"
117
151
  };
152
+ const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
118
153
  class ReactiveEffect {
119
154
  constructor(fn) {
120
155
  this.fn = fn;
@@ -143,6 +178,18 @@ class ReactiveEffect {
143
178
  activeEffectScope.effects.push(this);
144
179
  }
145
180
  }
181
+ pause() {
182
+ this.flags |= 128;
183
+ }
184
+ resume() {
185
+ if (this.flags & 128) {
186
+ this.flags &= ~128;
187
+ if (pausedQueueEffects.has(this)) {
188
+ pausedQueueEffects.delete(this);
189
+ this.trigger();
190
+ }
191
+ }
192
+ }
146
193
  /**
147
194
  * @internal
148
195
  */
@@ -191,7 +238,9 @@ class ReactiveEffect {
191
238
  }
192
239
  }
193
240
  trigger() {
194
- if (this.scheduler) {
241
+ if (this.flags & 128) {
242
+ pausedQueueEffects.add(this);
243
+ } else if (this.scheduler) {
195
244
  this.scheduler();
196
245
  } else {
197
246
  this.runIfDirty();
@@ -491,9 +540,15 @@ function addSub(link) {
491
540
  link.dep.subs = link;
492
541
  }
493
542
  const targetMap = /* @__PURE__ */ new WeakMap();
494
- const ITERATE_KEY = Symbol("");
495
- const MAP_KEY_ITERATE_KEY = Symbol("");
496
- const ARRAY_ITERATE_KEY = Symbol("");
543
+ const ITERATE_KEY = Symbol(
544
+ ""
545
+ );
546
+ const MAP_KEY_ITERATE_KEY = Symbol(
547
+ ""
548
+ );
549
+ const ARRAY_ITERATE_KEY = Symbol(
550
+ ""
551
+ );
497
552
  function track(target, type, key) {
498
553
  if (shouldTrack && activeSub) {
499
554
  let depsMap = targetMap.get(target);
@@ -606,19 +661,16 @@ const arrayInstrumentations = {
606
661
  return apply(this, "every", fn, thisArg);
607
662
  },
608
663
  filter(fn, thisArg) {
609
- const result = apply(this, "filter", fn, thisArg);
610
- return isProxy(this) && !isShallow(this) ? result.map(toReactive) : result;
664
+ return apply(this, "filter", fn, thisArg, (v) => v.map(toReactive));
611
665
  },
612
666
  find(fn, thisArg) {
613
- const result = apply(this, "find", fn, thisArg);
614
- return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
667
+ return apply(this, "find", fn, thisArg, toReactive);
615
668
  },
616
669
  findIndex(fn, thisArg) {
617
670
  return apply(this, "findIndex", fn, thisArg);
618
671
  },
619
672
  findLast(fn, thisArg) {
620
- const result = apply(this, "findLast", fn, thisArg);
621
- return isProxy(this) && !isShallow(this) ? toReactive(result) : result;
673
+ return apply(this, "findLast", fn, thisArg, toReactive);
622
674
  },
623
675
  findLastIndex(fn, thisArg) {
624
676
  return apply(this, "findLastIndex", fn, thisArg);
@@ -696,11 +748,13 @@ function iterator(self, method, wrapValue) {
696
748
  }
697
749
  return iter;
698
750
  }
699
- function apply(self, method, fn, thisArg) {
751
+ function apply(self, method, fn, thisArg, wrappedRetFn) {
700
752
  const arr = shallowReadArray(self);
753
+ let needsWrap = false;
701
754
  let wrappedFn = fn;
702
755
  if (arr !== self) {
703
- if (!isShallow(self)) {
756
+ needsWrap = !isShallow(self);
757
+ if (needsWrap) {
704
758
  wrappedFn = function(item, index) {
705
759
  return fn.call(this, toReactive(item), index, self);
706
760
  };
@@ -710,7 +764,8 @@ function apply(self, method, fn, thisArg) {
710
764
  };
711
765
  }
712
766
  }
713
- return arr[method](wrappedFn, thisArg);
767
+ const result = arr[method](wrappedFn, thisArg);
768
+ return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
714
769
  }
715
770
  function reduce(self, method, fn, args) {
716
771
  const arr = shallowReadArray(self);
@@ -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,8 @@ export declare enum EffectFlags {
278
278
  NOTIFIED = 8,
279
279
  DIRTY = 16,
280
280
  ALLOW_RECURSE = 32,
281
- NO_BATCH = 64
281
+ NO_BATCH = 64,
282
+ PAUSED = 128
282
283
  }
283
284
  /**
284
285
  * Subscriber is a type that tracks (or subscribes to) a list of deps.
@@ -292,6 +293,8 @@ export declare class ReactiveEffect<T = any> implements Subscriber, ReactiveEffe
292
293
  onTrack?: (event: DebuggerEvent) => void;
293
294
  onTrigger?: (event: DebuggerEvent) => void;
294
295
  constructor(fn: () => T);
296
+ pause(): void;
297
+ resume(): void;
295
298
  run(): T;
296
299
  stop(): void;
297
300
  trigger(): void;
@@ -343,7 +346,7 @@ export interface ComputedRef<T = any> extends WritableComputedRef<T> {
343
346
  readonly value: T;
344
347
  [ComputedRefSymbol]: true;
345
348
  }
346
- export interface WritableComputedRef<T> extends Ref<T> {
349
+ export interface WritableComputedRef<T, S = T> extends Ref<T, S> {
347
350
  /**
348
351
  * @deprecated computed no longer uses effect
349
352
  */
@@ -351,9 +354,9 @@ export interface WritableComputedRef<T> extends Ref<T> {
351
354
  }
352
355
  export type ComputedGetter<T> = (oldValue?: T) => T;
353
356
  export type ComputedSetter<T> = (newValue: T) => void;
354
- export interface WritableComputedOptions<T> {
357
+ export interface WritableComputedOptions<T, S = T> {
355
358
  get: ComputedGetter<T>;
356
- set: ComputedSetter<T>;
359
+ set: ComputedSetter<S>;
357
360
  }
358
361
  /**
359
362
  * @private exported by @vue/reactivity for Vue core use, but not exported from
@@ -366,8 +369,8 @@ export declare class ComputedRefImpl<T = any> implements Subscriber {
366
369
  onTrack?: (event: DebuggerEvent) => void;
367
370
  onTrigger?: (event: DebuggerEvent) => void;
368
371
  constructor(fn: ComputedGetter<T>, setter: ComputedSetter<T> | undefined, isSSR: boolean);
369
- get value(): any;
370
- set value(newValue: any);
372
+ get value(): T;
373
+ set value(newValue: T);
371
374
  }
372
375
  /**
373
376
  * Takes a getter function and returns a readonly reactive ref object for the
@@ -403,12 +406,13 @@ export declare class ComputedRefImpl<T = any> implements Subscriber {
403
406
  * @see {@link https://vuejs.org/api/reactivity-core.html#computed}
404
407
  */
405
408
  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>;
409
+ export declare function computed<T, S = T>(options: WritableComputedOptions<T, S>, debugOptions?: DebuggerOptions): WritableComputedRef<T, S>;
407
410
 
408
411
  declare const RefSymbol: unique symbol;
409
412
  declare const RawSymbol: unique symbol;
410
- export interface Ref<T = any> {
411
- value: T;
413
+ export interface Ref<T = any, S = T> {
414
+ get value(): T;
415
+ set value(_: S);
412
416
  /**
413
417
  * Type differentiator only.
414
418
  * We need this to be in public d.ts but don't want it to show up in IDE
@@ -430,7 +434,7 @@ export declare function isRef<T>(r: Ref<T> | unknown): r is Ref<T>;
430
434
  * @param value - The object to wrap in the ref.
431
435
  * @see {@link https://vuejs.org/api/reactivity-core.html#ref}
432
436
  */
433
- export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
437
+ export declare function ref<T>(value: T): [T] extends [Ref] ? IfAny<T, Ref<T>, T> : Ref<UnwrapRef<T>, UnwrapRef<T> | T>;
434
438
  export declare function ref<T = any>(): Ref<T | undefined>;
435
439
  declare const ShallowRefMarker: unique symbol;
436
440
  export type ShallowRef<T = any> = Ref<T> & {
@@ -481,8 +485,8 @@ export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
481
485
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#triggerref}
482
486
  */
483
487
  export declare function triggerRef(ref: Ref): void;
484
- export type MaybeRef<T = any> = T | Ref<T>;
485
- export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
488
+ export type MaybeRef<T = any> = T | Ref<T> | ShallowRef<T> | WritableComputedRef<T>;
489
+ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | ComputedRef<T> | (() => T);
486
490
  /**
487
491
  * Returns the inner value if the argument is a ref, otherwise return the
488
492
  * argument itself. This is a sugar function for
@@ -499,7 +503,7 @@ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T);
499
503
  * @param ref - Ref or plain value to be converted into the plain value.
500
504
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#unref}
501
505
  */
502
- export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<T>): T;
506
+ export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T>): T;
503
507
  /**
504
508
  * Normalizes values / refs / getters to values.
505
509
  * This is similar to {@link unref()}, except that it also normalizes getters.
@@ -516,7 +520,7 @@ export declare function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<
516
520
  * @param source - A getter, an existing ref, or a non-function value.
517
521
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue}
518
522
  */
519
- export declare function toValue<T>(source: MaybeRefOrGetter<T> | ComputedRef<T> | ShallowRef<T>): T;
523
+ export declare function toValue<T>(source: MaybeRefOrGetter<T>): T;
520
524
  /**
521
525
  * Returns a proxy for the given object that shallowly unwraps properties that
522
526
  * are refs. If the object already is reactive, it's returned as-is. If not, a
@@ -653,8 +657,14 @@ export declare function trigger(target: object, type: TriggerOpTypes, key?: unkn
653
657
 
654
658
  export declare class EffectScope {
655
659
  detached: boolean;
660
+ private _isPaused;
656
661
  constructor(detached?: boolean);
657
662
  get active(): boolean;
663
+ pause(): void;
664
+ /**
665
+ * Resumes the effect scope, including all child scopes and effects.
666
+ */
667
+ resume(): void;
658
668
  run<T>(fn: () => T): T | undefined;
659
669
  stop(fromParent?: boolean): void;
660
670
  }