@destyler/shared
Advanced tools
Comparing version 0.0.1-beta.12 to 0.0.1-beta.13
@@ -1,2 +0,2 @@ | ||
import { ExtractPropTypes, Ref, ComponentPublicInstance, VNode, WatchOptionsBase, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, ToRef } from 'vue'; | ||
import { ExtractPropTypes, Ref, WatchSource, ComponentPublicInstance, VNode, WatchOptionsBase, ComputedRef, WritableComputedRef, ComputedGetter, WritableComputedOptions, ToRef, WatchCallback, WatchOptions, WatchStopHandle } from 'vue'; | ||
@@ -20,2 +20,3 @@ declare const isNumber: (v: any) => v is number; | ||
type Orientation = 'horizontal' | 'vertical'; | ||
type ScrollType = 'auto' | 'always' | 'scroll' | 'hover'; | ||
interface Measurable { | ||
@@ -114,2 +115,29 @@ getBoundingClientRect(): DOMRect; | ||
} | ||
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never; | ||
type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
then(onfulfilled: infer F, ...args: infer _): any; | ||
} ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
type Promisify<T> = Promise<Awaited<T>>; | ||
type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>; | ||
interface Pausable { | ||
/** | ||
* A ref indicate whether a pausable instance is active | ||
*/ | ||
isActive: Readonly<Ref<boolean>>; | ||
/** | ||
* Temporary pause the effect from executing | ||
*/ | ||
pause: Fn; | ||
/** | ||
* Resume the effects | ||
*/ | ||
resume: Fn; | ||
} | ||
type MultiWatchSources = (WatchSource<unknown> | object)[]; | ||
type MapSources<T> = { | ||
[K in keyof T]: T[K] extends WatchSource<infer V> ? V : never; | ||
}; | ||
type MapOldSources<T, Immediate> = { | ||
[K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never; | ||
}; | ||
@@ -191,2 +219,59 @@ /** | ||
export { type AnyFn, type ArrowKeyOptions, type CheckedState, type ComputedRefWithControl, type ComputedWithControlRefExtra, type DataOrientation, type Direction, type ExtractInternalPropTypes, type ExtractPublicPropTypes, FIRST_KEYS, FIRST_LAST_KEYS, type Fn, type GraceIntent, ITEM_NAME, ITEM_SELECT, LAST_KEYS, type MaybeComputedElementRef, type MaybeElement, type MaybeElementRef, type MaybeRef, type MaybeRefOrGetter, type Measurable, type Orientation, type Point, type Polygon, SELECTION_KEYS, SUB_CLOSE_KEYS, SUB_OPEN_KEYS, type Side, type Stoppable, type Type, type UnRefElementReturn, type VueInstance, type WritableComputedRefWithControl, clamp, computedEager, computedWithControl, computedWithControl as controlledComputed, createContext, createGlobalState, computedEager as eagerComputed, focusFirst, getCheckedState, getOpenState, getScrollParent, handleAndDispatchCustomEvent, isClient, isDef, isDocument, isIndeterminate, isMouseEvent, isNumber, isPointInPolygon, isPointerInGraceArea, isValidVNodeElement, noop, refAutoReset, renderSlotFragments, resolveRef, resolveUnref, toRef, toValue, tryOnScopeDispose, unrefElement, unwrapElement, wrapArray }; | ||
type FunctionArgs<Args extends any[] = any[], Return = void> = (...args: Args) => Return; | ||
interface FunctionWrapperOptions<Args extends any[] = any[], This = any> { | ||
fn: FunctionArgs<Args, This>; | ||
args: Args; | ||
thisArg: This; | ||
} | ||
type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>; | ||
interface ConfigurableEventFilter { | ||
/** | ||
* Filter for if events should to be received. | ||
*/ | ||
eventFilter?: EventFilter; | ||
} | ||
interface DebounceFilterOptions { | ||
/** | ||
* The maximum time allowed to be delayed before it's invoked. | ||
* In milliseconds. | ||
*/ | ||
maxWait?: MaybeRefOrGetter<number>; | ||
/** | ||
* Whether to reject the last call if it's been cancel. | ||
* | ||
* @default false | ||
*/ | ||
rejectOnCancel?: boolean; | ||
} | ||
/** | ||
* @internal | ||
*/ | ||
declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>; | ||
declare const bypassFilter: EventFilter; | ||
/** | ||
* Create an EventFilter that debounce the events | ||
*/ | ||
declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>; | ||
/** | ||
* Create an EventFilter that throttle the events | ||
* | ||
* @param ms | ||
* @param [trailing] | ||
* @param [leading] | ||
* @param [rejectOnCancel] | ||
*/ | ||
declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>; | ||
/** | ||
* EventFilter that gives extra controls to pause and resume the filter | ||
* | ||
* @param extendFilter Extra filter to apply when the PausableFilter is active, default to none | ||
* | ||
*/ | ||
declare function pausableFilter(extendFilter?: EventFilter): Pausable & { | ||
eventFilter: EventFilter; | ||
}; | ||
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; | ||
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; | ||
export { type AnyFn, type ArgumentsType, type ArrowKeyOptions, type Awaited, type CheckedState, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type DataOrientation, type DebounceFilterOptions, type Direction, type EventFilter, type ExtractInternalPropTypes, type ExtractPublicPropTypes, FIRST_KEYS, FIRST_LAST_KEYS, type Fn, type FunctionArgs, type FunctionWrapperOptions, type GraceIntent, ITEM_NAME, ITEM_SELECT, LAST_KEYS, type MapOldSources, type MapSources, type MaybeComputedElementRef, type MaybeElement, type MaybeElementRef, type MaybeRef, type MaybeRefOrGetter, type Measurable, type MultiWatchSources, type Orientation, type Pausable, type Point, type Polygon, type Promisify, type PromisifyFn, SELECTION_KEYS, SUB_CLOSE_KEYS, SUB_OPEN_KEYS, type ScrollType, type Side, type Stoppable, type Type, type UnRefElementReturn, type VueInstance, type WritableComputedRefWithControl, bypassFilter, clamp, computedEager, computedWithControl, computedWithControl as controlledComputed, createContext, createFilterWrapper, createGlobalState, debounceFilter, computedEager as eagerComputed, focusFirst, getCheckedState, getOpenState, getScrollParent, handleAndDispatchCustomEvent, isClient, isDef, isDocument, isIndeterminate, isMouseEvent, isNumber, isPointInPolygon, isPointerInGraceArea, isValidVNodeElement, noop, pausableFilter, refAutoReset, renderSlotFragments, resolveRef, resolveUnref, throttleFilter, toRef, toValue, tryOnScopeDispose, unrefElement, unwrapElement, watchOnce, wrapArray }; |
{ | ||
"name": "@destyler/shared", | ||
"version": "0.0.1-beta.12", | ||
"version": "0.0.1-beta.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Elone Hoo <elonehoo@gmail.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
59695
1028