@varlet/shared 3.19.3 → 3.20.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/lib/index.cjs CHANGED
@@ -1,17 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let node_crypto = require("node:crypto");
3
- //#region ../../node_modules/.pnpm/rattail@2.0.9_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._f3zbpnrccb4zea33q3fpausmni/node_modules/rattail/dist/isString-eoLxw4CX.mjs
3
+ //#region ../../node_modules/.pnpm/rattail@2.1.1_oxfmt@0.60.0_vite-plus@0.2.6_@types+node@20.19.39_@vitest+coverage-istanbul@4.1_njw3paytr7isgqoonhsyyq2e2q/node_modules/rattail/dist/callOrReturn-Kvk3rYZJ.mjs
4
4
  function isArray(val) {
5
5
  return Array.isArray(val);
6
6
  }
7
- function isString(val) {
8
- return typeof val === "string";
9
- }
10
- //#endregion
11
- //#region ../../node_modules/.pnpm/rattail@2.0.9_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._f3zbpnrccb4zea33q3fpausmni/node_modules/rattail/dist/callOrReturn-MpTzoGlG.mjs
12
7
  function isFunction(val) {
13
8
  return typeof val === "function";
14
9
  }
10
+ function isString(val) {
11
+ return typeof val === "string";
12
+ }
15
13
  function callOrReturn(fnOrValue, ...args) {
16
14
  if (isFunction(fnOrValue)) return fnOrValue(...args);
17
15
  return fnOrValue;
@@ -40,7 +38,7 @@ function unsafeStringify(arr, offset = 0) {
40
38
  }
41
39
  //#endregion
42
40
  //#region ../../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist-node/rng.js
43
- const rnds8Pool = new Uint8Array(256);
41
+ const rnds8Pool = /* @__PURE__ */ new Uint8Array(256);
44
42
  let poolPtr = rnds8Pool.length;
45
43
  function rng() {
46
44
  if (poolPtr > rnds8Pool.length - 16) {
@@ -90,7 +88,7 @@ function updateV1State(state, now, rnds) {
90
88
  function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
91
89
  if (rnds.length < 16) throw new Error("Random bytes length must be >= 16");
92
90
  if (!buf) {
93
- buf = new Uint8Array(16);
91
+ buf = /* @__PURE__ */ new Uint8Array(16);
94
92
  offset = 0;
95
93
  } else if (offset < 0 || offset + 16 > buf.length) throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
96
94
  msecs ??= Date.now();
@@ -153,7 +151,7 @@ function v6(options, buf, offset) {
153
151
  let bytes = v1({
154
152
  ...options,
155
153
  _v6: true
156
- }, new Uint8Array(16));
154
+ }, /* @__PURE__ */ new Uint8Array(16));
157
155
  bytes = v1ToV6(bytes);
158
156
  if (buf) {
159
157
  for (let i = 0; i < 16; i++) buf[offset + i] = bytes[i];
@@ -253,7 +251,7 @@ function init(converter, defaultAttributes) {
253
251
  }
254
252
  var api = init(defaultConverter, { path: "/" });
255
253
  //#endregion
256
- //#region ../../node_modules/.pnpm/rattail@2.0.9_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._f3zbpnrccb4zea33q3fpausmni/node_modules/rattail/dist/index.mjs
254
+ //#region ../../node_modules/.pnpm/rattail@2.1.1_oxfmt@0.60.0_vite-plus@0.2.6_@types+node@20.19.39_@vitest+coverage-istanbul@4.1_njw3paytr7isgqoonhsyyq2e2q/node_modules/rattail/dist/index.mjs
257
255
  function at(arr, index) {
258
256
  if (!arr.length) return;
259
257
  if (index < 0) index += arr.length;
package/lib/index.d.cts CHANGED
@@ -45,122 +45,168 @@ interface Emitter<Events extends Record<EventType, unknown>> {
45
45
  */
46
46
  declare function mitt<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): Emitter<Events>;
47
47
  //#endregion
48
- //#region ../../node_modules/.pnpm/rattail@2.0.9_@voidzero-dev+vite-plus-core@0.1.18_@types+node@20.19.39_esbuild@0.27.7_jiti@2._f3zbpnrccb4zea33q3fpausmni/node_modules/rattail/dist/index.d.mts
48
+ //#region ../../node_modules/.pnpm/rattail@2.1.1_oxfmt@0.60.0_vite-plus@0.2.6_@types+node@20.19.39_@vitest+coverage-istanbul@4.1_njw3paytr7isgqoonhsyyq2e2q/node_modules/rattail/dist/index.d.mts
49
49
  //#region src/array/at.d.ts
50
- declare function at<T>(arr: T[], index: number): T | undefined; //#endregion
50
+ declare function at<T>(arr: T[], index: number): T | undefined;
51
+ //#endregion
51
52
  //#region src/array/chunk.d.ts
52
- declare function chunk<T>(arr: T[], size?: number): T[][]; //#endregion
53
+ declare function chunk<T>(arr: T[], size?: number): T[][];
54
+ //#endregion
53
55
  //#region src/array/removeItem.d.ts
54
- declare function removeItem<T>(arr: T[], item: T): T[] | undefined; //#endregion
56
+ declare function removeItem<T>(arr: T[], item: T): T[] | undefined;
57
+ //#endregion
55
58
  //#region src/array/removeItemBy.d.ts
56
- declare function removeItemBy<T>(arr: T[], fn: (v: T) => any): T[] | undefined; //#endregion
59
+ declare function removeItemBy<T>(arr: T[], fn: (v: T) => any): T[] | undefined;
60
+ //#endregion
57
61
  //#region src/array/removeItemsBy.d.ts
58
- declare function removeItemsBy<T>(arr: T[], fn: (v: T) => any): T[]; //#endregion
62
+ declare function removeItemsBy<T>(arr: T[], fn: (v: T) => any): T[];
63
+ //#endregion
59
64
  //#region src/array/toggleItem.d.ts
60
- declare function toggleItem<T>(arr: T[], item: T): T[]; //#endregion
65
+ declare function toggleItem<T>(arr: T[], item: T): T[];
66
+ //#endregion
61
67
  //#region src/array/uniq.d.ts
62
- declare function uniq<T>(arr: T[]): T[]; //#endregion
68
+ declare function uniq<T>(arr: T[]): T[];
69
+ //#endregion
63
70
  //#region src/array/uniqBy.d.ts
64
- declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) => any): T[]; //#endregion
71
+ declare function uniqBy<T>(arr: T[], fn: (a: T, b: T) => any): T[];
72
+ //#endregion
65
73
  //#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
74
+ declare function find<T>(arr: T[], fn: (item: T, index: number, array: T[]) => any, from?: 'start' | 'end'): [T, number] | [null, -1];
75
+ //#endregion
67
76
  //#region src/array/shuffle.d.ts
68
- declare function shuffle<T>(arr: T[]): T[]; //#endregion
77
+ declare function shuffle<T>(arr: T[]): T[];
78
+ //#endregion
69
79
  //#region src/array/removeArrayBlank.d.ts
70
- declare function removeArrayBlank<T>(arr: (T | null | undefined)[]): T[]; //#endregion
80
+ declare function removeArrayBlank<T>(arr: (T | null | undefined)[]): T[];
81
+ //#endregion
71
82
  //#region src/array/removeArrayEmpty.d.ts
72
- declare function removeArrayEmpty<T>(arr: (T | null | undefined | '')[]): T[]; //#endregion
83
+ declare function removeArrayEmpty<T>(arr: (T | null | undefined | '')[]): T[];
84
+ //#endregion
73
85
  //#region src/array/normalizeToArray.d.ts
74
- declare function normalizeToArray<T>(value: T | T[]): T[]; //#endregion
86
+ declare function normalizeToArray<T>(value: T | T[]): T[];
87
+ //#endregion
75
88
  //#region src/array/difference.d.ts
76
- declare function difference<T>(arr: T[], ...values: T[][]): T[]; //#endregion
89
+ declare function difference<T>(arr: T[], ...values: T[][]): T[];
90
+ //#endregion
77
91
  //#region src/array/differenceWith.d.ts
78
92
  type Fn$4<T> = (a: T, b: T) => any;
79
- declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$4<T>]): T[]; //#endregion
93
+ declare function differenceWith<T>(arr: T[], ...values: [...T[][], fn: Fn$4<T>]): T[];
94
+ //#endregion
80
95
  //#region src/array/intersection.d.ts
81
- declare function intersection<T>(...values: T[][]): T[]; //#endregion
96
+ declare function intersection<T>(...values: T[][]): T[];
97
+ //#endregion
82
98
  //#region src/array/intersectionWith.d.ts
83
99
  type Fn$3<T> = (a: T, b: T) => any;
84
- declare function intersectionWith<T>(...values: [...T[][], fn: Fn$3<T>]): T[]; //#endregion
100
+ declare function intersectionWith<T>(...values: [...T[][], fn: Fn$3<T>]): T[];
101
+ //#endregion
85
102
  //#region src/array/groupBy.d.ts
86
103
  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
104
+ declare function groupBy<T, K extends PropertyKey>(arr: T[], fn: Fn$2<T, K>): Record<K, T[]>;
105
+ //#endregion
88
106
  //#region src/array/xor.d.ts
89
- declare function xor<T>(...values: T[][]): T[]; //#endregion
107
+ declare function xor<T>(...values: T[][]): T[];
108
+ //#endregion
90
109
  //#region src/array/xorWith.d.ts
91
110
  type Fn$1<T> = (a: T, b: T) => any;
92
- declare function xorWith<T>(...values: [...T[][], fn: Fn$1<T>]): T[]; //#endregion
111
+ declare function xorWith<T>(...values: [...T[][], fn: Fn$1<T>]): T[];
112
+ //#endregion
93
113
  //#region src/object/pick.d.ts
94
- declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>; //#endregion
114
+ declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
115
+ //#endregion
95
116
  //#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
117
+ declare function pickBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
118
+ //#endregion
97
119
  //#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
120
+ declare function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T, K>;
121
+ //#endregion
99
122
  //#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
123
+ declare function omitBy<T extends object>(object: T, fn: (value: any, key: keyof T) => any): Partial<T>;
124
+ //#endregion
101
125
  //#region src/object/deriveKey.d.ts
102
126
  type DeriveKeyMap<T extends object> = Partial<Record<keyof T, PropertyKey>>;
103
- type DeriveKeyResult<T extends object, M extends DeriveKeyMap<T>> = T & { [K in keyof M as M[K] extends PropertyKey ? M[K] : never]: K extends keyof T ? T[K] : never };
104
- declare function deriveKey<T extends object, M extends DeriveKeyMap<T>>(object: T, mapping: M): DeriveKeyResult<T, M>; //#endregion
127
+ type DeriveKeyResult<T extends object, M extends DeriveKeyMap<T>> = T & { [K in keyof M as M[K] extends PropertyKey ? M[K] : never]: K extends keyof T ? T[K] : never; };
128
+ declare function deriveKey<T extends object, M extends DeriveKeyMap<T>>(object: T, mapping: M): DeriveKeyResult<T, M>;
129
+ //#endregion
105
130
  //#region src/object/rekey.d.ts
106
131
  type RekeyMap<T extends object> = Partial<Record<keyof T, PropertyKey>>;
107
- type RekeyResult<T extends object, M extends RekeyMap<T>> = Omit<T, keyof M> & { [K in keyof M as M[K] extends PropertyKey ? M[K] : never]: K extends keyof T ? T[K] : never };
108
- declare function rekey<T extends object, M extends RekeyMap<T>>(object: T, mapping: M): RekeyResult<T, M>; //#endregion
132
+ type RekeyResult<T extends object, M extends RekeyMap<T>> = Omit<T, keyof M> & { [K in keyof M as M[K] extends PropertyKey ? M[K] : never]: K extends keyof T ? T[K] : never; };
133
+ declare function rekey<T extends object, M extends RekeyMap<T>>(object: T, mapping: M): RekeyResult<T, M>;
134
+ //#endregion
109
135
  //#region src/object/mapObject.d.ts
110
- 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
136
+ 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>;
137
+ //#endregion
111
138
  //#region src/object/promiseWithResolvers.d.ts
112
139
  type PromiseWithResolvers<T> = {
113
140
  promise: Promise<T>;
114
141
  resolve: (value: T | PromiseLike<T>) => void;
115
142
  reject: (reason?: any) => void;
116
143
  };
117
- declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>; //#endregion
144
+ declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
145
+ //#endregion
118
146
  //#region src/object/set.d.ts
119
- declare function set<T extends object | any[]>(object: T, path: (string | number)[], value: any): void; //#endregion
147
+ declare function set<T extends object | any[]>(object: T, path: (string | number)[], value: any): void;
148
+ //#endregion
120
149
  //#region src/object/objectKeys.d.ts
121
- declare function objectKeys<T extends object>(object: T): `${keyof T & string}`[]; //#endregion
150
+ declare function objectKeys<T extends object>(object: T): `${keyof T & string}`[];
151
+ //#endregion
122
152
  //#region src/object/objectEntries.d.ts
123
153
  declare function objectEntries<T extends object>(object: T): [keyof T & string, T[keyof T & string]][];
124
154
  //#endregion
125
155
  //#region src/util/cancelAnimationFrame.d.ts
126
- declare function cancelAnimationFrame(handle: number): void; //#endregion
156
+ declare function cancelAnimationFrame(handle: number): void;
157
+ //#endregion
127
158
  //#region src/util/classes.d.ts
128
159
  type ClassName = string | undefined | null;
129
160
  type Classes = (ClassName | [any, ClassName, ClassName?])[];
130
- declare function classes(...classes: Classes): any[]; //#endregion
161
+ declare function classes(...classes: Classes): any[];
162
+ //#endregion
131
163
  //#region src/util/copyText.d.ts
132
- declare function copyText(value: string): void; //#endregion
164
+ declare function copyText(value: string): void;
165
+ //#endregion
133
166
  //#region src/util/createNamespaceFn.d.ts
134
167
  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}`;
135
168
  declare function createNamespaceFn<N extends string>(namespace: N): <C extends string>(name: C) => {
136
169
  name: string;
137
170
  n: <S extends string | undefined = undefined>(suffix?: S | undefined) => BEM<S, N, `${N}-${C}`>;
138
171
  classes: typeof classes;
139
- }; //#endregion
172
+ };
173
+ //#endregion
140
174
  //#region src/util/doubleRaf.d.ts
141
- declare function doubleRaf(): Promise<unknown>; //#endregion
175
+ declare function doubleRaf(): Promise<unknown>;
176
+ //#endregion
142
177
  //#region src/util/getAllParentScroller.d.ts
143
- declare function getAllParentScroller(el: HTMLElement): (HTMLElement | Window)[]; //#endregion
178
+ declare function getAllParentScroller(el: HTMLElement): (HTMLElement | Window)[];
179
+ //#endregion
144
180
  //#region src/util/getParentScroller.d.ts
145
- declare function getParentScroller(el: HTMLElement): HTMLElement | Window; //#endregion
181
+ declare function getParentScroller(el: HTMLElement): HTMLElement | Window;
182
+ //#endregion
146
183
  //#region src/util/getRect.d.ts
147
- declare function getRect(element: Element | Window): DOMRect; //#endregion
184
+ declare function getRect(element: Element | Window): DOMRect;
185
+ //#endregion
148
186
  //#region src/util/getScrollLeft.d.ts
149
- declare function getScrollLeft(element: Element | Window): number; //#endregion
187
+ declare function getScrollLeft(element: Element | Window): number;
188
+ //#endregion
150
189
  //#region src/util/getScrollTop.d.ts
151
- declare function getScrollTop(element: Element | Window): number; //#endregion
190
+ declare function getScrollTop(element: Element | Window): number;
191
+ //#endregion
152
192
  //#region src/util/getStyle.d.ts
153
- declare function getStyle(element: Element): CSSStyleDeclaration; //#endregion
193
+ declare function getStyle(element: Element): CSSStyleDeclaration;
194
+ //#endregion
154
195
  //#region src/util/inViewport.d.ts
155
- declare function inViewport(element: HTMLElement): boolean; //#endregion
196
+ declare function inViewport(element: HTMLElement): boolean;
197
+ //#endregion
156
198
  //#region src/util/prettyJSONObject.d.ts
157
- declare function prettyJSONObject(jsonObject: Record<string, any>): string; //#endregion
199
+ declare function prettyJSONObject(jsonObject: Record<string, any>): string;
200
+ //#endregion
158
201
  //#region src/util/preventDefault.d.ts
159
- declare function preventDefault(event: Event): void; //#endregion
202
+ declare function preventDefault(event: Event): void;
203
+ //#endregion
160
204
  //#region src/util/raf.d.ts
161
- declare function raf(): Promise<unknown>; //#endregion
205
+ declare function raf(): Promise<unknown>;
206
+ //#endregion
162
207
  //#region src/util/requestAnimationFrame.d.ts
163
- declare function requestAnimationFrame(fn: FrameRequestCallback): number; //#endregion
208
+ declare function requestAnimationFrame(fn: FrameRequestCallback): number;
209
+ //#endregion
164
210
  //#region src/util/storage.d.ts
165
211
  interface Storage extends globalThis.Storage {
166
212
  set(key: string, value: any): void;
@@ -183,11 +229,14 @@ interface CookieStorage {
183
229
  declare function createStorage(storage: globalThis.Storage): Storage;
184
230
  declare function createCookieStorage(options?: CookieAttributes): CookieStorage;
185
231
  declare const sessionStorage: Storage;
186
- declare const localStorage: Storage; //#endregion
232
+ declare const localStorage: Storage;
233
+ //#endregion
187
234
  //#region src/util/tryParseJSON.d.ts
188
- declare function tryParseJSON<T>(json: string): T | undefined; //#endregion
235
+ declare function tryParseJSON<T>(json: string): T | undefined;
236
+ //#endregion
189
237
  //#region src/util/download.d.ts
190
- declare function download(val: string | Blob | File, filename?: string): void; //#endregion
238
+ declare function download(val: string | Blob | File, filename?: string): void;
239
+ //#endregion
191
240
  //#region src/util/enumOf.d.ts
192
241
  type ValueOf<T> = T[keyof T];
193
242
  type EnumOfValue = string | number | boolean;
@@ -206,13 +255,13 @@ type EnumOfNormalizeToOption<V> = V extends {
206
255
  description?: EnumOfStringOrGetter;
207
256
  };
208
257
  type EnumOfResolvedField<V> = V extends ((...args: any[]) => infer R) ? R : V;
209
- type EnumOfResolvedOption<O> = O extends unknown ? { [K in keyof O]: EnumOfResolvedField<O[K]> } : never;
258
+ type EnumOfResolvedOption<O> = O extends unknown ? { [K in keyof O]: EnumOfResolvedField<O[K]>; } : never;
210
259
  type EnumOfExtractOptionShape<T extends Record<string, EnumOfConfigValue>> = EnumOfResolvedOption<EnumOfNormalizeToOption<ValueOf<T>>>;
211
260
  type EnumOfExtractValues<T extends object> = { [P in keyof T]: T[P] extends {
212
261
  value: infer V;
213
- } ? V : T[P] };
214
- 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];
215
- 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;
262
+ } ? V : T[P]; };
263
+ 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];
264
+ 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;
216
265
  type EnumOfResultMethods<V, T extends Record<string, EnumOfConfigValue>> = {
217
266
  values(): V[];
218
267
  label(v: V): string;
@@ -226,16 +275,14 @@ type EnumOfResult<T extends Record<string, EnumOfConfigValue>> = EnumOfExtractVa
226
275
  declare function enumOf<const T extends Record<string, EnumOfConfigValue>>(config: T): EnumOfResult<T>;
227
276
  type EnumOf<T extends {
228
277
  values: () => any[];
229
- }> = ReturnType<T['values']>[number]; //#endregion
278
+ }> = ReturnType<T['values']>[number];
279
+ //#endregion
230
280
  //#region src/util/motion.d.ts
231
281
  interface MotionOptions {
232
282
  from: number;
233
283
  to: number;
234
284
  duration?: number;
235
- frame?: ({
236
- value,
237
- done
238
- }: {
285
+ frame?: ({ value, done }: {
239
286
  value: number;
240
287
  done: boolean;
241
288
  }) => void;
@@ -249,7 +296,8 @@ interface Motion {
249
296
  reset: () => void;
250
297
  getState: () => MotionState;
251
298
  }
252
- declare function motion(options: MotionOptions): Motion; //#endregion
299
+ declare function motion(options: MotionOptions): Motion;
300
+ //#endregion
253
301
  //#region src/util/duration.d.ts
254
302
  interface DurationContext {
255
303
  years(value: number): this;
@@ -264,7 +312,8 @@ interface DurationContext {
264
312
  milliseconds: boolean;
265
313
  }): number;
266
314
  }
267
- declare function duration(): DurationContext; //#endregion
315
+ declare function duration(): DurationContext;
316
+ //#endregion
268
317
  //#region src/util/createCacheManager.d.ts
269
318
  interface CreateCacheManagerOptions {
270
319
  ttl?: number;
@@ -277,7 +326,8 @@ declare function createCacheManager<T = any>(options?: CreateCacheManagerOptions
277
326
  }) => void;
278
327
  remove: (key: any) => boolean;
279
328
  clear: () => void;
280
- }; //#endregion
329
+ };
330
+ //#endregion
281
331
  //#region src/util/navigation.d.ts
282
332
  interface NavigationTarget {
283
333
  to: string;
@@ -291,122 +341,177 @@ declare const navigation: {
291
341
  open(target: string | NavigationTarget): void;
292
342
  back(): void;
293
343
  go(delta: number): void;
294
- }; //#endregion
344
+ };
345
+ //#endregion
295
346
  //#region src/function/call.d.ts
296
- declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined; //#endregion
347
+ declare function call<P extends any[], R>(fn?: ((...arg: P) => R) | ((...arg: P) => R)[] | null, ...args: P): R | R[] | undefined;
348
+ //#endregion
297
349
  //#region src/function/tryCall.d.ts
298
- declare function tryCall<Args extends any[], T>(fn: (...args: Args) => T, ...args: Args): [unknown, undefined] | [undefined, T]; //#endregion
350
+ declare function tryCall<Args extends any[], T>(fn: (...args: Args) => T, ...args: Args): [unknown, undefined] | [undefined, T];
351
+ //#endregion
299
352
  //#region src/function/tryAsyncCall.d.ts
300
- declare function tryAsyncCall<Args extends any[], T>(fn: (...args: Args) => Promise<T>, ...args: Args): Promise<[unknown, undefined] | [undefined, T]>; //#endregion
353
+ declare function tryAsyncCall<Args extends any[], T>(fn: (...args: Args) => Promise<T>, ...args: Args): Promise<[unknown, undefined] | [undefined, T]>;
354
+ //#endregion
301
355
  //#region src/function/once.d.ts
302
- declare function once<F extends (...args: any[]) => any>(fn: F): (this: unknown, ...args: Parameters<F>) => ReturnType<F>; //#endregion
356
+ declare function once<F extends (...args: any[]) => any>(fn: F): (this: unknown, ...args: Parameters<F>) => ReturnType<F>;
357
+ //#endregion
303
358
  //#region src/function/debounce.d.ts
304
- declare function debounce<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void; //#endregion
359
+ declare function debounce<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void;
360
+ //#endregion
305
361
  //#region src/function/throttle.d.ts
306
- declare function throttle<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void; //#endregion
362
+ declare function throttle<F extends (...args: any[]) => any>(fn: F, delay?: number): (this: unknown, ...args: Parameters<F>) => void;
363
+ //#endregion
307
364
  //#region src/function/NOOP.d.ts
308
- declare function NOOP(): void; //#endregion
365
+ declare function NOOP(): void;
366
+ //#endregion
309
367
  //#region src/function/callOrReturn.d.ts
310
- declare function callOrReturn<T, A extends any[]>(fnOrValue: T | ((...args: A) => T), ...args: A): T; //#endregion
368
+ declare function callOrReturn<T, A extends any[]>(fnOrValue: T | ((...args: A) => T), ...args: A): T;
369
+ //#endregion
311
370
  //#region src/general/getGlobalThis.d.ts
312
- declare function getGlobalThis(): typeof globalThis; //#endregion
371
+ declare function getGlobalThis(): typeof globalThis;
372
+ //#endregion
313
373
  //#region src/general/hasOwn.d.ts
314
- declare function hasOwn<T extends object>(val: T, key: PropertyKey): key is keyof T; //#endregion
374
+ declare function hasOwn<T extends object>(val: T, key: PropertyKey): key is keyof T;
375
+ //#endregion
315
376
  //#region src/general/inBrowser.d.ts
316
- declare function inBrowser(): boolean; //#endregion
377
+ declare function inBrowser(): boolean;
378
+ //#endregion
317
379
  //#region src/general/inMobile.d.ts
318
- declare function inMobile(): boolean; //#endregion
380
+ declare function inMobile(): boolean;
381
+ //#endregion
319
382
  //#region src/general/isArray.d.ts
320
- declare function isArray(val: unknown): val is any[]; //#endregion
383
+ declare function isArray(val: unknown): val is any[];
384
+ //#endregion
321
385
  //#region src/general/isArrayBuffer.d.ts
322
- declare function isArrayBuffer(val: unknown): val is ArrayBuffer; //#endregion
386
+ declare function isArrayBuffer(val: unknown): val is ArrayBuffer;
387
+ //#endregion
323
388
  //#region src/general/isBoolean.d.ts
324
- declare function isBoolean(val: unknown): val is boolean; //#endregion
389
+ declare function isBoolean(val: unknown): val is boolean;
390
+ //#endregion
325
391
  //#region src/general/isDataView.d.ts
326
- declare function isDataView(val: unknown): val is DataView; //#endregion
392
+ declare function isDataView(val: unknown): val is DataView;
393
+ //#endregion
327
394
  //#region src/general/isDate.d.ts
328
- declare function isDate(val: unknown): val is Date; //#endregion
395
+ declare function isDate(val: unknown): val is Date;
396
+ //#endregion
329
397
  //#region src/general/isDOMException.d.ts
330
- declare function isDOMException(val: unknown): val is DOMException; //#endregion
398
+ declare function isDOMException(val: unknown): val is DOMException;
399
+ //#endregion
331
400
  //#region src/general/isEmpty.d.ts
332
- declare function isEmpty(val: unknown): boolean; //#endregion
401
+ declare function isEmpty(val: unknown): boolean;
402
+ //#endregion
333
403
  //#region src/general/isEqual.d.ts
334
- declare function isEqual(value: any, other: any): boolean; //#endregion
404
+ declare function isEqual(value: any, other: any): boolean;
405
+ //#endregion
335
406
  //#region src/general/isEqualWith.d.ts
336
- declare function isEqualWith(value: any, other: any, fn: (value: any, other: any) => any): boolean; //#endregion
407
+ declare function isEqualWith(value: any, other: any, fn: (value: any, other: any) => any): boolean;
408
+ //#endregion
337
409
  //#region src/general/isError.d.ts
338
- declare function isError(val: unknown): val is Error; //#endregion
410
+ declare function isError(val: unknown): val is Error;
411
+ //#endregion
339
412
  //#region src/general/isFunction.d.ts
340
- declare function isFunction(val: unknown): val is Function; //#endregion
413
+ declare function isFunction(val: unknown): val is Function;
414
+ //#endregion
341
415
  //#region src/general/isMap.d.ts
342
- declare function isMap(val: unknown): val is Map<any, any>; //#endregion
416
+ declare function isMap(val: unknown): val is Map<any, any>;
417
+ //#endregion
343
418
  //#region src/general/isNonEmptyArray.d.ts
344
- declare function isNonEmptyArray(val: unknown): val is any[]; //#endregion
419
+ declare function isNonEmptyArray(val: unknown): val is any[];
420
+ //#endregion
345
421
  //#region src/general/isNullish.d.ts
346
- declare function isNullish(val: unknown): val is null | undefined; //#endregion
422
+ declare function isNullish(val: unknown): val is null | undefined;
423
+ //#endregion
347
424
  //#region src/general/isNumber.d.ts
348
- declare function isNumber(val: unknown): val is number; //#endregion
425
+ declare function isNumber(val: unknown): val is number;
426
+ //#endregion
349
427
  //#region src/general/isNumeric.d.ts
350
- declare function isNumeric(val: unknown): val is number | string; //#endregion
428
+ declare function isNumeric(val: unknown): val is number | string;
429
+ //#endregion
351
430
  //#region src/general/isObject.d.ts
352
- declare function isObject(val: unknown): val is Record<string, any>; //#endregion
431
+ declare function isObject(val: unknown): val is Record<string, any>;
432
+ //#endregion
353
433
  //#region src/general/isPlainObject.d.ts
354
- declare function isPlainObject(val: unknown): val is Record<string, any>; //#endregion
434
+ declare function isPlainObject(val: unknown): val is Record<string, any>;
435
+ //#endregion
355
436
  //#region src/general/isPromise.d.ts
356
- declare function isPromise<T = any>(val: unknown): val is Promise<T>; //#endregion
437
+ declare function isPromise<T = any>(val: unknown): val is Promise<T>;
438
+ //#endregion
357
439
  //#region src/general/isRegExp.d.ts
358
- declare function isRegExp(val: unknown): val is RegExp; //#endregion
440
+ declare function isRegExp(val: unknown): val is RegExp;
441
+ //#endregion
359
442
  //#region src/general/isSet.d.ts
360
- declare function isSet(val: unknown): val is Set<any>; //#endregion
443
+ declare function isSet(val: unknown): val is Set<any>;
444
+ //#endregion
361
445
  //#region src/general/isString.d.ts
362
- declare function isString(val: unknown): val is string; //#endregion
446
+ declare function isString(val: unknown): val is string;
447
+ //#endregion
363
448
  //#region src/general/isSymbol.d.ts
364
- declare function isSymbol(val: unknown): val is symbol; //#endregion
449
+ declare function isSymbol(val: unknown): val is symbol;
450
+ //#endregion
365
451
  //#region src/general/isTruthy.d.ts
366
- declare function isTruthy<T>(v: T): v is NonNullable<T>; //#endregion
452
+ declare function isTruthy<T>(v: T): v is NonNullable<T>;
453
+ //#endregion
367
454
  //#region src/general/isTypedArray.d.ts
368
- declare function isTypedArray(val: unknown): val is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; //#endregion
455
+ declare function isTypedArray(val: unknown): val is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
456
+ //#endregion
369
457
  //#region src/general/isWeakMap.d.ts
370
- declare function isWeakMap(val: unknown): val is WeakMap<any, any>; //#endregion
458
+ declare function isWeakMap(val: unknown): val is WeakMap<any, any>;
459
+ //#endregion
371
460
  //#region src/general/isWeakSet.d.ts
372
- declare function isWeakSet(val: unknown): val is WeakSet<any>; //#endregion
461
+ declare function isWeakSet(val: unknown): val is WeakSet<any>;
462
+ //#endregion
373
463
  //#region src/general/isWindow.d.ts
374
- declare function isWindow(val: unknown): val is Window; //#endregion
464
+ declare function isWindow(val: unknown): val is Window;
465
+ //#endregion
375
466
  //#region src/general/supportTouch.d.ts
376
- declare function supportTouch(): boolean; //#endregion
467
+ declare function supportTouch(): boolean;
468
+ //#endregion
377
469
  //#region src/general/toRawType.d.ts
378
- declare function toRawType(value: unknown): string; //#endregion
470
+ declare function toRawType(value: unknown): string;
471
+ //#endregion
379
472
  //#region src/general/toTypeString.d.ts
380
473
  declare const objectToString: typeof Object.prototype.toString;
381
- declare function toTypeString(value: unknown): string; //#endregion
474
+ declare function toTypeString(value: unknown): string;
475
+ //#endregion
382
476
  //#region src/general/isFile.d.ts
383
- declare function isFile(val: unknown): val is File; //#endregion
477
+ declare function isFile(val: unknown): val is File;
478
+ //#endregion
384
479
  //#region src/general/isBlob.d.ts
385
- declare function isBlob(val: unknown): val is Blob; //#endregion
480
+ declare function isBlob(val: unknown): val is Blob;
481
+ //#endregion
386
482
  //#region src/general/isPrimitive.d.ts
387
- declare function isPrimitive(val: unknown): boolean; //#endregion
483
+ declare function isPrimitive(val: unknown): boolean;
484
+ //#endregion
388
485
  //#region src/general/isEmptyPlainObject.d.ts
389
- declare function isEmptyPlainObject(val: unknown): val is Record<string, any>; //#endregion
390
- //#region src/general/assert.d.ts
486
+ declare function isEmptyPlainObject(val: unknown): val is Record<string, any>;
391
487
  //#endregion
392
488
  //#region src/general/hasDuplicates.d.ts
393
- declare function hasDuplicates<T>(arr: T[]): boolean; //#endregion
489
+ declare function hasDuplicates<T>(arr: T[]): boolean;
490
+ //#endregion
394
491
  //#region src/general/hasDuplicatesBy.d.ts
395
- declare function hasDuplicatesBy<T>(arr: T[], fn: (a: T, b: T) => any): boolean; //#endregion
492
+ declare function hasDuplicatesBy<T>(arr: T[], fn: (a: T, b: T) => any): boolean;
493
+ //#endregion
396
494
  //#region src/number/clamp.d.ts
397
- declare function clamp(num: number, min: number, max: number): number; //#endregion
495
+ declare function clamp(num: number, min: number, max: number): number;
496
+ //#endregion
398
497
  //#region src/number/clampArrayRange.d.ts
399
- declare function clampArrayRange(index: number, arr: unknown[]): number; //#endregion
498
+ declare function clampArrayRange(index: number, arr: unknown[]): number;
499
+ //#endregion
400
500
  //#region src/number/delay.d.ts
401
- declare function delay(time: number): Promise<void>; //#endregion
501
+ declare function delay(time: number): Promise<void>;
502
+ //#endregion
402
503
  //#region src/number/randomNumber.d.ts
403
- declare function randomNumber(min?: number, max?: number): number; //#endregion
504
+ declare function randomNumber(min?: number, max?: number): number;
505
+ //#endregion
404
506
  //#region src/number/times.d.ts
405
- declare function times<T>(num: number, fn: (index: number) => T): T[]; //#endregion
507
+ declare function times<T>(num: number, fn: (index: number) => T): T[];
508
+ //#endregion
406
509
  //#region src/number/toNumber.d.ts
407
- declare function toNumber(val: number | string | boolean | undefined | null): number; //#endregion
510
+ declare function toNumber(val: number | string | boolean | undefined | null): number;
511
+ //#endregion
408
512
  //#region src/number/genNumberKey.d.ts
409
- declare function genNumberKey(): number; //#endregion
513
+ declare function genNumberKey(): number;
514
+ //#endregion
410
515
  //#region src/string/maskString.d.ts
411
516
  interface MaskStringOptions {
412
517
  prefix?: number;
@@ -414,70 +519,94 @@ interface MaskStringOptions {
414
519
  mask?: string;
415
520
  maskLength?: number;
416
521
  }
417
- declare function maskString(text: string, {
418
- prefix,
419
- suffix,
420
- mask,
421
- maskLength
422
- }?: MaskStringOptions): string; //#endregion
522
+ declare function maskString(text: string, { prefix, suffix, mask, maskLength }?: MaskStringOptions): string;
523
+ //#endregion
423
524
  //#region src/string/camelize.d.ts
424
- declare function camelize(s: string): string; //#endregion
525
+ declare function camelize(s: string): string;
526
+ //#endregion
425
527
  //#region src/string/ensurePrefix.d.ts
426
- declare function ensurePrefix(s: string, prefix: string): string; //#endregion
528
+ declare function ensurePrefix(s: string, prefix: string): string;
529
+ //#endregion
427
530
  //#region src/string/ensureSuffix.d.ts
428
- declare function ensureSuffix(s: string, suffix: string): string; //#endregion
531
+ declare function ensureSuffix(s: string, suffix: string): string;
532
+ //#endregion
429
533
  //#region src/string/genStringKey.d.ts
430
- declare function genStringKey(): string; //#endregion
534
+ declare function genStringKey(): string;
535
+ //#endregion
431
536
  //#region src/string/kebabCase.d.ts
432
- declare function kebabCase(s: string): string; //#endregion
537
+ declare function kebabCase(s: string): string;
538
+ //#endregion
433
539
  //#region src/string/pascalCase.d.ts
434
- declare function pascalCase(s: string): string; //#endregion
540
+ declare function pascalCase(s: string): string;
541
+ //#endregion
435
542
  //#region src/string/lowerFirst.d.ts
436
- declare function lowerFirst(s: string): string; //#endregion
543
+ declare function lowerFirst(s: string): string;
544
+ //#endregion
437
545
  //#region src/string/upperFirst.d.ts
438
- declare function upperFirst(s: string): string; //#endregion
546
+ declare function upperFirst(s: string): string;
547
+ //#endregion
439
548
  //#region src/string/randomColor.d.ts
440
- declare function randomColor(): string; //#endregion
549
+ declare function randomColor(): string;
550
+ //#endregion
441
551
  //#region src/string/randomString.d.ts
442
- declare function randomString(length?: number): string; //#endregion
552
+ declare function randomString(length?: number): string;
553
+ //#endregion
443
554
  //#region src/string/slash.d.ts
444
- declare function slash(path: string): string; //#endregion
555
+ declare function slash(path: string): string;
556
+ //#endregion
445
557
  //#region src/collection/cloneDeep.d.ts
446
- declare function cloneDeep<T>(value: T): T; //#endregion
558
+ declare function cloneDeep<T>(value: T): T;
559
+ //#endregion
447
560
  //#region src/collection/cloneDeepWith.d.ts
448
- declare function cloneDeepWith<T>(value: T, fn: (value: any) => any): T; //#endregion
561
+ declare function cloneDeepWith<T>(value: T, fn: (value: any) => any): T;
562
+ //#endregion
449
563
  //#region src/collection/merge.d.ts
450
- declare function merge<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: K[]): T & K; //#endregion
564
+ declare function merge<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: K[]): T & K;
565
+ //#endregion
451
566
  //#region src/collection/mergeWith.d.ts
452
567
  type Fn = (objValue: any, srcValue: any, key: string | number | symbol, object?: any, source?: any) => any;
453
- declare function mergeWith<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: [...K[], fn: Fn]): T & K; //#endregion
568
+ declare function mergeWith<T extends Record<string, any>, K extends Record<string, any>>(object: T, ...sources: [...K[], fn: Fn]): T & K;
569
+ //#endregion
454
570
  //#region src/file/toArrayBuffer.d.ts
455
- declare function toArrayBuffer(file: File): Promise<ArrayBuffer>; //#endregion
571
+ declare function toArrayBuffer(file: File): Promise<ArrayBuffer>;
572
+ //#endregion
456
573
  //#region src/file/toDataURL.d.ts
457
- declare function toDataURL(file: File): Promise<string>; //#endregion
574
+ declare function toDataURL(file: File): Promise<string>;
575
+ //#endregion
458
576
  //#region src/file/toText.d.ts
459
- declare function toText(file: File): Promise<string>; //#endregion
577
+ declare function toText(file: File): Promise<string>;
578
+ //#endregion
460
579
  //#region src/math/maxBy.d.ts
461
- declare function maxBy<T>(arr: T[], fn: (val: T) => number): T; //#endregion
580
+ declare function maxBy<T>(arr: T[], fn: (val: T) => number): T;
581
+ //#endregion
462
582
  //#region src/math/minBy.d.ts
463
- declare function minBy<T>(arr: T[], fn: (val: T) => number): T; //#endregion
583
+ declare function minBy<T>(arr: T[], fn: (val: T) => number): T;
584
+ //#endregion
464
585
  //#region src/math/sum.d.ts
465
- declare function sum(arr: number[]): number; //#endregion
586
+ declare function sum(arr: number[]): number;
587
+ //#endregion
466
588
  //#region src/math/sumBy.d.ts
467
- declare function sumBy<T>(arr: T[], fn: (val: T) => number): number; //#endregion
589
+ declare function sumBy<T>(arr: T[], fn: (val: T) => number): number;
590
+ //#endregion
468
591
  //#region src/math/sumHash.d.ts
469
- declare function sumHash(value: any): string; //#endregion
592
+ declare function sumHash(value: any): string;
593
+ //#endregion
470
594
  //#region src/math/mean.d.ts
471
- declare function mean(arr: number[]): number; //#endregion
595
+ declare function mean(arr: number[]): number;
596
+ //#endregion
472
597
  //#region src/math/meanBy.d.ts
473
- declare function meanBy<T>(arr: T[], fn: (val: T) => number): number; //#endregion
598
+ declare function meanBy<T>(arr: T[], fn: (val: T) => number): number;
599
+ //#endregion
474
600
  //#region src/math/sample.d.ts
475
- declare function sample<T>(arr: T[]): T | undefined; //#endregion
601
+ declare function sample<T>(arr: T[]): T | undefined;
602
+ //#endregion
476
603
  //#region src/math/round.d.ts
477
604
  declare function round(val: number, precision?: number): number;
478
- declare function baseRound(val: number, precision: number, fn: (val: number) => number): number; //#endregion
605
+ declare function baseRound(val: number, precision: number, fn: (val: number) => number): number;
606
+ //#endregion
479
607
  //#region src/math/floor.d.ts
480
- declare function floor(val: number, precision?: number): number; //#endregion
608
+ declare function floor(val: number, precision?: number): number;
609
+ //#endregion
481
610
  //#region src/math/ceil.d.ts
482
611
  declare function ceil(val: number, precision?: number): number;
483
612
  //#endregion
package/lib/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "rattail";
2
-
3
2
  //#region src/index.d.ts
4
3
  declare function assert(condition: boolean, source: string, message: string): asserts condition;
5
4
  declare function warn(source: string, message: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/shared",
3
- "version": "3.19.3",
3
+ "version": "3.20.0",
4
4
  "description": "shared utils of varlet",
5
5
  "keywords": [
6
6
  "shared",
@@ -32,12 +32,12 @@
32
32
  "lib"
33
33
  ],
34
34
  "dependencies": {
35
- "rattail": "^2.0.9"
35
+ "rattail": "^2.1.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^20.19.0",
39
39
  "typescript": "5.6.3",
40
- "vite-plus": "0.1.18"
40
+ "vite-plus": "0.2.6"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vp pack",