@stacksjs/browser 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{utils/base.d.ts → base.d.ts} +2 -2
- package/dist/debounce.d.ts +1 -0
- package/dist/function.d.ts +2 -0
- package/dist/guards.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/math.d.ts +3 -0
- package/dist/promise.d.ts +10 -0
- package/dist/regex.d.ts +3 -0
- package/dist/{utils/retry.d.ts → retry.d.ts} +1 -1
- package/dist/sleep.d.ts +15 -0
- package/dist/throttle.d.ts +1 -0
- package/dist/vendors.d.ts +4 -0
- package/package.json +1 -1
- package/dist/utils/debounce.d.ts +0 -1
- package/dist/utils/function.d.ts +0 -18
- package/dist/utils/guards.d.ts +0 -28
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/math.d.ts +0 -3
- package/dist/utils/promise.d.ts +0 -58
- package/dist/utils/regex.d.ts +0 -3
- package/dist/utils/sleep.d.ts +0 -31
- package/dist/utils/throttle.d.ts +0 -20
- package/dist/utils/vendors.d.ts +0 -4
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare interface SingletonPromiseReturn<T> {
|
|
2
|
+
(): Promise<T>
|
|
3
|
+
reset: () => Promise<void>
|
|
4
|
+
}
|
|
5
|
+
export declare interface ControlledPromise<T = void> extends Promise<T> {
|
|
6
|
+
resolve: (value: T | PromiseLike<T>) => void
|
|
7
|
+
reject: (reason?: any) => void
|
|
8
|
+
}
|
|
9
|
+
export declare function createPromiseLock(): void;
|
|
10
|
+
export declare function createControlledPromise<T>(): ControlledPromise<T>;
|
package/dist/regex.d.ts
ADDED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function retry(fn: Function, options: any): Promise<any>;
|
|
2
|
-
export declare function calculateDelay(attemptCount: number, initialDelay: number, backoffFactor: number, jitter?: boolean): number;
|
|
2
|
+
export declare function calculateDelay(attemptCount: number, initialDelay: number, backoffFactor: number, jitter?: boolean,): number;
|
package/dist/sleep.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare type NonNegativeInteger<T extends number> = number extends T
|
|
2
|
+
? never
|
|
3
|
+
: `${T}` extends `-${string}` | `${string}.${string}`
|
|
4
|
+
? never
|
|
5
|
+
: T
|
|
6
|
+
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
+
export declare function wait(ms: number): Promise<void>;
|
|
8
|
+
export declare function delay(ms: number): Promise<void>;
|
|
9
|
+
export declare type WaitOptions = number | {
|
|
10
|
+
interval?: number
|
|
11
|
+
timeout?: number
|
|
12
|
+
}
|
|
13
|
+
export declare function waitUntil(condition: () => boolean, options: WaitOptions = {}): Promise<void> { return new Promise((resolve) => { const { interval, timeout } = normalizeOptions(options) if (condition()) { resolve() return } const check = () => { if (condition()) { resolve() } else { setTimeout(check, interval) } } if (timeout) { setTimeout(resolve, timeout) } check() }}) };
|
|
14
|
+
declare function normalizeOptions(options: WaitOptions);
|
|
15
|
+
export declare function waitWhile(condition: () => boolean, options: WaitOptions = {}): Promise<void> { return new Promise((resolve) => { const { interval = 100, timeout = 0 } = options if (!condition()) { resolve() return } const check = () => { if (!condition()) { resolve() } else { setTimeout(check, interval) } } if (timeout) { setTimeout(resolve, timeout) } check() }}) };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function throttle(fn: Function, wait = 300): void;
|
package/package.json
CHANGED
package/dist/utils/debounce.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { debounce } from "perfect-debounce";
|
package/dist/utils/function.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Fn, Nullable } from "@stacksjs/types";
|
|
2
|
-
/**
|
|
3
|
-
* Call every function in an array
|
|
4
|
-
*/
|
|
5
|
-
export declare function batchInvoke(functions: Nullable<Fn>[]): void;
|
|
6
|
-
/**
|
|
7
|
-
* Pass the value through the callback, and return the value
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```
|
|
11
|
-
* function createUser(name: string): User {
|
|
12
|
-
* return tap(new User, user => {
|
|
13
|
-
* user.name = name
|
|
14
|
-
* })
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare function tap<T>(value: T, callback: (value: T) => void): T;
|
package/dist/utils/guards.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type guard to filter out null-ish values
|
|
3
|
-
*
|
|
4
|
-
* @category Guards
|
|
5
|
-
* @example array.filter(notNullish)
|
|
6
|
-
*/
|
|
7
|
-
export declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>;
|
|
8
|
-
/**
|
|
9
|
-
* Type guard to filter out null values
|
|
10
|
-
*
|
|
11
|
-
* @category Guards
|
|
12
|
-
* @example array.filter(noNull)
|
|
13
|
-
*/
|
|
14
|
-
export declare function noNull<T>(v: T | null): v is Exclude<T, null>;
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to filter out null-ish values
|
|
17
|
-
*
|
|
18
|
-
* @category Guards
|
|
19
|
-
* @example array.filter(notUndefined)
|
|
20
|
-
*/
|
|
21
|
-
export declare function notUndefined<T>(v: T): v is Exclude<T, undefined>;
|
|
22
|
-
/**
|
|
23
|
-
* Type guard to filter out falsy values
|
|
24
|
-
*
|
|
25
|
-
* @category Guards
|
|
26
|
-
* @example array.filter(isTruthy)
|
|
27
|
-
*/
|
|
28
|
-
export declare function isTruthy<T>(v: T): v is NonNullable<T>;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./base";
|
|
2
|
-
export * from "./debounce";
|
|
3
|
-
export * from "./function";
|
|
4
|
-
export * from "./guards";
|
|
5
|
-
export * from "./math";
|
|
6
|
-
export * from "./promise";
|
|
7
|
-
export * from "./regex";
|
|
8
|
-
export * from "./retry";
|
|
9
|
-
export * from "./sleep";
|
|
10
|
-
export * from "./throttle";
|
|
11
|
-
export * from "./vendors";
|
package/dist/utils/math.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const clamp: (n: number, min: number, max: number) => number;
|
|
2
|
-
export declare function rand(min: number, max: number): number;
|
|
3
|
-
export { and, createGenericProjection, createProjection, logicNot, logicOr, or, useAbs, useAverage, useCeil, useClamp, useFloor, useMath, useMax, useMin, usePrecision, useProjection, useRound, useSum, useTrunc } from "@vueuse/math";
|
package/dist/utils/promise.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export interface SingletonPromiseReturn<T> {
|
|
2
|
-
(): Promise<T>;
|
|
3
|
-
/**
|
|
4
|
-
* Reset current staled promise.
|
|
5
|
-
* Await it to have proper shutdown.
|
|
6
|
-
*/
|
|
7
|
-
reset: () => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Promise with `resolve` and `reject` methods of itself
|
|
11
|
-
*/
|
|
12
|
-
export interface ControlledPromise<T = void> extends Promise<T> {
|
|
13
|
-
resolve: (value: T | PromiseLike<T>) => void;
|
|
14
|
-
reject: (reason?: any) => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Create singleton promise function.
|
|
18
|
-
*
|
|
19
|
-
* @category Promise
|
|
20
|
-
*/
|
|
21
|
-
export declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
|
|
22
|
-
/**
|
|
23
|
-
* Create a promise lock.
|
|
24
|
-
*
|
|
25
|
-
* @category Promise
|
|
26
|
-
* @example
|
|
27
|
-
* ```
|
|
28
|
-
* const lock = createPromiseLock()
|
|
29
|
-
*
|
|
30
|
-
* lock.run(async () => {
|
|
31
|
-
* await doSomething()
|
|
32
|
-
* })
|
|
33
|
-
*
|
|
34
|
-
* // in anther context:
|
|
35
|
-
* await lock.wait() // it will wait all tasking finished
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function createPromiseLock(): {
|
|
39
|
-
run<T = void>(fn: () => Promise<T>): Promise<T>;
|
|
40
|
-
wait(): Promise<void>;
|
|
41
|
-
isWaiting(): boolean;
|
|
42
|
-
clear(): void;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Return a Promise with `resolve` and `reject` methods
|
|
46
|
-
*
|
|
47
|
-
* @category Promise
|
|
48
|
-
* @example
|
|
49
|
-
* ```
|
|
50
|
-
* const promise = createControlledPromise()
|
|
51
|
-
*
|
|
52
|
-
* await promise
|
|
53
|
-
*
|
|
54
|
-
* // in anther context:
|
|
55
|
-
* promise.resolve(data)
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare function createControlledPromise<T>(): ControlledPromise<T>;
|
package/dist/utils/regex.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export type { Flag, Input, MagicRegExp, MagicRegExpMatchArray, MapToStringCapturedBy, StringCapturedBy } from "magic-regexp";
|
|
2
|
-
export { anyOf, carriageReturn, caseInsensitive, char, charIn, charNotIn, digit, dotAll, exactly, global, letter, linefeed, maybe, multiline, not, oneOrMore, sticky, tab, unicode, whitespace, withIndices, word, wordBoundary, wordChar } from "magic-regexp";
|
|
3
|
-
export declare function createRegExp(pattern: string, options?: { flags?: string }): RegExp;
|
package/dist/utils/sleep.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type NonNegativeInteger<T extends number> = number extends T ? never : `${T}` extends `-${string}` | `${string}.${string}` ? never : T;
|
|
2
|
-
/**
|
|
3
|
-
* Pauses execution for a specified number of milliseconds.
|
|
4
|
-
* @param ms The number of milliseconds to pause execution.
|
|
5
|
-
* @returns A promise that resolves after the specified delay.
|
|
6
|
-
*/
|
|
7
|
-
export declare function sleep(ms: number): Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* Pauses execution for a specified number of milliseconds.
|
|
10
|
-
* @param ms The number of milliseconds to pause execution.
|
|
11
|
-
* @returns A promise that resolves after the specified delay.
|
|
12
|
-
*/
|
|
13
|
-
export declare function wait(ms: number): Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Pauses execution for a specified number of milliseconds.
|
|
16
|
-
* @param ms The number of milliseconds to pause execution.
|
|
17
|
-
* @returns A promise that resolves after the specified delay.
|
|
18
|
-
*/
|
|
19
|
-
export declare function delay(ms: number): Promise<void>;
|
|
20
|
-
export type WaitOptions = number | {
|
|
21
|
-
interval?: number;
|
|
22
|
-
timeout?: number;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Pauses execution until a specified condition is met.
|
|
26
|
-
*/
|
|
27
|
-
export declare function waitUntil(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Pauses execution while a specified condition is met.
|
|
30
|
-
*/
|
|
31
|
-
export declare function waitWhile(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
package/dist/utils/throttle.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttle a function.
|
|
3
|
-
*
|
|
4
|
-
* @param {Function} fn - The function to throttle.
|
|
5
|
-
* @param {number} [wait] - The time to wait between function calls.
|
|
6
|
-
* @returns {Function} - A new function that throttles the calls to the original function.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* // logs window dimensions at most every 250ms
|
|
11
|
-
* window.addEventListener(
|
|
12
|
-
* "resize",
|
|
13
|
-
* throttle(function (evt) {
|
|
14
|
-
* console.log(window.innerWidth)
|
|
15
|
-
* console.log(window.innerHeight)
|
|
16
|
-
* }, 250)
|
|
17
|
-
* )
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function throttle(fn: Function, wait?: number): (this: unknown, ...args: any[]) => void;
|
package/dist/utils/vendors.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { asyncComputed, autoResetRef, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, cloneFnJSON, computedAsync, computedEager, computedInject, computedWithControl, controlledComputed, controlledRef, createEventHook, createFetch, createGlobalState, createInjectionState, createReactiveFn, createReusableTemplate, createSharedComposable, createTemplatePromise, createUnrefFn, customStorageEventName, debouncedRef, debouncedWatch, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, eagerComputed, executeTransition, extendRef, formatTimeAgo, getSSRHandler, ignorableWatch, injectLocal, isDefined, makeDestructurable, mapGamepadToXbox360Controller, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableWatch, provideLocal, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, setSSRHandler, syncRef, syncRefs, templateRef, throttledRef, throttledWatch, toReactive, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useAnimate, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayIncludes, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCounter, useCssVar, useCurrentElement, useCycleList, useDark, useDateFormat, useDebounce, useDebouncedRefHistory, useDebounceFn, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useInterval, useIntervalFn, useKeyModifier, useLastChanged, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextareaAutosize, useTextDirection, useTextSelection, useThrottle, useThrottledRefHistory, useThrottleFn, useTimeAgo, useTimeout, useTimeoutFn, useTimeoutPoll, useTimestamp, useTitle, useToggle, useToNumber, useToString, useTransition, useUrlSearchParams, useUserMedia, useVibrate, useVirtualList, useVModel, useVModels, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever } from "@vueuse/core";
|
|
2
|
-
export type { HeadObject, HeadObjectPlain } from "@vueuse/head";
|
|
3
|
-
export { createHead, Head, HeadVuePlugin, renderHeadToString } from "@vueuse/head";
|
|
4
|
-
export { default as readableSize } from "pretty-bytes";
|