@vue/reactivity 3.5.0-beta.2 → 3.5.0-beta.3

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-beta.2
2
+ * @vue/reactivity v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -805,14 +805,14 @@ function iterator(self, method, wrapValue) {
805
805
  const arrayProto = Array.prototype;
806
806
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
807
807
  const arr = shallowReadArray(self);
808
- let methodFn;
809
- if ((methodFn = arr[method]) !== arrayProto[method]) {
810
- return methodFn.apply(arr, args);
808
+ const needsWrap = arr !== self && !isShallow(self);
809
+ const methodFn = arr[method];
810
+ if (methodFn !== arrayProto[method]) {
811
+ const result2 = methodFn.apply(arr, args);
812
+ return needsWrap ? toReactive(result2) : result2;
811
813
  }
812
- let needsWrap = false;
813
814
  let wrappedFn = fn;
814
815
  if (arr !== self) {
815
- needsWrap = !isShallow(self);
816
816
  if (needsWrap) {
817
817
  wrappedFn = function(item, index) {
818
818
  return fn.call(this, toReactive(item), index, self);
@@ -1682,6 +1682,228 @@ const ReactiveFlags = {
1682
1682
  "IS_REF": "__v_isRef"
1683
1683
  };
1684
1684
 
1685
+ const WatchErrorCodes = {
1686
+ "WATCH_GETTER": 2,
1687
+ "2": "WATCH_GETTER",
1688
+ "WATCH_CALLBACK": 3,
1689
+ "3": "WATCH_CALLBACK",
1690
+ "WATCH_CLEANUP": 4,
1691
+ "4": "WATCH_CLEANUP"
1692
+ };
1693
+ const INITIAL_WATCHER_VALUE = {};
1694
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1695
+ let activeWatcher = void 0;
1696
+ function getCurrentWatcher() {
1697
+ return activeWatcher;
1698
+ }
1699
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1700
+ if (owner) {
1701
+ let cleanups = cleanupMap.get(owner);
1702
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1703
+ cleanups.push(cleanupFn);
1704
+ } else if (!failSilently) {
1705
+ warn(
1706
+ `onWatcherCleanup() was called when there was no active watcher to associate with.`
1707
+ );
1708
+ }
1709
+ }
1710
+ function watch(source, cb, options = shared.EMPTY_OBJ) {
1711
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1712
+ const warnInvalidSource = (s) => {
1713
+ (options.onWarn || warn)(
1714
+ `Invalid watch source: `,
1715
+ s,
1716
+ `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
1717
+ );
1718
+ };
1719
+ const reactiveGetter = (source2) => {
1720
+ if (deep) return source2;
1721
+ if (isShallow(source2) || deep === false || deep === 0)
1722
+ return traverse(source2, 1);
1723
+ return traverse(source2);
1724
+ };
1725
+ let effect;
1726
+ let getter;
1727
+ let cleanup;
1728
+ let boundCleanup;
1729
+ let forceTrigger = false;
1730
+ let isMultiSource = false;
1731
+ if (isRef(source)) {
1732
+ getter = () => source.value;
1733
+ forceTrigger = isShallow(source);
1734
+ } else if (isReactive(source)) {
1735
+ getter = () => reactiveGetter(source);
1736
+ forceTrigger = true;
1737
+ } else if (shared.isArray(source)) {
1738
+ isMultiSource = true;
1739
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1740
+ getter = () => source.map((s) => {
1741
+ if (isRef(s)) {
1742
+ return s.value;
1743
+ } else if (isReactive(s)) {
1744
+ return reactiveGetter(s);
1745
+ } else if (shared.isFunction(s)) {
1746
+ return call ? call(s, 2) : s();
1747
+ } else {
1748
+ warnInvalidSource(s);
1749
+ }
1750
+ });
1751
+ } else if (shared.isFunction(source)) {
1752
+ if (cb) {
1753
+ getter = call ? () => call(source, 2) : source;
1754
+ } else {
1755
+ getter = () => {
1756
+ if (cleanup) {
1757
+ pauseTracking();
1758
+ try {
1759
+ cleanup();
1760
+ } finally {
1761
+ resetTracking();
1762
+ }
1763
+ }
1764
+ const currentEffect = activeWatcher;
1765
+ activeWatcher = effect;
1766
+ try {
1767
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1768
+ } finally {
1769
+ activeWatcher = currentEffect;
1770
+ }
1771
+ };
1772
+ }
1773
+ } else {
1774
+ getter = shared.NOOP;
1775
+ warnInvalidSource(source);
1776
+ }
1777
+ if (cb && deep) {
1778
+ const baseGetter = getter;
1779
+ const depth = deep === true ? Infinity : deep;
1780
+ getter = () => traverse(baseGetter(), depth);
1781
+ }
1782
+ if (once) {
1783
+ if (cb) {
1784
+ const _cb = cb;
1785
+ cb = (...args) => {
1786
+ _cb(...args);
1787
+ effect.stop();
1788
+ };
1789
+ } else {
1790
+ const _getter = getter;
1791
+ getter = () => {
1792
+ _getter();
1793
+ effect.stop();
1794
+ };
1795
+ }
1796
+ }
1797
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1798
+ const job = (immediateFirstRun) => {
1799
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1800
+ return;
1801
+ }
1802
+ if (cb) {
1803
+ const newValue = effect.run();
1804
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
1805
+ if (cleanup) {
1806
+ cleanup();
1807
+ }
1808
+ const currentWatcher = activeWatcher;
1809
+ activeWatcher = effect;
1810
+ try {
1811
+ const args = [
1812
+ newValue,
1813
+ // pass undefined as the old value when it's changed for the first time
1814
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1815
+ boundCleanup
1816
+ ];
1817
+ call ? call(cb, 3, args) : (
1818
+ // @ts-expect-error
1819
+ cb(...args)
1820
+ );
1821
+ oldValue = newValue;
1822
+ } finally {
1823
+ activeWatcher = currentWatcher;
1824
+ }
1825
+ }
1826
+ } else {
1827
+ effect.run();
1828
+ }
1829
+ };
1830
+ if (augmentJob) {
1831
+ augmentJob(job);
1832
+ }
1833
+ effect = new ReactiveEffect(getter);
1834
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1835
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1836
+ cleanup = effect.onStop = () => {
1837
+ const cleanups = cleanupMap.get(effect);
1838
+ if (cleanups) {
1839
+ if (call) {
1840
+ call(cleanups, 4);
1841
+ } else {
1842
+ for (const cleanup2 of cleanups) cleanup2();
1843
+ }
1844
+ cleanupMap.delete(effect);
1845
+ }
1846
+ };
1847
+ {
1848
+ effect.onTrack = options.onTrack;
1849
+ effect.onTrigger = options.onTrigger;
1850
+ }
1851
+ if (cb) {
1852
+ if (immediate) {
1853
+ job(true);
1854
+ } else {
1855
+ oldValue = effect.run();
1856
+ }
1857
+ } else if (scheduler) {
1858
+ scheduler(job.bind(null, true), true);
1859
+ } else {
1860
+ effect.run();
1861
+ }
1862
+ const scope = getCurrentScope();
1863
+ const watchHandle = () => {
1864
+ effect.stop();
1865
+ if (scope) {
1866
+ shared.remove(scope.effects, effect);
1867
+ }
1868
+ };
1869
+ watchHandle.pause = effect.pause.bind(effect);
1870
+ watchHandle.resume = effect.resume.bind(effect);
1871
+ watchHandle.stop = watchHandle;
1872
+ return watchHandle;
1873
+ }
1874
+ function traverse(value, depth = Infinity, seen) {
1875
+ if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
1876
+ return value;
1877
+ }
1878
+ seen = seen || /* @__PURE__ */ new Set();
1879
+ if (seen.has(value)) {
1880
+ return value;
1881
+ }
1882
+ seen.add(value);
1883
+ depth--;
1884
+ if (isRef(value)) {
1885
+ traverse(value.value, depth, seen);
1886
+ } else if (shared.isArray(value)) {
1887
+ for (let i = 0; i < value.length; i++) {
1888
+ traverse(value[i], depth, seen);
1889
+ }
1890
+ } else if (shared.isSet(value) || shared.isMap(value)) {
1891
+ value.forEach((v) => {
1892
+ traverse(v, depth, seen);
1893
+ });
1894
+ } else if (shared.isPlainObject(value)) {
1895
+ for (const key in value) {
1896
+ traverse(value[key], depth, seen);
1897
+ }
1898
+ for (const key of Object.getOwnPropertySymbols(value)) {
1899
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
1900
+ traverse(value[key], depth, seen);
1901
+ }
1902
+ }
1903
+ }
1904
+ return value;
1905
+ }
1906
+
1685
1907
  exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
1686
1908
  exports.EffectFlags = EffectFlags;
1687
1909
  exports.EffectScope = EffectScope;
@@ -1691,12 +1913,14 @@ exports.ReactiveEffect = ReactiveEffect;
1691
1913
  exports.ReactiveFlags = ReactiveFlags;
1692
1914
  exports.TrackOpTypes = TrackOpTypes;
1693
1915
  exports.TriggerOpTypes = TriggerOpTypes;
1916
+ exports.WatchErrorCodes = WatchErrorCodes;
1694
1917
  exports.computed = computed;
1695
1918
  exports.customRef = customRef;
1696
1919
  exports.effect = effect;
1697
1920
  exports.effectScope = effectScope;
1698
1921
  exports.enableTracking = enableTracking;
1699
1922
  exports.getCurrentScope = getCurrentScope;
1923
+ exports.getCurrentWatcher = getCurrentWatcher;
1700
1924
  exports.isProxy = isProxy;
1701
1925
  exports.isReactive = isReactive;
1702
1926
  exports.isReadonly = isReadonly;
@@ -1705,6 +1929,7 @@ exports.isShallow = isShallow;
1705
1929
  exports.markRaw = markRaw;
1706
1930
  exports.onEffectCleanup = onEffectCleanup;
1707
1931
  exports.onScopeDispose = onScopeDispose;
1932
+ exports.onWatcherCleanup = onWatcherCleanup;
1708
1933
  exports.pauseTracking = pauseTracking;
1709
1934
  exports.proxyRefs = proxyRefs;
1710
1935
  exports.reactive = reactive;
@@ -1724,6 +1949,8 @@ exports.toRef = toRef;
1724
1949
  exports.toRefs = toRefs;
1725
1950
  exports.toValue = toValue;
1726
1951
  exports.track = track;
1952
+ exports.traverse = traverse;
1727
1953
  exports.trigger = trigger;
1728
1954
  exports.triggerRef = triggerRef;
1729
1955
  exports.unref = unref;
1956
+ exports.watch = watch;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/reactivity v3.5.0-beta.2
2
+ * @vue/reactivity v3.5.0-beta.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -746,14 +746,14 @@ function iterator(self, method, wrapValue) {
746
746
  const arrayProto = Array.prototype;
747
747
  function apply(self, method, fn, thisArg, wrappedRetFn, args) {
748
748
  const arr = shallowReadArray(self);
749
- let methodFn;
750
- if ((methodFn = arr[method]) !== arrayProto[method]) {
751
- return methodFn.apply(arr, args);
749
+ const needsWrap = arr !== self && !isShallow(self);
750
+ const methodFn = arr[method];
751
+ if (methodFn !== arrayProto[method]) {
752
+ const result2 = methodFn.apply(arr, args);
753
+ return needsWrap ? toReactive(result2) : result2;
752
754
  }
753
- let needsWrap = false;
754
755
  let wrappedFn = fn;
755
756
  if (arr !== self) {
756
- needsWrap = !isShallow(self);
757
757
  if (needsWrap) {
758
758
  wrappedFn = function(item, index) {
759
759
  return fn.call(this, toReactive(item), index, self);
@@ -1555,6 +1555,210 @@ const ReactiveFlags = {
1555
1555
  "IS_REF": "__v_isRef"
1556
1556
  };
1557
1557
 
1558
+ const WatchErrorCodes = {
1559
+ "WATCH_GETTER": 2,
1560
+ "2": "WATCH_GETTER",
1561
+ "WATCH_CALLBACK": 3,
1562
+ "3": "WATCH_CALLBACK",
1563
+ "WATCH_CLEANUP": 4,
1564
+ "4": "WATCH_CLEANUP"
1565
+ };
1566
+ const INITIAL_WATCHER_VALUE = {};
1567
+ const cleanupMap = /* @__PURE__ */ new WeakMap();
1568
+ let activeWatcher = void 0;
1569
+ function getCurrentWatcher() {
1570
+ return activeWatcher;
1571
+ }
1572
+ function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
1573
+ if (owner) {
1574
+ let cleanups = cleanupMap.get(owner);
1575
+ if (!cleanups) cleanupMap.set(owner, cleanups = []);
1576
+ cleanups.push(cleanupFn);
1577
+ }
1578
+ }
1579
+ function watch(source, cb, options = shared.EMPTY_OBJ) {
1580
+ const { immediate, deep, once, scheduler, augmentJob, call } = options;
1581
+ const reactiveGetter = (source2) => {
1582
+ if (deep) return source2;
1583
+ if (isShallow(source2) || deep === false || deep === 0)
1584
+ return traverse(source2, 1);
1585
+ return traverse(source2);
1586
+ };
1587
+ let effect;
1588
+ let getter;
1589
+ let cleanup;
1590
+ let boundCleanup;
1591
+ let forceTrigger = false;
1592
+ let isMultiSource = false;
1593
+ if (isRef(source)) {
1594
+ getter = () => source.value;
1595
+ forceTrigger = isShallow(source);
1596
+ } else if (isReactive(source)) {
1597
+ getter = () => reactiveGetter(source);
1598
+ forceTrigger = true;
1599
+ } else if (shared.isArray(source)) {
1600
+ isMultiSource = true;
1601
+ forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
1602
+ getter = () => source.map((s) => {
1603
+ if (isRef(s)) {
1604
+ return s.value;
1605
+ } else if (isReactive(s)) {
1606
+ return reactiveGetter(s);
1607
+ } else if (shared.isFunction(s)) {
1608
+ return call ? call(s, 2) : s();
1609
+ } else ;
1610
+ });
1611
+ } else if (shared.isFunction(source)) {
1612
+ if (cb) {
1613
+ getter = call ? () => call(source, 2) : source;
1614
+ } else {
1615
+ getter = () => {
1616
+ if (cleanup) {
1617
+ pauseTracking();
1618
+ try {
1619
+ cleanup();
1620
+ } finally {
1621
+ resetTracking();
1622
+ }
1623
+ }
1624
+ const currentEffect = activeWatcher;
1625
+ activeWatcher = effect;
1626
+ try {
1627
+ return call ? call(source, 3, [boundCleanup]) : source(boundCleanup);
1628
+ } finally {
1629
+ activeWatcher = currentEffect;
1630
+ }
1631
+ };
1632
+ }
1633
+ } else {
1634
+ getter = shared.NOOP;
1635
+ }
1636
+ if (cb && deep) {
1637
+ const baseGetter = getter;
1638
+ const depth = deep === true ? Infinity : deep;
1639
+ getter = () => traverse(baseGetter(), depth);
1640
+ }
1641
+ if (once) {
1642
+ if (cb) {
1643
+ const _cb = cb;
1644
+ cb = (...args) => {
1645
+ _cb(...args);
1646
+ effect.stop();
1647
+ };
1648
+ } else {
1649
+ const _getter = getter;
1650
+ getter = () => {
1651
+ _getter();
1652
+ effect.stop();
1653
+ };
1654
+ }
1655
+ }
1656
+ let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
1657
+ const job = (immediateFirstRun) => {
1658
+ if (!(effect.flags & 1) || !effect.dirty && !immediateFirstRun) {
1659
+ return;
1660
+ }
1661
+ if (cb) {
1662
+ const newValue = effect.run();
1663
+ if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => shared.hasChanged(v, oldValue[i])) : shared.hasChanged(newValue, oldValue))) {
1664
+ if (cleanup) {
1665
+ cleanup();
1666
+ }
1667
+ const currentWatcher = activeWatcher;
1668
+ activeWatcher = effect;
1669
+ try {
1670
+ const args = [
1671
+ newValue,
1672
+ // pass undefined as the old value when it's changed for the first time
1673
+ oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
1674
+ boundCleanup
1675
+ ];
1676
+ call ? call(cb, 3, args) : (
1677
+ // @ts-expect-error
1678
+ cb(...args)
1679
+ );
1680
+ oldValue = newValue;
1681
+ } finally {
1682
+ activeWatcher = currentWatcher;
1683
+ }
1684
+ }
1685
+ } else {
1686
+ effect.run();
1687
+ }
1688
+ };
1689
+ if (augmentJob) {
1690
+ augmentJob(job);
1691
+ }
1692
+ effect = new ReactiveEffect(getter);
1693
+ effect.scheduler = scheduler ? () => scheduler(job, false) : job;
1694
+ boundCleanup = (fn) => onWatcherCleanup(fn, false, effect);
1695
+ cleanup = effect.onStop = () => {
1696
+ const cleanups = cleanupMap.get(effect);
1697
+ if (cleanups) {
1698
+ if (call) {
1699
+ call(cleanups, 4);
1700
+ } else {
1701
+ for (const cleanup2 of cleanups) cleanup2();
1702
+ }
1703
+ cleanupMap.delete(effect);
1704
+ }
1705
+ };
1706
+ if (cb) {
1707
+ if (immediate) {
1708
+ job(true);
1709
+ } else {
1710
+ oldValue = effect.run();
1711
+ }
1712
+ } else if (scheduler) {
1713
+ scheduler(job.bind(null, true), true);
1714
+ } else {
1715
+ effect.run();
1716
+ }
1717
+ const scope = getCurrentScope();
1718
+ const watchHandle = () => {
1719
+ effect.stop();
1720
+ if (scope) {
1721
+ shared.remove(scope.effects, effect);
1722
+ }
1723
+ };
1724
+ watchHandle.pause = effect.pause.bind(effect);
1725
+ watchHandle.resume = effect.resume.bind(effect);
1726
+ watchHandle.stop = watchHandle;
1727
+ return watchHandle;
1728
+ }
1729
+ function traverse(value, depth = Infinity, seen) {
1730
+ if (depth <= 0 || !shared.isObject(value) || value["__v_skip"]) {
1731
+ return value;
1732
+ }
1733
+ seen = seen || /* @__PURE__ */ new Set();
1734
+ if (seen.has(value)) {
1735
+ return value;
1736
+ }
1737
+ seen.add(value);
1738
+ depth--;
1739
+ if (isRef(value)) {
1740
+ traverse(value.value, depth, seen);
1741
+ } else if (shared.isArray(value)) {
1742
+ for (let i = 0; i < value.length; i++) {
1743
+ traverse(value[i], depth, seen);
1744
+ }
1745
+ } else if (shared.isSet(value) || shared.isMap(value)) {
1746
+ value.forEach((v) => {
1747
+ traverse(v, depth, seen);
1748
+ });
1749
+ } else if (shared.isPlainObject(value)) {
1750
+ for (const key in value) {
1751
+ traverse(value[key], depth, seen);
1752
+ }
1753
+ for (const key of Object.getOwnPropertySymbols(value)) {
1754
+ if (Object.prototype.propertyIsEnumerable.call(value, key)) {
1755
+ traverse(value[key], depth, seen);
1756
+ }
1757
+ }
1758
+ }
1759
+ return value;
1760
+ }
1761
+
1558
1762
  exports.ARRAY_ITERATE_KEY = ARRAY_ITERATE_KEY;
1559
1763
  exports.EffectFlags = EffectFlags;
1560
1764
  exports.EffectScope = EffectScope;
@@ -1564,12 +1768,14 @@ exports.ReactiveEffect = ReactiveEffect;
1564
1768
  exports.ReactiveFlags = ReactiveFlags;
1565
1769
  exports.TrackOpTypes = TrackOpTypes;
1566
1770
  exports.TriggerOpTypes = TriggerOpTypes;
1771
+ exports.WatchErrorCodes = WatchErrorCodes;
1567
1772
  exports.computed = computed;
1568
1773
  exports.customRef = customRef;
1569
1774
  exports.effect = effect;
1570
1775
  exports.effectScope = effectScope;
1571
1776
  exports.enableTracking = enableTracking;
1572
1777
  exports.getCurrentScope = getCurrentScope;
1778
+ exports.getCurrentWatcher = getCurrentWatcher;
1573
1779
  exports.isProxy = isProxy;
1574
1780
  exports.isReactive = isReactive;
1575
1781
  exports.isReadonly = isReadonly;
@@ -1578,6 +1784,7 @@ exports.isShallow = isShallow;
1578
1784
  exports.markRaw = markRaw;
1579
1785
  exports.onEffectCleanup = onEffectCleanup;
1580
1786
  exports.onScopeDispose = onScopeDispose;
1787
+ exports.onWatcherCleanup = onWatcherCleanup;
1581
1788
  exports.pauseTracking = pauseTracking;
1582
1789
  exports.proxyRefs = proxyRefs;
1583
1790
  exports.reactive = reactive;
@@ -1597,6 +1804,8 @@ exports.toRef = toRef;
1597
1804
  exports.toRefs = toRefs;
1598
1805
  exports.toValue = toValue;
1599
1806
  exports.track = track;
1807
+ exports.traverse = traverse;
1600
1808
  exports.trigger = trigger;
1601
1809
  exports.triggerRef = triggerRef;
1602
1810
  exports.unref = unref;
1811
+ exports.watch = watch;
@@ -707,3 +707,41 @@ export declare function reactiveReadArray<T>(array: T[]): T[];
707
707
  */
708
708
  export declare function shallowReadArray<T>(arr: T[]): T[];
709
709
 
710
+ export declare enum WatchErrorCodes {
711
+ WATCH_GETTER = 2,
712
+ WATCH_CALLBACK = 3,
713
+ WATCH_CLEANUP = 4
714
+ }
715
+ type WatchEffect = (onCleanup: OnCleanup) => void;
716
+ type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T);
717
+ type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onCleanup: OnCleanup) => any;
718
+ type OnCleanup = (cleanupFn: () => void) => void;
719
+ export interface WatchOptions<Immediate = boolean> extends DebuggerOptions {
720
+ immediate?: Immediate;
721
+ deep?: boolean | number;
722
+ once?: boolean;
723
+ scheduler?: WatchScheduler;
724
+ onWarn?: (msg: string, ...args: any[]) => void;
725
+ }
726
+ export type WatchStopHandle = () => void;
727
+ export interface WatchHandle extends WatchStopHandle {
728
+ pause: () => void;
729
+ resume: () => void;
730
+ stop: () => void;
731
+ }
732
+ export type WatchScheduler = (job: () => void, isFirstRun: boolean) => void;
733
+ /**
734
+ * Returns the current active effect if there is one.
735
+ */
736
+ export declare function getCurrentWatcher(): ReactiveEffect<any> | undefined;
737
+ /**
738
+ * Registers a cleanup callback on the current active effect. This
739
+ * registered cleanup callback will be invoked right before the
740
+ * associated effect re-runs.
741
+ *
742
+ * @param cleanupFn - The callback function to attach to the effect's cleanup.
743
+ */
744
+ export declare function onWatcherCleanup(cleanupFn: () => void, failSilently?: boolean, owner?: ReactiveEffect | undefined): void;
745
+ export declare function watch(source: WatchSource | WatchSource[] | WatchEffect | object, cb?: WatchCallback | null, options?: WatchOptions): WatchHandle;
746
+ export declare function traverse(value: unknown, depth?: number, seen?: Set<unknown>): unknown;
747
+