@varlet/shared 3.14.2 → 3.15.0-alpha.1776606769606
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/lib/index.cjs +1713 -38
- package/lib/index.d.cts +478 -4
- package/lib/index.d.ts +4 -3
- package/lib/index.js +10 -16
- package/package.json +7 -7
package/lib/index.d.cts
CHANGED
|
@@ -1,8 +1,482 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region ../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/types.d.ts
|
|
2
|
+
type Version1Options = {
|
|
3
|
+
node?: Uint8Array;
|
|
4
|
+
clockseq?: number;
|
|
5
|
+
random?: Uint8Array;
|
|
6
|
+
rng?: () => Uint8Array;
|
|
7
|
+
msecs?: number;
|
|
8
|
+
nsecs?: number;
|
|
9
|
+
_v6?: boolean;
|
|
10
|
+
};
|
|
11
|
+
type Version4Options = {
|
|
12
|
+
random?: Uint8Array;
|
|
13
|
+
rng?: () => Uint8Array;
|
|
14
|
+
};
|
|
15
|
+
type Version6Options = Version1Options;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region ../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.d.ts
|
|
18
|
+
declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
|
|
19
|
+
declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v6.d.ts
|
|
22
|
+
declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
|
|
23
|
+
declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/index.d.ts
|
|
26
|
+
declare type EventType = string | symbol;
|
|
27
|
+
declare type Handler<T = unknown> = (event: T) => void;
|
|
28
|
+
declare type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void;
|
|
29
|
+
declare type EventHandlerList<T = unknown> = Array<Handler<T>>;
|
|
30
|
+
declare type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
|
|
31
|
+
declare type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
|
|
32
|
+
interface Emitter<Events extends Record<EventType, unknown>> {
|
|
33
|
+
all: EventHandlerMap<Events>;
|
|
34
|
+
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
|
|
35
|
+
on(type: '*', handler: WildcardHandler<Events>): void;
|
|
36
|
+
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
|
|
37
|
+
off(type: '*', handler: WildcardHandler<Events>): void;
|
|
38
|
+
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
|
|
39
|
+
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Mitt: Tiny (~200b) functional event emitter / pubsub.
|
|
43
|
+
* @name mitt
|
|
44
|
+
* @returns {Mitt}
|
|
45
|
+
*/
|
|
46
|
+
declare function mitt<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): Emitter<Events>;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../../node_modules/.pnpm/rattail@2.0.5_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._oaa5dabgz63tacyacthirbl23y/node_modules/rattail/dist/index.d.mts
|
|
49
|
+
//#region src/array/at.d.ts
|
|
50
|
+
declare function at<T>(arr: T[], index: number): T | undefined; //#endregion
|
|
51
|
+
//#region src/array/chunk.d.ts
|
|
52
|
+
declare function chunk<T>(arr: T[], size?: number): T[][]; //#endregion
|
|
53
|
+
//#region src/array/removeItem.d.ts
|
|
54
|
+
declare function removeItem<T>(arr: T[], item: T): T[] | undefined; //#endregion
|
|
55
|
+
//#region src/array/removeItemBy.d.ts
|
|
56
|
+
declare function removeItemBy<T>(arr: T[], fn: (v: T) => any): T[] | undefined; //#endregion
|
|
57
|
+
//#region src/array/removeItemsBy.d.ts
|
|
58
|
+
declare function removeItemsBy<T>(arr: T[], fn: (v: T) => any): T[]; //#endregion
|
|
59
|
+
//#region src/array/toggleItem.d.ts
|
|
60
|
+
declare function toggleItem<T>(arr: T[], item: T): T[]; //#endregion
|
|
61
|
+
//#region src/array/uniq.d.ts
|
|
62
|
+
declare function uniq<T>(arr: T[]): T[]; //#endregion
|
|
63
|
+
//#region src/array/uniqBy.d.ts
|
|
64
|
+
declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) => any): T[]; //#endregion
|
|
65
|
+
//#region src/array/find.d.ts
|
|
66
|
+
declare function find<T>(arr: T[], fn: (item: T, index: number, array: T[]) => any, from?: 'start' | 'end'): [T, number] | [null, -1]; //#endregion
|
|
67
|
+
//#region src/array/shuffle.d.ts
|
|
68
|
+
declare function shuffle<T>(arr: T[]): T[]; //#endregion
|
|
69
|
+
//#region src/array/removeArrayBlank.d.ts
|
|
70
|
+
declare function removeArrayBlank<T>(arr: (T | null | undefined)[]): T[]; //#endregion
|
|
71
|
+
//#region src/array/removeArrayEmpty.d.ts
|
|
72
|
+
declare function removeArrayEmpty<T>(arr: (T | null | undefined | '')[]): T[]; //#endregion
|
|
73
|
+
//#region src/array/normalizeToArray.d.ts
|
|
74
|
+
declare function normalizeToArray<T>(value: T | T[]): T[]; //#endregion
|
|
75
|
+
//#region src/array/difference.d.ts
|
|
76
|
+
declare function difference<T>(arr: T[], ...values: T[][]): T[]; //#endregion
|
|
77
|
+
//#region src/array/differenceWith.d.ts
|
|
78
|
+
type Fn$4<T> = (a: T, b: T) => any;
|
|
79
|
+
declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$4<T>]): T[]; //#endregion
|
|
80
|
+
//#region src/array/intersection.d.ts
|
|
81
|
+
declare function intersection<T>(...values: T[][]): T[]; //#endregion
|
|
82
|
+
//#region src/array/intersectionWith.d.ts
|
|
83
|
+
type Fn$3<T> = (a: T, b: T) => any;
|
|
84
|
+
declare function intersectionWith<T>(...values: [...T[][], fn: Fn$3<T>]): T[]; //#endregion
|
|
85
|
+
//#region src/array/groupBy.d.ts
|
|
86
|
+
type Fn$2<T, K> = (val: T) => K;
|
|
87
|
+
declare function groupBy<T, K extends PropertyKey>(arr: T[], fn: Fn$2<T, K>): Record<K, T[]>; //#endregion
|
|
88
|
+
//#region src/array/xor.d.ts
|
|
89
|
+
declare function xor<T>(...values: T[][]): T[]; //#endregion
|
|
90
|
+
//#region src/array/xorWith.d.ts
|
|
91
|
+
type Fn$1<T> = (a: T, b: T) => any;
|
|
92
|
+
declare function xorWith<T>(...values: [...T[][], fn: Fn$1<T>]): T[]; //#endregion
|
|
93
|
+
//#region src/object/pick.d.ts
|
|
94
|
+
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>; //#endregion
|
|
95
|
+
//#region src/object/pickBy.d.ts
|
|
96
|
+
declare function pickBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>; //#endregion
|
|
97
|
+
//#region src/object/omit.d.ts
|
|
98
|
+
declare function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>; //#endregion
|
|
99
|
+
//#region src/object/omitBy.d.ts
|
|
100
|
+
declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>; //#endregion
|
|
101
|
+
//#region src/object/mapObject.d.ts
|
|
102
|
+
declare function mapObject<K extends PropertyKey, V, NK extends PropertyKey = K, NV = V>(object: Record<K, V>, fn: (key: K, value: V) => [PropertyKey, NV] | undefined): Record<NK, NV>; //#endregion
|
|
103
|
+
//#region src/object/promiseWithResolvers.d.ts
|
|
104
|
+
type PromiseWithResolvers<T> = {
|
|
105
|
+
promise: Promise<T>;
|
|
106
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
107
|
+
reject: (reason?: any) => void;
|
|
108
|
+
};
|
|
109
|
+
declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>; //#endregion
|
|
110
|
+
//#region src/object/set.d.ts
|
|
111
|
+
declare function set<T extends object | any[]>(object: T, path: (string | number)[], value: any): void; //#endregion
|
|
112
|
+
//#region src/object/objectKeys.d.ts
|
|
113
|
+
declare function objectKeys<T extends object>(object: T): `${keyof T & string}`[]; //#endregion
|
|
114
|
+
//#region src/object/objectEntries.d.ts
|
|
115
|
+
declare function objectEntries<T extends object>(object: T): [keyof T & string, T[keyof T & string]][];
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/util/cancelAnimationFrame.d.ts
|
|
118
|
+
declare function cancelAnimationFrame(handle: number): void; //#endregion
|
|
119
|
+
//#region src/util/classes.d.ts
|
|
120
|
+
type ClassName = string | undefined | null;
|
|
121
|
+
type Classes = (ClassName | [any, ClassName, ClassName?])[];
|
|
122
|
+
declare function classes(...classes: Classes): any[]; //#endregion
|
|
123
|
+
//#region src/util/copyText.d.ts
|
|
124
|
+
declare function copyText(value: string): void; //#endregion
|
|
125
|
+
//#region src/util/createNamespaceFn.d.ts
|
|
126
|
+
type BEM<S extends string | undefined, N extends string, NC extends string> = S extends undefined ? NC : S extends `$--${infer CM}` ? `${N}--${CM}` : S extends `--${infer M}` ? `${NC}--${M}` : `${NC}__${S}`;
|
|
127
|
+
declare function createNamespaceFn<N extends string>(namespace: N): <C extends string>(name: C) => {
|
|
128
|
+
name: string;
|
|
129
|
+
n: <S extends string | undefined = undefined>(suffix?: S | undefined) => BEM<S, N, `${N}-${C}`>;
|
|
130
|
+
classes: typeof classes;
|
|
131
|
+
}; //#endregion
|
|
132
|
+
//#region src/util/doubleRaf.d.ts
|
|
133
|
+
declare function doubleRaf(): Promise<unknown>; //#endregion
|
|
134
|
+
//#region src/util/getAllParentScroller.d.ts
|
|
135
|
+
declare function getAllParentScroller(el: HTMLElement): (HTMLElement | Window)[]; //#endregion
|
|
136
|
+
//#region src/util/getParentScroller.d.ts
|
|
137
|
+
declare function getParentScroller(el: HTMLElement): HTMLElement | Window; //#endregion
|
|
138
|
+
//#region src/util/getRect.d.ts
|
|
139
|
+
declare function getRect(element: Element | Window): DOMRect; //#endregion
|
|
140
|
+
//#region src/util/getScrollLeft.d.ts
|
|
141
|
+
declare function getScrollLeft(element: Element | Window): number; //#endregion
|
|
142
|
+
//#region src/util/getScrollTop.d.ts
|
|
143
|
+
declare function getScrollTop(element: Element | Window): number; //#endregion
|
|
144
|
+
//#region src/util/getStyle.d.ts
|
|
145
|
+
declare function getStyle(element: Element): CSSStyleDeclaration; //#endregion
|
|
146
|
+
//#region src/util/inViewport.d.ts
|
|
147
|
+
declare function inViewport(element: HTMLElement): boolean; //#endregion
|
|
148
|
+
//#region src/util/prettyJSONObject.d.ts
|
|
149
|
+
declare function prettyJSONObject(jsonObject: Record<string, any>): string; //#endregion
|
|
150
|
+
//#region src/util/preventDefault.d.ts
|
|
151
|
+
declare function preventDefault(event: Event): void; //#endregion
|
|
152
|
+
//#region src/util/raf.d.ts
|
|
153
|
+
declare function raf(): Promise<unknown>; //#endregion
|
|
154
|
+
//#region src/util/requestAnimationFrame.d.ts
|
|
155
|
+
declare function requestAnimationFrame(fn: FrameRequestCallback): number; //#endregion
|
|
156
|
+
//#region src/util/storage.d.ts
|
|
157
|
+
interface Storage extends globalThis.Storage {
|
|
158
|
+
set(key: string, value: any): void;
|
|
159
|
+
get(key: string): any;
|
|
160
|
+
remove(key: string): void;
|
|
161
|
+
}
|
|
162
|
+
interface CookieAttributes {
|
|
163
|
+
expires?: number | Date | undefined;
|
|
164
|
+
path?: string | undefined;
|
|
165
|
+
domain?: string | undefined;
|
|
166
|
+
secure?: boolean | undefined;
|
|
167
|
+
sameSite?: 'strict' | 'Strict' | 'lax' | 'Lax' | 'none' | 'None' | undefined;
|
|
168
|
+
[property: string]: any;
|
|
169
|
+
}
|
|
170
|
+
interface CookieStorage {
|
|
171
|
+
set(key: string, value: any, options?: CookieAttributes): void;
|
|
172
|
+
get(key: string): any;
|
|
173
|
+
remove(key: string, options?: CookieAttributes): void;
|
|
174
|
+
}
|
|
175
|
+
declare function createStorage(storage: globalThis.Storage): Storage;
|
|
176
|
+
declare function createCookieStorage(options?: CookieAttributes): CookieStorage;
|
|
177
|
+
declare const sessionStorage: Storage;
|
|
178
|
+
declare const localStorage: Storage; //#endregion
|
|
179
|
+
//#region src/util/tryParseJSON.d.ts
|
|
180
|
+
declare function tryParseJSON<T>(json: string): T | undefined; //#endregion
|
|
181
|
+
//#region src/util/download.d.ts
|
|
182
|
+
declare function download(val: string | Blob | File, filename?: string): void; //#endregion
|
|
183
|
+
//#region src/util/enumOf.d.ts
|
|
184
|
+
type ValueOf<T> = T[keyof T];
|
|
185
|
+
type EnumOfValue = string | number | boolean;
|
|
186
|
+
type EnumOfStringOrGetter = string | (() => string);
|
|
187
|
+
type EnumOfValueObject = {
|
|
188
|
+
value: EnumOfValue;
|
|
189
|
+
label?: EnumOfStringOrGetter;
|
|
190
|
+
description?: EnumOfStringOrGetter;
|
|
191
|
+
};
|
|
192
|
+
type EnumOfConfigValue = EnumOfValue | (EnumOfValueObject & Record<string, unknown>);
|
|
193
|
+
type EnumOfNormalizeToOption<V> = V extends {
|
|
194
|
+
value: unknown;
|
|
195
|
+
} ? V : {
|
|
196
|
+
value: V;
|
|
197
|
+
label?: EnumOfStringOrGetter;
|
|
198
|
+
description?: EnumOfStringOrGetter;
|
|
199
|
+
};
|
|
200
|
+
type EnumOfResolvedField<V> = V extends ((...args: any[]) => infer R) ? R : V;
|
|
201
|
+
type EnumOfResolvedOption<O> = O extends unknown ? { [K in keyof O]: EnumOfResolvedField<O[K]> } : never;
|
|
202
|
+
type EnumOfExtractOptionShape<T extends Record<string, EnumOfConfigValue>> = EnumOfResolvedOption<EnumOfNormalizeToOption<ValueOf<T>>>;
|
|
203
|
+
type EnumOfExtractValues<T extends object> = { [P in keyof T]: T[P] extends {
|
|
204
|
+
value: infer V;
|
|
205
|
+
} ? V : T[P] };
|
|
206
|
+
type EnumOfKeyForValue<T extends object, V> = { [K in keyof T]: EnumOfExtractValues<T>[K] extends V ? (V extends EnumOfExtractValues<T>[K] ? K : never) : never }[keyof T];
|
|
207
|
+
type EnumOfOptionForValue<T extends Record<string, EnumOfConfigValue>, Value> = Value extends infer V ? EnumOfKeyForValue<T, V> extends keyof T ? EnumOfResolvedOption<EnumOfNormalizeToOption<T[EnumOfKeyForValue<T, V>]>> : EnumOfExtractOptionShape<T> : never;
|
|
208
|
+
type EnumOfResultMethods<V, T extends Record<string, EnumOfConfigValue>> = {
|
|
209
|
+
values(): V[];
|
|
210
|
+
label(v: V): string;
|
|
211
|
+
labels(): string[];
|
|
212
|
+
description(v: V): string;
|
|
213
|
+
descriptions(): string[];
|
|
214
|
+
option<Value extends V>(v: Value): EnumOfOptionForValue<T, Value>;
|
|
215
|
+
options(): EnumOfExtractOptionShape<T>[];
|
|
216
|
+
};
|
|
217
|
+
type EnumOfResult<T extends Record<string, EnumOfConfigValue>> = EnumOfExtractValues<T> & EnumOfResultMethods<ValueOf<EnumOfExtractValues<T>>, T>;
|
|
218
|
+
declare function enumOf<const T extends Record<string, EnumOfConfigValue>>(config: T): EnumOfResult<T>;
|
|
219
|
+
type EnumOf<T extends {
|
|
220
|
+
values: () => any[];
|
|
221
|
+
}> = ReturnType<T['values']>[number]; //#endregion
|
|
222
|
+
//#region src/util/motion.d.ts
|
|
223
|
+
interface MotionOptions {
|
|
224
|
+
from: number;
|
|
225
|
+
to: number;
|
|
226
|
+
duration?: number;
|
|
227
|
+
frame?: ({
|
|
228
|
+
value,
|
|
229
|
+
done
|
|
230
|
+
}: {
|
|
231
|
+
value: number;
|
|
232
|
+
done: boolean;
|
|
233
|
+
}) => void;
|
|
234
|
+
timingFunction?: (v: number) => number;
|
|
235
|
+
onStateChange?: (state: MotionState) => void;
|
|
236
|
+
}
|
|
237
|
+
type MotionState = 'running' | 'paused' | 'pending' | 'finished';
|
|
238
|
+
interface Motion {
|
|
239
|
+
start: () => void;
|
|
240
|
+
pause: () => void;
|
|
241
|
+
reset: () => void;
|
|
242
|
+
getState: () => MotionState;
|
|
243
|
+
}
|
|
244
|
+
declare function motion(options: MotionOptions): Motion; //#endregion
|
|
245
|
+
//#region src/util/duration.d.ts
|
|
246
|
+
interface DurationContext {
|
|
247
|
+
years(value: number): this;
|
|
248
|
+
months(value: number): this;
|
|
249
|
+
weeks(value: number): this;
|
|
250
|
+
days(value: number): this;
|
|
251
|
+
hours(value: number): this;
|
|
252
|
+
minutes(value: number): this;
|
|
253
|
+
seconds(value: number): this;
|
|
254
|
+
milliseconds(value: number): this;
|
|
255
|
+
valueOf(options?: {
|
|
256
|
+
milliseconds: boolean;
|
|
257
|
+
}): number;
|
|
258
|
+
}
|
|
259
|
+
declare function duration(): DurationContext; //#endregion
|
|
260
|
+
//#region src/util/createCacheManager.d.ts
|
|
261
|
+
interface CreateCacheManagerOptions {
|
|
262
|
+
ttl?: number;
|
|
263
|
+
}
|
|
264
|
+
declare function createCacheManager<T = any>(options?: CreateCacheManagerOptions): {
|
|
265
|
+
has: (key: any) => boolean;
|
|
266
|
+
get: (key: any) => T | undefined;
|
|
267
|
+
set: (key: any, value: T, options?: {
|
|
268
|
+
ttl: number;
|
|
269
|
+
}) => void;
|
|
270
|
+
remove: (key: any) => boolean;
|
|
271
|
+
clear: () => void;
|
|
272
|
+
}; //#endregion
|
|
273
|
+
//#region src/util/navigation.d.ts
|
|
274
|
+
interface NavigationTarget {
|
|
275
|
+
to: string;
|
|
276
|
+
query?: Record<string, any>;
|
|
277
|
+
hash?: string;
|
|
278
|
+
}
|
|
279
|
+
declare function buildNavigationUrl(target: string | NavigationTarget): string;
|
|
280
|
+
declare const navigation: {
|
|
281
|
+
push(target: string | NavigationTarget): void;
|
|
282
|
+
replace(target: string | NavigationTarget): void;
|
|
283
|
+
open(target: string | NavigationTarget): void;
|
|
284
|
+
back(): void;
|
|
285
|
+
go(delta: number): void;
|
|
286
|
+
}; //#endregion
|
|
287
|
+
//#region src/function/call.d.ts
|
|
288
|
+
declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined; //#endregion
|
|
289
|
+
//#region src/function/tryCall.d.ts
|
|
290
|
+
declare function tryCall<Args extends any[], T>(fn: (...args: Args) => T, ...args: Args): [unknown, undefined] | [undefined, T]; //#endregion
|
|
291
|
+
//#region src/function/tryAsyncCall.d.ts
|
|
292
|
+
declare function tryAsyncCall<Args extends any[], T>(fn: (...args: Args) => Promise<T>, ...args: Args): Promise<[unknown, undefined] | [undefined, T]>; //#endregion
|
|
293
|
+
//#region src/function/once.d.ts
|
|
294
|
+
declare function once<F extends (...args: any[]) => any>(fn: F): (this: unknown, ...args: Parameters<F>) => ReturnType<F>; //#endregion
|
|
295
|
+
//#region src/function/debounce.d.ts
|
|
296
|
+
declare function debounce<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void; //#endregion
|
|
297
|
+
//#region src/function/throttle.d.ts
|
|
298
|
+
declare function throttle<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void; //#endregion
|
|
299
|
+
//#region src/function/NOOP.d.ts
|
|
300
|
+
declare function NOOP(): void; //#endregion
|
|
301
|
+
//#region src/function/callOrReturn.d.ts
|
|
302
|
+
declare function callOrReturn<T, A extends any[]>(fnOrValue: T | ((...args: A) => T), ...args: A): T; //#endregion
|
|
303
|
+
//#region src/general/getGlobalThis.d.ts
|
|
304
|
+
declare function getGlobalThis(): typeof globalThis; //#endregion
|
|
305
|
+
//#region src/general/hasOwn.d.ts
|
|
306
|
+
declare function hasOwn<T extends object>(val: T, key: PropertyKey): key is keyof T; //#endregion
|
|
307
|
+
//#region src/general/inBrowser.d.ts
|
|
308
|
+
declare function inBrowser(): boolean; //#endregion
|
|
309
|
+
//#region src/general/inMobile.d.ts
|
|
310
|
+
declare function inMobile(): boolean; //#endregion
|
|
311
|
+
//#region src/general/isArray.d.ts
|
|
312
|
+
declare function isArray(val: unknown): val is any[]; //#endregion
|
|
313
|
+
//#region src/general/isArrayBuffer.d.ts
|
|
314
|
+
declare function isArrayBuffer(val: unknown): val is ArrayBuffer; //#endregion
|
|
315
|
+
//#region src/general/isBoolean.d.ts
|
|
316
|
+
declare function isBoolean(val: unknown): val is boolean; //#endregion
|
|
317
|
+
//#region src/general/isDataView.d.ts
|
|
318
|
+
declare function isDataView(val: unknown): val is DataView; //#endregion
|
|
319
|
+
//#region src/general/isDate.d.ts
|
|
320
|
+
declare function isDate(val: unknown): val is Date; //#endregion
|
|
321
|
+
//#region src/general/isDOMException.d.ts
|
|
322
|
+
declare function isDOMException(val: unknown): val is DOMException; //#endregion
|
|
323
|
+
//#region src/general/isEmpty.d.ts
|
|
324
|
+
declare function isEmpty(val: unknown): boolean; //#endregion
|
|
325
|
+
//#region src/general/isEqual.d.ts
|
|
326
|
+
declare function isEqual(value: any, other: any): boolean; //#endregion
|
|
327
|
+
//#region src/general/isEqualWith.d.ts
|
|
328
|
+
declare function isEqualWith(value: any, other: any, fn: (value: any, other: any) => any): boolean; //#endregion
|
|
329
|
+
//#region src/general/isError.d.ts
|
|
330
|
+
declare function isError(val: unknown): val is Error; //#endregion
|
|
331
|
+
//#region src/general/isFunction.d.ts
|
|
332
|
+
declare function isFunction(val: unknown): val is Function; //#endregion
|
|
333
|
+
//#region src/general/isMap.d.ts
|
|
334
|
+
declare function isMap(val: unknown): val is Map<any, any>; //#endregion
|
|
335
|
+
//#region src/general/isNonEmptyArray.d.ts
|
|
336
|
+
declare function isNonEmptyArray(val: unknown): val is any[]; //#endregion
|
|
337
|
+
//#region src/general/isNullish.d.ts
|
|
338
|
+
declare function isNullish(val: unknown): val is null | undefined; //#endregion
|
|
339
|
+
//#region src/general/isNumber.d.ts
|
|
340
|
+
declare function isNumber(val: unknown): val is number; //#endregion
|
|
341
|
+
//#region src/general/isNumeric.d.ts
|
|
342
|
+
declare function isNumeric(val: unknown): val is number | string; //#endregion
|
|
343
|
+
//#region src/general/isObject.d.ts
|
|
344
|
+
declare function isObject(val: unknown): val is Record<string, any>; //#endregion
|
|
345
|
+
//#region src/general/isPlainObject.d.ts
|
|
346
|
+
declare function isPlainObject(val: unknown): val is Record<string, any>; //#endregion
|
|
347
|
+
//#region src/general/isPromise.d.ts
|
|
348
|
+
declare function isPromise<T = any>(val: unknown): val is Promise<T>; //#endregion
|
|
349
|
+
//#region src/general/isRegExp.d.ts
|
|
350
|
+
declare function isRegExp(val: unknown): val is RegExp; //#endregion
|
|
351
|
+
//#region src/general/isSet.d.ts
|
|
352
|
+
declare function isSet(val: unknown): val is Set<any>; //#endregion
|
|
353
|
+
//#region src/general/isString.d.ts
|
|
354
|
+
declare function isString(val: unknown): val is string; //#endregion
|
|
355
|
+
//#region src/general/isSymbol.d.ts
|
|
356
|
+
declare function isSymbol(val: unknown): val is symbol; //#endregion
|
|
357
|
+
//#region src/general/isTruthy.d.ts
|
|
358
|
+
declare function isTruthy<T>(v: T): v is NonNullable<T>; //#endregion
|
|
359
|
+
//#region src/general/isTypedArray.d.ts
|
|
360
|
+
declare function isTypedArray(val: unknown): val is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; //#endregion
|
|
361
|
+
//#region src/general/isWeakMap.d.ts
|
|
362
|
+
declare function isWeakMap(val: unknown): val is WeakMap<any, any>; //#endregion
|
|
363
|
+
//#region src/general/isWeakSet.d.ts
|
|
364
|
+
declare function isWeakSet(val: unknown): val is WeakSet<any>; //#endregion
|
|
365
|
+
//#region src/general/isWindow.d.ts
|
|
366
|
+
declare function isWindow(val: unknown): val is Window; //#endregion
|
|
367
|
+
//#region src/general/supportTouch.d.ts
|
|
368
|
+
declare function supportTouch(): boolean; //#endregion
|
|
369
|
+
//#region src/general/toRawType.d.ts
|
|
370
|
+
declare function toRawType(value: unknown): string; //#endregion
|
|
371
|
+
//#region src/general/toTypeString.d.ts
|
|
372
|
+
declare const objectToString: typeof Object.prototype.toString;
|
|
373
|
+
declare function toTypeString(value: unknown): string; //#endregion
|
|
374
|
+
//#region src/general/isFile.d.ts
|
|
375
|
+
declare function isFile(val: unknown): val is File; //#endregion
|
|
376
|
+
//#region src/general/isBlob.d.ts
|
|
377
|
+
declare function isBlob(val: unknown): val is Blob; //#endregion
|
|
378
|
+
//#region src/general/isPrimitive.d.ts
|
|
379
|
+
declare function isPrimitive(val: unknown): boolean; //#endregion
|
|
380
|
+
//#region src/general/isEmptyPlainObject.d.ts
|
|
381
|
+
declare function isEmptyPlainObject(val: unknown): val is Record<string, any>; //#endregion
|
|
382
|
+
//#region src/general/assert.d.ts
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/general/hasDuplicates.d.ts
|
|
385
|
+
declare function hasDuplicates<T>(arr: T[]): boolean; //#endregion
|
|
386
|
+
//#region src/general/hasDuplicatesBy.d.ts
|
|
387
|
+
declare function hasDuplicatesBy<T>(arr: T[], fn: (a: T, b: T) => any): boolean; //#endregion
|
|
388
|
+
//#region src/number/clamp.d.ts
|
|
389
|
+
declare function clamp(num: number, min: number, max: number): number; //#endregion
|
|
390
|
+
//#region src/number/clampArrayRange.d.ts
|
|
391
|
+
declare function clampArrayRange(index: number, arr: unknown[]): number; //#endregion
|
|
392
|
+
//#region src/number/delay.d.ts
|
|
393
|
+
declare function delay(time: number): Promise<void>; //#endregion
|
|
394
|
+
//#region src/number/randomNumber.d.ts
|
|
395
|
+
declare function randomNumber(min?: number, max?: number): number; //#endregion
|
|
396
|
+
//#region src/number/times.d.ts
|
|
397
|
+
declare function times<T>(num: number, fn: (index: number) => T): T[]; //#endregion
|
|
398
|
+
//#region src/number/toNumber.d.ts
|
|
399
|
+
declare function toNumber(val: number | string | boolean | undefined | null): number; //#endregion
|
|
400
|
+
//#region src/number/genNumberKey.d.ts
|
|
401
|
+
declare function genNumberKey(): number; //#endregion
|
|
402
|
+
//#region src/string/maskString.d.ts
|
|
403
|
+
interface MaskStringOptions {
|
|
404
|
+
prefix?: number;
|
|
405
|
+
suffix?: number;
|
|
406
|
+
mask?: string;
|
|
407
|
+
maskLength?: number;
|
|
408
|
+
}
|
|
409
|
+
declare function maskString(text: string, {
|
|
410
|
+
prefix,
|
|
411
|
+
suffix,
|
|
412
|
+
mask,
|
|
413
|
+
maskLength
|
|
414
|
+
}?: MaskStringOptions): string; //#endregion
|
|
415
|
+
//#region src/string/camelize.d.ts
|
|
416
|
+
declare function camelize(s: string): string; //#endregion
|
|
417
|
+
//#region src/string/ensurePrefix.d.ts
|
|
418
|
+
declare function ensurePrefix(s: string, prefix: string): string; //#endregion
|
|
419
|
+
//#region src/string/ensureSuffix.d.ts
|
|
420
|
+
declare function ensureSuffix(s: string, suffix: string): string; //#endregion
|
|
421
|
+
//#region src/string/genStringKey.d.ts
|
|
422
|
+
declare function genStringKey(): string; //#endregion
|
|
423
|
+
//#region src/string/kebabCase.d.ts
|
|
424
|
+
declare function kebabCase(s: string): string; //#endregion
|
|
425
|
+
//#region src/string/pascalCase.d.ts
|
|
426
|
+
declare function pascalCase(s: string): string; //#endregion
|
|
427
|
+
//#region src/string/lowerFirst.d.ts
|
|
428
|
+
declare function lowerFirst(s: string): string; //#endregion
|
|
429
|
+
//#region src/string/upperFirst.d.ts
|
|
430
|
+
declare function upperFirst(s: string): string; //#endregion
|
|
431
|
+
//#region src/string/randomColor.d.ts
|
|
432
|
+
declare function randomColor(): string; //#endregion
|
|
433
|
+
//#region src/string/randomString.d.ts
|
|
434
|
+
declare function randomString(length?: number): string; //#endregion
|
|
435
|
+
//#region src/string/slash.d.ts
|
|
436
|
+
declare function slash(path: string): string; //#endregion
|
|
437
|
+
//#region src/collection/cloneDeep.d.ts
|
|
438
|
+
declare function cloneDeep<T>(value: T): T; //#endregion
|
|
439
|
+
//#region src/collection/cloneDeepWith.d.ts
|
|
440
|
+
declare function cloneDeepWith<T>(value: T, fn: (value: any) => any): T; //#endregion
|
|
441
|
+
//#region src/collection/merge.d.ts
|
|
442
|
+
declare function merge<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: K[]): T & K; //#endregion
|
|
443
|
+
//#region src/collection/mergeWith.d.ts
|
|
444
|
+
type Fn = (objValue: any, srcValue: any, key: string | number | symbol, object?: any, source?: any) => any;
|
|
445
|
+
declare function mergeWith<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: [...K[], fn: Fn]): T & K; //#endregion
|
|
446
|
+
//#region src/file/toArrayBuffer.d.ts
|
|
447
|
+
declare function toArrayBuffer(file: File): Promise<ArrayBuffer>; //#endregion
|
|
448
|
+
//#region src/file/toDataURL.d.ts
|
|
449
|
+
declare function toDataURL(file: File): Promise<string>; //#endregion
|
|
450
|
+
//#region src/file/toText.d.ts
|
|
451
|
+
declare function toText(file: File): Promise<string>; //#endregion
|
|
452
|
+
//#region src/math/maxBy.d.ts
|
|
453
|
+
declare function maxBy<T>(arr: T[], fn: (val: T) => number): T; //#endregion
|
|
454
|
+
//#region src/math/minBy.d.ts
|
|
455
|
+
declare function minBy<T>(arr: T[], fn: (val: T) => number): T; //#endregion
|
|
456
|
+
//#region src/math/sum.d.ts
|
|
457
|
+
declare function sum(arr: number[]): number; //#endregion
|
|
458
|
+
//#region src/math/sumBy.d.ts
|
|
459
|
+
declare function sumBy<T>(arr: T[], fn: (val: T) => number): number; //#endregion
|
|
460
|
+
//#region src/math/sumHash.d.ts
|
|
461
|
+
declare function sumHash(value: any): string; //#endregion
|
|
462
|
+
//#region src/math/mean.d.ts
|
|
463
|
+
declare function mean(arr: number[]): number; //#endregion
|
|
464
|
+
//#region src/math/meanBy.d.ts
|
|
465
|
+
declare function meanBy<T>(arr: T[], fn: (val: T) => number): number; //#endregion
|
|
466
|
+
//#region src/math/sample.d.ts
|
|
467
|
+
declare function sample<T>(arr: T[]): T | undefined; //#endregion
|
|
468
|
+
//#region src/math/round.d.ts
|
|
469
|
+
declare function round(val: number, precision?: number): number;
|
|
470
|
+
declare function baseRound(val: number, precision: number, fn: (val: number) => number): number; //#endregion
|
|
471
|
+
//#region src/math/floor.d.ts
|
|
472
|
+
declare function floor(val: number, precision?: number): number; //#endregion
|
|
473
|
+
//#region src/math/ceil.d.ts
|
|
474
|
+
declare function ceil(val: number, precision?: number): number;
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/index.d.ts
|
|
3
477
|
declare function assert(condition: boolean, source: string, message: string): asserts condition;
|
|
4
478
|
declare function warn(source: string, message: string): void;
|
|
5
479
|
declare function error(source: string, message: string): void;
|
|
6
480
|
declare const isURL: (val: string | undefined | null) => boolean;
|
|
7
|
-
|
|
8
|
-
export { assert, error, isURL, warn };
|
|
481
|
+
//#endregion
|
|
482
|
+
export { BEM, ClassName, Classes, CookieAttributes, CookieStorage, CreateCacheManagerOptions, DurationContext, Emitter, EnumOf, EnumOfConfigValue, EnumOfExtractOptionShape, EnumOfExtractValues, EnumOfKeyForValue, EnumOfNormalizeToOption, EnumOfOptionForValue, EnumOfResolvedField, EnumOfResolvedOption, EnumOfResult, EnumOfResultMethods, EnumOfStringOrGetter, EnumOfValue, EnumOfValueObject, EventHandlerList, EventHandlerMap, EventType, Handler, MaskStringOptions, Motion, MotionOptions, MotionState, NOOP, NavigationTarget, PromiseWithResolvers, Storage, WildCardEventHandlerList, WildcardHandler, assert, at, baseRound, buildNavigationUrl, call, callOrReturn, camelize, cancelAnimationFrame, ceil, chunk, clamp, clampArrayRange, classes, cloneDeep, cloneDeepWith, copyText, createCacheManager, createCookieStorage, createNamespaceFn, createStorage, debounce, delay, difference, differenceWith, doubleRaf, download, duration, ensurePrefix, ensureSuffix, enumOf, error, find, floor, genNumberKey, genStringKey, getAllParentScroller, getGlobalThis, getParentScroller, getRect, getScrollLeft, getScrollTop, getStyle, groupBy, hasDuplicates, hasDuplicatesBy, hasOwn, inBrowser, inMobile, inViewport, intersection, intersectionWith, isArray, isArrayBuffer, isBlob, isBoolean, isDOMException, isDataView, isDate, isEmpty, isEmptyPlainObject, isEqual, isEqualWith, isError, isFile, isFunction, isMap, isNonEmptyArray, isNullish, isNumber, isNumeric, isObject, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isTruthy, isTypedArray, isURL, isWeakMap, isWeakSet, isWindow, kebabCase, localStorage, lowerFirst, mapObject, maskString, maxBy, mean, meanBy, merge, mergeWith, minBy, mitt, motion, navigation, normalizeToArray, objectEntries, objectKeys, objectToString, omit, omitBy, once, pascalCase, pick, pickBy, prettyJSONObject, preventDefault, promiseWithResolvers, raf, randomColor, randomNumber, randomString, removeArrayBlank, removeArrayEmpty, removeItem, removeItemBy, removeItemsBy, requestAnimationFrame, round, sample, sessionStorage, set, shuffle, slash, sum, sumBy, sumHash, supportTouch, throttle, times, toArrayBuffer, toDataURL, toNumber, toRawType, toText, toTypeString, toggleItem, tryAsyncCall, tryCall, tryParseJSON, uniq, uniqBy, upperFirst, v4 as uuid, v6 as uuidV6, warn, xor, xorWith };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "rattail";
|
|
2
2
|
|
|
3
|
+
//#region src/index.d.ts
|
|
3
4
|
declare function assert(condition: boolean, source: string, message: string): asserts condition;
|
|
4
5
|
declare function warn(source: string, message: string): void;
|
|
5
6
|
declare function error(source: string, message: string): void;
|
|
6
7
|
declare const isURL: (val: string | undefined | null) => boolean;
|
|
7
|
-
|
|
8
|
-
export { assert, error, isURL, warn };
|
|
8
|
+
//#endregion
|
|
9
|
+
export { assert, error, isURL, warn };
|
package/lib/index.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import { assert as _assert } from "rattail";
|
|
1
|
+
import { assert as assert$1 } from "rattail";
|
|
3
2
|
export * from "rattail";
|
|
3
|
+
//#region src/index.ts
|
|
4
4
|
function assert(condition, source, message) {
|
|
5
|
-
|
|
5
|
+
return assert$1(condition, `Varlet [${source}]: ${message}`);
|
|
6
6
|
}
|
|
7
7
|
function warn(source, message) {
|
|
8
|
-
|
|
8
|
+
console.warn(`Varlet [${source}]: ${message}`);
|
|
9
9
|
}
|
|
10
10
|
function error(source, message) {
|
|
11
|
-
|
|
11
|
+
console.error(`Varlet [${source}]: ${message}`);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return /^(http)|(\.*\/)/.test(val);
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
assert,
|
|
21
|
-
error,
|
|
22
|
-
isURL,
|
|
23
|
-
warn
|
|
13
|
+
const isURL = (val) => {
|
|
14
|
+
if (!val) return false;
|
|
15
|
+
return /^(http)|(\.*\/)/.test(val);
|
|
24
16
|
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { assert, error, isURL, warn };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/shared",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0-alpha.1776606769606",
|
|
4
4
|
"description": "shared utils of varlet",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shared",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"lib"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"rattail": "
|
|
35
|
+
"rattail": "^2.0.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^
|
|
39
|
-
"
|
|
40
|
-
"
|
|
38
|
+
"@types/node": "^20.19.0",
|
|
39
|
+
"typescript": "5.6.3",
|
|
40
|
+
"vite-plus": "0.1.18"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "
|
|
44
|
-
"dev": "
|
|
43
|
+
"build": "vp pack",
|
|
44
|
+
"dev": "vp pack --watch"
|
|
45
45
|
}
|
|
46
46
|
}
|