index.d.ts 46 KB

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