You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1222 rivejä
52 KiB

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