index.d.ts 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. import * as vue_demi from 'vue-demi';
  2. import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, ShallowUnwrapRef as ShallowUnwrapRef$1, WatchOptions, UnwrapRef, ToRefs, WatchCallback, WatchStopHandle } from 'vue-demi';
  3. declare function computedEager<T>(fn: () => T, options?: WatchOptionsBase): Readonly<Ref<T>>;
  4. interface ComputedWithControlRefExtra {
  5. /**
  6. * Force update the computed value.
  7. */
  8. trigger(): void;
  9. }
  10. interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {
  11. }
  12. interface WritableComputedRefWithControl<T> extends WritableComputedRef<T>, ComputedWithControlRefExtra {
  13. }
  14. declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: ComputedGetter<T>): ComputedRefWithControl<T>;
  15. declare function computedWithControl<T, S>(source: WatchSource<S> | WatchSource<S>[], fn: WritableComputedOptions<T>): WritableComputedRefWithControl<T>;
  16. type EventHookOn<T = any> = (fn: (param: T) => void) => {
  17. off: () => void;
  18. };
  19. type EventHookOff<T = any> = (fn: (param: T) => void) => void;
  20. type EventHookTrigger<T = any> = (param: T) => void;
  21. interface EventHook<T = any> {
  22. on: EventHookOn<T>;
  23. off: EventHookOff<T>;
  24. trigger: EventHookTrigger<T>;
  25. }
  26. /**
  27. * Utility for creating event hooks
  28. *
  29. * @see https://vueuse.org/createEventHook
  30. */
  31. declare function createEventHook<T = any>(): EventHook<T>;
  32. type CreateGlobalStateReturn<T> = () => T;
  33. /**
  34. * Keep states in the global scope to be reusable across Vue instances.
  35. *
  36. * @see https://vueuse.org/createGlobalState
  37. * @param stateFactory A factory function to create the state
  38. */
  39. declare function createGlobalState<T>(stateFactory: () => T): CreateGlobalStateReturn<T>;
  40. /**
  41. * Create global state that can be injected into components.
  42. *
  43. * @see https://vueuse.org/createInjectionState
  44. *
  45. */
  46. declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
  47. /**
  48. * Make a composable function usable with multiple Vue instances.
  49. *
  50. * @see https://vueuse.org/createSharedComposable
  51. */
  52. declare function createSharedComposable<Fn extends ((...args: any[]) => any)>(composable: Fn): Fn;
  53. interface ExtendRefOptions<Unwrap extends boolean = boolean> {
  54. /**
  55. * Is the extends properties enumerable
  56. *
  57. * @default false
  58. */
  59. enumerable?: boolean;
  60. /**
  61. * Unwrap for Ref properties
  62. *
  63. * @default true
  64. */
  65. unwrap?: Unwrap;
  66. }
  67. /**
  68. * Overload 1: Unwrap set to false
  69. */
  70. declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions<false>>(ref: R, extend: Extend, options?: Options): ShallowUnwrapRef$1<Extend> & R;
  71. /**
  72. * Overload 2: Unwrap unset or set to true
  73. */
  74. declare function extendRef<R extends Ref<any>, Extend extends object, Options extends ExtendRefOptions>(ref: R, extend: Extend, options?: Options): Extend & R;
  75. declare const isClient: boolean;
  76. declare const isDef: <T = any>(val?: T | undefined) => val is T;
  77. declare const assert: (condition: boolean, ...infos: any[]) => void;
  78. declare const isBoolean: (val: any) => val is boolean;
  79. declare const isFunction: <T extends Function>(val: any) => val is T;
  80. declare const isNumber: (val: any) => val is number;
  81. declare const isString: (val: unknown) => val is string;
  82. declare const isObject: (val: any) => val is object;
  83. declare const isWindow: (val: any) => val is Window;
  84. declare const now: () => number;
  85. declare const timestamp: () => number;
  86. declare const clamp: (n: number, min: number, max: number) => number;
  87. declare const noop: () => void;
  88. declare const rand: (min: number, max: number) => number;
  89. declare const isIOS: boolean | "";
  90. declare const hasOwn: <T extends object, K extends keyof T>(val: T, key: K) => key is K;
  91. /**
  92. * Void function
  93. */
  94. type Fn = () => void;
  95. /**
  96. * Any function
  97. */
  98. type AnyFn = (...args: any[]) => any;
  99. /**
  100. * A ref that allow to set null or undefined
  101. */
  102. type RemovableRef<T> = Omit<Ref<T>, 'value'> & {
  103. get value(): T;
  104. set value(value: T | null | undefined);
  105. };
  106. /**
  107. * @deprecated Use `RemovableRef`
  108. */
  109. type RemoveableRef<T> = RemovableRef<T>;
  110. /**
  111. * Maybe it's a ref, or a plain value
  112. *
  113. * ```ts
  114. * type MaybeRef<T> = T | Ref<T>
  115. * ```
  116. */
  117. type MaybeRef<T> = T | Ref<T>;
  118. /**
  119. * Maybe it's a ref, or a plain value, or a getter function
  120. *
  121. * ```ts
  122. * type MaybeComputedRef<T> = (() => T) | T | Ref<T> | ComputedRef<T>
  123. * ```
  124. */
  125. type MaybeComputedRef<T> = MaybeReadonlyRef<T> | MaybeRef<T>;
  126. /**
  127. * Maybe it's a computed ref, or a getter function
  128. *
  129. * ```ts
  130. * type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>
  131. * ```
  132. */
  133. type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;
  134. /**
  135. * Make all the nested attributes of an object or array to MaybeRef<T>
  136. *
  137. * Good for accepting options that will be wrapped with `reactive` or `ref`
  138. *
  139. * ```ts
  140. * UnwrapRef<DeepMaybeRef<T>> === T
  141. * ```
  142. */
  143. type DeepMaybeRef<T> = T extends Ref<infer V> ? MaybeRef<V> : T extends Array<any> | object ? {
  144. [K in keyof T]: DeepMaybeRef<T[K]>;
  145. } : MaybeRef<T>;
  146. type Arrayable<T> = T[] | T;
  147. /**
  148. * Infers the element type of an array
  149. */
  150. type ElementOf<T> = T extends (infer E)[] ? E : never;
  151. type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T;
  152. type Awaitable<T> = Promise<T> | T;
  153. type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
  154. type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promise<ReturnType<T>>;
  155. interface Pausable {
  156. /**
  157. * A ref indicate whether a pausable instance is active
  158. */
  159. isActive: Readonly<Ref<boolean>>;
  160. /**
  161. * Temporary pause the effect from executing
  162. */
  163. pause: Fn;
  164. /**
  165. * Resume the effects
  166. */
  167. resume: Fn;
  168. }
  169. interface Stoppable<StartFnArgs extends any[] = any[]> {
  170. /**
  171. * A ref indicate whether a stoppable instance is executing
  172. */
  173. isPending: Readonly<Ref<boolean>>;
  174. /**
  175. * Stop the effect from executing
  176. */
  177. stop: Fn;
  178. /**
  179. * Start the effects
  180. */
  181. start: (...args: StartFnArgs) => void;
  182. }
  183. /**
  184. * @deprecated Use `Stoppable`
  185. */
  186. type Stopable = Stoppable;
  187. interface ConfigurableFlush {
  188. /**
  189. * Timing for monitoring changes, refer to WatchOptions for more details
  190. *
  191. * @default 'pre'
  192. */
  193. flush?: WatchOptions['flush'];
  194. }
  195. interface ConfigurableFlushSync {
  196. /**
  197. * Timing for monitoring changes, refer to WatchOptions for more details.
  198. * Unlike `watch()`, the default is set to `sync`
  199. *
  200. * @default 'sync'
  201. */
  202. flush?: WatchOptions['flush'];
  203. }
  204. type MapSources<T> = {
  205. [K in keyof T]: T[K] extends WatchSource<infer V> ? V : never;
  206. };
  207. type MapOldSources<T, Immediate> = {
  208. [K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never;
  209. };
  210. type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return;
  211. interface FunctionWrapperOptions<Args extends any[] = any[], This = any> {
  212. fn: FunctionArgs<Args, This>;
  213. args: Args;
  214. thisArg: This;
  215. }
  216. type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promise<ReturnType<Invoke>>;
  217. interface ConfigurableEventFilter {
  218. /**
  219. * Filter for if events should to be received.
  220. *
  221. * @see https://vueuse.org/guide/config.html#event-filters
  222. */
  223. eventFilter?: EventFilter;
  224. }
  225. interface DebounceFilterOptions {
  226. /**
  227. * The maximum time allowed to be delayed before it's invoked.
  228. * In milliseconds.
  229. */
  230. maxWait?: MaybeComputedRef<number>;
  231. /**
  232. * Whether to reject the last call if it's been cancel.
  233. *
  234. * @default false
  235. */
  236. rejectOnCancel?: boolean;
  237. }
  238. /**
  239. * @internal
  240. */
  241. declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<ReturnType<T>>;
  242. declare const bypassFilter: EventFilter;
  243. /**
  244. * Create an EventFilter that debounce the events
  245. *
  246. * @param ms
  247. * @param options
  248. */
  249. declare function debounceFilter(ms: MaybeComputedRef<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>;
  250. /**
  251. * Create an EventFilter that throttle the events
  252. *
  253. * @param ms
  254. * @param [trailing=true]
  255. * @param [leading=true]
  256. * @param [rejectOnCancel=false]
  257. */
  258. declare function throttleFilter(ms: MaybeComputedRef<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
  259. /**
  260. * EventFilter that gives extra controls to pause and resume the filter
  261. *
  262. * @param extendFilter Extra filter to apply when the PausableFilter is active, default to none
  263. *
  264. */
  265. declare function pausableFilter(extendFilter?: EventFilter): Pausable & {
  266. eventFilter: EventFilter;
  267. };
  268. declare function __onlyVue3(name?: string): void;
  269. declare function __onlyVue27Plus(name?: string): void;
  270. declare const directiveHooks: {
  271. mounted: "mounted";
  272. updated: "updated";
  273. unmounted: "unmounted";
  274. };
  275. declare function promiseTimeout(ms: number, throwOnTimeout?: boolean, reason?: string): Promise<void>;
  276. declare function identity<T>(arg: T): T;
  277. interface SingletonPromiseReturn<T> {
  278. (): Promise<T>;
  279. /**
  280. * Reset current staled promise.
  281. * await it to have proper shutdown.
  282. */
  283. reset: () => Promise<void>;
  284. }
  285. /**
  286. * Create singleton promise function
  287. *
  288. * @example
  289. * ```
  290. * const promise = createSingletonPromise(async () => { ... })
  291. *
  292. * await promise()
  293. * await promise() // all of them will be bind to a single promise instance
  294. * await promise() // and be resolved together
  295. * ```
  296. */
  297. declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
  298. declare function invoke<T>(fn: () => T): T;
  299. declare function containsProp(obj: object, ...props: string[]): boolean;
  300. /**
  301. * Increase string a value with unit
  302. *
  303. * @example '2px' + 1 = '3px'
  304. * @example '15em' + (-2) = '13em'
  305. */
  306. declare function increaseWithUnit(target: number, delta: number): number;
  307. declare function increaseWithUnit(target: string, delta: number): string;
  308. declare function increaseWithUnit(target: string | number, delta: number): string | number;
  309. /**
  310. * Create a new subset object by giving keys
  311. *
  312. * @category Object
  313. */
  314. declare function objectPick<O extends object, T extends keyof O>(obj: O, keys: T[], omitUndefined?: boolean): Pick<O, T>;
  315. /**
  316. * Shorthand for accessing `ref.value`
  317. */
  318. declare function get<T>(ref: MaybeRef<T>): T;
  319. declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K];
  320. declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>;
  321. declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>;
  322. declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>;
  323. declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
  324. type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: {
  325. [K in keyof A]: Computed extends true ? MaybeComputedRef<A[K]> : MaybeRef<A[K]>;
  326. }) => ComputedRef<R> : never;
  327. interface ReactifyOptions<T extends boolean> {
  328. /**
  329. * Accept passing a function as a reactive getter
  330. *
  331. * @default true
  332. */
  333. computedGetter?: T;
  334. }
  335. /**
  336. * Converts plain function into a reactive function.
  337. * The converted function accepts refs as it's arguments
  338. * and returns a ComputedRef, with proper typing.
  339. *
  340. * @param fn - Source function
  341. */
  342. declare function reactify<T extends Function, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): Reactified<T, K>;
  343. type ReactifyNested<T, Keys extends keyof T = keyof T, S extends boolean = true> = {
  344. [K in Keys]: T[K] extends (...args: any[]) => any ? Reactified<T[K], S> : T[K];
  345. };
  346. interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> {
  347. /**
  348. * Includes names from Object.getOwnPropertyNames
  349. *
  350. * @default true
  351. */
  352. includeOwnProperties?: boolean;
  353. }
  354. /**
  355. * Apply `reactify` to an object
  356. */
  357. declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyNested<T, Keys, true>;
  358. declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyNested<T, keyof T, S>;
  359. /**
  360. * Computed reactive object.
  361. */
  362. declare function reactiveComputed<T extends {}>(fn: () => T): T;
  363. /**
  364. * Reactively omit fields from a reactive object
  365. *
  366. * @see https://vueuse.org/reactiveOmit
  367. */
  368. declare function reactiveOmit<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): Omit<T, K>;
  369. /**
  370. * Reactively pick fields from a reactive object
  371. *
  372. * @see https://vueuse.org/reactivePick
  373. */
  374. declare function reactivePick<T extends object, K extends keyof T>(obj: T, ...keys: (K | K[])[]): {
  375. [S in K]: UnwrapRef<T[S]>;
  376. };
  377. /**
  378. * Create a ref which will be reset to the default value after some time.
  379. *
  380. * @see https://vueuse.org/refAutoReset
  381. * @param defaultValue The value which will be set.
  382. * @param afterMs A zero-or-greater delay in milliseconds.
  383. */
  384. declare function refAutoReset<T>(defaultValue: T, afterMs?: MaybeComputedRef<number>): Ref<T>;
  385. /**
  386. * Debounce updates of a ref.
  387. *
  388. * @return A new debounced ref.
  389. */
  390. declare function refDebounced<T>(value: Ref<T>, ms?: MaybeComputedRef<number>, options?: DebounceFilterOptions): Readonly<Ref<T>>;
  391. /**
  392. * Apply default value to a ref.
  393. *
  394. * @param source source ref
  395. * @param targets
  396. */
  397. declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>;
  398. /**
  399. * Throttle execution of a function. Especially useful for rate limiting
  400. * execution of handlers on events like resize and scroll.
  401. *
  402. * @param value Ref value to be watched with throttle effect
  403. * @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
  404. * @param [trailing=true] if true, update the value again after the delay time is up
  405. * @param [leading=true] if true, update the value on the leading edge of the ms timeout
  406. */
  407. declare function refThrottled<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T>;
  408. interface ControlledRefOptions<T> {
  409. /**
  410. * Callback function before the ref changing.
  411. *
  412. * Returning `false` to dismiss the change.
  413. */
  414. onBeforeChange?: (value: T, oldValue: T) => void | boolean;
  415. /**
  416. * Callback function after the ref changed
  417. *
  418. * This happens synchronously, with less overhead compare to `watch`
  419. */
  420. onChanged?: (value: T, oldValue: T) => void;
  421. }
  422. /**
  423. * Explicitly define the deps of computed.
  424. *
  425. * @param source
  426. * @param fn
  427. */
  428. declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue_demi.ShallowUnwrapRef<{
  429. get: (tracking?: boolean) => T;
  430. set: (value: T, triggering?: boolean) => void;
  431. untrackedGet: () => T;
  432. silentSet: (v: T) => void;
  433. peek: () => T;
  434. lay: (v: T) => void;
  435. }> & vue_demi.Ref<T>;
  436. /**
  437. * Alias for `refWithControl`
  438. */
  439. declare const controlledRef: typeof refWithControl;
  440. /**
  441. * Normalize value/ref/getter to `ref` or `computed`.
  442. */
  443. declare function resolveRef<T>(r: MaybeComputedRef<T>): ComputedRef<T>;
  444. declare function resolveRef<T>(r: MaybeRef<T>): Ref<T>;
  445. declare function resolveRef<T>(r: T): Ref<T>;
  446. /**
  447. * Get the value of value/ref/getter.
  448. */
  449. declare function resolveUnref<T>(r: MaybeComputedRef<T>): T;
  450. declare function set<T>(ref: Ref<T>, value: T): void;
  451. declare function set<O extends object, K extends keyof O>(target: O, key: K, value: O[K]): void;
  452. interface SyncRefOptions<L, R = L> extends ConfigurableFlushSync {
  453. /**
  454. * Watch deeply
  455. *
  456. * @default false
  457. */
  458. deep?: boolean;
  459. /**
  460. * Sync values immediately
  461. *
  462. * @default true
  463. */
  464. immediate?: boolean;
  465. /**
  466. * Direction of syncing. Value will be redefined if you define syncConvertors
  467. *
  468. * @default 'both'
  469. */
  470. direction?: 'ltr' | 'rtl' | 'both';
  471. /**
  472. * Custom transform function
  473. */
  474. transform?: {
  475. ltr?: (left: L) => R;
  476. rtl?: (right: R) => L;
  477. };
  478. }
  479. /**
  480. * Two-way refs synchronization.
  481. *
  482. * @param left
  483. * @param right
  484. */
  485. declare function syncRef<L, R = L>(left: Ref<L>, right: Ref<R>, options?: SyncRefOptions<L, R>): () => void;
  486. interface SyncRefsOptions extends ConfigurableFlushSync {
  487. /**
  488. * Watch deeply
  489. *
  490. * @default false
  491. */
  492. deep?: boolean;
  493. /**
  494. * Sync values immediately
  495. *
  496. * @default true
  497. */
  498. immediate?: boolean;
  499. }
  500. /**
  501. * Keep target ref(s) in sync with the source ref
  502. *
  503. * @param source source ref
  504. * @param targets
  505. */
  506. declare function syncRefs<T>(source: WatchSource<T>, targets: Ref<T> | Ref<T>[], options?: SyncRefsOptions): vue_demi.WatchStopHandle;
  507. /**
  508. * Converts ref to reactive.
  509. *
  510. * @see https://vueuse.org/toReactive
  511. * @param objectRef A ref of object
  512. */
  513. declare function toReactive<T extends object>(objectRef: MaybeRef<T>): T;
  514. /**
  515. * Extended `toRefs` that also accepts refs of an object.
  516. *
  517. * @see https://vueuse.org/toRefs
  518. * @param objectRef A ref or normal object or array.
  519. */
  520. declare function toRefs<T extends object>(objectRef: MaybeRef<T>): ToRefs<T>;
  521. /**
  522. * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
  523. *
  524. * @param fn
  525. * @param sync if set to false, it will run in the nextTick() of Vue
  526. */
  527. declare function tryOnBeforeMount(fn: Fn, sync?: boolean): void;
  528. /**
  529. * Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
  530. *
  531. * @param fn
  532. */
  533. declare function tryOnBeforeUnmount(fn: Fn): void;
  534. /**
  535. * Call onMounted() if it's inside a component lifecycle, if not, just call the function
  536. *
  537. * @param fn
  538. * @param sync if set to false, it will run in the nextTick() of Vue
  539. */
  540. declare function tryOnMounted(fn: Fn, sync?: boolean): void;
  541. /**
  542. * Call onScopeDispose() if it's inside an effect scope lifecycle, if not, do nothing
  543. *
  544. * @param fn
  545. */
  546. declare function tryOnScopeDispose(fn: Fn): boolean;
  547. /**
  548. * Call onUnmounted() if it's inside a component lifecycle, if not, do nothing
  549. *
  550. * @param fn
  551. */
  552. declare function tryOnUnmounted(fn: Fn): void;
  553. interface UntilToMatchOptions {
  554. /**
  555. * Milliseconds timeout for promise to resolve/reject if the when condition does not meet.
  556. * 0 for never timed out
  557. *
  558. * @default 0
  559. */
  560. timeout?: number;
  561. /**
  562. * Reject the promise when timeout
  563. *
  564. * @default false
  565. */
  566. throwOnTimeout?: boolean;
  567. /**
  568. * `flush` option for internal watch
  569. *
  570. * @default 'sync'
  571. */
  572. flush?: WatchOptions['flush'];
  573. /**
  574. * `deep` option for internal watch
  575. *
  576. * @default 'false'
  577. */
  578. deep?: WatchOptions['deep'];
  579. }
  580. interface UntilBaseInstance<T, Not extends boolean = false> {
  581. toMatch<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, U>> : Promise<U>;
  582. toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<T>;
  583. changed(options?: UntilToMatchOptions): Promise<T>;
  584. changedTimes(n?: number, options?: UntilToMatchOptions): Promise<T>;
  585. }
  586. type Falsy = false | void | null | undefined | 0 | 0n | '';
  587. interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
  588. readonly not: UntilValueInstance<T, Not extends true ? false : true>;
  589. toBe<P = T>(value: MaybeComputedRef<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
  590. toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
  591. toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
  592. toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
  593. toBeNaN(options?: UntilToMatchOptions): Promise<T>;
  594. }
  595. interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
  596. readonly not: UntilArrayInstance<T>;
  597. toContains(value: MaybeComputedRef<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
  598. }
  599. /**
  600. * Promised one-time watch for changes
  601. *
  602. * @see https://vueuse.org/until
  603. * @example
  604. * ```
  605. * const { count } = useCounter()
  606. *
  607. * await until(count).toMatch(v => v > 7)
  608. *
  609. * alert('Counter is now larger than 7!')
  610. * ```
  611. */
  612. declare function until<T extends unknown[]>(r: WatchSource<T> | MaybeComputedRef<T>): UntilArrayInstance<T>;
  613. declare function until<T>(r: WatchSource<T> | MaybeComputedRef<T>): UntilValueInstance<T>;
  614. /**
  615. * Reactive `Array.every`
  616. *
  617. * @see https://vueuse.org/useArrayEvery
  618. * @param {Array} list - the array was called upon.
  619. * @param fn - a function to test each element.
  620. *
  621. * @returns {boolean} **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
  622. */
  623. declare function useArrayEvery<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef<T>[]) => unknown): ComputedRef<boolean>;
  624. /**
  625. * Reactive `Array.filter`
  626. *
  627. * @see https://vueuse.org/useArrayFilter
  628. * @param {Array} list - the array was called upon.
  629. * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
  630. *
  631. * @returns {Array} a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned.
  632. */
  633. declare function useArrayFilter<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: T[]) => boolean): ComputedRef<T[]>;
  634. /**
  635. * Reactive `Array.find`
  636. *
  637. * @see https://vueuse.org/useArrayFind
  638. * @param {Array} list - the array was called upon.
  639. * @param fn - a function to test each element.
  640. *
  641. * @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
  642. */
  643. declare function useArrayFind<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef<T>[]) => boolean): ComputedRef<T | undefined>;
  644. /**
  645. * Reactive `Array.findIndex`
  646. *
  647. * @see https://vueuse.org/useArrayFindIndex
  648. * @param {Array} list - the array was called upon.
  649. * @param fn - a function to test each element.
  650. *
  651. * @returns {number} the index of the first element in the array that passes the test. Otherwise, "-1".
  652. */
  653. declare function useArrayFindIndex<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef<T>[]) => unknown): ComputedRef<number>;
  654. /**
  655. * Reactive `Array.findLast`
  656. *
  657. * @see https://vueuse.org/useArrayFindLast
  658. * @param {Array} list - the array was called upon.
  659. * @param fn - a function to test each element.
  660. *
  661. * @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
  662. */
  663. declare function useArrayFindLast<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef<T>[]) => boolean): ComputedRef<T | undefined>;
  664. /**
  665. * Reactive `Array.join`
  666. *
  667. * @see https://vueuse.org/useArrayJoin
  668. * @param {Array} list - the array was called upon.
  669. * @param {string} separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
  670. *
  671. * @returns {string} a string with all array elements joined. If arr.length is 0, the empty string is returned.
  672. */
  673. declare function useArrayJoin(list: MaybeComputedRef<MaybeComputedRef<any>[]>, separator?: MaybeComputedRef<string>): ComputedRef<string>;
  674. /**
  675. * Reactive `Array.map`
  676. *
  677. * @see https://vueuse.org/useArrayMap
  678. * @param {Array} list - the array was called upon.
  679. * @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
  680. *
  681. * @returns {Array} a new array with each element being the result of the callback function.
  682. */
  683. declare function useArrayMap<T, U = T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: T[]) => U): ComputedRef<U[]>;
  684. type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentIndex: number) => R;
  685. /**
  686. * Reactive `Array.reduce`
  687. *
  688. * @see https://vueuse.org/useArrayReduce
  689. * @param {Array} list - the array was called upon.
  690. * @param reducer - a "reducer" function.
  691. *
  692. * @returns the value that results from running the "reducer" callback function to completion over the entire array.
  693. */
  694. declare function useArrayReduce<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>;
  695. /**
  696. * Reactive `Array.reduce`
  697. *
  698. * @see https://vueuse.org/useArrayReduce
  699. * @param {Array} list - the array was called upon.
  700. * @param reducer - a "reducer" function.
  701. * @param initialValue - a value to be initialized the first time when the callback is called.
  702. *
  703. * @returns the value that results from running the "reducer" callback function to completion over the entire array.
  704. */
  705. declare function useArrayReduce<T, U>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeComputedRef<U>): ComputedRef<U>;
  706. /**
  707. * Reactive `Array.some`
  708. *
  709. * @see https://vueuse.org/useArraySome
  710. * @param {Array} list - the array was called upon.
  711. * @param fn - a function to test each element.
  712. *
  713. * @returns {boolean} **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
  714. */
  715. declare function useArraySome<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>, fn: (element: T, index: number, array: MaybeComputedRef<T>[]) => unknown): ComputedRef<boolean>;
  716. /**
  717. * reactive unique array
  718. * @see https://vueuse.org/useArrayUnique
  719. * @param {Array} list - the array was called upon.
  720. * @returns {Array} A computed ref that returns a unique array of items.
  721. */
  722. declare function useArrayUnique<T>(list: MaybeComputedRef<MaybeComputedRef<T>[]>): ComputedRef<T[]>;
  723. interface UseCounterOptions {
  724. min?: number;
  725. max?: number;
  726. }
  727. /**
  728. * Basic counter with utility functions.
  729. *
  730. * @see https://vueuse.org/useCounter
  731. * @param [initialValue=0]
  732. * @param {Object} options
  733. */
  734. declare function useCounter(initialValue?: number, options?: UseCounterOptions): {
  735. count: vue_demi.Ref<number>;
  736. inc: (delta?: number) => number;
  737. dec: (delta?: number) => number;
  738. get: () => number;
  739. set: (val: number) => number;
  740. reset: (val?: number) => number;
  741. };
  742. type DateLike = Date | number | string | undefined;
  743. interface UseDateFormatOptions {
  744. /**
  745. * The locale(s) to used for dd/ddd/dddd/MMM/MMMM format
  746. *
  747. * [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).
  748. */
  749. locales?: Intl.LocalesArgument;
  750. /**
  751. * A custom function to re-modify the way to display meridiem
  752. *
  753. */
  754. customMeridiem?: (hours: number, minutes: number, isLowercase?: boolean, hasPeriod?: boolean) => string;
  755. }
  756. declare const formatDate: (date: Date, formatStr: string, options?: UseDateFormatOptions) => string;
  757. declare const normalizeDate: (date: DateLike) => Date;
  758. /**
  759. * Get the formatted date according to the string of tokens passed in.
  760. *
  761. * @see https://vueuse.org/useDateFormat
  762. * @param date - The date to format, can either be a `Date` object, a timestamp, or a string
  763. * @param formatStr - The combination of tokens to format the date
  764. * @param options - UseDateFormatOptions
  765. */
  766. declare function useDateFormat(date: MaybeComputedRef<DateLike>, formatStr?: MaybeComputedRef<string>, options?: UseDateFormatOptions): vue_demi.ComputedRef<string>;
  767. type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
  768. /**
  769. * Debounce execution of a function.
  770. *
  771. * @see https://vueuse.org/useDebounceFn
  772. * @param fn A function to be executed after delay milliseconds debounced.
  773. * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
  774. * @param opts options
  775. *
  776. * @return A new, debounce, function.
  777. */
  778. declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeComputedRef<number>, options?: DebounceFilterOptions): PromisifyFn<T>;
  779. interface UseIntervalOptions<Controls extends boolean> {
  780. /**
  781. * Expose more controls
  782. *
  783. * @default false
  784. */
  785. controls?: Controls;
  786. /**
  787. * Execute the update immediately on calling
  788. *
  789. * @default true
  790. */
  791. immediate?: boolean;
  792. /**
  793. * Callback on every interval
  794. */
  795. callback?: (count: number) => void;
  796. }
  797. interface UseIntervalControls {
  798. counter: Ref<number>;
  799. reset: () => void;
  800. }
  801. /**
  802. * Reactive counter increases on every interval
  803. *
  804. * @see https://vueuse.org/useInterval
  805. * @param interval
  806. * @param options
  807. */
  808. declare function useInterval(interval?: MaybeComputedRef<number>, options?: UseIntervalOptions<false>): Ref<number>;
  809. declare function useInterval(interval: MaybeComputedRef<number>, options: UseIntervalOptions<true>): UseIntervalControls & Pausable;
  810. interface UseIntervalFnOptions {
  811. /**
  812. * Start the timer immediately
  813. *
  814. * @default true
  815. */
  816. immediate?: boolean;
  817. /**
  818. * Execute the callback immediate after calling this function
  819. *
  820. * @default false
  821. */
  822. immediateCallback?: boolean;
  823. }
  824. /**
  825. * Wrapper for `setInterval` with controls
  826. *
  827. * @param cb
  828. * @param interval
  829. * @param options
  830. */
  831. declare function useIntervalFn(cb: Fn, interval?: MaybeComputedRef<number>, options?: UseIntervalFnOptions): Pausable;
  832. interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends number | null | undefined = undefined> extends WatchOptions<Immediate> {
  833. initialValue?: InitialValue;
  834. }
  835. /**
  836. * Records the timestamp of the last change
  837. *
  838. * @see https://vueuse.org/useLastChanged
  839. */
  840. declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): Ref<number | null>;
  841. declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true>): Ref<number>;
  842. declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<boolean, number>): Ref<number>;
  843. /**
  844. * Throttle execution of a function. Especially useful for rate limiting
  845. * execution of handlers on events like resize and scroll.
  846. *
  847. * @param fn A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
  848. * to `callback` when the throttled-function is executed.
  849. * @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
  850. *
  851. * @param [trailing=false] if true, call fn again after the time is up
  852. *
  853. * @param [leading=true] if true, call fn on the leading edge of the ms timeout
  854. *
  855. * @param [rejectOnCancel=false] if true, reject the last call if it's been cancel
  856. *
  857. * @return A new, throttled, function.
  858. */
  859. declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeComputedRef<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn<T>;
  860. interface UseTimeoutFnOptions {
  861. /**
  862. * Start the timer immediate after calling this function
  863. *
  864. * @default true
  865. */
  866. immediate?: boolean;
  867. }
  868. /**
  869. * Wrapper for `setTimeout` with controls.
  870. *
  871. * @param cb
  872. * @param interval
  873. * @param options
  874. */
  875. declare function useTimeoutFn<CallbackFn extends (...args: any[]) => any>(cb: CallbackFn, interval: MaybeComputedRef<number>, options?: UseTimeoutFnOptions): Stoppable<Parameters<CallbackFn> | []>;
  876. interface UseTimeoutOptions<Controls extends boolean> extends UseTimeoutFnOptions {
  877. /**
  878. * Expose more controls
  879. *
  880. * @default false
  881. */
  882. controls?: Controls;
  883. /**
  884. * Callback on timeout
  885. */
  886. callback?: Fn;
  887. }
  888. /**
  889. * Update value after a given time with controls.
  890. *
  891. * @see {@link https://vueuse.org/useTimeout}
  892. * @param interval
  893. * @param options
  894. */
  895. declare function useTimeout(interval?: number, options?: UseTimeoutOptions<false>): ComputedRef<boolean>;
  896. declare function useTimeout(interval: number, options: UseTimeoutOptions<true>): {
  897. ready: ComputedRef<boolean>;
  898. } & Stoppable;
  899. interface UseToNumberOptions {
  900. /**
  901. * Method to use to convert the value to a number.
  902. *
  903. * @default 'parseFloat'
  904. */
  905. method?: 'parseFloat' | 'parseInt';
  906. /**
  907. * The base in mathematical numeral systems passed to `parseInt`.
  908. * Only works with `method: 'parseInt'`
  909. */
  910. radix?: number;
  911. /**
  912. * Replace NaN with zero
  913. *
  914. * @default false
  915. */
  916. nanToZero?: boolean;
  917. }
  918. /**
  919. * Computed reactive object.
  920. */
  921. declare function useToNumber(value: MaybeComputedRef<number | string>, options?: UseToNumberOptions): ComputedRef<number>;
  922. /**
  923. * Reactively convert a ref to string.
  924. *
  925. * @see https://vueuse.org/useToString
  926. */
  927. declare function useToString(value: MaybeComputedRef<unknown>): ComputedRef<string>;
  928. interface UseToggleOptions<Truthy, Falsy> {
  929. truthyValue?: MaybeComputedRef<Truthy>;
  930. falsyValue?: MaybeComputedRef<Falsy>;
  931. }
  932. declare function useToggle<Truthy, Falsy, T = Truthy | Falsy>(initialValue: Ref<T>, options?: UseToggleOptions<Truthy, Falsy>): (value?: T) => T;
  933. declare function useToggle<Truthy = true, Falsy = false, T = Truthy | Falsy>(initialValue?: T, options?: UseToggleOptions<Truthy, Falsy>): [Ref<T>, (value?: T) => T];
  934. declare type WatchArrayCallback<V = any, OV = any> = (value: V, oldValue: OV, added: V, removed: OV, onCleanup: (cleanupFn: () => void) => void) => any;
  935. /**
  936. * Watch for an array with additions and removals.
  937. *
  938. * @see https://vueuse.org/watchArray
  939. */
  940. declare function watchArray<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T[]> | T[], cb: WatchArrayCallback<T[], Immediate extends true ? T[] | undefined : T[]>, options?: WatchOptions<Immediate>): vue_demi.WatchStopHandle;
  941. interface WatchWithFilterOptions<Immediate> extends WatchOptions<Immediate>, ConfigurableEventFilter {
  942. }
  943. declare function watchWithFilter<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
  944. declare function watchWithFilter<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
  945. declare function watchWithFilter<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchStopHandle;
  946. interface WatchAtMostOptions<Immediate> extends WatchWithFilterOptions<Immediate> {
  947. count: MaybeComputedRef<number>;
  948. }
  949. interface WatchAtMostReturn {
  950. stop: WatchStopHandle;
  951. count: Ref<number>;
  952. }
  953. declare function watchAtMost<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
  954. declare function watchAtMost<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options: WatchAtMostOptions<Immediate>): WatchAtMostReturn;
  955. interface WatchDebouncedOptions<Immediate> extends WatchOptions<Immediate>, DebounceFilterOptions {
  956. debounce?: MaybeComputedRef<number>;
  957. }
  958. declare function watchDebounced<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
  959. declare function watchDebounced<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
  960. declare function watchDebounced<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchDebouncedOptions<Immediate>): WatchStopHandle;
  961. type IgnoredUpdater = (updater: () => void) => void;
  962. interface WatchIgnorableReturn {
  963. ignoreUpdates: IgnoredUpdater;
  964. ignorePrevAsyncUpdates: () => void;
  965. stop: WatchStopHandle;
  966. }
  967. declare function watchIgnorable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
  968. declare function watchIgnorable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
  969. declare function watchIgnorable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchIgnorableReturn;
  970. declare function watchOnce<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(source: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): void;
  971. declare function watchOnce<T, Immediate extends Readonly<boolean> = false>(sources: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): void;
  972. interface WatchPausableReturn extends Pausable {
  973. stop: WatchStopHandle;
  974. }
  975. declare function watchPausable<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
  976. declare function watchPausable<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
  977. declare function watchPausable<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchWithFilterOptions<Immediate>): WatchPausableReturn;
  978. interface WatchThrottledOptions<Immediate> extends WatchOptions<Immediate> {
  979. throttle?: MaybeComputedRef<number>;
  980. trailing?: boolean;
  981. leading?: boolean;
  982. }
  983. declare function watchThrottled<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
  984. declare function watchThrottled<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
  985. declare function watchThrottled<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchThrottledOptions<Immediate>): WatchStopHandle;
  986. interface WatchTriggerableReturn<FnReturnT = void> extends WatchIgnorableReturn {
  987. /** Execute `WatchCallback` immediately */
  988. trigger: () => FnReturnT;
  989. }
  990. type OnCleanup = (cleanupFn: () => void) => void;
  991. type WatchTriggerableCallback<V = any, OV = any, R = void> = (value: V, oldValue: OV, onCleanup: OnCleanup) => R;
  992. declare function watchTriggerable<T extends Readonly<WatchSource<unknown>[]>, FnReturnT>(sources: [...T], cb: WatchTriggerableCallback<MapSources<T>, MapOldSources<T, true>, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
  993. declare function watchTriggerable<T, FnReturnT>(source: WatchSource<T>, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
  994. declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: WatchTriggerableCallback<T, T | undefined, FnReturnT>, options?: WatchWithFilterOptions<boolean>): WatchTriggerableReturn<FnReturnT>;
  995. /**
  996. * Shorthand for watching value to be truthy
  997. *
  998. * @see https://vueuse.org/whenever
  999. */
  1000. declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
  1001. export { AnyFn, ArgumentsType, Arrayable, Awaitable, ComputedRefWithControl, ComputedWithControlRefExtra, ConfigurableEventFilter, ConfigurableFlush, ConfigurableFlushSync, ControlledRefOptions, CreateGlobalStateReturn, DateLike, DebounceFilterOptions, DeepMaybeRef, ElementOf, EventFilter, EventHook, EventHookOff, EventHookOn, EventHookTrigger, ExtendRefOptions, Fn, FunctionArgs, FunctionWrapperOptions, IgnoredUpdater, MapOldSources, MapSources, MaybeComputedRef, MaybeReadonlyRef, MaybeRef, Pausable, PromisifyFn, Reactified, ReactifyNested, ReactifyObjectOptions, ReactifyOptions, RemovableRef, RemoveableRef, ShallowUnwrapRef, SingletonPromiseReturn, Stopable, Stoppable, SyncRefOptions, SyncRefsOptions, UntilArrayInstance, UntilBaseInstance, UntilToMatchOptions, UntilValueInstance, UseArrayReducer, UseCounterOptions, UseDateFormatOptions, UseDateFormatReturn, UseIntervalControls, UseIntervalFnOptions, UseIntervalOptions, UseLastChangedOptions, UseTimeoutFnOptions, UseTimeoutOptions, UseToNumberOptions, UseToggleOptions, WatchArrayCallback, WatchAtMostOptions, WatchAtMostReturn, WatchDebouncedOptions, WatchIgnorableReturn, WatchPausableReturn, WatchThrottledOptions, WatchTriggerableCallback, WatchTriggerableReturn, WatchWithFilterOptions, WritableComputedRefWithControl, __onlyVue27Plus, __onlyVue3, assert, refAutoReset as autoResetRef, bypassFilter, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, makeDestructurable, noop, normalizeDate, now, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };