From 6846007a0a64467facbf09b6ad1269f63bb8fb12 Mon Sep 17 00:00:00 2001 From: YongGit <1013588891@qq.com> Date: Sat, 13 Jul 2024 11:54:39 +0800 Subject: [PATCH] feat: lodash -> lodash-es --- package.json | 2 +- packages/hooks/package.json | 2 +- packages/hooks/src/useDebounceFn/index.ts | 2 +- packages/hooks/src/useEventEmitter/event.ts | 2 +- packages/hooks/src/useKeyPress/index.ts | 1 - .../useRequest/plugins/useDebouncePlugin.ts | 4 +- .../useRequest/plugins/useThrottlePlugin.ts | 4 +- packages/hooks/src/useSetState/index.ts | 2 +- packages/hooks/src/useThrottleFn/index.ts | 2 +- .../src/utils/useDeepCompareWithTarget.ts | 2 +- packages/types/index.d.ts | 1792 ++++++++--------- packages/use-request/package.json | 2 +- .../src/plugins/useDebouncePlugin.ts | 4 +- .../src/plugins/useThrottlePlugin.ts | 4 +- packages/use-worker/package.json | 2 +- .../src/hook/useDeepCompareWithTarget.ts | 2 +- pnpm-lock.yaml | 27 +- 17 files changed, 933 insertions(+), 923 deletions(-) diff --git a/package.json b/package.json index 65c2f2e4..f4b4781d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@vitest/ui": "^0.25.3", "@types/fs-extra": "^9.0.13", "@types/jest": "^29.0.0", - "@types/lodash": "^4.14.178", + "@types/lodash-es": "^4.17.12", "@types/marked": "^4.0.3", "@types/node": "^17.0.21", "@types/qs": "^6.9.7", diff --git a/packages/hooks/package.json b/packages/hooks/package.json index d44a1349..f311435f 100644 --- a/packages/hooks/package.json +++ b/packages/hooks/package.json @@ -36,7 +36,7 @@ "@vue/devtools-api": "^6.5.0", "@types/js-cookie": "^3.0.1", "js-cookie": "^3.0.1", - "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "qs": "^6.11.0", "query-string": "^7.1.1", "screenfull": "^5.0.0" diff --git a/packages/hooks/src/useDebounceFn/index.ts b/packages/hooks/src/useDebounceFn/index.ts index f085280e..0951f98e 100644 --- a/packages/hooks/src/useDebounceFn/index.ts +++ b/packages/hooks/src/useDebounceFn/index.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce' +import { debounce } from 'lodash-es' export interface DebounceOptions { /** diff --git a/packages/hooks/src/useEventEmitter/event.ts b/packages/hooks/src/useEventEmitter/event.ts index c1f7058a..e9e34617 100644 --- a/packages/hooks/src/useEventEmitter/event.ts +++ b/packages/hooks/src/useEventEmitter/event.ts @@ -1,4 +1,4 @@ -import cloneDeep from 'lodash/cloneDeep' +import { cloneDeep } from 'lodash-es' import { ref, watchEffect } from 'vue' type SubscriptionParams = { diff --git a/packages/hooks/src/useKeyPress/index.ts b/packages/hooks/src/useKeyPress/index.ts index abe4af3c..4d836f3e 100644 --- a/packages/hooks/src/useKeyPress/index.ts +++ b/packages/hooks/src/useKeyPress/index.ts @@ -1,5 +1,4 @@ import { ref } from 'vue' -// import { isFunction, isNumber, isString } from 'lodash' import { BasicTarget, getTargetElement } from '../utils/domTarget' import useDeepCompareEffectWithTarget from '../utils/useDeepCompareWithTarget' import { isNumber, isFunction, isString } from '../utils' diff --git a/packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts b/packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts index 7d3aae76..173925ef 100644 --- a/packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts +++ b/packages/hooks/src/useRequest/plugins/useDebouncePlugin.ts @@ -1,6 +1,6 @@ import { ref, computed, watchEffect, unref } from "vue"; -import type { DebouncedFunc, DebounceSettings } from "lodash"; -import debounce from "lodash/debounce"; +import type { DebouncedFunc, DebounceSettings } from "lodash-es"; +import { debounce } from "lodash-es"; import type { UseRequestPlugin } from "../types"; const useDebouncePlugin: UseRequestPlugin = ( diff --git a/packages/hooks/src/useRequest/plugins/useThrottlePlugin.ts b/packages/hooks/src/useRequest/plugins/useThrottlePlugin.ts index 2ced2afd..01149a24 100644 --- a/packages/hooks/src/useRequest/plugins/useThrottlePlugin.ts +++ b/packages/hooks/src/useRequest/plugins/useThrottlePlugin.ts @@ -1,6 +1,6 @@ import { computed, unref, watchEffect } from 'vue' -import { DebouncedFunc, ThrottleSettings } from 'lodash' -import throttle from 'lodash/throttle' +import { DebouncedFunc, ThrottleSettings } from 'lodash-es' +import { throttle } from 'lodash-es' import { UseRequestPlugin } from '../types' const useThrottlePlugin: UseRequestPlugin = ( diff --git a/packages/hooks/src/useSetState/index.ts b/packages/hooks/src/useSetState/index.ts index b9ebca8a..e4484319 100644 --- a/packages/hooks/src/useSetState/index.ts +++ b/packages/hooks/src/useSetState/index.ts @@ -1,5 +1,5 @@ import { ref, Ref, unref, UnwrapRef, readonly, DeepReadonly, UnwrapNestedRefs } from 'vue' -import merge from 'lodash/merge' +import { merge } from 'lodash-es' type UseSetStateType = S | (() => S) | Ref | (() => Ref) diff --git a/packages/hooks/src/useThrottleFn/index.ts b/packages/hooks/src/useThrottleFn/index.ts index 8488470f..dacebd75 100644 --- a/packages/hooks/src/useThrottleFn/index.ts +++ b/packages/hooks/src/useThrottleFn/index.ts @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle' +import { throttle } from 'lodash-es' import { onUnmounted, ref, computed } from 'vue' import { UseThrottleOptions } from '../useThrottle' diff --git a/packages/hooks/src/utils/useDeepCompareWithTarget.ts b/packages/hooks/src/utils/useDeepCompareWithTarget.ts index 2fbf40a3..83ab245a 100644 --- a/packages/hooks/src/utils/useDeepCompareWithTarget.ts +++ b/packages/hooks/src/utils/useDeepCompareWithTarget.ts @@ -1,5 +1,5 @@ import { ref } from 'vue' -import isEqual from 'lodash/isEqual' +import { isEqual } from 'lodash-es' import { EffectCallback } from './createEffectWithTarget' import { DependencyList } from './depsAreSame' import { BasicTarget } from './domTarget' diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index d69fb8a7..58c0fb5b 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -1,7 +1,7 @@ import type { ComponentPublicInstance } from 'vue'; import { ComputedRef } from 'vue'; import Cookies from 'js-cookie'; -import type { DebouncedFunc } from 'lodash'; +import type { DebouncedFunc } from 'lodash-es'; import { DeepReadonly } from 'vue'; import { Ref } from 'vue'; import { UnwrapNestedRefs } from 'vue'; @@ -12,106 +12,106 @@ import { WatchSource } from 'vue'; declare type BasicTarget = (() => TargetValue) | TargetValue | Ref>; declare interface CachedData { - data: TData; - params: TParams; - time: number; + data: TData; + params: TParams; + time: number; } export declare const clearUseRequestCache: (key?: string | string[]) => void; declare interface DebounceOptions { - /** - * The number of milliseconds to delay. - */ - wait?: number; - /** - * Specify invoking on the leading edge of the timeout. - */ - leading?: boolean; - /** - * Specify invoking on the trailing edge of the timeout. - */ - trailing?: boolean; - /** - * The maximum time func is allowed to be delayed before it’s invoked. - */ - maxWait?: number; + /** + * The number of milliseconds to delay. + */ + wait?: number; + /** + * Specify invoking on the leading edge of the timeout. + */ + leading?: boolean; + /** + * Specify invoking on the trailing edge of the timeout. + */ + trailing?: boolean; + /** + * The maximum time func is allowed to be delayed before it’s invoked. + */ + maxWait?: number; } declare type DependencyList = WatchSource | any[] | any; declare class EventEmitter { - private subscriptions; - private emitEffectCache; - constructor(); - /** - * Subscribe to the event - * @param event string - * @param listener Subscription - */ - useSubscription: (event: string, listener?: Subscription) => void; - /** - * Send an event notification - * @param event string | number - * @param args T extends any[] ? any[] : any - */ - emit: (event: string | number, ...args: T extends any[] ? any[] : any) => void; - emitEffect: (event: string | number) => void; - removeListener: (event: string) => void; - clear: () => void; + private subscriptions; + private emitEffectCache; + constructor(); + /** + * Subscribe to the event + * @param event string + * @param listener Subscription + */ + useSubscription: (event: string, listener?: Subscription) => void; + /** + * Send an event notification + * @param event string | number + * @param args T extends any[] ? any[] : any + */ + emit: (event: string | number, ...args: T extends any[] ? any[] : any) => void; + emitEffect: (event: string | number) => void; + removeListener: (event: string) => void; + clear: () => void; } declare const eventEmitterOverall: EventEmitter; declare class Fetch { - serviceRef: Ref>; - options: Partial & UseRequestOptionsWithFormatResult>; - setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState) => void; - initState: Partial>; - pluginImpls: UseRequestPluginReturn[] | undefined; - count: number; - state: UseRequestFetchState; - previousValidData: UseRequestFetchState['data']; - constructor(serviceRef: Ref>, options: Partial & UseRequestOptionsWithFormatResult>, setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState) => void, initState?: Partial>); - /** - * set state - * @param currentState currentState - */ - setState(currentState?: Partial>): void; - /** - * should rename - * @param data Result value `unknown` - * @param key Result key `data`| `params` | `loading`| `error` - */ - setData(data: unknown, key?: keyof UseRequestFetchState | (keyof UseRequestFetchState)[]): void; - /** - * - * @param data Result value `unknown` - * @param key Result key `data`| `params` | `loading`| `error` - */ - setFetchState(data: unknown, key?: keyof UseRequestFetchState | (keyof UseRequestFetchState)[]): void; - /** - * Traverse the plugin that needs to be run, - * which is a callback function for the plugin to obtain fetch instances and execute plugin logic at the corresponding nodes. - */ - runPluginHandler(event: keyof UseRequestPluginReturn, ...rest: unknown[]): any; - runAsync(...params: TParams): Promise; - run(...params: TParams): void; - cancel(): void; - refresh(): void; - refreshAsync(): Promise; - mutate(data?: TData | ((oldData?: TData) => TData | undefined)): void; + serviceRef: Ref>; + options: Partial & UseRequestOptionsWithFormatResult>; + setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState) => void; + initState: Partial>; + pluginImpls: UseRequestPluginReturn[] | undefined; + count: number; + state: UseRequestFetchState; + previousValidData: UseRequestFetchState['data']; + constructor(serviceRef: Ref>, options: Partial & UseRequestOptionsWithFormatResult>, setUpdateData: (currentState: unknown, key?: keyof UseRequestFetchState) => void, initState?: Partial>); + /** + * set state + * @param currentState currentState + */ + setState(currentState?: Partial>): void; + /** + * should rename + * @param data Result value `unknown` + * @param key Result key `data`| `params` | `loading`| `error` + */ + setData(data: unknown, key?: keyof UseRequestFetchState | (keyof UseRequestFetchState)[]): void; + /** + * + * @param data Result value `unknown` + * @param key Result key `data`| `params` | `loading`| `error` + */ + setFetchState(data: unknown, key?: keyof UseRequestFetchState | (keyof UseRequestFetchState)[]): void; + /** + * Traverse the plugin that needs to be run, + * which is a callback function for the plugin to obtain fetch instances and execute plugin logic at the corresponding nodes. + */ + runPluginHandler(event: keyof UseRequestPluginReturn, ...rest: unknown[]): any; + runAsync(...params: TParams): Promise; + run(...params: TParams): void; + cancel(): void; + refresh(): void; + refreshAsync(): Promise; + mutate(data?: TData | ((oldData?: TData) => TData | undefined)): void; } declare type FetchType = Record | undefined; - params: TParams; - loading: boolean; - key: string | number; + data: Readonly | undefined; + params: TParams; + loading: boolean; + key: string | number; }>; declare interface IFuncUpdater { - (previousState?: T): T; + (previousState?: T): T; } declare type InterruptibleRejectType = (error: any) => void; @@ -119,11 +119,11 @@ declare type InterruptibleRejectType = (error: any) => void; declare type IProps = Record; declare interface LongPressModifiers { - stop?: boolean; - once?: boolean; - prevent?: boolean; - capture?: boolean; - self?: boolean; + stop?: boolean; + once?: boolean; + prevent?: boolean; + capture?: boolean; + self?: boolean; } declare type noop = (...args: any) => any; @@ -133,26 +133,26 @@ declare type noop_2 = (...p: any) => void; declare type noop_3 = (...args: any) => any; declare interface Options { - serializer?: (value: T) => string; - deserializer?: (value: string) => T; + serializer?: (value: T) => string; + deserializer?: (value: string) => T; } declare interface OptionsWithDefaultValue extends Options { - defaultValue: T | IFuncUpdater; + defaultValue: T | IFuncUpdater; } declare type ParamsType

= P extends any[] ? any[] : any; declare type Position = { - left: number; - top: number; + left: number; + top: number; }; declare enum ReadyState_2 { - Connecting = 0, - Open = 1, - Closing = 2, - Closed = 3 + Connecting = 0, + Open = 1, + Closing = 2, + Closed = 3 } declare type RequestHook = (service: UseRequestService, options: UseRequestOptions, plugins: UseRequestPlugin[]) => useRequestResult; @@ -162,20 +162,20 @@ declare type ResizeObserverCallback_2 = (entries: ReadonlyArray void; declare type Size = { - width: Readonly>; - height: Readonly>; + width: Readonly>; + height: Readonly>; }; declare type StorageStateResultHasDefaultValue = [ -Ref | Ref, -(value?: T | IFuncUpdater | undefined) => void + Ref | Ref, + (value?: T | IFuncUpdater | undefined) => void ]; declare type Subscription = ({ params, event }: SubscriptionParams) => void; declare type SubscriptionParams = { - params: T; - event: string | number; + params: T; + event: string | number; }; declare type TargetType = HTMLElement | Element | Window | Document | ComponentPublicInstance; @@ -183,62 +183,62 @@ declare type TargetType = HTMLElement | Element | Window | Document | ComponentP declare type TargetValue = T | undefined | null; declare interface UrlState { - [key: string]: any; + [key: string]: any; } export declare function useAsyncOrder({ task, option }: UseAsyncOrderType): void; declare type UseAsyncOrderType = { - task: ((resolve?: Resolve, reject?: InterruptibleRejectType, index?: number) => void)[]; - option?: { - /** - * Delay execution - */ - delay?: number; - /** - * Preparation phase callback - * @returns void - */ - onReady?: () => void; - /** - * Successful callback - * @param result any - * @returns void - */ - onSuccess?: (result: unknown) => void; - /** - * Error callback - * @param err unknown - * @returns void - */ - onError?: (err: unknown) => void; - }; -}; - -export declare function useBoolean(defaultValue?: boolean): UseBooleanResult; - -declare interface UseBooleanActions { + task: ((resolve?: Resolve, reject?: InterruptibleRejectType, index?: number) => void)[]; + option?: { /** - * Set state to `true` - * @returns void + * Delay execution */ - setTrue: () => void; + delay?: number; /** - * Set state to `false` + * Preparation phase callback * @returns void */ - setFalse: () => void; + onReady?: () => void; /** - * Set state - * @param value boolean + * Successful callback + * @param result any * @returns void */ - set: (value: boolean) => void; + onSuccess?: (result: unknown) => void; /** - * Toggle state + * Error callback + * @param err unknown * @returns void */ - toggle: () => void; + onError?: (err: unknown) => void; + }; +}; + +export declare function useBoolean(defaultValue?: boolean): UseBooleanResult; + +declare interface UseBooleanActions { + /** + * Set state to `true` + * @returns void + */ + setTrue: () => void; + /** + * Set state to `false` + * @returns void + */ + setFalse: () => void; + /** + * Set state + * @param value boolean + * @returns void + */ + set: (value: boolean) => void; + /** + * Toggle state + * @returns void + */ + toggle: () => void; } declare type UseBooleanResult = [Readonly>, UseBooleanActions]; @@ -246,7 +246,7 @@ declare type UseBooleanResult = [Readonly>, UseBooleanActions]; export declare function useCookieState(cookieKey: string, options?: UseCookieStateOptions): readonly [Readonly UseCookieStateType)>>, (newValue: UseCookieStateType | ((prevState: UseCookieStateType) => UseCookieStateType), newOptions?: Cookies.CookieAttributes) => void]; declare interface UseCookieStateOptions extends Cookies.CookieAttributes { - defaultValue?: UseCookieStateType | (() => UseCookieStateType); + defaultValue?: UseCookieStateType | (() => UseCookieStateType); } declare type UseCookieStateType = string | undefined; @@ -254,40 +254,40 @@ declare type UseCookieStateType = string | undefined; export declare function useCounter(initialValue?: number, options?: UseCounterOptions): [Ref, UseCounterActions]; declare interface UseCounterActions { - /** - * Increment, default delta is 1 - * @param delta number - * @returns void - */ - inc: (delta?: number) => void; - /** - * Decrement, default delta is 1 - * @param delta number - * @returns void - */ - dec: (delta?: number) => void; - /** - * Set current value - * @param value number | ((c: number) => number) - * @returns void - */ - set: (value: number | ((c: number) => number)) => void; - /** - * Reset current value to initial value - * @returns void - */ - reset: () => void; + /** + * Increment, default delta is 1 + * @param delta number + * @returns void + */ + inc: (delta?: number) => void; + /** + * Decrement, default delta is 1 + * @param delta number + * @returns void + */ + dec: (delta?: number) => void; + /** + * Set current value + * @param value number | ((c: number) => number) + * @returns void + */ + set: (value: number | ((c: number) => number)) => void; + /** + * Reset current value to initial value + * @returns void + */ + reset: () => void; } declare interface UseCounterOptions { - /** - * Min count - */ - min?: number; - /** - * Max count - */ - max?: number; + /** + * Min count + */ + min?: number; + /** + * Max count + */ + max?: number; } export declare function useDarkMode(): [ComputedRef, (value?: unknown) => void]; @@ -295,151 +295,151 @@ export declare function useDarkMode(): [ComputedRef, (value?: unknown) export declare function useDebounce(value: Ref, options?: DebounceOptions): Ref; export declare function useDebounceFn(fn: T, options?: DebounceOptions): { - /** - * Invode and pass parameters to fn. - * `(...args: any[]) => any` - */ - run: DebouncedFunc; - /** - * Cancel the invocation of currently debounced function. - * `() => void` - */ - cancel: () => void; - /** - * Immediately invoke currently debounced function. - * `() => void` - */ - flush: () => ReturnType | undefined; + /** + * Invode and pass parameters to fn. + * `(...args: any[]) => any` + */ + run: DebouncedFunc; + /** + * Cancel the invocation of currently debounced function. + * `() => void` + */ + cancel: () => void; + /** + * Immediately invoke currently debounced function. + * `() => void` + */ + flush: () => ReturnType | undefined; }; export declare const useDrag: (data: T, target: BasicTarget, options?: UseDragOptions) => void; declare interface UseDragOptions { - draggable?: boolean; - /** - * On drag start callback - * @param event DragEvent - * @returns void - */ - onDragStart?: (event: DragEvent) => void; - /** - * On drag end callback - * @param event DragEvent - * @returns void - */ - onDragEnd?: (event: DragEvent) => void; + draggable?: boolean; + /** + * On drag start callback + * @param event DragEvent + * @returns void + */ + onDragStart?: (event: DragEvent) => void; + /** + * On drag end callback + * @param event DragEvent + * @returns void + */ + onDragEnd?: (event: DragEvent) => void; } export declare const useDrop: (target: BasicTarget, options?: UseDropOptions) => void; declare interface UseDropOptions { - /** - * The callback when file is dropped or pasted - * @param files File[] - * @param event DragEvent - * @returns void - */ - onFiles?: (files: File[], event?: DragEvent) => void; - /** - * The callback when uri is dropped or pasted - * @param url string - * @param event DragEvent - * @returns void - */ - onUri?: (url: string, event?: DragEvent) => void; - /** - * The callback when DOM is dropped or pasted - * @param content any - * @param event DragEvent - * @returns void - */ - onDom?: (content: any, event?: DragEvent) => void; - /** - * The callback when text is dropped or pasted - * @param text `string` - * @param event `ClipboardEvent` - * @returns `void` - */ - onText?: (text: string, event?: ClipboardEvent) => void; - /** - * On drag enter callback - * @param event `DragEvent` - * @returns `void` - */ - onDragEnter?: (event?: DragEvent) => void; - /** - * On drag over callback - * @param event `DragEvent`` - * @returns `void` - */ - onDragOver?: (event?: DragEvent) => void; - /** - * On drag leave callback - * @param event `DragEvent` - * @returns `void` - */ - onDragLeave?: (event?: DragEvent) => void; - /** - * The callback when any is dropped - * @param event DragEvent - * @returns void - */ - onDrop?: (event?: DragEvent) => void; - /** - * The callback when any is pasted - * @param event ClipboardEvent - * @returns void - */ - onPaste?: (event?: ClipboardEvent) => void; + /** + * The callback when file is dropped or pasted + * @param files File[] + * @param event DragEvent + * @returns void + */ + onFiles?: (files: File[], event?: DragEvent) => void; + /** + * The callback when uri is dropped or pasted + * @param url string + * @param event DragEvent + * @returns void + */ + onUri?: (url: string, event?: DragEvent) => void; + /** + * The callback when DOM is dropped or pasted + * @param content any + * @param event DragEvent + * @returns void + */ + onDom?: (content: any, event?: DragEvent) => void; + /** + * The callback when text is dropped or pasted + * @param text `string` + * @param event `ClipboardEvent` + * @returns `void` + */ + onText?: (text: string, event?: ClipboardEvent) => void; + /** + * On drag enter callback + * @param event `DragEvent` + * @returns `void` + */ + onDragEnter?: (event?: DragEvent) => void; + /** + * On drag over callback + * @param event `DragEvent`` + * @returns `void` + */ + onDragOver?: (event?: DragEvent) => void; + /** + * On drag leave callback + * @param event `DragEvent` + * @returns `void` + */ + onDragLeave?: (event?: DragEvent) => void; + /** + * The callback when any is dropped + * @param event DragEvent + * @returns void + */ + onDrop?: (event?: DragEvent) => void; + /** + * The callback when any is pasted + * @param event ClipboardEvent + * @returns void + */ + onPaste?: (event?: ClipboardEvent) => void; } export declare function useElementBounding(target: BasicTarget, options?: UseElementBoundingOptions): UseElementBoundingReturnType; declare interface UseElementBoundingOptions { - /** - * - * When the component is mounted, initialize all values to 0 - * - * @default true - */ - reset?: boolean; - /** - * - * windowResize - * - * @default true - */ - windowResize?: boolean; - /** - * - * windowScroll - * - * @default true - */ - windowScroll?: boolean; - /** - * - * immediate - * - * @default true - */ - immediate?: boolean; + /** + * + * When the component is mounted, initialize all values to 0 + * + * @default true + */ + reset?: boolean; + /** + * + * windowResize + * + * @default true + */ + windowResize?: boolean; + /** + * + * windowScroll + * + * @default true + */ + windowScroll?: boolean; + /** + * + * immediate + * + * @default true + */ + immediate?: boolean; } declare interface UseElementBoundingReturnType { - width: Ref; - height: Ref; - top: Ref; - left: Ref; - bottom: Ref; - right: Ref; + width: Ref; + height: Ref; + top: Ref; + left: Ref; + bottom: Ref; + right: Ref; } export declare function useEventEmitter(options?: { - /** - * Is it global - */ - global?: boolean; + /** + * Is it global + */ + global?: boolean; }): UseEventEmitterType; declare type UseEventEmitterType = EventEmitter | typeof eventEmitterOverall; @@ -455,22 +455,22 @@ export declare function useEventListener(eventNa export declare function useEventListener(eventName: string, handler: noop_2, options: UseEventListenerOptions): void; declare type UseEventListenerOptions = { - /** - * DOM element or ref - */ - target?: T; - /** - * Optional, a Boolean indicating that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. - */ - capture?: boolean; - /** - * Optional, A Boolean indicating that the listener should be invoked at most once after being added. If true, the listener would be automatically removed when invoked. - */ - once?: boolean; - /** - * Optional, A Boolean which, if true, indicates that the function specified by listener will never call preventDefault(). If a passive listener does call preventDefault(), the user agent will do nothing other than generate a console warning. - */ - passive?: boolean; + /** + * DOM element or ref + */ + target?: T; + /** + * Optional, a Boolean indicating that events of this type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. + */ + capture?: boolean; + /** + * Optional, A Boolean indicating that the listener should be invoked at most once after being added. If true, the listener would be automatically removed when invoked. + */ + once?: boolean; + /** + * Optional, A Boolean which, if true, indicates that the function specified by listener will never call preventDefault(). If a passive listener does call preventDefault(), the user agent will do nothing other than generate a console warning. + */ + passive?: boolean; }; declare type UseEventListenerTarget = BasicTarget; @@ -478,18 +478,18 @@ declare type UseEventListenerTarget = BasicTarget, options?: UseExternalOptions): Readonly>; declare interface UseExternalOptions { - /** - * The type of extarnal resources which need to load, support `js`/`css`, if no type, it will deduced according to path - */ - type?: 'js' | 'css'; - /** - * Attributes supported by `script` - */ - js?: Partial; - /** - * Attributes supported by `link` - */ - css?: Partial; + /** + * The type of extarnal resources which need to load, support `js`/`css`, if no type, it will deduced according to path + */ + type?: 'js' | 'css'; + /** + * Attributes supported by `script` + */ + js?: Partial; + /** + * Attributes supported by `link` + */ + css?: Partial; } declare type UseExternalStatus = 'unset' | 'loading' | 'ready' | 'error'; @@ -497,191 +497,191 @@ declare type UseExternalStatus = 'unset' | 'loading' | 'ready' | 'error'; export declare function useFavicon(href?: string | Ref): void; export declare function useFetchs(service: UseRequestService>, options: UseRequestOptions, any> & { - manual: true; + manual: true; }, self: { - fetchKey?: (...args: ParamsType) => string; + fetchKey?: (...args: ParamsType) => string; }): { - fetchs: Ref>; - fetchRun: (...args: TParams extends any[] ? any[] : any) => void; + fetchs: Ref>; + fetchRun: (...args: TParams extends any[] ? any[] : any) => void; }; export declare function useFocusWithin( -/** - * DOM element or ref - */ -target: BasicTarget, options?: UseFocusWithinOptions): Readonly>; + /** + * DOM element or ref + */ + target: BasicTarget, options?: UseFocusWithinOptions): Readonly>; declare interface UseFocusWithinOptions { - /** - * Callback to be executed on focus - * @param e FocusEvent - * @returns void - */ - onFocus?: (e: FocusEvent) => void; - /** - * Callback to be executed on blur - * @param e FocusEvent - * @returns void - */ - onBlur?: (e: FocusEvent) => void; - /** - * Callback to be executed on focus change - * @param isFocusWithin boolean - * @returns void - */ - onChange?: (isFocusWithin: boolean) => void; + /** + * Callback to be executed on focus + * @param e FocusEvent + * @returns void + */ + onFocus?: (e: FocusEvent) => void; + /** + * Callback to be executed on blur + * @param e FocusEvent + * @returns void + */ + onBlur?: (e: FocusEvent) => void; + /** + * Callback to be executed on focus change + * @param isFocusWithin boolean + * @returns void + */ + onChange?: (isFocusWithin: boolean) => void; } export declare function useFormatResult(data: TData | Ref, formatResultCallback: (data: TData) => FData): ComputedRef; export declare const useFullscreen: (target?: BasicTarget, options?: UseFullscreenOptions) => readonly [Readonly>, { - readonly enterFullscreen: () => void; - readonly exitFullscreen: () => void; - readonly toggleFullscreen: () => void; - readonly isEnabled: true; + readonly enterFullscreen: () => void; + readonly exitFullscreen: () => void; + readonly toggleFullscreen: () => void; + readonly isEnabled: true; }]; declare interface UseFullscreenOptions { - /** - * Exit full screen trigger - * @returns void - */ - onExit?: () => void; - /** - * Enter full screen trigger - * @returns void - */ - onEnter?: () => void; - /** - * - * The element enters full screen by default when the binding element is not found or the element is not passed - * @default html - */ - defaultElement?: HTMLElement | Element; + /** + * Exit full screen trigger + * @returns void + */ + onExit?: () => void; + /** + * Enter full screen trigger + * @returns void + */ + onEnter?: () => void; + /** + * + * The element enters full screen by default when the binding element is not found or the element is not passed + * @default html + */ + defaultElement?: HTMLElement | Element; } export declare function useHover(target: BasicTarget, options?: UseHoverOptions): Ref; declare interface UseHoverOptions { - /** - * Callback to be executed on mouse hover - * @returns void - */ - onEnter?: () => void; - /** - * Callback to be executed on mouse leave - * @returns void - */ - onLeave?: () => void; - /** - * Callback to be executed on hover change - * @param isHovering boolean - * @returns void - */ - onChange?: (isHovering: boolean) => void; + /** + * Callback to be executed on mouse hover + * @returns void + */ + onEnter?: () => void; + /** + * Callback to be executed on mouse leave + * @returns void + */ + onLeave?: () => void; + /** + * Callback to be executed on hover change + * @param isHovering boolean + * @returns void + */ + onChange?: (isHovering: boolean) => void; } declare type UseInfiniteData = { - list: any[]; - [key: string]: any; + list: any[]; + [key: string]: any; }; export declare const useInfiniteScroll: (service: UseInfiniteService, options?: UseInfiniteScrollOptions) => { - data: Readonly>; - loading: Readonly>; - loadingMore: Readonly>; - noMore: ComputedRef; - loadMore: () => void; - loadMoreAsync: () => Promise | undefined; - reload: () => void; - reloadAsync: () => Promise; - mutate: (mutateData: any) => void; - scrollMethod: () => void; - cancel: () => void; + data: Readonly>; + loading: Readonly>; + loadingMore: Readonly>; + noMore: ComputedRef; + loadMore: () => void; + loadMoreAsync: () => Promise | undefined; + reload: () => void; + reloadAsync: () => Promise; + mutate: (mutateData: any) => void; + scrollMethod: () => void; + cancel: () => void; }; declare interface UseInfiniteScrollOptions { - /** - * specifies the parent element. If it exists, it will trigger the `loadMore` when scrolling to the bottom. Needs to work with `isNoMore` to know when there is no more data to load - */ - target?: BasicTarget; - /** - * determines if there is no more data, the input parameter is the latest merged `data` - * @param data TData - * @returns boolean - */ - isNoMore?: (data?: TData) => boolean; - /** - * The pixel threshold to the bottom for the scrolling to load - */ - threshold?: number; - /** - * - The default is `false`. That is, the service is automatically executed during initialization. - * - If set to `true`, you need to manually call `run` or `runAsync` to trigger execution. - */ - manual?: boolean; - /** - * When the content of the array changes, `reload` will be triggered - */ - reloadDeps?: DependencyList; - /** - * Triggered before service execution - * @returns void - */ - onBefore?: () => void; - /** - * Triggered when service resolve - * @param data TData - * @returns void - */ - onSuccess?: (data: TData) => void; - /** - * Triggered when service reject - * @param e Error - * @returns void - */ - onError?: (e: Error) => void; - /** - * Triggered when service execution is complete - * @param data TData - * @param e Error - * @returns void - */ - onFinally?: (data?: TData, e?: Error) => void; + /** + * specifies the parent element. If it exists, it will trigger the `loadMore` when scrolling to the bottom. Needs to work with `isNoMore` to know when there is no more data to load + */ + target?: BasicTarget; + /** + * determines if there is no more data, the input parameter is the latest merged `data` + * @param data TData + * @returns boolean + */ + isNoMore?: (data?: TData) => boolean; + /** + * The pixel threshold to the bottom for the scrolling to load + */ + threshold?: number; + /** + * - The default is `false`. That is, the service is automatically executed during initialization. + * - If set to `true`, you need to manually call `run` or `runAsync` to trigger execution. + */ + manual?: boolean; + /** + * When the content of the array changes, `reload` will be triggered + */ + reloadDeps?: DependencyList; + /** + * Triggered before service execution + * @returns void + */ + onBefore?: () => void; + /** + * Triggered when service resolve + * @param data TData + * @returns void + */ + onSuccess?: (data: TData) => void; + /** + * Triggered when service reject + * @param e Error + * @returns void + */ + onError?: (e: Error) => void; + /** + * Triggered when service execution is complete + * @param data TData + * @param e Error + * @returns void + */ + onFinally?: (data?: TData, e?: Error) => void; } declare type UseInfiniteService = (currentData?: TData) => Promise; export declare function useInterval( -/** - * The function to be executed every `delay` milliseconds. - */ -fn: () => void, -/** - * The time in milliseconds, the timer should delay in between executions of the specified function. The timer will be cancelled if delay is set to `undefined`. - */ -delay: Ref | number | undefined, options?: { + /** + * The function to be executed every `delay` milliseconds. + */ + fn: () => void, + /** + * The time in milliseconds, the timer should delay in between executions of the specified function. The timer will be cancelled if delay is set to `undefined`. + */ + delay: Ref | number | undefined, options?: { /** * Whether the function should be executed immediately on first execution. */ immediate?: boolean; -}): void; + }): void; export declare function useInViewport(target: BasicTarget, options?: UseInViewportOptions): readonly [Readonly>, Readonly>]; declare interface UseInViewportOptions { - /** - * Margin around the root - */ - rootMargin?: string; - /** - * Either a single number or an array of numbers which indicate at what percentage of the target's visibility the ratio should be executed - */ - threshold?: number | number[]; - /** - * The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null. - */ - root?: BasicTarget; + /** + * Margin around the root + */ + rootMargin?: string; + /** + * Either a single number or an array of numbers which indicate at what percentage of the target's visibility the ratio should be executed + */ + threshold?: number | number[]; + /** + * The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null. + */ + root?: BasicTarget; } export declare function useKeyPress(keyFilter: UseKeyPressKeyFilter, eventHandler: UseKeyPressEventHandler, option?: UseKeyPressOptions): void; @@ -695,18 +695,18 @@ declare type UseKeyPressKeyFilter = UseKeyPressKeyType | UseKeyPressKeyType[] | declare type UseKeyPressKeyType = number | string; declare type UseKeyPressOptions = { - /** - * Trigger Events - */ - events?: UseKeyPressKeyEvent[]; - /** - * DOM element or ref - */ - target?: UseKeyPressTarget; - /** - * Exact match. If set true, the event will only be trigger when the keys match exactly. For example, pressing [shif + c] will not trigger [c] - */ - exactMatch?: boolean; + /** + * Trigger Events + */ + events?: UseKeyPressKeyEvent[]; + /** + * DOM element or ref + */ + target?: UseKeyPressTarget; + /** + * Exact match. If set true, the event will only be trigger when the keys match exactly. For example, pressing [shif + c] will not trigger [c] + */ + exactMatch?: boolean; }; declare type UseKeyPressTarget = BasicTarget; @@ -716,95 +716,95 @@ export declare const useLocalStorageState: (key: string | Ref, option export declare function useLockFn

(fn: (...args: P) => Promise): (...args: P) => Promise; export declare const useLongPress: (target: BasicTarget, options?: UseLongPressOptions) => { - pressingTime: DeepReadonly>; - isPressing: DeepReadonly>; + pressingTime: DeepReadonly>; + isPressing: DeepReadonly>; }; declare interface UseLongPressOptions { - delay?: number; - minUpdateTime?: number; - cancelOnMove?: boolean; - modifiers?: LongPressModifiers; + delay?: number; + minUpdateTime?: number; + cancelOnMove?: boolean; + modifiers?: LongPressModifiers; } export declare function useMap(initialValue?: UseMapValue): [Readonly>>, UseMapActions]; declare type UseMapActions = { - /** - * Add item - * @param key K - * @param value T - * @returns void - */ - set: (key: K, value: T) => void; - /** - * Get item - * @param key K - * @param value T - * @returns undefined - */ - get: (key: K) => T | undefined; - /** - * Remove key - * @param key K - * @returns void - */ - remove: (key: K) => void; - /** - * Add item - * @param key K - * @returns boolean - */ - has: (key: K) => boolean; - /** - * clear - * @returns void - */ - clear: () => void; - /** - * Set a new Map - * @param newMap UseMapValue - * @returns void - */ - setAll: (newMap: UseMapValue) => void; - /** - * Reset to default - * @returns void - */ - reset: () => void; + /** + * Add item + * @param key K + * @param value T + * @returns void + */ + set: (key: K, value: T) => void; + /** + * Get item + * @param key K + * @param value T + * @returns undefined + */ + get: (key: K) => T | undefined; + /** + * Remove key + * @param key K + * @returns void + */ + remove: (key: K) => void; + /** + * Add item + * @param key K + * @returns boolean + */ + has: (key: K) => boolean; + /** + * clear + * @returns void + */ + clear: () => void; + /** + * Set a new Map + * @param newMap UseMapValue + * @returns void + */ + setAll: (newMap: UseMapValue) => void; + /** + * Reset to default + * @returns void + */ + reset: () => void; }; declare type UseMapValue = Iterable; export declare function useMedia( -/** - * Media to query for an array of objects - */ -queries: any[], -/** - * The default value for each media query object - */ -values: { + /** + * Media to query for an array of objects + */ + queries: any[], + /** + * The default value for each media query object + */ + values: { [x: string]: any; -}, -/** - * DefaultValue - */ -defaultValue: any): any; + }, + /** + * DefaultValue + */ + defaultValue: any): any; export declare function useMouse(target?: BasicTarget): Readonly>; export declare const useMutationObserver: (callback: MutationCallback, target: BasicTarget, options?: MutationObserverInit) => void; @@ -812,14 +812,14 @@ export declare const useMutationObserver: (callback: MutationCallback, target: B export declare function useNetwork(): Readonly>; declare interface UseNetworkState { - since?: Date; - online?: boolean; - rtt?: number; - type?: string; - downlink?: number; - saveData?: boolean; - downlinkMax?: number; - effectiveType?: string; + since?: Date; + online?: boolean; + rtt?: number; + type?: string; + downlink?: number; + saveData?: boolean; + downlinkMax?: number; + effectiveType?: string; } export declare function usePrevious(state: Ref | ComputedRef, shouldUpdate?: UsePreviousShouldUpdateFunc): Readonly | undefined>>; @@ -831,247 +831,247 @@ export declare function useRequest[] = UseRequestPlugin[]>(service: UseRequestService, options?: UseRequestOptions ? R : never : never>, plugins?: PluginsOptions): useRequestResult; declare type UseRequestBasicOptions = { - /** - * Init data. - */ - initialData?: TData; - /** - * - The default is `false.` That is, the service is automatically executed during initialization. - * - f set to `true`, you need to manually call `run` or r`unAsync` to trigger execution. - */ - manual?: boolean; - /** - * The parameters passed to the service at the first default execution - */ - defaultParams?: TParams; - /** - * Triggered before service execution - * @param params TParams - * @returns void - */ - onBefore?: (params: TParams) => void; - /** - * Triggered when service resolve. - * @param data TData - * @param params TParams - * @returns void - */ - onSuccess?: (data: TData, params: TParams) => void; - /** - * Triggered when service reject. - * @param e Error - * @param params TParams - * @returns void - */ - onError?: (e: Error, params: TParams) => void; - /** - * Triggered when service execution is complete. - * @param params TParams - * @param data TData - * @param e Error - * @returns void - */ - onFinally?: (params: TParams, data?: TData, e?: Error) => void; - /** - * Is the current request ready - */ - ready?: Ref | boolean; - /** - * Dependent on responsive objects, and the `watch` incoming listener object usage for `vue`. - */ - refreshDeps?: Parameters[0][] | boolean; - refreshDepsAction?: () => void; - /** - * Set the delay time for `loading` to become `true`. - * - */ - loadingDelay?: number | Ref; - /** - * open vue devtools,debugKey must existence and uniqueness. - */ - debugKey?: string; - /** - * Format the request results, which recommend to use `useFormatResult`. - * @param data TData - * @returns unknown need cover TData - */ - /** - * Polling interval, in milliseconds. If the value is greater than 0, the polling mode is activated. - */ - pollingInterval?: Ref | number; - /** - * Whether to continue polling when the page is hidden. If set to false, polling will be temporarily paused when the page is hidden, and resume when the page is visible again. - */ - pollingWhenHidden?: boolean; - /** - * Number of polling error retries. If set to -1, `an infinite number of times`. - */ - pollingErrorRetryCount?: number; - /** - * Whether to re-initiate the request when the screen refocus or revisible. - */ - refreshOnWindowFocus?: Ref | boolean; - /** - * Re-request interval, in milliseconds. - */ - focusTimespan?: Ref | number; - /** - * Debounce delay time, in milliseconds. After setting, enter the debounce mode. - */ - debounceWait?: Ref | number; - /** - * Execute the request before the delay starts. - */ - debounceLeading?: Ref | boolean; - /** - * Execute the request after the delay ends. - */ - debounceTrailing?: Ref | boolean; - /** - * The maximum time request is allowed to be delayed before it’s executed. - */ - debounceMaxWait?: Ref | number; - /** - * Throttle wait time, in milliseconds. After setting, enter the throttle mode. - */ - throttleWait?: Ref | number; - /** - * Execute the request before throttling starts. - */ - throttleLeading?: Ref | boolean; - /** - * Execute the request after throttling ends. - */ - throttleTrailing?: Ref | boolean; - /** - * A unique ID of the request. If `cacheKey` is set, we will enable the caching mechanism. The data of the same `cacheKey` is globally synchronized. - */ - cacheKey?: string; - /** - * - Set the cache time. By default, the cached data will be cleared after 5 minutes. - * - If set to `-1`, the cached data will never expire. - */ - cacheTime?: number; - /** - * - Time to consider the cached data is fresh. Within this time interval, the request will not be re-initiated. - * - If set to `-1`, it means that the data is always fresh - */ - staleTime?: number; - /** - * - Custom set cache. - * - `setCache` and `getCache` need to be used together. - * - In the custom cache mode, `cacheTime` and `clearCache` are useless, please implement it yourself according to the actual situation. - * @param data CachedData - * @returns void - */ - setCache?: (data: CachedData) => void; - /** - * Custom get cache - * @param params TParams - * @returns CachedData - */ - getCache?: (params: TParams) => CachedData | undefined; - /** - * The number of retries. If set to `-1`, it will try again indefinitely. - */ - retryCount?: number; - /** - * - Retry interval in milliseconds. - * If not set, the simple exponential backoff algorithm will be used by default, taking `1000 * 2 ** retryCount`, that is, waiting for 2s for the first retry, and 4s for the second retry. By analogy, if it is greater than 30s, take 30s. - */ - retryInterval?: number; - /** - * Middleware - */ - use?: UseRequestMiddleware[]; - rollbackOnError?: boolean | ((params: TParams) => boolean); + /** + * Init data. + */ + initialData?: TData; + /** + * - The default is `false.` That is, the service is automatically executed during initialization. + * - f set to `true`, you need to manually call `run` or r`unAsync` to trigger execution. + */ + manual?: boolean; + /** + * The parameters passed to the service at the first default execution + */ + defaultParams?: TParams; + /** + * Triggered before service execution + * @param params TParams + * @returns void + */ + onBefore?: (params: TParams) => void; + /** + * Triggered when service resolve. + * @param data TData + * @param params TParams + * @returns void + */ + onSuccess?: (data: TData, params: TParams) => void; + /** + * Triggered when service reject. + * @param e Error + * @param params TParams + * @returns void + */ + onError?: (e: Error, params: TParams) => void; + /** + * Triggered when service execution is complete. + * @param params TParams + * @param data TData + * @param e Error + * @returns void + */ + onFinally?: (params: TParams, data?: TData, e?: Error) => void; + /** + * Is the current request ready + */ + ready?: Ref | boolean; + /** + * Dependent on responsive objects, and the `watch` incoming listener object usage for `vue`. + */ + refreshDeps?: Parameters[0][] | boolean; + refreshDepsAction?: () => void; + /** + * Set the delay time for `loading` to become `true`. + * + */ + loadingDelay?: number | Ref; + /** + * open vue devtools,debugKey must existence and uniqueness. + */ + debugKey?: string; + /** + * Format the request results, which recommend to use `useFormatResult`. + * @param data TData + * @returns unknown need cover TData + */ + /** + * Polling interval, in milliseconds. If the value is greater than 0, the polling mode is activated. + */ + pollingInterval?: Ref | number; + /** + * Whether to continue polling when the page is hidden. If set to false, polling will be temporarily paused when the page is hidden, and resume when the page is visible again. + */ + pollingWhenHidden?: boolean; + /** + * Number of polling error retries. If set to -1, `an infinite number of times`. + */ + pollingErrorRetryCount?: number; + /** + * Whether to re-initiate the request when the screen refocus or revisible. + */ + refreshOnWindowFocus?: Ref | boolean; + /** + * Re-request interval, in milliseconds. + */ + focusTimespan?: Ref | number; + /** + * Debounce delay time, in milliseconds. After setting, enter the debounce mode. + */ + debounceWait?: Ref | number; + /** + * Execute the request before the delay starts. + */ + debounceLeading?: Ref | boolean; + /** + * Execute the request after the delay ends. + */ + debounceTrailing?: Ref | boolean; + /** + * The maximum time request is allowed to be delayed before it’s executed. + */ + debounceMaxWait?: Ref | number; + /** + * Throttle wait time, in milliseconds. After setting, enter the throttle mode. + */ + throttleWait?: Ref | number; + /** + * Execute the request before throttling starts. + */ + throttleLeading?: Ref | boolean; + /** + * Execute the request after throttling ends. + */ + throttleTrailing?: Ref | boolean; + /** + * A unique ID of the request. If `cacheKey` is set, we will enable the caching mechanism. The data of the same `cacheKey` is globally synchronized. + */ + cacheKey?: string; + /** + * - Set the cache time. By default, the cached data will be cleared after 5 minutes. + * - If set to `-1`, the cached data will never expire. + */ + cacheTime?: number; + /** + * - Time to consider the cached data is fresh. Within this time interval, the request will not be re-initiated. + * - If set to `-1`, it means that the data is always fresh + */ + staleTime?: number; + /** + * - Custom set cache. + * - `setCache` and `getCache` need to be used together. + * - In the custom cache mode, `cacheTime` and `clearCache` are useless, please implement it yourself according to the actual situation. + * @param data CachedData + * @returns void + */ + setCache?: (data: CachedData) => void; + /** + * Custom get cache + * @param params TParams + * @returns CachedData + */ + getCache?: (params: TParams) => CachedData | undefined; + /** + * The number of retries. If set to `-1`, it will try again indefinitely. + */ + retryCount?: number; + /** + * - Retry interval in milliseconds. + * If not set, the simple exponential backoff algorithm will be used by default, taking `1000 * 2 ** retryCount`, that is, waiting for 2s for the first retry, and 4s for the second retry. By analogy, if it is greater than 30s, take 30s. + */ + retryInterval?: number; + /** + * Middleware + */ + use?: UseRequestMiddleware[]; + rollbackOnError?: boolean | ((params: TParams) => boolean); }; export declare const useRequestDevToolsPlugin: { - install(app: any): void; + install(app: any): void; }; declare interface UseRequestFetchState { - loading: boolean; - params?: TParams; - data?: TData; - error?: Error | unknown; + loading: boolean; + params?: TParams; + data?: TData; + error?: Error | unknown; } declare type UseRequestMiddleware = (useRequestNext: RequestHook) => RequestHook; declare type UseRequestOptions = UseRequestBasicOptions & { - pluginOptions?: TPlugin; + pluginOptions?: TPlugin; }; declare type UseRequestOptionsWithFormatResult = UseRequestOptions & { - formatResult: (res: SR) => TData; + formatResult: (res: SR) => TData; }; declare interface UseRequestPlugin { - (fetchInstance: Fetch, options: UseRequestOptions): UseRequestPluginReturn; - onInit?: (options: UseRequestOptions) => Partial>; + (fetchInstance: Fetch, options: UseRequestOptions): UseRequestPluginReturn; + onInit?: (options: UseRequestOptions) => Partial>; } declare interface UseRequestPluginReturn { - name?: string; - onBefore?: (params: TParams) => ({ - stopNow?: boolean; - returnNow?: boolean; - } & Partial>) | void; - onRequest?: (service: UseRequestService, params: TParams) => { - servicePromise?: Promise; - }; - onSuccess?: (data: TData, params: TParams) => void; - onError?: (e: Error, params: TParams) => void; - onFinally?: (params: TParams, data?: TData, e?: Error) => void; - onCancel?: () => void; - onMutate?: (data: TData) => void; + name?: string; + onBefore?: (params: TParams) => ({ + stopNow?: boolean; + returnNow?: boolean; + } & Partial>) | void; + onRequest?: (service: UseRequestService, params: TParams) => { + servicePromise?: Promise; + }; + onSuccess?: (data: TData, params: TParams) => void; + onError?: (e: Error, params: TParams) => void; + onFinally?: (params: TParams, data?: TData, e?: Error) => void; + onCancel?: () => void; + onMutate?: (data: TData) => void; } export declare function useRequestProvider(config: UseRequestOptions): void; declare interface useRequestResult { - /** - * Is the service being executed. - */ - loading: Readonly>; - /** - * Data returned by service. - */ - data: Readonly>; - /** - * Exception thrown by service. - */ - error: Readonly>; - /** - * params An array of parameters for the service being executed. For example, you triggered `run(1, 2, 3)`, then params is equal to `[1, 2, 3]`. - */ - params: Readonly>; - /** - * Ignore the current promise response. - */ - cancel: Fetch['cancel']; - /** - * Use the last params, call `run` again. - */ - refresh: Fetch['refresh']; - /** - * Use the last params, call `runAsync` again. - */ - refreshAsync: Fetch['refreshAsync']; - /** - * Manually trigger the execution of the service, and the parameters will be passed to the service. - */ - run: Fetch['run']; - /** - * Automatic handling of exceptions, feedback through `onError` - */ - runAsync: Fetch['runAsync']; - /** - * Mutate `data` directly - */ - mutate: Fetch['mutate']; + /** + * Is the service being executed. + */ + loading: Readonly>; + /** + * Data returned by service. + */ + data: Readonly>; + /** + * Exception thrown by service. + */ + error: Readonly>; + /** + * params An array of parameters for the service being executed. For example, you triggered `run(1, 2, 3)`, then params is equal to `[1, 2, 3]`. + */ + params: Readonly>; + /** + * Ignore the current promise response. + */ + cancel: Fetch['cancel']; + /** + * Use the last params, call `run` again. + */ + refresh: Fetch['refresh']; + /** + * Use the last params, call `runAsync` again. + */ + refreshAsync: Fetch['refreshAsync']; + /** + * Manually trigger the execution of the service, and the parameters will be passed to the service. + */ + run: Fetch['run']; + /** + * Automatic handling of exceptions, feedback through `onError` + */ + runAsync: Fetch['runAsync']; + /** + * Mutate `data` directly + */ + mutate: Fetch['mutate']; } declare type UseRequestService = (...args: TParams) => Promise; @@ -1079,18 +1079,18 @@ declare type UseRequestService = (...args: TPa export declare function useResizeObserver(target: BasicTarget | BasicTarget[], callback: ResizeObserverCallback_2, options?: UseResizeObserverOptions): UseResizeObserverReturnType; declare interface UseResizeObserverOptions { - /** - * The box the observer is observing changes to. - * The default is content-box. - * - * @default 'content-box' - */ - box?: ResizeObserverBoxOptions; + /** + * The box the observer is observing changes to. + * The default is content-box. + * + * @default 'content-box' + */ + box?: ResizeObserverBoxOptions; } declare interface UseResizeObserverReturnType { - isSupported: Ref; - stop: () => void; + isSupported: Ref; + stop: () => void; } export declare function useScroll(target?: UseScrollTarget, shouldUpdate?: UseScrollListenController): Readonly>; @@ -1104,16 +1104,16 @@ export declare const useSessionStorageState: (key: string | Ref, opti export declare function useSet(initialValue?: T[]): [Readonly>>, UseSetActions]; declare interface UseSetActions { - add: (value: T) => void; - remove: (value: T) => void; - has: (value: T) => boolean; - clear: () => void; - reset: () => void; + add: (value: T) => void; + remove: (value: T) => void; + has: (value: T) => boolean; + clear: () => void; + reset: () => void; } export declare function useSetState>(initialState: UseSetStateType): [ -DeepReadonly] ? S : Ref>>>, -(patch: Record, cover?: boolean) => void + DeepReadonly] ? S : Ref>>>, + (patch: Record, cover?: boolean) => void ]; declare type UseSetStateType = S | (() => S) | Ref | (() => Ref); @@ -1122,107 +1122,107 @@ declare type UseSetStateType = S | (() => S) | Ref | (() => Ref); * * @param {dom id节点或者 ref句柄} target */ - export declare function useSize(target: BasicTarget): Size; - - export declare function useThrottle(value: Ref, options?: UseThrottleOptions): Ref; - - export declare function useThrottleFn(fn: T, options?: UseThrottleOptions): { - run: ComputedRef) => ReturnType>>; - cancel: () => void; - flush: () => ReturnType | undefined; - }; - - declare interface UseThrottleOptions { - wait?: number; - leading?: boolean; - trailing?: boolean; - } - - export declare function useTimeout(fn: () => void, delay: Ref | number | undefined, options?: { - immediate?: boolean; - }): void; - - export declare function useTitle(title: Ref | string, options?: UseTitleOptions): void; - - declare interface UseTitleOptions { - restoreOnUnmount?: boolean; - } - - export declare function useToggle(): [Ref, UseToggleActions]; - - export declare function useToggle(defaultValue: T): [Ref, UseToggleActions]; - - export declare function useToggle(defaultValue: T, reverseValue: U): [Ref, UseToggleActions]; - - declare interface UseToggleActions { - setLeft: () => void; - setRight: () => void; - set: (value: T) => void; - toggle: () => void; - } - - declare type UseTrackedEffect = (changes?: number[], previousDeps?: Ref[], currentDeps?: Ref[]) => void | (() => void); - - export declare const useTrackedEffect: (effect: UseTrackedEffect, deps?: Ref[]) => void; - - export declare function useUpdate(): { - update: Readonly>; - setUpdate: () => void; - }; - - export declare function useUrlState>(initialState?: S | (() => S), options?: UseUrlStateOptions): Ref; - - declare interface UseUrlStateOptions { - localStorageKey?: string; - detectNumber?: boolean; - routerPush?: (url: string) => void; - } - - export declare const useVirtualList: (list: Ref, options: UseVirtualListOptions) => readonly [Ref<{ - index: number; - data: T; - }[]>, { - ref: (ele: any) => void; - onScroll: (e: any) => void; - }, (index: number) => void]; - - declare interface UseVirtualListOptions { - wrapperTarget: Ref>; - itemHeight: number | ((index: number, data: T) => number); - overscan?: number; - } - - declare type UseVirtualListTargetValue = T | undefined | null; - - /** - * @param socketUrl socketUrl地址 - * @param options 配置 - * @return readyState(Connecting = 0,Open = 1,Closing = 2,Closed = 3) - */ - export declare function useWebSocket(socketUrl: Ref | string, options?: UseWebSocketOptions): UseWebSocketResult; - - declare interface UseWebSocketOptions { - reconnectLimit?: number; - reconnectInterval?: number; - manual?: Ref | boolean; - onOpen?: (event: WebSocketEventMap['open'], instance: WebSocket) => void; - onClose?: (event: WebSocketEventMap['close'], instance: WebSocket) => void; - onMessage?: (message: WebSocketEventMap['message'], instance: WebSocket) => void; - onError?: (event: WebSocketEventMap['error'], instance: WebSocket) => void; - protocols?: string | string[]; - } - - declare interface UseWebSocketResult { - latestMessage: Readonly>; - sendMessage?: WebSocket['send']; - disconnect?: () => void; - connect?: () => void; - readyState: Readonly>; - webSocketIns?: WebSocket; - } - - export declare function useWhyDidYouUpdate(componentName: string, props: IProps): void; - - export declare function useWinResize(Action?: () => void): null; - - export { } +export declare function useSize(target: BasicTarget): Size; + +export declare function useThrottle(value: Ref, options?: UseThrottleOptions): Ref; + +export declare function useThrottleFn(fn: T, options?: UseThrottleOptions): { + run: ComputedRef) => ReturnType>>; + cancel: () => void; + flush: () => ReturnType | undefined; +}; + +declare interface UseThrottleOptions { + wait?: number; + leading?: boolean; + trailing?: boolean; +} + +export declare function useTimeout(fn: () => void, delay: Ref | number | undefined, options?: { + immediate?: boolean; +}): void; + +export declare function useTitle(title: Ref | string, options?: UseTitleOptions): void; + +declare interface UseTitleOptions { + restoreOnUnmount?: boolean; +} + +export declare function useToggle(): [Ref, UseToggleActions]; + +export declare function useToggle(defaultValue: T): [Ref, UseToggleActions]; + +export declare function useToggle(defaultValue: T, reverseValue: U): [Ref, UseToggleActions]; + +declare interface UseToggleActions { + setLeft: () => void; + setRight: () => void; + set: (value: T) => void; + toggle: () => void; +} + +declare type UseTrackedEffect = (changes?: number[], previousDeps?: Ref[], currentDeps?: Ref[]) => void | (() => void); + +export declare const useTrackedEffect: (effect: UseTrackedEffect, deps?: Ref[]) => void; + +export declare function useUpdate(): { + update: Readonly>; + setUpdate: () => void; +}; + +export declare function useUrlState>(initialState?: S | (() => S), options?: UseUrlStateOptions): Ref; + +declare interface UseUrlStateOptions { + localStorageKey?: string; + detectNumber?: boolean; + routerPush?: (url: string) => void; +} + +export declare const useVirtualList: (list: Ref, options: UseVirtualListOptions) => readonly [Ref<{ + index: number; + data: T; +}[]>, { + ref: (ele: any) => void; + onScroll: (e: any) => void; +}, (index: number) => void]; + +declare interface UseVirtualListOptions { + wrapperTarget: Ref>; + itemHeight: number | ((index: number, data: T) => number); + overscan?: number; +} + +declare type UseVirtualListTargetValue = T | undefined | null; + +/** + * @param socketUrl socketUrl地址 + * @param options 配置 + * @return readyState(Connecting = 0,Open = 1,Closing = 2,Closed = 3) + */ +export declare function useWebSocket(socketUrl: Ref | string, options?: UseWebSocketOptions): UseWebSocketResult; + +declare interface UseWebSocketOptions { + reconnectLimit?: number; + reconnectInterval?: number; + manual?: Ref | boolean; + onOpen?: (event: WebSocketEventMap['open'], instance: WebSocket) => void; + onClose?: (event: WebSocketEventMap['close'], instance: WebSocket) => void; + onMessage?: (message: WebSocketEventMap['message'], instance: WebSocket) => void; + onError?: (event: WebSocketEventMap['error'], instance: WebSocket) => void; + protocols?: string | string[]; +} + +declare interface UseWebSocketResult { + latestMessage: Readonly>; + sendMessage?: WebSocket['send']; + disconnect?: () => void; + connect?: () => void; + readyState: Readonly>; + webSocketIns?: WebSocket; +} + +export declare function useWhyDidYouUpdate(componentName: string, props: IProps): void; + +export declare function useWinResize(Action?: () => void): null; + +export { } diff --git a/packages/use-request/package.json b/packages/use-request/package.json index dd9f217d..4b15b4ae 100644 --- a/packages/use-request/package.json +++ b/packages/use-request/package.json @@ -19,7 +19,7 @@ "keywords": [], "dependencies": { "@vue/devtools-api": "^6.5.0", - "lodash": "^4.17.21" + "lodash-es": "^4.17.21" }, "repository": "https://github.com/InhiblabCore/vue-hooks-plus", "homepage": "https://github.com/InhiblabCore/vue-hooks-plus", diff --git a/packages/use-request/src/plugins/useDebouncePlugin.ts b/packages/use-request/src/plugins/useDebouncePlugin.ts index 7d3aae76..173925ef 100644 --- a/packages/use-request/src/plugins/useDebouncePlugin.ts +++ b/packages/use-request/src/plugins/useDebouncePlugin.ts @@ -1,6 +1,6 @@ import { ref, computed, watchEffect, unref } from "vue"; -import type { DebouncedFunc, DebounceSettings } from "lodash"; -import debounce from "lodash/debounce"; +import type { DebouncedFunc, DebounceSettings } from "lodash-es"; +import { debounce } from "lodash-es"; import type { UseRequestPlugin } from "../types"; const useDebouncePlugin: UseRequestPlugin = ( diff --git a/packages/use-request/src/plugins/useThrottlePlugin.ts b/packages/use-request/src/plugins/useThrottlePlugin.ts index 2ced2afd..01149a24 100644 --- a/packages/use-request/src/plugins/useThrottlePlugin.ts +++ b/packages/use-request/src/plugins/useThrottlePlugin.ts @@ -1,6 +1,6 @@ import { computed, unref, watchEffect } from 'vue' -import { DebouncedFunc, ThrottleSettings } from 'lodash' -import throttle from 'lodash/throttle' +import { DebouncedFunc, ThrottleSettings } from 'lodash-es' +import { throttle } from 'lodash-es' import { UseRequestPlugin } from '../types' const useThrottlePlugin: UseRequestPlugin = ( diff --git a/packages/use-worker/package.json b/packages/use-worker/package.json index 19067a98..f7d04265 100644 --- a/packages/use-worker/package.json +++ b/packages/use-worker/package.json @@ -24,6 +24,6 @@ "author": "NelsonYong", "license": "MIT", "dependencies": { - "lodash": "^4.17.21" + "lodash-es": "^4.17.21" } } diff --git a/packages/use-worker/src/hook/useDeepCompareWithTarget.ts b/packages/use-worker/src/hook/useDeepCompareWithTarget.ts index f5fbadbb..56bc8b0f 100644 --- a/packages/use-worker/src/hook/useDeepCompareWithTarget.ts +++ b/packages/use-worker/src/hook/useDeepCompareWithTarget.ts @@ -1,5 +1,5 @@ import { computed, ref, WatchSource } from 'vue' -import isEqual from 'lodash/isEqual' +import { isEqual } from 'lodash-es' export type EffectCallback = () => void export type DependencyList = WatchSource | any[] | any diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c30acbd3..07595e26 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,7 +8,7 @@ importers: '@commitlint/config-conventional': ^17.1.0 '@types/fs-extra': ^9.0.13 '@types/jest': ^29.0.0 - '@types/lodash': ^4.14.178 + '@types/lodash-es': ^4.17.12 '@types/marked': ^4.0.3 '@types/md5': ^2.3.2 '@types/node': ^17.0.21 @@ -65,7 +65,7 @@ importers: '@commitlint/config-conventional': 17.7.0 '@types/fs-extra': 9.0.13 '@types/jest': 29.5.3 - '@types/lodash': 4.14.197 + '@types/lodash-es': 4.17.12 '@types/marked': 4.3.1 '@types/md5': 2.3.2 '@types/node': 17.0.45 @@ -141,7 +141,7 @@ importers: '@types/js-cookie': ^3.0.1 '@vue/devtools-api': ^6.5.0 js-cookie: ^3.0.1 - lodash: ^4.17.21 + lodash-es: ^4.17.21 qs: ^6.11.0 query-string: ^7.1.1 screenfull: ^5.0.0 @@ -149,7 +149,7 @@ importers: '@types/js-cookie': 3.0.3 '@vue/devtools-api': 6.5.0 js-cookie: 3.0.5 - lodash: 4.17.21 + lodash-es: 4.17.21 qs: 6.11.2 query-string: 7.1.3 screenfull: 5.2.0 @@ -186,10 +186,10 @@ importers: packages/use-request: specifiers: '@vue/devtools-api': ^6.5.0 - lodash: ^4.17.21 + lodash-es: ^4.17.21 dependencies: '@vue/devtools-api': 6.5.0 - lodash: 4.17.21 + lodash-es: 4.17.21 packages/use-request-plugins: specifiers: @@ -199,9 +199,9 @@ importers: packages/use-worker: specifiers: - lodash: ^4.17.21 + lodash-es: ^4.17.21 dependencies: - lodash: 4.17.21 + lodash-es: 4.17.21 packages/vitepress/vitepress-demo-block: specifiers: @@ -1485,6 +1485,12 @@ packages: resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==} dev: true + /@types/lodash-es/4.17.12: + resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} + dependencies: + '@types/lodash': 4.14.197 + dev: true + /@types/lodash/4.14.197: resolution: {integrity: sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g==} dev: true @@ -4446,6 +4452,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash-es/4.17.21: + resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} + dev: false + /lodash.camelcase/4.3.0: resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} dev: true @@ -4500,6 +4510,7 @@ packages: /lodash/4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + dev: true /log-update/4.0.0: resolution: {integrity: sha512-9fkkDevMefjg0mmzWFBW8YkFP91OrizzkW3diF7CpG+S2EYdy4+TVfGwz1zeF8x7hCx1ovSPTOE9Ngib74qqUg==}