@pawover/kit 0.0.0-beta.9 → 0.1.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.
Files changed (47) hide show
  1. package/package.json +94 -70
  2. package/packages/hooks/dist/alova.d.ts +30 -0
  3. package/packages/hooks/dist/alova.js +64 -0
  4. package/packages/hooks/dist/index.d.ts +1 -0
  5. package/packages/hooks/dist/index.js +0 -0
  6. package/packages/hooks/dist/metadata.json +15 -0
  7. package/packages/hooks/dist/react.d.ts +155 -0
  8. package/packages/hooks/dist/react.js +2678 -0
  9. package/packages/utils/dist/index.d.ts +4884 -0
  10. package/packages/utils/dist/index.js +1741 -0
  11. package/packages/utils/dist/math.d.ts +58 -0
  12. package/packages/utils/dist/math.js +56 -0
  13. package/packages/utils/dist/metadata.json +14 -0
  14. package/packages/utils/dist/string-C_OCj9Lg.js +950 -0
  15. package/packages/utils/dist/vite.d.ts +29 -0
  16. package/packages/utils/dist/vite.js +39 -0
  17. package/packages/zod/dist/index.d.ts +58 -0
  18. package/packages/zod/dist/index.js +61 -0
  19. package/dist/enums.d.ts +0 -25
  20. package/dist/enums.d.ts.map +0 -1
  21. package/dist/enums.js +0 -25
  22. package/dist/enums.js.map +0 -1
  23. package/dist/hooks-alova.d.ts +0 -23
  24. package/dist/hooks-alova.d.ts.map +0 -1
  25. package/dist/hooks-alova.js +0 -39
  26. package/dist/hooks-alova.js.map +0 -1
  27. package/dist/hooks-react.d.ts +0 -95
  28. package/dist/hooks-react.d.ts.map +0 -1
  29. package/dist/hooks-react.js +0 -328
  30. package/dist/hooks-react.js.map +0 -1
  31. package/dist/index.d.ts +0 -3726
  32. package/dist/index.d.ts.map +0 -1
  33. package/dist/index.js +0 -1469
  34. package/dist/index.js.map +0 -1
  35. package/dist/patches-fetchEventSource.d.ts +0 -815
  36. package/dist/patches-fetchEventSource.d.ts.map +0 -1
  37. package/dist/patches-fetchEventSource.js +0 -316
  38. package/dist/patches-fetchEventSource.js.map +0 -1
  39. package/dist/vite.d.ts +0 -13
  40. package/dist/vite.d.ts.map +0 -1
  41. package/dist/vite.js +0 -23
  42. package/dist/vite.js.map +0 -1
  43. package/dist/zod.d.ts +0 -109
  44. package/dist/zod.d.ts.map +0 -1
  45. package/dist/zod.js +0 -143
  46. package/dist/zod.js.map +0 -1
  47. package/metadata.json +0 -167
@@ -0,0 +1,4884 @@
1
+ //#region src/array/index.type.d.ts
2
+ type MatchFunction<T, R = unknown> = (row: T, index: number) => R;
3
+ //#endregion
4
+ //#region src/array/arrayUtil.d.ts
5
+ /**
6
+ * 数组工具类
7
+ */
8
+ declare class ArrayUtil {
9
+ /**
10
+ * 构造数组
11
+ * @param candidate 待构造项
12
+ * @param checkEmpty 是否检查 `undefined` 和 `null`,默认为 `true`
13
+ * @returns 构造后的数组
14
+ * @example
15
+ * ```ts
16
+ * // 重载 1: checkEmpty = true (默认)
17
+ * ArrayUtil.cast(1); // [1]
18
+ * ArrayUtil.cast(null); // []
19
+ *
20
+ * // 重载 2: checkEmpty = false
21
+ * ArrayUtil.cast(null, false); // [null]
22
+ *
23
+ * // 通用场景
24
+ * ArrayUtil.cast([1, 2]); // [1, 2]
25
+ * ArrayUtil.cast(undefined); // []
26
+ * ```
27
+ */
28
+ static cast<T>(candidate: T | T[] | null | undefined, checkEmpty?: true): NonNullable<T>[];
29
+ static cast<T>(candidate: T | T[] | null | undefined, checkEmpty?: false): T[];
30
+ /**
31
+ * 获取数组第一项
32
+ *
33
+ * @param initialList 初始数组
34
+ * @param fallback 回退值
35
+ * @returns 数组第一项,如果为空则返回回退值
36
+ * @example
37
+ * ```ts
38
+ * // 重载 1: 无 fallback
39
+ * ArrayUtil.first([1, 2]); // 1
40
+ * ArrayUtil.first([]); // undefined
41
+ *
42
+ * // 重载 2: 有 fallback
43
+ * ArrayUtil.first([], 0); // 0
44
+ * ```
45
+ */
46
+ static first<T>(initialList: readonly T[]): T | undefined;
47
+ static first<T>(initialList: readonly T[], fallback: T): T;
48
+ /**
49
+ * 获取数组最后一项
50
+ *
51
+ * @param initialList 初始数组
52
+ * @param fallback 回退值
53
+ * @returns 数组最后一项,如果为空则返回回退值
54
+ * @example
55
+ * ```ts
56
+ * // 重载 1: 无 fallback
57
+ * ArrayUtil.last([1, 2, 3]); // 3
58
+ * ArrayUtil.last([]); // undefined
59
+ *
60
+ * // 重载 2: 有 fallback
61
+ * ArrayUtil.last([], 0); // 0
62
+ * ```
63
+ */
64
+ static last<T>(initialList: readonly T[]): T | undefined;
65
+ static last<T>(initialList: readonly T[], fallback: T): T;
66
+ /**
67
+ * 数组竞选
68
+ * - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
69
+ *
70
+ * @param initialList 数组
71
+ * @param match 匹配函数
72
+ * @returns 获胜的元素,如果数组为空或参数无效则返回 `null`
73
+ * @example
74
+ * ```ts
75
+ * const list = [1, 10, 5];
76
+ * ArrayUtil.compete(list, (a, b) => (a > b ? a : b)); // 10
77
+ * ArrayUtil.compete(list, (a, b) => (a < b ? a : b)); // 1
78
+ * ```
79
+ */
80
+ static compete<T>(initialList: readonly T[], match: (a: T, b: T, index: number) => T): T | null;
81
+ /**
82
+ * 统计数组的项目出现次数
83
+ * - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
84
+ *
85
+ * @param initialList 初始数组
86
+ * @param match 匹配函数
87
+ * @returns 统计对象
88
+ * @example
89
+ * ```ts
90
+ * const list = ["a", "b", "a", "c"];
91
+ * ArrayUtil.count(list, (x) => x); // { a: 2, b: 1, c: 1 }
92
+ *
93
+ * const users = [{ id: 1, group: "A" }, { id: 2, group: "B" }, { id: 3, group: "A" }];
94
+ * ArrayUtil.count(users, (u) => u.group); // { A: 2, B: 1 }
95
+ * ```
96
+ */
97
+ static count<T, K extends PropertyKey>(initialList: readonly T[], match: MatchFunction<T, K>): Record<string, number>;
98
+ /**
99
+ * 获取数组差集
100
+ * - 返回在 `initialList` 中存在,但在 `diffList` 中不存在的元素
101
+ *
102
+ * @param initialList 初始数组
103
+ * @param diffList 对比数组
104
+ * @param match 匹配函数
105
+ * @returns 差集数组
106
+ * @example
107
+ * ```ts
108
+ * ArrayUtil.difference([1, 2, 3], [2, 3, 4]); // [1]
109
+ * ArrayUtil.difference([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 1 }]
110
+ * ```
111
+ */
112
+ static difference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T, index: number) => unknown): T[];
113
+ /**
114
+ * 获取数组交集
115
+ * - 返回在 `initialList` 和 `diffList` 中都存在的元素
116
+ *
117
+ * @param initialList 初始数组
118
+ * @param diffList 对比数组
119
+ * @param match 匹配函数
120
+ * @returns 交集数组
121
+ * @example
122
+ * ```ts
123
+ * // 重载 1: 按元素本身比较
124
+ * ArrayUtil.intersection([1, 2], [2, 3]); // [2]
125
+ *
126
+ * // 重载 2: 按 match 结果比较
127
+ * ArrayUtil.intersection([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 2 }]
128
+ * ```
129
+ */
130
+ static intersection<T>(initialList: readonly T[], diffList: readonly T[]): T[];
131
+ static intersection<T, D = T>(initialList: readonly T[], diffList: readonly D[], match: MatchFunction<T>): T[];
132
+ /**
133
+ * 数组合并
134
+ * - 如果未提供 `match` 函数,则合并两个数组并去重(Union)
135
+ * - 如果提供了 `match` 函数,则仅更新 `initialList` 中匹配到的项(Left Join Update),不会追加 `mergeList` 中新增的项
136
+ *
137
+ * @param initialList 初始数组
138
+ * @param mergeList 待合并数组
139
+ * @param match 匹配函数
140
+ * @returns 合并后的数组
141
+ * @example
142
+ * ```ts
143
+ * // 重载 1: 基础合并去重
144
+ * ArrayUtil.merge([1, 2], [2, 3]); // [1, 2, 3]
145
+ * ArrayUtil.merge([], [1, 2, 3]); // [1, 2, 3]
146
+ *
147
+ * // 重载 2: 按条件更新
148
+ * const source = [{ id: 1, val: "a" }, { id: 2, val: "b" }];
149
+ * const update = [{ id: 2, val: "new" }, { id: 3, val: "c" }];
150
+ * ArrayUtil.merge(source, update, (x) => x.id); // [{ id: 1, val: "a" }, { id: 2, val: "new" }] -> id:3 被忽略
151
+ * ```
152
+ */
153
+ static merge<T>(initialList: readonly T[], mergeList: readonly T[]): T[];
154
+ static merge<T, D = T>(initialList: readonly T[], mergeList: readonly D[], match: MatchFunction<T>): T[];
155
+ /**
156
+ * 数组选择
157
+ * - 一次性应用 `filter` 和 `map` 操作
158
+ *
159
+ * @param initialList 初始数组
160
+ * @param filter filter 函数
161
+ * @param mapper map 函数
162
+ * @returns 处理后的新数组
163
+ * @example
164
+ * ```ts
165
+ * const list = [1, 2, 3, 4];
166
+ *
167
+ * // 重载 1: 仅过滤
168
+ * ArrayUtil.pick(list, (n) => n % 2 === 0); // [2, 4]
169
+ *
170
+ * // 重载 2: 过滤 + 映射
171
+ * ArrayUtil.pick(list, (n) => n % 2 === 0, (n) => n * 2); // [4, 8]
172
+ * ```
173
+ */
174
+ static pick<const T>(initialList: readonly T[], filter: (row: T, index: number) => boolean): T[];
175
+ static pick<const T, K = T>(initialList: readonly T[], filter: (row: T, index: number) => boolean, mapper: (row: T, index: number) => K): K[];
176
+ /**
177
+ * 数组项替换
178
+ * - 在给定的数组中,替换符合匹配函数结果的项目
179
+ * - 只替换第一个匹配项
180
+ *
181
+ * @param initialList 初始数组
182
+ * @param newItem 替换项
183
+ * @param match 匹配函数
184
+ * @returns 替换后的新数组
185
+ * @example
186
+ * ```ts
187
+ * // 重载 1/2: newItem 与数组元素类型兼容
188
+ * ArrayUtil.replace([1, 2, 3], 4, (n) => n === 2); // [1, 4, 3]
189
+ *
190
+ * // 重载 3: newItem 可扩展为新类型
191
+ * ArrayUtil.replace([1, 2, 3], "X", (n) => n === 2); // [1, "X", 3]
192
+ * ```
193
+ */
194
+ static replace<const T>(initialList: readonly T[], newItem: T, match: MatchFunction<T, boolean>): T[];
195
+ static replace<const T, K extends T>(initialList: readonly T[], newItem: K, match: MatchFunction<T, boolean>): T[];
196
+ static replace<const T, K>(initialList: readonly T[], newItem: K, match: MatchFunction<T, boolean>): (T | K)[];
197
+ /**
198
+ * 数组项替换并移动
199
+ * - 在给定的数组中,替换并移动符合匹配函数结果的项目
200
+ * - 只替换和移动第一个匹配项
201
+ * - 未匹配时,根据 `position` 在指定位置插入 `newItem`
202
+ *
203
+ * @param initialList 初始数组
204
+ * @param newItem 替换项
205
+ * @param match 匹配函数
206
+ * @param position 移动位置,可选 `start` | `end` | 索引位置, 默认为 `end`
207
+ * @returns
208
+ * @example
209
+ * ```ts
210
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, 0); // [5, 1, 3, 4]
211
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, 2); // [1, 3, 5, 4]
212
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, "start"); // [5, 1, 3, 4]
213
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2); // [1, 3, 4, 5]
214
+ * ```
215
+ */
216
+ static replaceMove<const T>(initialList: readonly T[], newItem: T, match: MatchFunction<T, boolean>, position?: "start" | "end" | number): T[];
217
+ /**
218
+ * 数组切分
219
+ * - 将数组以指定的长度切分后,组合在高维数组中
220
+ *
221
+ * @param initialList 初始数组
222
+ * @param size 分割尺寸,默认 `10`
223
+ * @returns 切分后的二维数组
224
+ * @example
225
+ * ```ts
226
+ * ArrayUtil.split([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
227
+ * ```
228
+ */
229
+ static split<T>(initialList: readonly T[], size?: number): T[][];
230
+ /**
231
+ * 数组分组过滤
232
+ * - 给定一个数组和一个条件,返回一个由两个数组组成的元组,其中第一个数组包含所有满足条件的项,第二个数组包含所有不满足条件的项
233
+ *
234
+ * @param initialList 初始数组
235
+ * @param match 条件匹配函数
236
+ * @returns [满足条件的项[], 不满足条件的项[]]
237
+ * @example
238
+ * ```ts
239
+ * ArrayUtil.fork([1, 2, 3, 4], (n) => n % 2 === 0); // [[2, 4], [1, 3]]
240
+ * ```
241
+ */
242
+ static fork<T>(initialList: readonly T[], match: MatchFunction<T, boolean>): [T[], T[]];
243
+ /**
244
+ * 数组解压
245
+ * - `ArrayUtil.zip` 的反向操作
246
+ *
247
+ * @param arrayList 压缩后的数组
248
+ * @returns 解压后的二维数组
249
+ * @example
250
+ * ```ts
251
+ * ArrayUtil.unzip([[1, "a"], [2, "b"]]); // [[1, 2], ["a", "b"]]
252
+ * ```
253
+ */
254
+ static unzip<T>(arrayList: readonly (readonly T[])[]): T[][];
255
+ /**
256
+ * 数组压缩
257
+ * - 将多个数组的元素按索引组合成元组
258
+ *
259
+ * @param arrays 多个数组
260
+ * @returns 压缩后的元组数组
261
+ * @example
262
+ * ```ts
263
+ * // 重载 1: 两个数组
264
+ * ArrayUtil.zip([1, 2], ["a", "b"]); // [[1, "a"], [2, "b"]]
265
+ *
266
+ * // 重载 2: 三个数组
267
+ * ArrayUtil.zip([1, 2], ["a", "b"], [true, false]); // [[1, "a", true], [2, "b", false]]
268
+ *
269
+ * // 重载 3: 四个数组
270
+ * ArrayUtil.zip([1], ["a"], [true], ["x"]); // [[1, "a", true, "x"]]
271
+ *
272
+ * // 重载 4: 五个数组
273
+ * ArrayUtil.zip([1], ["a"], [true], ["x"], [9]); // [[1, "a", true, "x", 9]]
274
+ *
275
+ * // 重载 5: 空参数
276
+ * ArrayUtil.zip(); // []
277
+ * ```
278
+ */
279
+ static zip<T1, T2, T3, T4, T5>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[], array5: readonly T5[]): [T1, T2, T3, T4, T5][];
280
+ static zip<T1, T2, T3, T4>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[]): [T1, T2, T3, T4][];
281
+ static zip<T1, T2, T3>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[]): [T1, T2, T3][];
282
+ static zip<T1, T2>(array1: readonly T1[], array2: readonly T2[]): [T1, T2][];
283
+ static zip(): [];
284
+ /**
285
+ * 数组压缩为对象
286
+ * - 将键数组和值(数组、函数或静态值)组合成对象
287
+ *
288
+ * @param keys 键数组
289
+ * @param values 值数组、生成值的函数或静态值
290
+ * @returns 生成的对象
291
+ * @example
292
+ * ```ts
293
+ * // 重载 1: 传值数组
294
+ * ArrayUtil.zipToObject(["a", "b"], [1, 2]); // { a: 1, b: 2 }
295
+ *
296
+ * // 重载 2: 传生成函数
297
+ * ArrayUtil.zipToObject(["a", "b"], (k, i) => k + i); // { a: "a0", b: "b1" }
298
+ *
299
+ * // 重载 3: 传静态值
300
+ * ArrayUtil.zipToObject(["a", "b"], 1); // { a: 1, b: 1 }
301
+ * ```
302
+ */
303
+ static zipToObject<const K extends PropertyKey, const V>(keys: readonly K[], array: readonly V[]): Record<K, V>;
304
+ static zipToObject<const K extends PropertyKey, const V>(keys: readonly K[], match: MatchFunction<K, V>): Record<K, V>;
305
+ static zipToObject<const K extends PropertyKey, const V>(keys: readonly K[], value: V): Record<K, V>;
306
+ }
307
+ //#endregion
308
+ //#region src/dateTime/dateTimeUtil.d.ts
309
+ /**
310
+ * 日期工具类
311
+ */
312
+ declare class DateTimeUtil {
313
+ /**
314
+ * 每秒的毫秒数
315
+ * @example
316
+ * ```ts
317
+ * DateTimeUtil.MILLISECONDS_PER_SECOND; // 1000
318
+ * ```
319
+ */
320
+ static readonly MILLISECONDS_PER_SECOND: number;
321
+ /**
322
+ * 每分钟的秒数
323
+ * @example
324
+ * ```ts
325
+ * DateTimeUtil.SECOND_PER_MINUTE; // 60
326
+ * ```
327
+ */
328
+ static readonly SECOND_PER_MINUTE: number;
329
+ /**
330
+ * 每小时的分钟数
331
+ * @example
332
+ * ```ts
333
+ * DateTimeUtil.MINUTE_PER_HOUR; // 60
334
+ * ```
335
+ */
336
+ static readonly MINUTE_PER_HOUR: number;
337
+ /**
338
+ * 每小时的秒数
339
+ * @example
340
+ * ```ts
341
+ * DateTimeUtil.SECOND_PER_HOUR; // 3600
342
+ * ```
343
+ */
344
+ static readonly SECOND_PER_HOUR: number;
345
+ /**
346
+ * 每天小时数
347
+ * @example
348
+ * ```ts
349
+ * DateTimeUtil.HOUR_PER_DAY; // 24
350
+ * ```
351
+ */
352
+ static readonly HOUR_PER_DAY: number;
353
+ /**
354
+ * 每天秒数
355
+ * @example
356
+ * ```ts
357
+ * DateTimeUtil.SECOND_PER_DAY; // 86400
358
+ * ```
359
+ */
360
+ static readonly SECOND_PER_DAY: number;
361
+ /**
362
+ * 每周天数
363
+ * @example
364
+ * ```ts
365
+ * DateTimeUtil.DAY_PER_WEEK; // 7
366
+ * ```
367
+ */
368
+ static readonly DAY_PER_WEEK: number;
369
+ /**
370
+ * 每月天数
371
+ * @example
372
+ * ```ts
373
+ * DateTimeUtil.DAY_PER_MONTH; // 30
374
+ * ```
375
+ */
376
+ static readonly DAY_PER_MONTH: number;
377
+ /**
378
+ * 每年天数
379
+ * @example
380
+ * ```ts
381
+ * DateTimeUtil.DAY_PER_YEAR; // 365
382
+ * ```
383
+ */
384
+ static readonly DAY_PER_YEAR: number;
385
+ /**
386
+ * 每年月数
387
+ * @example
388
+ * ```ts
389
+ * DateTimeUtil.MONTH_PER_YEAR; // 12
390
+ * ```
391
+ */
392
+ static readonly MONTH_PER_YEAR: number;
393
+ /**
394
+ * 每年平均周
395
+ * @example
396
+ * ```ts
397
+ * DateTimeUtil.WEEK_PER_YEAR; // 52
398
+ * ```
399
+ */
400
+ static readonly WEEK_PER_YEAR: number;
401
+ /**
402
+ * 每月平均周
403
+ * @example
404
+ * ```ts
405
+ * DateTimeUtil.WEEK_PER_MONTH; // 4
406
+ * ```
407
+ */
408
+ static readonly WEEK_PER_MONTH: number;
409
+ /**
410
+ * 常用时间格式模板集合
411
+ *
412
+ * @example
413
+ * ```ts
414
+ * DateTimeUtil.FORMAT.ISO_DATE; // "yyyy-MM-dd"
415
+ * DateTimeUtil.FORMAT.CN_DATE_TIME; // "yyyy年MM月dd日 HH时mm分ss秒"
416
+ * ```
417
+ */
418
+ static readonly FORMAT: {
419
+ readonly ISO_DATE: "yyyy-MM-dd";
420
+ readonly ISO_TIME: "HH:mm:ss";
421
+ readonly ISO_DATE_TIME: "yyyy-MM-dd HH:mm:ss";
422
+ readonly ISO_DATE_TIME_MS: "yyyy-MM-dd HH:mm:ss.SSS";
423
+ readonly ISO_DATETIME_TZ: "yyyy-MM-dd'T'HH:mm:ssXXX";
424
+ readonly ISO_DATETIME_TZ_MS: "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";
425
+ readonly US_DATE: "MM/dd/yyyy";
426
+ readonly US_DATE_TIME: "MM/dd/yyyy HH:mm:ss";
427
+ readonly US_DATE_SHORT_YEAR: "MM/dd/yy";
428
+ readonly EU_DATE: "dd/MM/yyyy";
429
+ readonly EU_DATE_TIME: "dd/MM/yyyy HH:mm:ss";
430
+ readonly CN_DATE: "yyyy年MM月dd日";
431
+ readonly CN_DATE_TIME: "yyyy年MM月dd日 HH时mm分ss秒";
432
+ readonly CN_DATE_WEEKDAY: "yyyy年MM月dd日 EEE";
433
+ readonly CN_WEEKDAY_FULL: "EEEE";
434
+ readonly SHORT_DATE: "yy-MM-dd";
435
+ readonly SHORT_DATE_SLASH: "yy/MM/dd";
436
+ readonly MONTH_DAY: "MM-dd";
437
+ readonly MONTH_DAY_CN: "MM月dd日";
438
+ readonly DATE_WITH_WEEKDAY_SHORT: "yyyy-MM-dd (EEE)";
439
+ readonly DATE_WITH_WEEKDAY_FULL: "yyyy-MM-dd (EEEE)";
440
+ readonly TIME_24: "HH:mm:ss";
441
+ readonly TIME_24_NO_SEC: "HH:mm";
442
+ readonly TIME_12: "hh:mm:ss a";
443
+ readonly TIME_12_NO_SEC: "hh:mm a";
444
+ readonly TIMESTAMP: "yyyyMMddHHmmss";
445
+ readonly TIMESTAMP_MS: "yyyyMMddHHmmssSSS";
446
+ readonly RFC2822: "EEE, dd MMM yyyy HH:mm:ss xxx";
447
+ readonly READABLE_DATE: "MMM dd, yyyy";
448
+ readonly READABLE_DATE_TIME: "MMM dd, yyyy HH:mm";
449
+ readonly COMPACT_DATETIME: "yyyyMMdd_HHmmss";
450
+ };
451
+ /**
452
+ * 获取当前时区信息
453
+ *
454
+ * @returns 时区信息对象 (UTC偏移和时区名称)
455
+ * @example
456
+ * ```ts
457
+ * DateTimeUtil.getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
458
+ * ```
459
+ */
460
+ static getTimeZone(): {
461
+ UTC: string;
462
+ timeZone: string;
463
+ };
464
+ }
465
+ //#endregion
466
+ //#region src/env/envUtil.d.ts
467
+ /**
468
+ * 环境检查工具类
469
+ */
470
+ declare class EnvUtil {
471
+ private static readonly _isBrowser;
472
+ private static readonly _isWebWorker;
473
+ private static readonly _isReactNative;
474
+ /**
475
+ * 检测是否处于浏览器环境
476
+ *
477
+ * @returns 是否为浏览器环境
478
+ * @example
479
+ * ```ts
480
+ * EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
481
+ * ```
482
+ */
483
+ static isBrowser(): boolean;
484
+ /**
485
+ * 检测是否处于 Web Worker 环境
486
+ *
487
+ * @returns 是否为 Web Worker 环境
488
+ * @example
489
+ * ```ts
490
+ * EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
491
+ * ```
492
+ */
493
+ static isWebWorker(): boolean;
494
+ /**
495
+ * 检测是否处于 React Native 环境
496
+ *
497
+ * @returns 是否为 React Native 环境
498
+ * @example
499
+ * ```ts
500
+ * EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
501
+ * ```
502
+ */
503
+ static isReactNative(): boolean;
504
+ /**
505
+ * 检查是否在 iframe 环境中
506
+ *
507
+ * @returns 是否在 iframe 中
508
+ * @example
509
+ * ```ts
510
+ * EnvUtil.isIframe(); // true: 当前页面在 iframe 中
511
+ * ```
512
+ */
513
+ static isIframe(): boolean;
514
+ /**
515
+ * 检测当前设备是否为桌面设备
516
+ *
517
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
518
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
519
+ * @param dpi - 标准 DPI 基准(默认 160)
520
+ * @returns 是否为桌面设备
521
+ * @example
522
+ * ```ts
523
+ * // 假设 window.innerWidth = 1920
524
+ * EnvUtil.isDesktop(); // true
525
+ *
526
+ * // 自定义阈值
527
+ * EnvUtil.isDesktop(1440, 13); // 更严格的桌面检测
528
+ * ```
529
+ */
530
+ static isDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
531
+ /**
532
+ * 检测当前设备是否为 Windows 桌面设备
533
+ *
534
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
535
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
536
+ * @param dpi - 标准 DPI 基准(默认 160)
537
+ * @returns 是否为 Windows 桌面设备
538
+ * @example
539
+ * ```ts
540
+ * // UA contains Windows
541
+ * EnvUtil.isWindowsDesktop(); // true
542
+ * ```
543
+ */
544
+ static isWindowsDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
545
+ /**
546
+ * 检测当前设备是否为 macOS 桌面设备
547
+ *
548
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
549
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
550
+ * @param dpi - 标准 DPI 基准(默认 160)
551
+ * @returns 是否为 macOS 桌面设备
552
+ * @example
553
+ * ```ts
554
+ * // UA contains Macintosh
555
+ * EnvUtil.isMacOSDesktop(); // true
556
+ * ```
557
+ */
558
+ static isMacOSDesktop(minWidth?: number, minScreenSize?: number, dpi?: number): boolean;
559
+ /**
560
+ * 检测当前设备是否为移动设备
561
+ *
562
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
563
+ * @param dpi - 标准 DPI 基准(默认 160)
564
+ * @returns 是否为移动设备
565
+ * @example
566
+ * ```ts
567
+ * // 假设 window.innerWidth = 500
568
+ * EnvUtil.isMobile(); // true
569
+ * ```
570
+ */
571
+ static isMobile(maxWidth?: number, dpi?: number): boolean;
572
+ /**
573
+ * 检测当前设备是否为IOS移动设备
574
+ *
575
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
576
+ * @param dpi - 标准 DPI 基准(默认 160)
577
+ * @returns 是否为 iOS 移动设备 (iPhone/iPod)
578
+ * @example
579
+ * ```ts
580
+ * // UA contains iPhone
581
+ * EnvUtil.isIOSMobile(); // true
582
+ * ```
583
+ */
584
+ static isIOSMobile(maxWidth?: number, dpi?: number): boolean;
585
+ /**
586
+ * 检测当前设备是否为平板
587
+ *
588
+ * @param minWidth - 平板最小宽度(默认 768px)
589
+ * @param maxWidth - 平板最大宽度(默认 1200px)
590
+ * @param dpi - 标准 DPI 基准(默认 160)
591
+ * @returns 是否为平板设备
592
+ * @example
593
+ * ```ts
594
+ * // 假设 window.innerWidth = 1000
595
+ * EnvUtil.isTablet(); // true
596
+ * ```
597
+ */
598
+ static isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
599
+ }
600
+ //#endregion
601
+ //#region ../../node_modules/.pnpm/@pawover+types@0.0.2_@types+react@19.2.15_typescript@6.0.3/node_modules/@pawover/types/dist/index.d.ts
602
+ //#endregion
603
+ //#region src/global.d.ts
604
+ /** 任意对象类型 */
605
+ type AnyObject<K extends PropertyKey = PropertyKey, T = any> = Record<K, T>;
606
+ /** 普通对象类型 */
607
+ type PlainObject<K extends PropertyKey = PropertyKey, T = unknown> = Record<K, T>;
608
+ /** 描述树类型 */
609
+ type TreeLike<T extends AnyObject, CK extends string = "children"> = T & Record<CK, TreeLike<T, CK>[]>;
610
+ /** 描述函数类型 */
611
+ type AnyFunction<P extends any[] = any[], R = any> = (...arg: P) => R;
612
+ /** 描述异步函数类型 */
613
+ type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promise<R>;
614
+ /** 描述生成器函数类型 */
615
+ type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
616
+ /** 描述异步生成器函数类型 */
617
+ type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
618
+ /** 描述无返回值函数 */
619
+ //#endregion
620
+ //#region src/function/functionUtil.d.ts
621
+ /**
622
+ * 函数工具类
623
+ */
624
+ declare class FunctionUtil {
625
+ /**
626
+ *将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
627
+ *
628
+ * @param promise 待处理的 Promise
629
+ * @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
630
+ * @returns `[err, null]` 或 `[null, data]`
631
+ * @example
632
+ * ```ts
633
+ * const [err, data] = await FunctionUtil.to(someAsyncFunc());
634
+ * ```
635
+ */
636
+ static to<T, U = Error>(promise: Readonly<Promise<T>>, errorExt?: PlainObject): Promise<[U, undefined] | [null, T]>;
637
+ /**
638
+ * 将 Arguments 对象转换为数组
639
+ *
640
+ * ⚠️ 注意:TypeScript 官方推荐使用 rest parameters (...args) 替代 arguments
641
+ * 本函数仅用于处理遗留代码或特殊场景(如装饰器中需保留 this 绑定)
642
+ *
643
+ * @param args Arguments 对象(必须为类数组对象)
644
+ * @param start 起始索引(可选,默认为 0)
645
+ * @returns 转换后的数组,元素类型为 T
646
+ *
647
+ * @throws TypeError 如果 args 为 null 或 undefined
648
+ *
649
+ * @example
650
+ * ```ts
651
+ * // 遗留代码场景
652
+ * function legacyFn(a: number, b: string) {
653
+ * const argsArray = FunctionUtil.toArgs(arguments);
654
+ * // argsArray: unknown[]
655
+ * }
656
+ *
657
+ * // 现代替代方案(推荐)
658
+ * function modernFn(a: number, b: string, ...rest: unknown[]) {
659
+ * // rest 已经是数组,无需 toArgs
660
+ * }
661
+ *
662
+ * // 参数截取
663
+ * function skipFirst(...args: unknown[]) {
664
+ * const rest = FunctionUtil.toArgs(arguments, 1);
665
+ * // rest: unknown[],跳过第一个参数
666
+ * }
667
+ * ```
668
+ */
669
+ static toArgs<T = unknown>(args: IArguments, start?: number | undefined): T[];
670
+ /**
671
+ * 将同步或异步函数统一包装为 Promise
672
+ * - 自动捕获同步异常
673
+ *
674
+ * @param fn 返回值可为同步值或 Promise 的函数
675
+ * @returns 标准化的 Promise
676
+ *
677
+ * @example
678
+ * ```ts
679
+ * // 同步函数
680
+ * FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
681
+ *
682
+ * // 异步函数
683
+ * FunctionUtil.toPromise(async () => await fetchData()).then(data => ...);
684
+ *
685
+ * // 异常处理
686
+ * FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
687
+ * ```
688
+ */
689
+ static toPromise<T>(fn: () => T | Promise<T>): Promise<T>;
690
+ }
691
+ //#endregion
692
+ //#region src/mime/mimeUtil.d.ts
693
+ /**
694
+ * MIME 工具类
695
+ */
696
+ declare class MimeUtil {
697
+ /**
698
+ * 标准 MIME 类型常量,用于文件类型标识和 HTTP Content-Type 头部
699
+ * 基于 IANA 注册标准和浏览器兼容性验证
700
+ */
701
+ static readonly MIME: {
702
+ /** 普通文本文件 */readonly TEXT: "text/plain"; /** 超文本标记语言文档 */
703
+ readonly HTML: "text/html"; /** 层叠样式表文件 */
704
+ readonly CSS: "text/css"; /** 逗号分隔值文件(表格数据) */
705
+ readonly CSV: "text/csv"; /** 制表符分隔值文件 */
706
+ readonly TSV: "text/tab-separated-values"; /** XML 文档 */
707
+ readonly XML: "text/xml"; /** XHTML 文档(XML 严格格式的 HTML) */
708
+ readonly XHTML: "application/xhtml+xml"; /** JavaScript 文件 */
709
+ readonly JS: "text/javascript"; /** TypeScript 文件 */
710
+ readonly TS: "text/typescript"; /** Python 文件 */
711
+ readonly PY: "text/x-python"; /** Shell 脚本 (.sh) */
712
+ readonly SH: "text/x-sh"; /** C 语言源文件 */
713
+ readonly C: "text/x-c"; /** C++ 源文件 */
714
+ readonly CPP: "text/x-c++"; /** C# 源文件 */
715
+ readonly CSHARP: "text/x-csharp"; /** Java 源文件 */
716
+ readonly JAVA: "text/x-java"; /** Go 源文件 */
717
+ readonly GO: "text/x-go"; /** Rust 源文件 */
718
+ readonly RUST: "text/x-rust"; /** PHP 文件 */
719
+ readonly PHP: "text/x-php"; /** Ruby 文件 */
720
+ readonly RUBY: "text/x-ruby"; /** Swift 源文件 */
721
+ readonly SWIFT: "text/x-swift"; /** YAML 文档 */
722
+ readonly YAML: "text/vnd.yaml"; /** TOML 文档 */
723
+ readonly TOML: "text/x-toml"; /** SQL 脚本 */
724
+ readonly SQL: "text/x-sql"; /** Markdown 格式文档 */
725
+ readonly MARKDOWN: "text/markdown"; /** 富文本格式文档(.rtf) */
726
+ readonly RTF: "application/rtf"; /** iCalendar 日历格式(.ics) */
727
+ readonly CALENDAR: "text/calendar"; /** JPEG 图像(.jpg/.jpeg) */
728
+ readonly JPEG: "image/jpeg"; /** PNG 图像(无损压缩,支持透明) */
729
+ readonly PNG: "image/png"; /** GIF 图像(支持动画) */
730
+ readonly GIF: "image/gif"; /** Windows 位图(.bmp) */
731
+ readonly BMP: "image/bmp"; /** SVG 向量图形(.svg) */
732
+ readonly SVG: "image/svg+xml"; /** APNG 动态图像(.apng) */
733
+ readonly APNG: "image/apng"; /** AVIF 图像(高效压缩) */
734
+ readonly AVIF: "image/avif"; /** 图标文件格式(.ico) */
735
+ readonly ICO: "image/vnd.microsoft.icon"; /** WebP 图像(高效压缩) */
736
+ readonly WEBP: "image/webp"; /** TIFF 图像(.tif/.tiff) */
737
+ readonly TIFF: "image/tiff"; /** HEIC 图像(高效编码) */
738
+ readonly HEIC: "image/heic"; /** Adobe Photoshop 文件(.psd) */
739
+ readonly PSD: "image/vnd.adobe.photoshop"; /** MP3 音频(.mp3) */
740
+ readonly MP3: "audio/mpeg"; /** AAC 音频(.aac) */
741
+ readonly AAC: "audio/aac"; /** MIDI 音乐文件(.mid/.midi) */
742
+ readonly MIDI: "audio/midi"; /** OGG 音频(.oga) */
743
+ readonly OGG_AUDIO: "audio/ogg"; /** Opus 音频(.opus) */
744
+ readonly OPUS: "audio/opus"; /** WAV 音频(.wav) */
745
+ readonly WAV: "audio/wav"; /** RealAudio 音频(.ra/.ram) */
746
+ readonly REAL_AUDIO: "audio/x-pn-realaudio"; /** MP4 视频(.mp4) */
747
+ readonly MP4: "video/mp4"; /** MPEG 视频(.mpeg/.mpg) */
748
+ readonly MPEG: "video/mpeg"; /** OGG 视频(.ogv) */
749
+ readonly OGG_VIDEO: "video/ogg"; /** AVI 视频(.avi) */
750
+ readonly AVI: "video/x-msvideo"; /** 3GPP 视频(.3gp) */
751
+ readonly THREE_GPP: "video/3gpp"; /** 3GPP2 视频(.3g2) */
752
+ readonly THREE_GPP2: "video/3gpp2"; /** WebM 视频(.webm) */
753
+ readonly WEBM: "video/webm"; /** PDF 文档 */
754
+ readonly PDF: "application/pdf"; /** Word 97-2003 文档(.doc) */
755
+ readonly DOC: "application/msword"; /** Word 2007+ 文档(.docx) */
756
+ readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; /** Excel 2007+ 工作簿(.xlsx) */
757
+ readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; /** 启用宏的Excel工作簿(.xlsm) */
758
+ readonly XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12"; /** Excel模板文件(.xltx) */
759
+ readonly XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template"; /** PowerPoint 2007+ 演示文稿(.pptx) */
760
+ readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation"; /** PowerPoint 97-2003 演示文稿(.ppt) */
761
+ readonly PPT: "application/vnd.ms-powerpoint"; /** OpenDocument 文本文档(.odt) */
762
+ readonly ODT: "application/vnd.oasis.opendocument.text"; /** OpenDocument 表格文档(.ods) */
763
+ readonly ODS: "application/vnd.oasis.opendocument.spreadsheet"; /** OpenDocument 演示文稿(.odp) */
764
+ readonly ODP: "application/vnd.oasis.opendocument.presentation"; /** EPUB 电子书(.epub) */
765
+ readonly EPUB: "application/epub+zip"; /** Kindle 电子书(.azw) */
766
+ readonly AZW: "application/vnd.amazon.ebook"; /** ZIP 压缩文件(.zip) */
767
+ readonly ZIP: "application/zip"; /** GZIP 压缩文件(.gz) */
768
+ readonly GZIP: "application/gzip"; /** GZIP 压缩文件(旧格式) */
769
+ readonly X_GZIP: "application/x-gzip"; /** TAR 归档文件(.tar) */
770
+ readonly TAR: "application/x-tar"; /** BZip 归档(.bz) */
771
+ readonly BZIP: "application/x-bzip"; /** BZip2 归档(.bz2) */
772
+ readonly BZIP2: "application/x-bzip2"; /** 7-Zip 压缩文件(.7z) */
773
+ readonly SEVEN_Z: "application/x-7z-compressed"; /** RAR 压缩文件(.rar) */
774
+ readonly RAR: "application/vnd.rar"; /** 通用二进制数据(默认类型) */
775
+ readonly OCTET_STREAM: "application/octet-stream"; /** JSON 数据格式(.json) */
776
+ readonly JSON: "application/json"; /** JSON-LD 格式(.jsonld) */
777
+ readonly LD_JSON: "application/ld+json"; /** Java 归档文件(.jar) */
778
+ readonly JAR: "application/java-archive"; /** WebAssembly 二进制指令格式(.wasm) */
779
+ readonly WASM: "application/wasm"; /** MS 嵌入式 OpenType 字体(.eot) */
780
+ readonly EOT: "application/vnd.ms-fontobject"; /** OpenType 字体(.otf) */
781
+ readonly OTF: "font/otf"; /** WOFF 字体(.woff) */
782
+ readonly WOFF: "font/woff"; /** WOFF2 字体(.woff2) */
783
+ readonly WOFF2: "font/woff2"; /** TrueType 字体(.ttf) */
784
+ readonly TTF: "font/ttf"; /** Excel 97-2003 工作簿(.xls) */
785
+ readonly XLS: "application/vnd.ms-excel"; /** Microsoft XPS 文档(.xps) */
786
+ readonly XPS: "application/vnd.ms-xpsdocument"; /** Word 启用宏文档(.docm) */
787
+ readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
788
+ };
789
+ }
790
+ //#endregion
791
+ //#region src/number/numberUtil.d.ts
792
+ /**
793
+ * 数字工具类
794
+ */
795
+ declare class NumberUtil {
796
+ /**
797
+ * 数字区间检查函数
798
+ *
799
+ * @param input 待检查数字
800
+ * @param interval 由两个数字组成的元组 [left, right]
801
+ * @param includeLeft 是否包含左边界(默认 true)
802
+ * @param includeRight 是否包含右边界(默认 false)
803
+ * @returns 是否在区间内
804
+ * @example
805
+ * ```ts
806
+ * NumberUtil.within(5, [1, 10]); // true
807
+ * NumberUtil.within(1, [1, 10], false); // false
808
+ * ```
809
+ */
810
+ static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
811
+ }
812
+ //#endregion
813
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/typed-array.d.ts
814
+ /**
815
+ Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
816
+
817
+ @category Array
818
+ */
819
+ type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
820
+ //#endregion
821
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/characters.d.ts
822
+ /**
823
+ Matches any digit as a string ('0'-'9').
824
+
825
+ @example
826
+ ```
827
+ import type {DigitCharacter} from 'type-fest';
828
+
829
+ const a: DigitCharacter = '0'; // Valid
830
+ // @ts-expect-error
831
+ const b: DigitCharacter = 0; // Invalid
832
+ ```
833
+
834
+ @category Type
835
+ */
836
+ type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
837
+ //#endregion
838
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-intersection.d.ts
839
+ /**
840
+ Convert a union type to an intersection type.
841
+
842
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
843
+
844
+ @example
845
+ ```
846
+ import type {UnionToIntersection} from 'type-fest';
847
+
848
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
849
+
850
+ type Intersection = UnionToIntersection<Union>;
851
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
852
+ ```
853
+
854
+ @category Type
855
+ */
856
+ type UnionToIntersection<Union> = (// `extends unknown` is always going to be the case and is used to convert the
857
+ // `Union` into a [distributive conditional
858
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
859
+ Union extends unknown // The union type is used as the only argument to a function since the union
860
+ // of function arguments is an intersection.
861
+ ? (distributedUnion: Union) => void // This won't happen.
862
+ : never // Infer the `Intersection` type since TypeScript represents the positional
863
+ // arguments of unions of functions as an intersection of the union.
864
+ ) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
865
+ ? Intersection & Union : never;
866
+ //#endregion
867
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/keys-of-union.d.ts
868
+ /**
869
+ Create a union of all keys from a given type, even those exclusive to specific union members.
870
+
871
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
872
+
873
+ @link https://stackoverflow.com/a/49402091
874
+
875
+ @example
876
+ ```
877
+ import type {KeysOfUnion} from 'type-fest';
878
+
879
+ type A = {
880
+ common: string;
881
+ a: number;
882
+ };
883
+
884
+ type B = {
885
+ common: string;
886
+ b: string;
887
+ };
888
+
889
+ type C = {
890
+ common: string;
891
+ c: boolean;
892
+ };
893
+
894
+ type Union = A | B | C;
895
+
896
+ type CommonKeys = keyof Union;
897
+ //=> 'common'
898
+
899
+ type AllKeys = KeysOfUnion<Union>;
900
+ //=> 'common' | 'a' | 'b' | 'c'
901
+ ```
902
+
903
+ @category Object
904
+ */
905
+ type KeysOfUnion<ObjectType> = // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
906
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
907
+ //#endregion
908
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
909
+ /**
910
+ Returns a boolean for whether the given type is `any`.
911
+
912
+ @link https://stackoverflow.com/a/49928360/1490091
913
+
914
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
915
+
916
+ @example
917
+ ```
918
+ import type {IsAny} from 'type-fest';
919
+
920
+ const typedObject = {a: 1, b: 2} as const;
921
+ const anyObject: any = {a: 1, b: 2};
922
+
923
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
924
+ return object[key];
925
+ }
926
+
927
+ const typedA = get(typedObject, 'a');
928
+ //=> 1
929
+
930
+ const anyA = get(anyObject, 'a');
931
+ //=> any
932
+ ```
933
+
934
+ @category Type Guard
935
+ @category Utilities
936
+ */
937
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
938
+ //#endregion
939
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
940
+ /**
941
+ Returns a boolean for whether the given key is an optional key of type.
942
+
943
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
944
+
945
+ @example
946
+ ```
947
+ import type {IsOptionalKeyOf} from 'type-fest';
948
+
949
+ type User = {
950
+ name: string;
951
+ surname: string;
952
+
953
+ luckyNumber?: number;
954
+ };
955
+
956
+ type Admin = {
957
+ name: string;
958
+ surname?: string;
959
+ };
960
+
961
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
962
+ //=> true
963
+
964
+ type T2 = IsOptionalKeyOf<User, 'name'>;
965
+ //=> false
966
+
967
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
968
+ //=> boolean
969
+
970
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
971
+ //=> false
972
+
973
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
974
+ //=> boolean
975
+ ```
976
+
977
+ @category Type Guard
978
+ @category Utilities
979
+ */
980
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
981
+ //#endregion
982
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
983
+ /**
984
+ Extract all optional keys from the given type.
985
+
986
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
987
+
988
+ @example
989
+ ```
990
+ import type {OptionalKeysOf, Except} from 'type-fest';
991
+
992
+ type User = {
993
+ name: string;
994
+ surname: string;
995
+
996
+ luckyNumber?: number;
997
+ };
998
+
999
+ const REMOVE_FIELD = Symbol('remove field symbol');
1000
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
1001
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
1002
+ };
1003
+
1004
+ const update1: UpdateOperation<User> = {
1005
+ name: 'Alice',
1006
+ };
1007
+
1008
+ const update2: UpdateOperation<User> = {
1009
+ name: 'Bob',
1010
+ luckyNumber: REMOVE_FIELD,
1011
+ };
1012
+ ```
1013
+
1014
+ @category Utilities
1015
+ */
1016
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
1017
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
1018
+ : never;
1019
+ //#endregion
1020
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
1021
+ /**
1022
+ Extract all required keys from the given type.
1023
+
1024
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
1025
+
1026
+ @example
1027
+ ```
1028
+ import type {RequiredKeysOf} from 'type-fest';
1029
+
1030
+ declare function createValidation<
1031
+ Entity extends object,
1032
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
1033
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
1034
+
1035
+ type User = {
1036
+ name: string;
1037
+ surname: string;
1038
+ luckyNumber?: number;
1039
+ };
1040
+
1041
+ const validator1 = createValidation<User>('name', value => value.length < 25);
1042
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
1043
+
1044
+ // @ts-expect-error
1045
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
1046
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
1047
+ ```
1048
+
1049
+ @category Utilities
1050
+ */
1051
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
1052
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
1053
+ //#endregion
1054
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-never.d.ts
1055
+ /**
1056
+ Returns a boolean for whether the given type is `never`.
1057
+
1058
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
1059
+ @link https://stackoverflow.com/a/53984913/10292952
1060
+ @link https://www.zhenghao.io/posts/ts-never
1061
+
1062
+ Useful in type utilities, such as checking if something does not occur.
1063
+
1064
+ @example
1065
+ ```
1066
+ import type {IsNever, And} from 'type-fest';
1067
+
1068
+ type A = IsNever<never>;
1069
+ //=> true
1070
+
1071
+ type B = IsNever<any>;
1072
+ //=> false
1073
+
1074
+ type C = IsNever<unknown>;
1075
+ //=> false
1076
+
1077
+ type D = IsNever<never[]>;
1078
+ //=> false
1079
+
1080
+ type E = IsNever<object>;
1081
+ //=> false
1082
+
1083
+ type F = IsNever<string>;
1084
+ //=> false
1085
+ ```
1086
+
1087
+ @example
1088
+ ```
1089
+ import type {IsNever} from 'type-fest';
1090
+
1091
+ type IsTrue<T> = T extends true ? true : false;
1092
+
1093
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
1094
+ type A = IsTrue<never>;
1095
+ //=> never
1096
+
1097
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
1098
+ type IsTrueFixed<T> =
1099
+ IsNever<T> extends true ? false : T extends true ? true : false;
1100
+
1101
+ type B = IsTrueFixed<never>;
1102
+ //=> false
1103
+ ```
1104
+
1105
+ @category Type Guard
1106
+ @category Utilities
1107
+ */
1108
+ type IsNever<T> = [T] extends [never] ? true : false;
1109
+ //#endregion
1110
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
1111
+ /**
1112
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
1113
+
1114
+ Use-cases:
1115
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
1116
+
1117
+ Note:
1118
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
1119
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
1120
+
1121
+ @example
1122
+ ```
1123
+ import type {If} from 'type-fest';
1124
+
1125
+ type A = If<true, 'yes', 'no'>;
1126
+ //=> 'yes'
1127
+
1128
+ type B = If<false, 'yes', 'no'>;
1129
+ //=> 'no'
1130
+
1131
+ type C = If<boolean, 'yes', 'no'>;
1132
+ //=> 'yes' | 'no'
1133
+
1134
+ type D = If<any, 'yes', 'no'>;
1135
+ //=> 'yes' | 'no'
1136
+
1137
+ type E = If<never, 'yes', 'no'>;
1138
+ //=> 'no'
1139
+ ```
1140
+
1141
+ @example
1142
+ ```
1143
+ import type {If, IsAny, IsNever} from 'type-fest';
1144
+
1145
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
1146
+ //=> 'not any'
1147
+
1148
+ type B = If<IsNever<never>, 'is never', 'not never'>;
1149
+ //=> 'is never'
1150
+ ```
1151
+
1152
+ @example
1153
+ ```
1154
+ import type {If, IsEqual} from 'type-fest';
1155
+
1156
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
1157
+
1158
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
1159
+ //=> 'equal'
1160
+
1161
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
1162
+ //=> 'not equal'
1163
+ ```
1164
+
1165
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
1166
+
1167
+ @example
1168
+ ```
1169
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
1170
+
1171
+ type HundredZeroes = StringRepeat<'0', 100>;
1172
+
1173
+ // The following implementation is not tail recursive
1174
+ type Includes<S extends string, Char extends string> =
1175
+ S extends `${infer First}${infer Rest}`
1176
+ ? If<IsEqual<First, Char>,
1177
+ 'found',
1178
+ Includes<Rest, Char>>
1179
+ : 'not found';
1180
+
1181
+ // Hence, instantiations with long strings will fail
1182
+ // @ts-expect-error
1183
+ type Fails = Includes<HundredZeroes, '1'>;
1184
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1185
+ // Error: Type instantiation is excessively deep and possibly infinite.
1186
+
1187
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
1188
+ type IncludesWithoutIf<S extends string, Char extends string> =
1189
+ S extends `${infer First}${infer Rest}`
1190
+ ? IsEqual<First, Char> extends true
1191
+ ? 'found'
1192
+ : IncludesWithoutIf<Rest, Char>
1193
+ : 'not found';
1194
+
1195
+ // Now, instantiations with long strings will work
1196
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
1197
+ //=> 'not found'
1198
+ ```
1199
+
1200
+ @category Type Guard
1201
+ @category Utilities
1202
+ */
1203
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
1204
+ //#endregion
1205
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/unknown-array.d.ts
1206
+ /**
1207
+ Represents an array with `unknown` value.
1208
+
1209
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
1210
+
1211
+ @example
1212
+ ```
1213
+ import type {UnknownArray} from 'type-fest';
1214
+
1215
+ type IsArray<T> = T extends UnknownArray ? true : false;
1216
+
1217
+ type A = IsArray<['foo']>;
1218
+ //=> true
1219
+
1220
+ type B = IsArray<readonly number[]>;
1221
+ //=> true
1222
+
1223
+ type C = IsArray<string>;
1224
+ //=> false
1225
+ ```
1226
+
1227
+ @category Type
1228
+ @category Array
1229
+ */
1230
+ type UnknownArray = readonly unknown[];
1231
+ //#endregion
1232
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
1233
+ /**
1234
+ Returns a boolean for whether A is false.
1235
+
1236
+ @example
1237
+ ```
1238
+ type A = Not<true>;
1239
+ //=> false
1240
+
1241
+ type B = Not<false>;
1242
+ //=> true
1243
+ ```
1244
+ */
1245
+ type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
1246
+ /**
1247
+ An if-else-like type that resolves depending on whether the given type is `any` or `never`.
1248
+
1249
+ @example
1250
+ ```
1251
+ // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
1252
+ type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1253
+ //=> 'VALID'
1254
+
1255
+ // When `T` is `any` => Returns `IfAny` branch
1256
+ type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1257
+ //=> 'IS_ANY'
1258
+
1259
+ // When `T` is `never` => Returns `IfNever` branch
1260
+ type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
1261
+ //=> 'IS_NEVER'
1262
+ ```
1263
+
1264
+ Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
1265
+
1266
+ @example
1267
+ ```ts
1268
+ import type {StringRepeat} from 'type-fest';
1269
+
1270
+ type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
1271
+
1272
+ // The following implementation is not tail recursive
1273
+ type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
1274
+
1275
+ // Hence, instantiations with long strings will fail
1276
+ // @ts-expect-error
1277
+ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
1278
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1279
+ // Error: Type instantiation is excessively deep and possibly infinite.
1280
+
1281
+ // To fix this, move the recursion into a helper type
1282
+ type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
1283
+
1284
+ type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
1285
+
1286
+ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
1287
+ //=> ''
1288
+ ```
1289
+ */
1290
+ type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
1291
+ /**
1292
+ Indicates the value of `exactOptionalPropertyTypes` compiler option.
1293
+ */
1294
+ type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
1295
+ //#endregion
1296
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/array.d.ts
1297
+ /**
1298
+ Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
1299
+
1300
+ @example
1301
+ ```
1302
+ type A = CollapseRestElement<[string, string, ...number[]]>;
1303
+ //=> [string, string, number]
1304
+
1305
+ type B = CollapseRestElement<[...string[], number, number]>;
1306
+ //=> [string, number, number]
1307
+
1308
+ type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
1309
+ //=> [string, string, number | bigint]
1310
+
1311
+ type D = CollapseRestElement<[string, number]>;
1312
+ //=> [string, number]
1313
+ ```
1314
+
1315
+ Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
1316
+
1317
+ @example
1318
+ ```
1319
+ // `exactOptionalPropertyTypes` enabled
1320
+ type A = CollapseRestElement<[string?, string?, ...number[]]>;
1321
+ //=> [string, string, number]
1322
+
1323
+ // `exactOptionalPropertyTypes` disabled
1324
+ type B = CollapseRestElement<[string?, string?, ...number[]]>;
1325
+ //=> [string | undefined, string | undefined, number]
1326
+ ```
1327
+ */
1328
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
1329
+ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
1330
+ ? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
1331
+ // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
1332
+ ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
1333
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
1334
+ : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
1335
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
1336
+ : never; // Should never happen
1337
+ //#endregion
1338
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/numeric.d.ts
1339
+ type _Numeric = number | bigint;
1340
+ type Zero = 0 | 0n;
1341
+ /**
1342
+ Matches the hidden `Infinity` type.
1343
+
1344
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
1345
+
1346
+ @see {@link NegativeInfinity}
1347
+
1348
+ @category Numeric
1349
+ */
1350
+ // See https://github.com/microsoft/TypeScript/issues/31752
1351
+ // eslint-disable-next-line no-loss-of-precision
1352
+ /**
1353
+ A negative `number`/`bigint` (`-∞ < x < 0`)
1354
+
1355
+ Use-case: Validating and documenting parameters.
1356
+
1357
+ @see {@link NegativeInteger}
1358
+ @see {@link NonNegative}
1359
+
1360
+ @category Numeric
1361
+ */
1362
+ type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
1363
+ /**
1364
+ Returns a boolean for whether the given number is a negative number.
1365
+
1366
+ @see {@link Negative}
1367
+
1368
+ @example
1369
+ ```
1370
+ import type {IsNegative} from 'type-fest';
1371
+
1372
+ type ShouldBeFalse = IsNegative<1>;
1373
+ type ShouldBeTrue = IsNegative<-1>;
1374
+ ```
1375
+
1376
+ @category Numeric
1377
+ */
1378
+ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
1379
+ //#endregion
1380
+ //#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
1381
+ declare const tag: unique symbol;
1382
+ //#endregion
1383
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tagged.d.ts
1384
+ // eslint-disable-next-line type-fest/require-exported-types
1385
+ type TagContainer<Token> = {
1386
+ readonly [tag]: Token;
1387
+ };
1388
+ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
1389
+ /**
1390
+ Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
1391
+
1392
+ A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
1393
+
1394
+ A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
1395
+
1396
+ A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
1397
+ - the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
1398
+ - `A` contains at least all the tags `B` has;
1399
+ - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
1400
+
1401
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
1402
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
1403
+ - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
1404
+ - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
1405
+
1406
+ @example
1407
+ ```
1408
+ import type {Tagged} from 'type-fest';
1409
+
1410
+ type AccountNumber = Tagged<number, 'AccountNumber'>;
1411
+ type AccountBalance = Tagged<number, 'AccountBalance'>;
1412
+
1413
+ function createAccountNumber(): AccountNumber {
1414
+ // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
1415
+ return 2 as AccountNumber;
1416
+ }
1417
+
1418
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
1419
+
1420
+ // This will compile successfully.
1421
+ getMoneyForAccount(createAccountNumber());
1422
+
1423
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type!
1424
+ // Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
1425
+ // @ts-expect-error
1426
+ getMoneyForAccount(2);
1427
+
1428
+ // You can also use tagged values like their underlying, untagged type.
1429
+ // I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
1430
+ // In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
1431
+ const accountNumber = createAccountNumber() + 2;
1432
+ ```
1433
+
1434
+ @example
1435
+ ```
1436
+ import type {Tagged} from 'type-fest';
1437
+
1438
+ // You can apply multiple tags to a type by using `Tagged` repeatedly.
1439
+ type Url = Tagged<string, 'URL'>;
1440
+ type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
1441
+
1442
+ // You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
1443
+ type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
1444
+ ```
1445
+
1446
+ @category Type
1447
+ */
1448
+ type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
1449
+ /**
1450
+ Get the untagged portion of a tagged type created with `Tagged`.
1451
+
1452
+ Why is this necessary?
1453
+
1454
+ 1. Use a `Tagged` type as object keys
1455
+ 2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
1456
+
1457
+ @example
1458
+ ```
1459
+ import type {Tagged, UnwrapTagged} from 'type-fest';
1460
+
1461
+ type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
1462
+
1463
+ const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
1464
+ SAVINGS: 99,
1465
+ CHECKING: 0.1,
1466
+ };
1467
+
1468
+ // Without UnwrapTagged, the following expression would throw a type error.
1469
+ const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
1470
+
1471
+ // Attempting to pass a non-Tagged type to UnwrapTagged will raise a type error.
1472
+ // @ts-expect-error
1473
+ type WontWork = UnwrapTagged<string>;
1474
+ ```
1475
+
1476
+ @category Type
1477
+ */
1478
+ type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
1479
+ type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
1480
+ /**
1481
+ Note: The `Opaque` type is deprecated in favor of `Tagged`.
1482
+
1483
+ Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
1484
+
1485
+ The generic type parameters can be anything.
1486
+
1487
+ Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
1488
+
1489
+ Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
1490
+
1491
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
1492
+
1493
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
1494
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
1495
+ - [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
1496
+ - [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
1497
+
1498
+ @example
1499
+ ```
1500
+ import type {Opaque} from 'type-fest';
1501
+
1502
+ type AccountNumber = Opaque<number, 'AccountNumber'>;
1503
+ type AccountBalance = Opaque<number, 'AccountBalance'>;
1504
+
1505
+ // The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
1506
+ type ThingOne = Opaque<string>;
1507
+ type ThingTwo = Opaque<string>;
1508
+
1509
+ // To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
1510
+ // To avoid this behaviour, you would instead pass the "Token" parameter, like so.
1511
+ type NewThingOne = Opaque<string, 'ThingOne'>;
1512
+ type NewThingTwo = Opaque<string, 'ThingTwo'>;
1513
+
1514
+ // Now they're completely separate types, so the following will fail to compile.
1515
+ function createNewThingOne(): NewThingOne {
1516
+ // As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
1517
+ return 'new thing one' as NewThingOne;
1518
+ }
1519
+
1520
+ // This will fail to compile, as they are fundamentally different types.
1521
+ // @ts-expect-error
1522
+ const thingTwo = createNewThingOne() as NewThingTwo;
1523
+
1524
+ // Here's another example of opaque typing.
1525
+ function createAccountNumber(): AccountNumber {
1526
+ return 2 as AccountNumber;
1527
+ }
1528
+
1529
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
1530
+
1531
+ // This will compile successfully.
1532
+ getMoneyForAccount(createAccountNumber());
1533
+
1534
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type.
1535
+ // @ts-expect-error
1536
+ getMoneyForAccount(2);
1537
+
1538
+ // You can use opaque values like they aren't opaque too.
1539
+ const accountNumber = createAccountNumber();
1540
+
1541
+ // This will compile successfully.
1542
+ const newAccountNumber = accountNumber + 2;
1543
+
1544
+ // As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
1545
+ type Person = {
1546
+ id: Opaque<number, Person>;
1547
+ name: string;
1548
+ };
1549
+ ```
1550
+
1551
+ @category Type
1552
+ @deprecated Use {@link Tagged} instead
1553
+ */
1554
+ //#endregion
1555
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-literal.d.ts
1556
+ /**
1557
+ Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
1558
+
1559
+ Useful for:
1560
+ - providing strongly-typed string manipulation functions
1561
+ - constraining strings to be a string literal
1562
+ - type utilities, such as when constructing parsers and ASTs
1563
+
1564
+ The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
1565
+
1566
+ @example
1567
+ ```
1568
+ import type {IsStringLiteral} from 'type-fest';
1569
+
1570
+ type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
1571
+
1572
+ // https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
1573
+ function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
1574
+ return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
1575
+ }
1576
+
1577
+ const output = capitalize('hello, world!');
1578
+ //=> 'Hello, world!'
1579
+ ```
1580
+
1581
+ @example
1582
+ ```
1583
+ // String types with infinite set of possible values return `false`.
1584
+
1585
+ import type {IsStringLiteral} from 'type-fest';
1586
+
1587
+ type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
1588
+ //=> false
1589
+
1590
+ type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
1591
+ //=> false
1592
+
1593
+ // This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
1594
+
1595
+ type Length<S extends string, Counter extends never[] = []> =
1596
+ IsStringLiteral<S> extends false
1597
+ ? number // return `number` for infinite string types
1598
+ : S extends `${string}${infer Tail}`
1599
+ ? Length<Tail, [...Counter, never]>
1600
+ : Counter['length'];
1601
+
1602
+ type L1 = Length<Lowercase<string>>;
1603
+ //=> number
1604
+
1605
+ type L2 = Length<`${number}`>;
1606
+ //=> number
1607
+ ```
1608
+
1609
+ @category Type Guard
1610
+ @category Utilities
1611
+ */
1612
+ type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
1613
+ type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
1614
+ // and since `{}` extends index signatures, the result becomes `false`.
1615
+ S extends string ? {} extends Record<S, never> ? false : true : false;
1616
+ //#endregion
1617
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tuple-of.d.ts
1618
+ /**
1619
+ Create a tuple type of the specified length with elements of the specified type.
1620
+
1621
+ @example
1622
+ ```
1623
+ import type {TupleOf} from 'type-fest';
1624
+
1625
+ type RGB = TupleOf<3, number>;
1626
+ //=> [number, number, number]
1627
+
1628
+ type Line = TupleOf<2, {x: number; y: number}>;
1629
+ //=> [{x: number; y: number}, {x: number; y: number}]
1630
+
1631
+ type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
1632
+ //=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
1633
+ ```
1634
+
1635
+ @example
1636
+ ```
1637
+ import type {TupleOf} from 'type-fest';
1638
+
1639
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
1640
+
1641
+ type ZeroToFour = Range<0, 5>;
1642
+ //=> '0' | '1' | '2' | '3' | '4'
1643
+
1644
+ type ThreeToEight = Range<3, 9>;
1645
+ //=> '3' | '4' | '5' | '6' | '7' | '8'
1646
+ ```
1647
+
1648
+ Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
1649
+
1650
+ @example
1651
+ ```
1652
+ import type {TupleOf} from 'type-fest';
1653
+
1654
+ type StringArray = TupleOf<number, string>;
1655
+ //=> string[]
1656
+ ```
1657
+
1658
+ Note: If the type for elements is not specified, it will default to `unknown`.
1659
+
1660
+ @example
1661
+ ```
1662
+ import type {TupleOf} from 'type-fest';
1663
+
1664
+ type UnknownTriplet = TupleOf<3>;
1665
+ //=> [unknown, unknown, unknown]
1666
+ ```
1667
+
1668
+ Note: If the specified length is negative, the result will be an empty tuple.
1669
+
1670
+ @example
1671
+ ```
1672
+ import type {TupleOf} from 'type-fest';
1673
+
1674
+ type EmptyTuple = TupleOf<-3, string>;
1675
+ //=> []
1676
+ ```
1677
+
1678
+ Note: If the specified length has a decimal part, the decimal part will be ignored.
1679
+
1680
+ @example
1681
+ ```
1682
+ import type {TupleOf} from 'type-fest';
1683
+
1684
+ type DecimalLength = TupleOf<3.5, string>;
1685
+ //=> [string, string, string]
1686
+ ```
1687
+
1688
+ Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
1689
+
1690
+ @category Array
1691
+ */
1692
+ type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], []>;
1693
+ type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
1694
+ type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [...RepeatTupleTenTimes<Accumulator>, ...DigitTupleOf<First, Fill>]> : Accumulator;
1695
+ type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
1696
+ type DigitTupleOf<Digit extends DigitCharacter, Fill> = [[], [Fill], [Fill, Fill], [Fill, Fill, Fill], [Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill]][Digit];
1697
+ //#endregion
1698
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
1699
+ /**
1700
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
1701
+
1702
+ @example
1703
+ ```
1704
+ import type {Simplify} from 'type-fest';
1705
+
1706
+ type PositionProps = {
1707
+ top: number;
1708
+ left: number;
1709
+ };
1710
+
1711
+ type SizeProps = {
1712
+ width: number;
1713
+ height: number;
1714
+ };
1715
+
1716
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
1717
+ type Props = Simplify<PositionProps & SizeProps>;
1718
+ ```
1719
+
1720
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
1721
+
1722
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
1723
+
1724
+ @example
1725
+ ```
1726
+ import type {Simplify} from 'type-fest';
1727
+
1728
+ interface SomeInterface {
1729
+ foo: number;
1730
+ bar?: string;
1731
+ baz: number | undefined;
1732
+ }
1733
+
1734
+ type SomeType = {
1735
+ foo: number;
1736
+ bar?: string;
1737
+ baz: number | undefined;
1738
+ };
1739
+
1740
+ const literal = {foo: 123, bar: 'hello', baz: 456};
1741
+ const someType: SomeType = literal;
1742
+ const someInterface: SomeInterface = literal;
1743
+
1744
+ declare function fn(object: Record<string, unknown>): void;
1745
+
1746
+ fn(literal); // Good: literal object type is sealed
1747
+ fn(someType); // Good: type is sealed
1748
+ // @ts-expect-error
1749
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
1750
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
1751
+ ```
1752
+
1753
+ @link https://github.com/microsoft/TypeScript/issues/15300
1754
+ @see {@link SimplifyDeep}
1755
+ @category Object
1756
+ */
1757
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
1758
+ //#endregion
1759
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
1760
+ /**
1761
+ Returns a boolean for whether the two given types are equal.
1762
+
1763
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
1764
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
1765
+
1766
+ Use-cases:
1767
+ - If you want to make a conditional branch based on the result of a comparison of two types.
1768
+
1769
+ @example
1770
+ ```
1771
+ import type {IsEqual} from 'type-fest';
1772
+
1773
+ // This type returns a boolean for whether the given array includes the given item.
1774
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
1775
+ type Includes<Value extends readonly any[], Item> =
1776
+ Value extends readonly [Value[0], ...infer rest]
1777
+ ? IsEqual<Value[0], Item> extends true
1778
+ ? true
1779
+ : Includes<rest, Item>
1780
+ : false;
1781
+ ```
1782
+
1783
+ @category Type Guard
1784
+ @category Utilities
1785
+ */
1786
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
1787
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
1788
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
1789
+ //#endregion
1790
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
1791
+ /**
1792
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
1793
+
1794
+ This is the counterpart of `PickIndexSignature`.
1795
+
1796
+ Use-cases:
1797
+ - Remove overly permissive signatures from third-party types.
1798
+
1799
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
1800
+
1801
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
1802
+
1803
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
1804
+
1805
+ ```
1806
+ const indexed: Record<string, unknown> = {}; // Allowed
1807
+
1808
+ // @ts-expect-error
1809
+ const keyed: Record<'foo', unknown> = {}; // Error
1810
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
1811
+ ```
1812
+
1813
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
1814
+
1815
+ ```
1816
+ type Indexed = {} extends Record<string, unknown>
1817
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
1818
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
1819
+
1820
+ type IndexedResult = Indexed;
1821
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
1822
+
1823
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
1824
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
1825
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
1826
+
1827
+ type KeyedResult = Keyed;
1828
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
1829
+ ```
1830
+
1831
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
1832
+
1833
+ ```
1834
+ type OmitIndexSignature<ObjectType> = {
1835
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
1836
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
1837
+ };
1838
+ ```
1839
+
1840
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
1841
+
1842
+ ```
1843
+ type OmitIndexSignature<ObjectType> = {
1844
+ [KeyType in keyof ObjectType
1845
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
1846
+ as {} extends Record<KeyType, unknown>
1847
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
1848
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
1849
+ ]: ObjectType[KeyType];
1850
+ };
1851
+ ```
1852
+
1853
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
1854
+
1855
+ @example
1856
+ ```
1857
+ import type {OmitIndexSignature} from 'type-fest';
1858
+
1859
+ type Example = {
1860
+ // These index signatures will be removed.
1861
+ [x: string]: any;
1862
+ [x: number]: any;
1863
+ [x: symbol]: any;
1864
+ [x: `head-${string}`]: string;
1865
+ [x: `${string}-tail`]: string;
1866
+ [x: `head-${string}-tail`]: string;
1867
+ [x: `${bigint}`]: string;
1868
+ [x: `embedded-${number}`]: string;
1869
+
1870
+ // These explicitly defined keys will remain.
1871
+ foo: 'bar';
1872
+ qux?: 'baz';
1873
+ };
1874
+
1875
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
1876
+ //=> {foo: 'bar'; qux?: 'baz'}
1877
+ ```
1878
+
1879
+ @see {@link PickIndexSignature}
1880
+ @category Object
1881
+ */
1882
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
1883
+ //#endregion
1884
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
1885
+ /**
1886
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
1887
+
1888
+ This is the counterpart of `OmitIndexSignature`.
1889
+
1890
+ @example
1891
+ ```
1892
+ import type {PickIndexSignature} from 'type-fest';
1893
+
1894
+ declare const symbolKey: unique symbol;
1895
+
1896
+ type Example = {
1897
+ // These index signatures will remain.
1898
+ [x: string]: unknown;
1899
+ [x: number]: unknown;
1900
+ [x: symbol]: unknown;
1901
+ [x: `head-${string}`]: string;
1902
+ [x: `${string}-tail`]: string;
1903
+ [x: `head-${string}-tail`]: string;
1904
+ [x: `${bigint}`]: string;
1905
+ [x: `embedded-${number}`]: string;
1906
+
1907
+ // These explicitly defined keys will be removed.
1908
+ ['kebab-case-key']: string;
1909
+ [symbolKey]: string;
1910
+ foo: 'bar';
1911
+ qux?: 'baz';
1912
+ };
1913
+
1914
+ type ExampleIndexSignature = PickIndexSignature<Example>;
1915
+ // {
1916
+ // [x: string]: unknown;
1917
+ // [x: number]: unknown;
1918
+ // [x: symbol]: unknown;
1919
+ // [x: `head-${string}`]: string;
1920
+ // [x: `${string}-tail`]: string;
1921
+ // [x: `head-${string}-tail`]: string;
1922
+ // [x: `${bigint}`]: string;
1923
+ // [x: `embedded-${number}`]: string;
1924
+ // }
1925
+ ```
1926
+
1927
+ @see {@link OmitIndexSignature}
1928
+ @category Object
1929
+ */
1930
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
1931
+ //#endregion
1932
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
1933
+ // Merges two objects without worrying about index signatures.
1934
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
1935
+ /**
1936
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
1937
+
1938
+ This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
1939
+
1940
+ @example
1941
+ ```
1942
+ import type {Merge} from 'type-fest';
1943
+
1944
+ type Foo = {
1945
+ a: string;
1946
+ b: number;
1947
+ };
1948
+
1949
+ type Bar = {
1950
+ a: number; // Conflicts with Foo['a']
1951
+ c: boolean;
1952
+ };
1953
+
1954
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
1955
+ type WithIntersection = (Foo & Bar)['a'];
1956
+ //=> never
1957
+
1958
+ // With `Merge`, `a` is cleanly overridden to `number`.
1959
+ type WithMerge = Merge<Foo, Bar>['a'];
1960
+ //=> number
1961
+ ```
1962
+
1963
+ @example
1964
+ ```
1965
+ import type {Merge} from 'type-fest';
1966
+
1967
+ type Foo = {
1968
+ [x: string]: unknown;
1969
+ [x: number]: unknown;
1970
+ foo: string;
1971
+ bar: symbol;
1972
+ };
1973
+
1974
+ type Bar = {
1975
+ [x: number]: number;
1976
+ [x: symbol]: unknown;
1977
+ bar: Date;
1978
+ baz: boolean;
1979
+ };
1980
+
1981
+ export type FooBar = Merge<Foo, Bar>;
1982
+ //=> {
1983
+ // [x: string]: unknown;
1984
+ // [x: number]: number;
1985
+ // [x: symbol]: unknown;
1986
+ // foo: string;
1987
+ // bar: Date;
1988
+ // baz: boolean;
1989
+ // }
1990
+ ```
1991
+
1992
+ Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
1993
+
1994
+ @see {@link ObjectMerge}
1995
+ @category Object
1996
+ */
1997
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
1998
+ ? Source extends unknown // For distributing `Source`
1999
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
2000
+ : never;
2001
+ // Should never happen
2002
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
2003
+ //#endregion
2004
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
2005
+ /**
2006
+ Works similar to the built-in `Pick` utility type, except for the following differences:
2007
+ - Distributes over union types and allows picking keys from any member of the union type.
2008
+ - Primitives types are returned as-is.
2009
+ - Picks all keys if `Keys` is `any`.
2010
+ - Doesn't pick `number` from a `string` index signature.
2011
+
2012
+ @example
2013
+ ```
2014
+ type ImageUpload = {
2015
+ url: string;
2016
+ size: number;
2017
+ thumbnailUrl: string;
2018
+ };
2019
+
2020
+ type VideoUpload = {
2021
+ url: string;
2022
+ duration: number;
2023
+ encodingFormat: string;
2024
+ };
2025
+
2026
+ // Distributes over union types and allows picking keys from any member of the union type
2027
+ type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
2028
+ //=> {url: string; size: number} | {url: string; duration: number}
2029
+
2030
+ // Primitive types are returned as-is
2031
+ type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
2032
+ //=> string | number
2033
+
2034
+ // Picks all keys if `Keys` is `any`
2035
+ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
2036
+ //=> {a: 1; b: 2} | {c: 3}
2037
+
2038
+ // Doesn't pick `number` from a `string` index signature
2039
+ type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
2040
+ //=> {}
2041
+ */
2042
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
2043
+ /**
2044
+ Merges user specified options with default options.
2045
+
2046
+ @example
2047
+ ```
2048
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2049
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
2050
+ type SpecifiedOptions = {leavesOnly: true};
2051
+
2052
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2053
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
2054
+ ```
2055
+
2056
+ @example
2057
+ ```
2058
+ // Complains if default values are not provided for optional options
2059
+
2060
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2061
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
2062
+ type SpecifiedOptions = {};
2063
+
2064
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2065
+ // ~~~~~~~~~~~~~~~~~~~
2066
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
2067
+ ```
2068
+
2069
+ @example
2070
+ ```
2071
+ // Complains if an option's default type does not conform to the expected type
2072
+
2073
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2074
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
2075
+ type SpecifiedOptions = {};
2076
+
2077
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2078
+ // ~~~~~~~~~~~~~~~~~~~
2079
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
2080
+ ```
2081
+
2082
+ @example
2083
+ ```
2084
+ // Complains if an option's specified type does not conform to the expected type
2085
+
2086
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
2087
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
2088
+ type SpecifiedOptions = {leavesOnly: 'yes'};
2089
+
2090
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
2091
+ // ~~~~~~~~~~~~~~~~
2092
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
2093
+ ```
2094
+ */
2095
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
2096
+ ? Result : never;
2097
+ type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
2098
+ /**
2099
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
2100
+
2101
+ Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
2102
+
2103
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
2104
+
2105
+ @example
2106
+ ```
2107
+ import type {LiteralUnion} from 'type-fest';
2108
+
2109
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
2110
+ //=> string
2111
+
2112
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
2113
+ //=> number
2114
+
2115
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
2116
+ //=> `on${string}`
2117
+
2118
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
2119
+ //=> 'click' | 'change' | `on${string}`
2120
+
2121
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
2122
+ //=> string | null | undefined
2123
+ ```
2124
+ */
2125
+ type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
2126
+ //#endregion
2127
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/some-extend.d.ts
2128
+ /**
2129
+ @see {@link SomeExtend}
2130
+ */
2131
+ type SomeExtendOptions = {
2132
+ /**
2133
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
2134
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
2135
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
2136
+ @default true
2137
+ @example
2138
+ ```
2139
+ import type {SomeExtend} from 'type-fest';
2140
+ type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
2141
+ //=> false
2142
+ type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
2143
+ //=> true
2144
+ type C = SomeExtend<[1, never], never, {strictNever: true}>;
2145
+ //=> true
2146
+ type D = SomeExtend<[1, never], never, {strictNever: false}>;
2147
+ //=> true
2148
+ type E = SomeExtend<[never], any, {strictNever: true}>;
2149
+ //=> true
2150
+ type F = SomeExtend<[never], any, {strictNever: false}>;
2151
+ //=> true
2152
+ ```
2153
+ */
2154
+ strictNever?: boolean;
2155
+ };
2156
+ type DefaultSomeExtendOptions = {
2157
+ strictNever: true;
2158
+ };
2159
+ /**
2160
+ Returns a boolean for whether some element in an array type extends another type.
2161
+
2162
+ @example
2163
+ ```
2164
+ import type {SomeExtend} from 'type-fest';
2165
+
2166
+ type A = SomeExtend<['1', '2', 3], number>;
2167
+ //=> true
2168
+
2169
+ type B = SomeExtend<[1, 2, 3], string>;
2170
+ //=> false
2171
+
2172
+ type C = SomeExtend<[string, number | string], number>;
2173
+ //=> boolean
2174
+
2175
+ type D = SomeExtend<[true, boolean, true], false>;
2176
+ //=> boolean
2177
+ ```
2178
+
2179
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
2180
+
2181
+ ```
2182
+ // @exactOptionalPropertyTypes: true
2183
+ import type {SomeExtend} from 'type-fest';
2184
+
2185
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
2186
+ //=> true
2187
+ ```
2188
+
2189
+ ```
2190
+ // @exactOptionalPropertyTypes: false
2191
+ import type {SomeExtend} from 'type-fest';
2192
+
2193
+ type A = SomeExtend<[1?, 2?, '3'?], string>;
2194
+ //=> boolean
2195
+
2196
+ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
2197
+ //=> true
2198
+ ```
2199
+
2200
+ @see {@link SomeExtendOptions}
2201
+
2202
+ @category Utilities
2203
+ @category Array
2204
+ */
2205
+ type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
2206
+ type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
2207
+ ? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
2208
+ //#endregion
2209
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or-all.d.ts
2210
+ /**
2211
+ Returns a boolean for whether any of the given elements is `true`.
2212
+
2213
+ Use-cases:
2214
+ - Check if at least one condition in a list of booleans is met.
2215
+
2216
+ @example
2217
+ ```
2218
+ import type {OrAll} from 'type-fest';
2219
+
2220
+ type FFT = OrAll<[false, false, true]>;
2221
+ //=> true
2222
+
2223
+ type FFF = OrAll<[false, false, false]>;
2224
+ //=> false
2225
+ ```
2226
+
2227
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
2228
+ For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
2229
+
2230
+ @example
2231
+ ```
2232
+ import type {OrAll} from 'type-fest';
2233
+
2234
+ type A = OrAll<[false, boolean]>;
2235
+ //=> boolean
2236
+
2237
+ type B = OrAll<[true, boolean]>;
2238
+ //=> true
2239
+ ```
2240
+
2241
+ Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
2242
+
2243
+ @example
2244
+ ```
2245
+ import type {OrAll} from 'type-fest';
2246
+
2247
+ type A = OrAll<[never, never, true]>;
2248
+ //=> true
2249
+
2250
+ type B = OrAll<[never, never, false]>;
2251
+ //=> false
2252
+
2253
+ type C = OrAll<[never, never, never]>;
2254
+ //=> false
2255
+
2256
+ type D = OrAll<[never, never, boolean]>;
2257
+ //=> boolean
2258
+ ```
2259
+
2260
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
2261
+
2262
+ @example
2263
+ ```
2264
+ import type {OrAll} from 'type-fest';
2265
+
2266
+ type A = OrAll<[false, any]>;
2267
+ //=> boolean
2268
+
2269
+ type B = OrAll<[true, any]>;
2270
+ //=> true
2271
+ ```
2272
+
2273
+ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
2274
+
2275
+ @see {@link Or}
2276
+ @see {@link AndAll}
2277
+ */
2278
+ type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
2279
+ //#endregion
2280
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or.d.ts
2281
+ /**
2282
+ Returns a boolean for whether either of two given types is `true`.
2283
+
2284
+ Use-case: Constructing complex conditional types where at least one condition must be satisfied.
2285
+
2286
+ @example
2287
+ ```
2288
+ import type {Or} from 'type-fest';
2289
+
2290
+ type TT = Or<true, true>;
2291
+ //=> true
2292
+
2293
+ type TF = Or<true, false>;
2294
+ //=> true
2295
+
2296
+ type FT = Or<false, true>;
2297
+ //=> true
2298
+
2299
+ type FF = Or<false, false>;
2300
+ //=> false
2301
+ ```
2302
+
2303
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
2304
+ For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
2305
+
2306
+ @example
2307
+ ```
2308
+ import type {Or} from 'type-fest';
2309
+
2310
+ type A = Or<false, boolean>;
2311
+ //=> boolean
2312
+
2313
+ type B = Or<boolean, false>;
2314
+ //=> boolean
2315
+
2316
+ type C = Or<true, boolean>;
2317
+ //=> true
2318
+
2319
+ type D = Or<boolean, true>;
2320
+ //=> true
2321
+
2322
+ type E = Or<boolean, boolean>;
2323
+ //=> boolean
2324
+ ```
2325
+
2326
+ Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
2327
+
2328
+ @example
2329
+ ```
2330
+ import type {Or} from 'type-fest';
2331
+
2332
+ type A = Or<true, never>;
2333
+ //=> true
2334
+
2335
+ type B = Or<never, true>;
2336
+ //=> true
2337
+
2338
+ type C = Or<false, never>;
2339
+ //=> false
2340
+
2341
+ type D = Or<never, false>;
2342
+ //=> false
2343
+
2344
+ type E = Or<boolean, never>;
2345
+ //=> boolean
2346
+
2347
+ type F = Or<never, boolean>;
2348
+ //=> boolean
2349
+
2350
+ type G = Or<never, never>;
2351
+ //=> false
2352
+ ```
2353
+
2354
+ @see {@link OrAll}
2355
+ @see {@link And}
2356
+ @see {@link Xor}
2357
+ */
2358
+ type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
2359
+ //#endregion
2360
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/all-extend.d.ts
2361
+ /**
2362
+ @see {@link AllExtend}
2363
+ */
2364
+ type AllExtendOptions = {
2365
+ /**
2366
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
2367
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
2368
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
2369
+ @default true
2370
+ @example
2371
+ ```
2372
+ import type {AllExtend} from 'type-fest';
2373
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
2374
+ //=> false
2375
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
2376
+ //=> true
2377
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
2378
+ //=> true
2379
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
2380
+ //=> true
2381
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
2382
+ //=> true
2383
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
2384
+ //=> true
2385
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
2386
+ //=> false
2387
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
2388
+ //=> false
2389
+ ```
2390
+ */
2391
+ strictNever?: boolean;
2392
+ };
2393
+ type DefaultAllExtendOptions = {
2394
+ strictNever: true;
2395
+ };
2396
+ /**
2397
+ Returns a boolean for whether every element in an array type extends another type.
2398
+
2399
+ @example
2400
+ ```
2401
+ import type {AllExtend} from 'type-fest';
2402
+
2403
+ type A = AllExtend<[1, 2, 3], number>;
2404
+ //=> true
2405
+
2406
+ type B = AllExtend<[1, 2, '3'], number>;
2407
+ //=> false
2408
+
2409
+ type C = AllExtend<[number, number | string], number>;
2410
+ //=> boolean
2411
+
2412
+ type D = AllExtend<[true, boolean, true], true>;
2413
+ //=> boolean
2414
+ ```
2415
+
2416
+ Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
2417
+
2418
+ ```
2419
+ // @exactOptionalPropertyTypes: true
2420
+ import type {AllExtend} from 'type-fest';
2421
+
2422
+ type A = AllExtend<[1?, 2?, 3?], number>;
2423
+ //=> true
2424
+ ```
2425
+
2426
+ ```
2427
+ // @exactOptionalPropertyTypes: false
2428
+ import type {AllExtend} from 'type-fest';
2429
+
2430
+ type A = AllExtend<[1?, 2?, 3?], number>;
2431
+ //=> boolean
2432
+
2433
+ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
2434
+ //=> true
2435
+ ```
2436
+
2437
+ @see {@link AllExtendOptions}
2438
+
2439
+ @category Utilities
2440
+ @category Array
2441
+ */
2442
+ type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
2443
+ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
2444
+ ? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
2445
+ //#endregion
2446
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and-all.d.ts
2447
+ /**
2448
+ Returns a boolean for whether all of the given elements are `true`.
2449
+
2450
+ Use-cases:
2451
+ - Check if all conditions in a list of booleans are met.
2452
+
2453
+ @example
2454
+ ```
2455
+ import type {AndAll} from 'type-fest';
2456
+
2457
+ type TTT = AndAll<[true, true, true]>;
2458
+ //=> true
2459
+
2460
+ type TTF = AndAll<[true, true, false]>;
2461
+ //=> false
2462
+
2463
+ type TFT = AndAll<[true, false, true]>;
2464
+ //=> false
2465
+ ```
2466
+
2467
+ Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
2468
+ For example, `AndAll<[true, boolean]>` expands to `AndAll<[true, true]> | AndAll<[true, false]>`, which simplifies to `true | false` (i.e., `boolean`).
2469
+
2470
+ @example
2471
+ ```
2472
+ import type {AndAll} from 'type-fest';
2473
+
2474
+ type A = AndAll<[true, boolean]>;
2475
+ //=> boolean
2476
+
2477
+ type B = AndAll<[false, boolean]>;
2478
+ //=> false
2479
+ ```
2480
+
2481
+ Note: If any of the elements is `never`, the result becomes `false`.
2482
+
2483
+ @example
2484
+ ```
2485
+ import type {AndAll} from 'type-fest';
2486
+
2487
+ type A = AndAll<[true, true, never]>;
2488
+ //=> false
2489
+
2490
+ type B = AndAll<[false, never, never]>;
2491
+ //=> false
2492
+
2493
+ type C = AndAll<[never, never, never]>;
2494
+ //=> false
2495
+
2496
+ type D = AndAll<[boolean, true, never]>;
2497
+ //=> false
2498
+ ```
2499
+
2500
+ Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
2501
+
2502
+ @example
2503
+ ```
2504
+ import type {AndAll} from 'type-fest';
2505
+
2506
+ type A = AndAll<[false, any]>;
2507
+ //=> false
2508
+
2509
+ type B = AndAll<[true, any]>;
2510
+ //=> boolean
2511
+ ```
2512
+
2513
+ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](https://en.wikipedia.org/wiki/Logical_conjunction#:~:text=In%20keeping%20with%20the%20concept%20of%20vacuous%20truth%2C%20when%20conjunction%20is%20defined%20as%20an%20operator%20or%20function%20of%20arbitrary%20arity%2C%20the%20empty%20conjunction%20(AND%2Ding%20over%20an%20empty%20set%20of%20operands)%20is%20often%20defined%20as%20having%20the%20result%20true.), i.e., there are no `false` elements in an empty tuple.
2514
+
2515
+ @see {@link And}
2516
+ @see {@link OrAll}
2517
+ */
2518
+ type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
2519
+ //#endregion
2520
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and.d.ts
2521
+ /**
2522
+ Returns a boolean for whether two given types are both `true`.
2523
+
2524
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
2525
+
2526
+ @example
2527
+ ```
2528
+ import type {And} from 'type-fest';
2529
+
2530
+ type TT = And<true, true>;
2531
+ //=> true
2532
+
2533
+ type TF = And<true, false>;
2534
+ //=> false
2535
+
2536
+ type FT = And<false, true>;
2537
+ //=> false
2538
+
2539
+ type FF = And<false, false>;
2540
+ //=> false
2541
+ ```
2542
+
2543
+ Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
2544
+ For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
2545
+
2546
+ @example
2547
+ ```
2548
+ import type {And} from 'type-fest';
2549
+
2550
+ type A = And<true, boolean>;
2551
+ //=> boolean
2552
+
2553
+ type B = And<boolean, true>;
2554
+ //=> boolean
2555
+
2556
+ type C = And<false, boolean>;
2557
+ //=> false
2558
+
2559
+ type D = And<boolean, false>;
2560
+ //=> false
2561
+
2562
+ type E = And<boolean, boolean>;
2563
+ //=> boolean
2564
+ ```
2565
+
2566
+ Note: If either of the types is `never`, the result becomes `false`.
2567
+
2568
+ @example
2569
+ ```
2570
+ import type {And} from 'type-fest';
2571
+
2572
+ type A = And<true, never>;
2573
+ //=> false
2574
+
2575
+ type B = And<never, true>;
2576
+ //=> false
2577
+
2578
+ type C = And<false, never>;
2579
+ //=> false
2580
+
2581
+ type D = And<never, false>;
2582
+ //=> false
2583
+
2584
+ type E = And<boolean, never>;
2585
+ //=> false
2586
+
2587
+ type F = And<never, boolean>;
2588
+ //=> false
2589
+
2590
+ type G = And<never, never>;
2591
+ //=> false
2592
+ ```
2593
+
2594
+ @see {@link AndAll}
2595
+ @see {@link Or}
2596
+ @see {@link Xor}
2597
+ */
2598
+ type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
2599
+ //#endregion
2600
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/except.d.ts
2601
+ /**
2602
+ Filter out keys from an object.
2603
+
2604
+ Returns `never` if `Exclude` is strictly equal to `Key`.
2605
+ Returns `never` if `Key` extends `Exclude`.
2606
+ Returns `Key` otherwise.
2607
+
2608
+ @example
2609
+ ```
2610
+ type Filtered = Filter<'foo', 'foo'>;
2611
+ //=> never
2612
+ ```
2613
+
2614
+ @example
2615
+ ```
2616
+ type Filtered = Filter<'bar', string>;
2617
+ //=> never
2618
+ ```
2619
+
2620
+ @example
2621
+ ```
2622
+ type Filtered = Filter<'bar', 'foo'>;
2623
+ //=> 'bar'
2624
+ ```
2625
+
2626
+ @see {Except}
2627
+ */
2628
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
2629
+ type ExceptOptions = {
2630
+ /**
2631
+ Disallow assigning non-specified properties.
2632
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
2633
+ @default false
2634
+ */
2635
+ requireExactProps?: boolean;
2636
+ };
2637
+ type DefaultExceptOptions = {
2638
+ requireExactProps: false;
2639
+ };
2640
+ /**
2641
+ Create a type from an object type without certain keys.
2642
+
2643
+ We recommend setting the `requireExactProps` option to `true`.
2644
+
2645
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
2646
+
2647
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
2648
+
2649
+ @example
2650
+ ```
2651
+ import type {Except} from 'type-fest';
2652
+
2653
+ type Foo = {
2654
+ a: number;
2655
+ b: string;
2656
+ };
2657
+
2658
+ type FooWithoutA = Except<Foo, 'a'>;
2659
+ //=> {b: string}
2660
+
2661
+ // @ts-expect-error
2662
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
2663
+ // errors: 'a' does not exist in type '{ b: string; }'
2664
+
2665
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
2666
+ //=> {a: number} & Partial<Record<'b', never>>
2667
+
2668
+ // @ts-expect-error
2669
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
2670
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
2671
+
2672
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
2673
+
2674
+ // Consider the following example:
2675
+
2676
+ type UserData = {
2677
+ [metadata: string]: string;
2678
+ email: string;
2679
+ name: string;
2680
+ role: 'admin' | 'user';
2681
+ };
2682
+
2683
+ // `Omit` clearly doesn't behave as expected in this case:
2684
+ type PostPayload = Omit<UserData, 'email'>;
2685
+ //=> {[x: string]: string; [x: number]: string}
2686
+
2687
+ // In situations like this, `Except` works better.
2688
+ // It simply removes the `email` key while preserving all the other keys.
2689
+ type PostPayloadFixed = Except<UserData, 'email'>;
2690
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
2691
+ ```
2692
+
2693
+ @category Object
2694
+ */
2695
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
2696
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
2697
+ //#endregion
2698
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/exclude-exactly.d.ts
2699
+ /**
2700
+ A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
2701
+
2702
+ @example
2703
+ ```
2704
+ import type {ExcludeExactly} from 'type-fest';
2705
+
2706
+ type TestExclude1 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
2707
+ //=> 1 | 2 | 3
2708
+
2709
+ type TestExcludeExactly1 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
2710
+ //=> 'a' | 'b' | 'c' | 1 | 2 | 3
2711
+
2712
+ type TestExclude2 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
2713
+ //=> never
2714
+
2715
+ type TestExcludeExactly2 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
2716
+ //=> 'a' | 'b' | 'c' | 1 | 2 | 3
2717
+
2718
+ type TestExclude3 = Exclude<{a: string} | {a: string; b: string}, {a: string}>;
2719
+ //=> never
2720
+
2721
+ type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string}, {a: string}>;
2722
+ //=> {a: string; b: string}
2723
+ ```
2724
+
2725
+ @category Improved Built-in
2726
+ */
2727
+ type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, _ExcludeExactly<Union, Delete>, // If `Union` is `any`, then if `Delete` is `any`, return `never`, else return `Union`.
2728
+ If<IsAny<Delete>, never, Union>, // If `Union` is `never`, then if `Delete` is `never`, return `never`, else return `Union`.
2729
+ If<IsNever<Delete>, never, Union>>;
2730
+ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unknown // For distributing `Union`
2731
+ ? [Delete extends unknown // For distributing `Delete`
2732
+ ? If<IsEqual<Union, Delete>, true, never> : never] extends [never] ? Union : never : never, // If `Delete` is `any` or `never`, then return `Union`,
2733
+ // because `Union` cannot be `any` or `never` here.
2734
+ Union, Union>;
2735
+ //#endregion
2736
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-member.d.ts
2737
+ /**
2738
+ Returns an arbitrary member of a union type.
2739
+
2740
+ Use-cases:
2741
+ - Implementing recursive type functions that accept a union type.
2742
+
2743
+ @example
2744
+ ```
2745
+ import type {UnionMember, IsNever} from 'type-fest';
2746
+
2747
+ type UnionLength<T, Acc extends any[] = []> =
2748
+ UnionMember<T> extends infer Member
2749
+ ? IsNever<Member> extends false
2750
+ ? UnionLength<Exclude<T, Member>, [...Acc, Member]>
2751
+ : Acc['length']
2752
+ : never;
2753
+
2754
+ type T1 = UnionLength<'foo' | 'bar' | 'baz'>;
2755
+ //=> 3
2756
+
2757
+ type T2 = UnionLength<{a: string}>;
2758
+ //=> 1
2759
+ ```
2760
+
2761
+ - Picking an arbitrary member from a union
2762
+
2763
+ @example
2764
+ ```
2765
+ import type {UnionMember, Primitive, LiteralToPrimitive} from 'type-fest';
2766
+
2767
+ type IsHomogenous<T extends Primitive> = [T] extends [LiteralToPrimitive<UnionMember<T>>] ? true : false;
2768
+
2769
+ type T1 = IsHomogenous<1 | 2 | 3 | 4>;
2770
+ //=> true
2771
+
2772
+ type T2 = IsHomogenous<'foo' | 'bar'>;
2773
+ //=> true
2774
+
2775
+ type T3 = IsHomogenous<'foo' | 'bar' | 1>;
2776
+ //=> false
2777
+ ```
2778
+
2779
+ Returns `never` when the input is `never`.
2780
+
2781
+ @example
2782
+ ```
2783
+ import type {UnionMember} from 'type-fest';
2784
+
2785
+ type LastNever = UnionMember<never>;
2786
+ //=> never
2787
+ ```
2788
+
2789
+ @category Type
2790
+ */
2791
+ type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
2792
+ //#endregion
2793
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-tuple.d.ts
2794
+ /**
2795
+ Convert a union type into an unordered tuple type of its elements.
2796
+
2797
+ "Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
2798
+
2799
+ This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
2800
+
2801
+ @example
2802
+ ```
2803
+ import type {UnionToTuple} from 'type-fest';
2804
+
2805
+ type Numbers = 1 | 2 | 3;
2806
+ type NumbersTuple = UnionToTuple<Numbers>;
2807
+ //=> [1, 2, 3]
2808
+ ```
2809
+
2810
+ @example
2811
+ ```
2812
+ import type {UnionToTuple} from 'type-fest';
2813
+
2814
+ const pets = {
2815
+ dog: '🐶',
2816
+ cat: '🐱',
2817
+ snake: '🐍',
2818
+ };
2819
+
2820
+ type Pet = keyof typeof pets;
2821
+ //=> 'dog' | 'cat' | 'snake'
2822
+
2823
+ const petList = Object.keys(pets) as UnionToTuple<Pet>;
2824
+ //=> ['dog', 'cat', 'snake']
2825
+ ```
2826
+
2827
+ @category Array
2828
+ */
2829
+ type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
2830
+ // Nudges the compiler that `UnionToTuple` always yields an array.
2831
+ type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
2832
+ //#endregion
2833
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/set-optional.d.ts
2834
+ /**
2835
+ Create a type that makes the given keys optional, while keeping the remaining keys as is.
2836
+
2837
+ Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
2838
+
2839
+ @example
2840
+ ```
2841
+ import type {SetOptional} from 'type-fest';
2842
+
2843
+ type Foo = {
2844
+ a: number;
2845
+ b?: string;
2846
+ c: boolean;
2847
+ };
2848
+
2849
+ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
2850
+ //=> {a: number; b?: string; c?: boolean}
2851
+ ```
2852
+
2853
+ @category Object
2854
+ */
2855
+ type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
2856
+ type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
2857
+ ? Simplify< // Pick just the keys that are readonly from the base type.
2858
+ Except<BaseType, Keys> // Pick the keys that should be mutable from the base type and make them mutable.
2859
+ & Partial<HomomorphicPick<BaseType, Keys>>> : never;
2860
+ //#endregion
2861
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/value-of.d.ts
2862
+ /**
2863
+ Create a union of the given object's values, and optionally specify which keys to get the values from.
2864
+
2865
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/31438) if you want to have this type as a built-in in TypeScript.
2866
+
2867
+ @example
2868
+ ```
2869
+ import type {ValueOf} from 'type-fest';
2870
+
2871
+ type A = ValueOf<{id: number; name: string; active: boolean}>;
2872
+ //=> string | number | boolean
2873
+
2874
+ type B = ValueOf<{id: number; name: string; active: boolean}, 'name'>;
2875
+ //=> string
2876
+
2877
+ type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
2878
+ //=> string | number
2879
+ ```
2880
+
2881
+ @category Object
2882
+ */
2883
+ type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
2884
+ //#endregion
2885
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/split.d.ts
2886
+ /**
2887
+ Split options.
2888
+
2889
+ @see {@link Split}
2890
+ */
2891
+ type SplitOptions = {
2892
+ /**
2893
+ When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
2894
+ @default true
2895
+ @example
2896
+ ```ts
2897
+ import type {Split} from 'type-fest';
2898
+ type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
2899
+ //=> ['foo', string, 'bar']
2900
+ type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
2901
+ //=> string[]
2902
+ type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
2903
+ //=> ['foo', 'r', 'z']
2904
+ type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
2905
+ //=> string[]
2906
+ ```
2907
+ */
2908
+ strictLiteralChecks?: boolean;
2909
+ };
2910
+ type DefaultSplitOptions = {
2911
+ strictLiteralChecks: true;
2912
+ };
2913
+ /**
2914
+ Represents an array of strings split using a given character or character set.
2915
+
2916
+ Use-case: Defining the return type of a method like `String.prototype.split`.
2917
+
2918
+ @example
2919
+ ```
2920
+ import type {Split} from 'type-fest';
2921
+
2922
+ declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
2923
+
2924
+ type Item = 'foo' | 'bar' | 'baz' | 'waldo';
2925
+ const items = 'foo,bar,baz,waldo';
2926
+ const array: Item[] = split(items, ',');
2927
+ ```
2928
+
2929
+ @see {@link SplitOptions}
2930
+
2931
+ @category String
2932
+ @category Template literal
2933
+ */
2934
+ type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
2935
+ type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
2936
+ ? Delimiter extends string // For distributing `Delimiter`
2937
+ // If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
2938
+ ? Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S] // Otherwise, return `string[]`
2939
+ : string[] : never // Should never happen
2940
+ : never; // Should never happen
2941
+ //#endregion
2942
+ //#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/replace.d.ts
2943
+ type ReplaceOptions = {
2944
+ all?: boolean;
2945
+ };
2946
+ type DefaultReplaceOptions = {
2947
+ all: false;
2948
+ };
2949
+ /**
2950
+ Represents a string with some or all matches replaced by a replacement.
2951
+
2952
+ Use-case:
2953
+ - `kebab-case-path` to `dotted.path.notation`
2954
+ - Changing date/time format: `01-08-2042` → `01/08/2042`
2955
+ - Manipulation of type properties, for example, removal of prefixes
2956
+
2957
+ @example
2958
+ ```
2959
+ import type {Replace} from 'type-fest';
2960
+
2961
+ declare function replace<
2962
+ Input extends string,
2963
+ Search extends string,
2964
+ Replacement extends string,
2965
+ >(
2966
+ input: Input,
2967
+ search: Search,
2968
+ replacement: Replacement,
2969
+ ): Replace<Input, Search, Replacement>;
2970
+
2971
+ declare function replaceAll<
2972
+ Input extends string,
2973
+ Search extends string,
2974
+ Replacement extends string,
2975
+ >(
2976
+ input: Input,
2977
+ search: Search,
2978
+ replacement: Replacement,
2979
+ ): Replace<Input, Search, Replacement, {all: true}>;
2980
+
2981
+ // The return type is the exact string literal, not just `string`.
2982
+
2983
+ replace('hello ?', '?', '🦄');
2984
+ //=> 'hello 🦄'
2985
+
2986
+ replace('hello ??', '?', '❓');
2987
+ //=> 'hello ❓?'
2988
+
2989
+ replaceAll('10:42:00', ':', '-');
2990
+ //=> '10-42-00'
2991
+
2992
+ replaceAll('__userName__', '__', '');
2993
+ //=> 'userName'
2994
+
2995
+ replaceAll('My Cool Title', ' ', '');
2996
+ //=> 'MyCoolTitle'
2997
+ ```
2998
+
2999
+ @category String
3000
+ @category Template literal
3001
+ */
3002
+ type Replace<Input extends string, Search extends string, Replacement extends string, Options extends ReplaceOptions = {}> = _Replace<Input, Search, Replacement, ApplyDefaultOptions<ReplaceOptions, DefaultReplaceOptions, Options>>;
3003
+ type _Replace<Input extends string, Search extends string, Replacement extends string, Options extends Required<ReplaceOptions>, Accumulator extends string = ''> = Search extends string // For distributing `Search`
3004
+ ? Replacement extends string // For distributing `Replacement`
3005
+ ? Input extends `${infer Head}${Search}${infer Tail}` ? Options['all'] extends true ? _Replace<Tail, Search, Replacement, Options, `${Accumulator}${Head}${Replacement}`> : `${Head}${Replacement}${Tail}` : `${Accumulator}${Input}` : never : never;
3006
+ //#endregion
3007
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/List.d.ts
3008
+ /**
3009
+ * A [[List]]
3010
+ * @param A its type
3011
+ * @returns [[List]]
3012
+ * @example
3013
+ * ```ts
3014
+ * type list0 = [1, 2, 3]
3015
+ * type list1 = number[]
3016
+ * ```
3017
+ */
3018
+ declare type List<A = any> = ReadonlyArray<A>;
3019
+ //#endregion
3020
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Cast.d.ts
3021
+ /**
3022
+ * Ask TS to re-check that `A1` extends `A2`.
3023
+ * And if it fails, `A2` will be enforced anyway.
3024
+ * Can also be used to add constraints on parameters.
3025
+ * @param A1 to check against
3026
+ * @param A2 to cast to
3027
+ * @returns `A1 | A2`
3028
+ * @example
3029
+ * ```ts
3030
+ * import {A} from 'ts-toolbelt'
3031
+ *
3032
+ * type test0 = A.Cast<'42', string> // '42'
3033
+ * type test1 = A.Cast<'42', number> // number
3034
+ * ```
3035
+ */
3036
+ declare type Cast<A1 extends any, A2 extends any> = A1 extends A2 ? A1 : A2;
3037
+ //#endregion
3038
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Any/Extends.d.ts
3039
+ /**
3040
+ * Check whether `A1` is part of `A2` or not. The difference with
3041
+ * `extends` is that it forces a [[Boolean]] return.
3042
+ * @param A1
3043
+ * @param A2
3044
+ * @returns [[Boolean]]
3045
+ * @example
3046
+ * ```ts
3047
+ * import {A} from 'ts-toolbelt'
3048
+ *
3049
+ * type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
3050
+ * type test1 = A.Extends<'a', 'a' | 'b'> // True
3051
+ *
3052
+ * type test2 = A.Extends<{a: string}, {a: any}> // True
3053
+ * type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
3054
+ *
3055
+ * type test4 = A.Extends<never, never> // False
3056
+ * /// Nothing cannot extend nothing, use `A.Equals`
3057
+ * ```
3058
+ */
3059
+ declare type Extends<A1 extends any, A2 extends any> = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0;
3060
+ //#endregion
3061
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Iteration.d.ts
3062
+ /**
3063
+ * An entry of `IterationMap`
3064
+ */
3065
+ declare type Iteration = [value: number, sign: '-' | '0' | '+', prev: keyof IterationMap, next: keyof IterationMap, oppo: keyof IterationMap];
3066
+ declare type IterationMap = {
3067
+ '__': [number, '-' | '0' | '+', '__', '__', '__'];
3068
+ '-100': [-100, '-', '__', '-99', '100'];
3069
+ '-99': [-99, '-', '-100', '-98', '99'];
3070
+ '-98': [-98, '-', '-99', '-97', '98'];
3071
+ '-97': [-97, '-', '-98', '-96', '97'];
3072
+ '-96': [-96, '-', '-97', '-95', '96'];
3073
+ '-95': [-95, '-', '-96', '-94', '95'];
3074
+ '-94': [-94, '-', '-95', '-93', '94'];
3075
+ '-93': [-93, '-', '-94', '-92', '93'];
3076
+ '-92': [-92, '-', '-93', '-91', '92'];
3077
+ '-91': [-91, '-', '-92', '-90', '91'];
3078
+ '-90': [-90, '-', '-91', '-89', '90'];
3079
+ '-89': [-89, '-', '-90', '-88', '89'];
3080
+ '-88': [-88, '-', '-89', '-87', '88'];
3081
+ '-87': [-87, '-', '-88', '-86', '87'];
3082
+ '-86': [-86, '-', '-87', '-85', '86'];
3083
+ '-85': [-85, '-', '-86', '-84', '85'];
3084
+ '-84': [-84, '-', '-85', '-83', '84'];
3085
+ '-83': [-83, '-', '-84', '-82', '83'];
3086
+ '-82': [-82, '-', '-83', '-81', '82'];
3087
+ '-81': [-81, '-', '-82', '-80', '81'];
3088
+ '-80': [-80, '-', '-81', '-79', '80'];
3089
+ '-79': [-79, '-', '-80', '-78', '79'];
3090
+ '-78': [-78, '-', '-79', '-77', '78'];
3091
+ '-77': [-77, '-', '-78', '-76', '77'];
3092
+ '-76': [-76, '-', '-77', '-75', '76'];
3093
+ '-75': [-75, '-', '-76', '-74', '75'];
3094
+ '-74': [-74, '-', '-75', '-73', '74'];
3095
+ '-73': [-73, '-', '-74', '-72', '73'];
3096
+ '-72': [-72, '-', '-73', '-71', '72'];
3097
+ '-71': [-71, '-', '-72', '-70', '71'];
3098
+ '-70': [-70, '-', '-71', '-69', '70'];
3099
+ '-69': [-69, '-', '-70', '-68', '69'];
3100
+ '-68': [-68, '-', '-69', '-67', '68'];
3101
+ '-67': [-67, '-', '-68', '-66', '67'];
3102
+ '-66': [-66, '-', '-67', '-65', '66'];
3103
+ '-65': [-65, '-', '-66', '-64', '65'];
3104
+ '-64': [-64, '-', '-65', '-63', '64'];
3105
+ '-63': [-63, '-', '-64', '-62', '63'];
3106
+ '-62': [-62, '-', '-63', '-61', '62'];
3107
+ '-61': [-61, '-', '-62', '-60', '61'];
3108
+ '-60': [-60, '-', '-61', '-59', '60'];
3109
+ '-59': [-59, '-', '-60', '-58', '59'];
3110
+ '-58': [-58, '-', '-59', '-57', '58'];
3111
+ '-57': [-57, '-', '-58', '-56', '57'];
3112
+ '-56': [-56, '-', '-57', '-55', '56'];
3113
+ '-55': [-55, '-', '-56', '-54', '55'];
3114
+ '-54': [-54, '-', '-55', '-53', '54'];
3115
+ '-53': [-53, '-', '-54', '-52', '53'];
3116
+ '-52': [-52, '-', '-53', '-51', '52'];
3117
+ '-51': [-51, '-', '-52', '-50', '51'];
3118
+ '-50': [-50, '-', '-51', '-49', '50'];
3119
+ '-49': [-49, '-', '-50', '-48', '49'];
3120
+ '-48': [-48, '-', '-49', '-47', '48'];
3121
+ '-47': [-47, '-', '-48', '-46', '47'];
3122
+ '-46': [-46, '-', '-47', '-45', '46'];
3123
+ '-45': [-45, '-', '-46', '-44', '45'];
3124
+ '-44': [-44, '-', '-45', '-43', '44'];
3125
+ '-43': [-43, '-', '-44', '-42', '43'];
3126
+ '-42': [-42, '-', '-43', '-41', '42'];
3127
+ '-41': [-41, '-', '-42', '-40', '41'];
3128
+ '-40': [-40, '-', '-41', '-39', '40'];
3129
+ '-39': [-39, '-', '-40', '-38', '39'];
3130
+ '-38': [-38, '-', '-39', '-37', '38'];
3131
+ '-37': [-37, '-', '-38', '-36', '37'];
3132
+ '-36': [-36, '-', '-37', '-35', '36'];
3133
+ '-35': [-35, '-', '-36', '-34', '35'];
3134
+ '-34': [-34, '-', '-35', '-33', '34'];
3135
+ '-33': [-33, '-', '-34', '-32', '33'];
3136
+ '-32': [-32, '-', '-33', '-31', '32'];
3137
+ '-31': [-31, '-', '-32', '-30', '31'];
3138
+ '-30': [-30, '-', '-31', '-29', '30'];
3139
+ '-29': [-29, '-', '-30', '-28', '29'];
3140
+ '-28': [-28, '-', '-29', '-27', '28'];
3141
+ '-27': [-27, '-', '-28', '-26', '27'];
3142
+ '-26': [-26, '-', '-27', '-25', '26'];
3143
+ '-25': [-25, '-', '-26', '-24', '25'];
3144
+ '-24': [-24, '-', '-25', '-23', '24'];
3145
+ '-23': [-23, '-', '-24', '-22', '23'];
3146
+ '-22': [-22, '-', '-23', '-21', '22'];
3147
+ '-21': [-21, '-', '-22', '-20', '21'];
3148
+ '-20': [-20, '-', '-21', '-19', '20'];
3149
+ '-19': [-19, '-', '-20', '-18', '19'];
3150
+ '-18': [-18, '-', '-19', '-17', '18'];
3151
+ '-17': [-17, '-', '-18', '-16', '17'];
3152
+ '-16': [-16, '-', '-17', '-15', '16'];
3153
+ '-15': [-15, '-', '-16', '-14', '15'];
3154
+ '-14': [-14, '-', '-15', '-13', '14'];
3155
+ '-13': [-13, '-', '-14', '-12', '13'];
3156
+ '-12': [-12, '-', '-13', '-11', '12'];
3157
+ '-11': [-11, '-', '-12', '-10', '11'];
3158
+ '-10': [-10, '-', '-11', '-9', '10'];
3159
+ '-9': [-9, '-', '-10', '-8', '9'];
3160
+ '-8': [-8, '-', '-9', '-7', '8'];
3161
+ '-7': [-7, '-', '-8', '-6', '7'];
3162
+ '-6': [-6, '-', '-7', '-5', '6'];
3163
+ '-5': [-5, '-', '-6', '-4', '5'];
3164
+ '-4': [-4, '-', '-5', '-3', '4'];
3165
+ '-3': [-3, '-', '-4', '-2', '3'];
3166
+ '-2': [-2, '-', '-3', '-1', '2'];
3167
+ '-1': [-1, '-', '-2', '0', '1'];
3168
+ '0': [0, '0', '-1', '1', '0'];
3169
+ '1': [1, '+', '0', '2', '-1'];
3170
+ '2': [2, '+', '1', '3', '-2'];
3171
+ '3': [3, '+', '2', '4', '-3'];
3172
+ '4': [4, '+', '3', '5', '-4'];
3173
+ '5': [5, '+', '4', '6', '-5'];
3174
+ '6': [6, '+', '5', '7', '-6'];
3175
+ '7': [7, '+', '6', '8', '-7'];
3176
+ '8': [8, '+', '7', '9', '-8'];
3177
+ '9': [9, '+', '8', '10', '-9'];
3178
+ '10': [10, '+', '9', '11', '-10'];
3179
+ '11': [11, '+', '10', '12', '-11'];
3180
+ '12': [12, '+', '11', '13', '-12'];
3181
+ '13': [13, '+', '12', '14', '-13'];
3182
+ '14': [14, '+', '13', '15', '-14'];
3183
+ '15': [15, '+', '14', '16', '-15'];
3184
+ '16': [16, '+', '15', '17', '-16'];
3185
+ '17': [17, '+', '16', '18', '-17'];
3186
+ '18': [18, '+', '17', '19', '-18'];
3187
+ '19': [19, '+', '18', '20', '-19'];
3188
+ '20': [20, '+', '19', '21', '-20'];
3189
+ '21': [21, '+', '20', '22', '-21'];
3190
+ '22': [22, '+', '21', '23', '-22'];
3191
+ '23': [23, '+', '22', '24', '-23'];
3192
+ '24': [24, '+', '23', '25', '-24'];
3193
+ '25': [25, '+', '24', '26', '-25'];
3194
+ '26': [26, '+', '25', '27', '-26'];
3195
+ '27': [27, '+', '26', '28', '-27'];
3196
+ '28': [28, '+', '27', '29', '-28'];
3197
+ '29': [29, '+', '28', '30', '-29'];
3198
+ '30': [30, '+', '29', '31', '-30'];
3199
+ '31': [31, '+', '30', '32', '-31'];
3200
+ '32': [32, '+', '31', '33', '-32'];
3201
+ '33': [33, '+', '32', '34', '-33'];
3202
+ '34': [34, '+', '33', '35', '-34'];
3203
+ '35': [35, '+', '34', '36', '-35'];
3204
+ '36': [36, '+', '35', '37', '-36'];
3205
+ '37': [37, '+', '36', '38', '-37'];
3206
+ '38': [38, '+', '37', '39', '-38'];
3207
+ '39': [39, '+', '38', '40', '-39'];
3208
+ '40': [40, '+', '39', '41', '-40'];
3209
+ '41': [41, '+', '40', '42', '-41'];
3210
+ '42': [42, '+', '41', '43', '-42'];
3211
+ '43': [43, '+', '42', '44', '-43'];
3212
+ '44': [44, '+', '43', '45', '-44'];
3213
+ '45': [45, '+', '44', '46', '-45'];
3214
+ '46': [46, '+', '45', '47', '-46'];
3215
+ '47': [47, '+', '46', '48', '-47'];
3216
+ '48': [48, '+', '47', '49', '-48'];
3217
+ '49': [49, '+', '48', '50', '-49'];
3218
+ '50': [50, '+', '49', '51', '-50'];
3219
+ '51': [51, '+', '50', '52', '-51'];
3220
+ '52': [52, '+', '51', '53', '-52'];
3221
+ '53': [53, '+', '52', '54', '-53'];
3222
+ '54': [54, '+', '53', '55', '-54'];
3223
+ '55': [55, '+', '54', '56', '-55'];
3224
+ '56': [56, '+', '55', '57', '-56'];
3225
+ '57': [57, '+', '56', '58', '-57'];
3226
+ '58': [58, '+', '57', '59', '-58'];
3227
+ '59': [59, '+', '58', '60', '-59'];
3228
+ '60': [60, '+', '59', '61', '-60'];
3229
+ '61': [61, '+', '60', '62', '-61'];
3230
+ '62': [62, '+', '61', '63', '-62'];
3231
+ '63': [63, '+', '62', '64', '-63'];
3232
+ '64': [64, '+', '63', '65', '-64'];
3233
+ '65': [65, '+', '64', '66', '-65'];
3234
+ '66': [66, '+', '65', '67', '-66'];
3235
+ '67': [67, '+', '66', '68', '-67'];
3236
+ '68': [68, '+', '67', '69', '-68'];
3237
+ '69': [69, '+', '68', '70', '-69'];
3238
+ '70': [70, '+', '69', '71', '-70'];
3239
+ '71': [71, '+', '70', '72', '-71'];
3240
+ '72': [72, '+', '71', '73', '-72'];
3241
+ '73': [73, '+', '72', '74', '-73'];
3242
+ '74': [74, '+', '73', '75', '-74'];
3243
+ '75': [75, '+', '74', '76', '-75'];
3244
+ '76': [76, '+', '75', '77', '-76'];
3245
+ '77': [77, '+', '76', '78', '-77'];
3246
+ '78': [78, '+', '77', '79', '-78'];
3247
+ '79': [79, '+', '78', '80', '-79'];
3248
+ '80': [80, '+', '79', '81', '-80'];
3249
+ '81': [81, '+', '80', '82', '-81'];
3250
+ '82': [82, '+', '81', '83', '-82'];
3251
+ '83': [83, '+', '82', '84', '-83'];
3252
+ '84': [84, '+', '83', '85', '-84'];
3253
+ '85': [85, '+', '84', '86', '-85'];
3254
+ '86': [86, '+', '85', '87', '-86'];
3255
+ '87': [87, '+', '86', '88', '-87'];
3256
+ '88': [88, '+', '87', '89', '-88'];
3257
+ '89': [89, '+', '88', '90', '-89'];
3258
+ '90': [90, '+', '89', '91', '-90'];
3259
+ '91': [91, '+', '90', '92', '-91'];
3260
+ '92': [92, '+', '91', '93', '-92'];
3261
+ '93': [93, '+', '92', '94', '-93'];
3262
+ '94': [94, '+', '93', '95', '-94'];
3263
+ '95': [95, '+', '94', '96', '-95'];
3264
+ '96': [96, '+', '95', '97', '-96'];
3265
+ '97': [97, '+', '96', '98', '-97'];
3266
+ '98': [98, '+', '97', '99', '-98'];
3267
+ '99': [99, '+', '98', '100', '-99'];
3268
+ '100': [100, '+', '99', '__', '-100'];
3269
+ };
3270
+ //#endregion
3271
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Prev.d.ts
3272
+ /**
3273
+ * Move `I`'s position backwards
3274
+ * @param I to move
3275
+ * @returns [[Iteration]]
3276
+ * @example
3277
+ * ```ts
3278
+ * import {I} from 'ts-toolbelt'
3279
+ *
3280
+ * type i = I.IterationOf<'20'>
3281
+ *
3282
+ * type test0 = I.Pos<i> // 20
3283
+ * type test1 = I.Pos<I.Prev<i>> // 19
3284
+ * ```
3285
+ */
3286
+ declare type Prev<I extends Iteration> = IterationMap[I[2]];
3287
+ //#endregion
3288
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/IterationOf.d.ts
3289
+ /**
3290
+ * Transform a number into an [[Iteration]]
3291
+ * (to use [[Prev]], [[Next]], & [[Pos]])
3292
+ * @param N to transform
3293
+ * @returns [[Iteration]]
3294
+ * @example
3295
+ * ```ts
3296
+ * import {I} from 'ts-toolbelt'
3297
+ *
3298
+ * type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
3299
+ *
3300
+ * type next = I.Next<i> // ["0", "2", "1", 1, "+"]
3301
+ * type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
3302
+ *
3303
+ * type nnext = I.Pos<next> // +1
3304
+ * type nprev = I.Pos<prev> // -1
3305
+ * ```
3306
+ */
3307
+ declare type IterationOf<N extends number> = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__'];
3308
+ //#endregion
3309
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/Pos.d.ts
3310
+ /**
3311
+ * Get the position of `I` (**number**)
3312
+ * @param I to query
3313
+ * @returns `number`
3314
+ * @example
3315
+ * ```ts
3316
+ * import {I} from 'ts-toolbelt'
3317
+ *
3318
+ * type i = I.IterationOf<'20'>
3319
+ *
3320
+ * type test0 = I.Pos<i> // 20
3321
+ * type test1 = I.Pos<I.Next<i>> // 21
3322
+ * ```
3323
+ */
3324
+ declare type Pos<I extends Iteration> = I[0];
3325
+ //#endregion
3326
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Tail.d.ts
3327
+ /**
3328
+ * Remove the first item out of a [[List]]
3329
+ * @param L
3330
+ * @returns [[List]]
3331
+ * @example
3332
+ * ```ts
3333
+ * ```
3334
+ */
3335
+ declare type Tail$1<L extends List> = L extends readonly [] ? L : L extends readonly [any?, ...infer LTail] ? LTail : L;
3336
+ //#endregion
3337
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Object/Overwrite.d.ts
3338
+ /**
3339
+ * Update the fields of `O` with the ones of `O1`
3340
+ * (only the existing fields will be updated)
3341
+ * @param O to update
3342
+ * @param O1 to update with
3343
+ * @returns [[Object]]
3344
+ * @example
3345
+ * ```ts
3346
+ * ```
3347
+ */
3348
+ declare type Overwrite<O extends object, O1 extends object> = { [K in keyof O]: K extends keyof O1 ? O1[K] : O[K] } & {};
3349
+ //#endregion
3350
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/_Internal.d.ts
3351
+ /**
3352
+ * Remove `?` & `readonly` from a [[List]]
3353
+ */
3354
+ declare type Naked<L extends List> = Overwrite<Required<L>, L>;
3355
+ //#endregion
3356
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Prepend.d.ts
3357
+ /**
3358
+ * Add an element `A` at the beginning of `L`
3359
+ * @param L to append to
3360
+ * @param A to be added to
3361
+ * @returns [[List]]
3362
+ * @example
3363
+ * ```ts
3364
+ * ```
3365
+ */
3366
+ declare type Prepend<L extends List, A extends any> = [A, ...L];
3367
+ //#endregion
3368
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/Iteration/_Internal.d.ts
3369
+ /**
3370
+ * Describes how to perform iterations
3371
+ */
3372
+ declare type Way = '->' | '<-';
3373
+ //#endregion
3374
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Append.d.ts
3375
+ /**
3376
+ * Add an element `A` at the end of `L`.
3377
+ * @param L to append to
3378
+ * @param A to be added to
3379
+ * @returns [[List]]
3380
+ * @example
3381
+ * ```ts
3382
+ * import {L} from 'ts-toolbelt'
3383
+ *
3384
+ * type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
3385
+ * type test1 = L.Append<[], 'a'> // ['a']
3386
+ * type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
3387
+ * type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]
3388
+ * ```
3389
+ */
3390
+ declare type Append<L extends List, A extends any> = [...L, A];
3391
+ //#endregion
3392
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Drop.d.ts
3393
+ /**
3394
+ * @hidden
3395
+ */
3396
+ declare type DropForth<L extends List, N extends Iteration> = {
3397
+ 0: DropForth<Tail$1<L>, Prev<N>>;
3398
+ 1: L;
3399
+ }[Extends<0, Pos<N>>];
3400
+ /**
3401
+ * @hidden
3402
+ */
3403
+ declare type DropBack<L extends List, N extends Iteration, I extends Iteration = Prev<N>, LN extends List = []> = {
3404
+ 0: DropBack<L, N, Prev<I>, Prepend<LN, L[Pos<I>]>>;
3405
+ 1: LN;
3406
+ }[Extends<-1, Pos<I>>];
3407
+ /**
3408
+ * @hidden
3409
+ */
3410
+ declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
3411
+ '->': DropForth<L, N>;
3412
+ '<-': DropBack<L, N>;
3413
+ }[way];
3414
+ /**
3415
+ * @hidden
3416
+ */
3417
+ declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
3418
+ /**
3419
+ * Remove `N` entries out of `L`
3420
+ * @param L to remove from
3421
+ * @param N to remove out
3422
+ * @param way (?=`'->'`) from front: '->', from end: '<-'
3423
+ * @returns [[List]]
3424
+ * @example
3425
+ * ```ts
3426
+ * ```
3427
+ */
3428
+ declare type Drop<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Drop<L, N, way> : never : never;
3429
+ //#endregion
3430
+ //#region ../../node_modules/.pnpm/ts-toolbelt@9.6.0/node_modules/ts-toolbelt/out/List/Take.d.ts
3431
+ /**
3432
+ * starts in reverse from `N` till `N` = 0
3433
+ * @hidden
3434
+ */
3435
+ declare type TakeForth<L extends List, N extends Iteration, I extends Iteration = Prev<N>, LN extends List = []> = {
3436
+ 0: TakeForth<L, N, Prev<I>, Prepend<LN, L[Pos<I>]>>;
3437
+ 1: LN;
3438
+ }[Extends<-1, Pos<I>>];
3439
+ /**
3440
+ * starts in reverse from the end till `N` = 0
3441
+ * @hidden
3442
+ */
3443
+ declare type TakeBack<L extends List, N extends Iteration> = {
3444
+ 0: TakeBack<Tail$1<L>, Prev<N>>;
3445
+ 1: L;
3446
+ }[Extends<0, Pos<N>>];
3447
+ /**
3448
+ * @hidden
3449
+ */
3450
+ declare type __Take<L extends List, N extends Iteration, way extends Way> = {
3451
+ '->': TakeForth<L, N>;
3452
+ '<-': TakeBack<L, N>;
3453
+ }[way];
3454
+ /**
3455
+ * @hidden
3456
+ */
3457
+ declare type _Take<L extends List, N extends number, way extends Way = '->'> = __Take<L, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
3458
+ /**
3459
+ * Extract `N` entries out of `L`
3460
+ * @param L to extract from
3461
+ * @param N to extract out
3462
+ * @param way (?=`'->'`) to extract from end
3463
+ * @returns [[List]]
3464
+ * @example
3465
+ * ```ts
3466
+ * ```
3467
+ */
3468
+ declare type Take<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Take<L, N, way> : never : never;
3469
+ //#endregion
3470
+ //#region src/object/index.type.d.ts
3471
+ type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
3472
+ type AnyArray<A = any> = readonly A[];
3473
+ type TupleToEntries<A extends readonly unknown[]> = If<IsAny<A>, unknown, { [Key in keyof A]: [Key, A[Key]] }>;
3474
+ type Groups<L extends AnyArray, LN extends AnyArray = [], D extends number[] = []> = D["length"] extends 40 ? LN : {
3475
+ 0: Groups<Drop<L, 1>, Append<LN, [`${LN["length"]}`, Take<L, 1>]>, [...D, 0]>;
3476
+ 1: LN;
3477
+ }[Extends<L, AnyArray<never>>];
3478
+ type TupleToGroups<L extends AnyArray> = Groups<L> extends infer X ? Cast<X, AnyArray> : never;
3479
+ type Crush<T> = T extends readonly (infer U)[] ? Record<string, U extends object ? unknown : U> : Simplify<UnionToIntersection<keyof T extends infer Prop ? Prop extends keyof T ? T[Prop] extends infer Value ? ([Extract<Value, object>] extends [never] ? never : Record<string, unknown>) | ([Exclude<Value, object>] extends [never] ? never : [Extract<Value, object>] extends [never] ? { [P in Prop]: Value } : Record<string, unknown>) : never : never : never>>;
3480
+ type IntersectOf<U> = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
3481
+ type ComputeRaw<A> = A extends AnyFunction ? A : { [K in keyof A]: A[K] } & unknown;
3482
+ type _Invert<O extends Record<PropertyKey, PropertyKey>> = ComputeRaw<IntersectOf<{ [K in keyof O]: Record<O[K], K> }[keyof O]>>;
3483
+ type Invert<O extends Record<keyof O, PropertyKey>> = O extends unknown ? _Invert<O> : never;
3484
+ //#endregion
3485
+ //#region src/object/objectUtil.d.ts
3486
+ /**
3487
+ * 对象工具类
3488
+ */
3489
+ declare class ObjectUtil {
3490
+ /**
3491
+ * 返回对象可枚举属性和方法的名称
3492
+ * - `Object.keys` 始终返回 `string[]` 类型,此函数可以返回具体类型
3493
+ *
3494
+ * @param value 对象
3495
+ * @returns 键数组
3496
+ * @example
3497
+ * ```ts
3498
+ * // 重载 1: string
3499
+ * ObjectUtil.keys("abc"); // ["0", "1", "2"]
3500
+ *
3501
+ * // 重载 2: ArrayLike
3502
+ * ObjectUtil.keys([10, 20]); // ["0", "1"]
3503
+ *
3504
+ * // 重载 3: PlainObject
3505
+ * ObjectUtil.keys({ a: 1, b: 2 }); // ["a", "b"]
3506
+ *
3507
+ * // 重载 4: AnyObject
3508
+ * const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
3509
+ * ObjectUtil.keys(anyObj); // ["x", "y"]
3510
+ * ```
3511
+ */
3512
+ static keys<const S extends string>(string: S): UnionToTuple<Range<0, Split<S, "">["length"]>>;
3513
+ static keys<const A extends ArrayLike<unknown>>(array: A): UnionToTuple<Range<0, A["length"]>>;
3514
+ static keys<O extends PlainObject>(plainObject: O): `${Extract<keyof O, string | number>}`[];
3515
+ static keys<O extends AnyObject>(anyObject: O): `${Extract<keyof O, string | number>}`[];
3516
+ /**
3517
+ * 返回对象可枚举属性的值的数组
3518
+ *
3519
+ * @param value 对象
3520
+ * @returns 值数组
3521
+ * @example
3522
+ * ```ts
3523
+ * // 重载 1: string
3524
+ * ObjectUtil.values("abc"); // ["a", "b", "c"]
3525
+ *
3526
+ * // 重载 2: ArrayLike
3527
+ * ObjectUtil.values([10, 20]); // [10, 20]
3528
+ *
3529
+ * // 重载 3: PlainObject
3530
+ * ObjectUtil.values({ a: 1, b: 2 }); // [1, 2]
3531
+ *
3532
+ * // 重载 4: AnyObject
3533
+ * const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
3534
+ * ObjectUtil.values(anyObj); // [1, 2]
3535
+ * ```
3536
+ */
3537
+ static values<S extends string>(string: S): Split<S, "">;
3538
+ static values<A extends ArrayLike<unknown>>(array: A): A;
3539
+ static values<O extends PlainObject>(plainObject: O): O[keyof O][];
3540
+ static values<O extends AnyObject>(anyObject: O): O[keyof O][];
3541
+ /**
3542
+ * 返回对象的可枚举属性的键/值数组
3543
+ *
3544
+ * @param value 对象
3545
+ * @returns 键值对数组
3546
+ * @example
3547
+ * ```ts
3548
+ * // 重载 1: string
3549
+ * ObjectUtil.entries("ab"); // [["0", "a"], ["1", "b"]]
3550
+ *
3551
+ * // 重载 2: readonly array
3552
+ * ObjectUtil.entries([10, 20] as const); // [["0", 10], ["1", 20]]
3553
+ *
3554
+ * // 重载 3: PlainObject
3555
+ * ObjectUtil.entries({ a: 1 }); // [["a", 1]]
3556
+ *
3557
+ * // 重载 4: AnyObject
3558
+ * const anyObj = { x: 1 } as Record<string, unknown>;
3559
+ * ObjectUtil.entries(anyObj); // [["x", 1]]
3560
+ * ```
3561
+ */
3562
+ static entries<const S extends string>(string: S): TupleToEntries<Split<S, "">>;
3563
+ static entries<const A extends readonly unknown[]>(array: A): TupleToGroups<A>;
3564
+ static entries<const O extends PlainObject>(plainObject: O): [`${keyof Except<O, symbol>}`, O[keyof Except<O, symbol>]][];
3565
+ static entries<const O extends AnyObject>(anyObject: O): [`${keyof Except<O, symbol>}`, O[keyof Except<O, symbol>]][];
3566
+ /**
3567
+ * 映射对象条目
3568
+ * - 将对象的键值对映射为新的键值对
3569
+ *
3570
+ * @param plainObject 对象
3571
+ * @param toEntry 映射函数
3572
+ * @returns 映射后的新对象
3573
+ * @example
3574
+ * ```ts
3575
+ * const obj = { a: 1, b: 2 };
3576
+ *
3577
+ * ObjectUtil.entriesMap(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
3578
+ *
3579
+ * ObjectUtil.entriesMap(obj, (k, v) => [`prefix_${String(k)}`, `${v}x`]); // { prefix_a: "1x", prefix_b: "2x" }
3580
+ * ```
3581
+ */
3582
+ static entriesMap<O extends PlainObject, NK extends PropertyKey, NV>(plainObject: O, toEntry: (key: keyof O, value: O[keyof O]) => [NK, NV]): PlainObject<NK, NV>;
3583
+ /**
3584
+ * 选取对象的指定属性
3585
+ *
3586
+ * @param plainObject 对象
3587
+ * @param keys 要选取的属性键数组
3588
+ * @returns 包含指定属性的新对象
3589
+ * @example
3590
+ * ```ts
3591
+ * // 重载 1: PlainObject
3592
+ * ObjectUtil.pick({ a: 1, b: 2 }, ["a"]); // { a: 1 }
3593
+ *
3594
+ * // 重载 2: AnyObject
3595
+ * const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
3596
+ * ObjectUtil.pick(anyObj, ["x"]); // { x: 1 }
3597
+ * ```
3598
+ */
3599
+ static pick<O extends PlainObject, K extends keyof O>(plainObject: O, keys: readonly K[]): Pick<O, K>;
3600
+ static pick<O extends AnyObject, K extends keyof O>(anyObject: O, keys: readonly K[]): Pick<O, K>;
3601
+ /**
3602
+ * 排除对象的指定属性
3603
+ *
3604
+ * @param plainObject 对象
3605
+ * @param keys 要排除的属性键数组
3606
+ * @returns 排除指定属性后的新对象
3607
+ * @example
3608
+ * ```ts
3609
+ * // 重载 1: PlainObject
3610
+ * ObjectUtil.omit({ a: 1, b: 2 }, ["a"]); // { b: 2 }
3611
+ *
3612
+ * // 重载 2: AnyObject
3613
+ * const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
3614
+ * ObjectUtil.omit(anyObj, ["x"]); // { y: 2 }
3615
+ * ```
3616
+ */
3617
+ static omit<O extends PlainObject, K extends keyof O>(plainObject: O, keys: readonly K[]): Omit<O, K>;
3618
+ static omit<O extends AnyObject, K extends keyof O>(anyObject: O, keys: readonly K[]): PlainObject;
3619
+ /**
3620
+ * 尽可能地交换对象的键和值
3621
+ *
3622
+ * @param obj 对象
3623
+ * @returns 键值互换后的对象
3624
+ * @example
3625
+ * ```ts
3626
+ * // 重载 1: Record<keyof O, PropertyKey>
3627
+ * const obj = { a: "1", b: 2 };
3628
+ * ObjectUtil.invert(obj); // { "1": "a", 2: "b" }
3629
+ *
3630
+ * // 重载 2: AnyObject
3631
+ * const anyObj = { x: Symbol.for("s"), y: true } as Record<string, unknown>;
3632
+ * ObjectUtil.invert(anyObj); // { [Symbol.for("s")]: "x" }
3633
+ * ```
3634
+ */
3635
+ static invert<const O extends Record<keyof O, PropertyKey>>(plainObject: O): Invert<O>;
3636
+ static invert<const O extends AnyObject>(anyObject: O): Invert<O>;
3637
+ /**
3638
+ * 压平对象
3639
+ * - 将多层级的对象转换为单层级的对象,键名使用点号连接
3640
+ *
3641
+ * @param plainObject 平面对象
3642
+ * @returns 压平后的对象
3643
+ * @example
3644
+ * ```ts
3645
+ * // 重载 1: PlainObject
3646
+ * const plainObj = { a: { b: 1 } };
3647
+ * ObjectUtil.crush(plainObj); // { "a.b": 1 }
3648
+ *
3649
+ * // 重载 2: AnyObject
3650
+ * const anyObj = { list: [{ id: 1 }] } as Record<string, unknown>;
3651
+ * ObjectUtil.crush(anyObj); // { "list.0.id": 1 }
3652
+ * ```
3653
+ */
3654
+ static crush<T extends PlainObject>(plainObject: T): Crush<T>;
3655
+ static crush<T extends AnyObject>(anyObject: T): Crush<T>;
3656
+ /**
3657
+ * 获取所有枚举成员的键
3658
+ *
3659
+ * @param enumeration 枚举对象
3660
+ * @returns 键数组
3661
+ * @example
3662
+ * ```ts
3663
+ * // 重载 1: PlainObject
3664
+ * enum StringEnum { A = "a", B = "b" }
3665
+ * ObjectUtil.enumKeys(StringEnum); // ["A", "B"]
3666
+ *
3667
+ * // 重载 2: AnyObject
3668
+ * enum NumberEnum { A, B }
3669
+ * const anyEnum = NumberEnum as Record<string, unknown>;
3670
+ * ObjectUtil.enumKeys(anyEnum); // ["A", "B"]
3671
+ * ```
3672
+ */
3673
+ static enumKeys<E extends PlainObject>(enumeration: E): (keyof E)[];
3674
+ static enumKeys<E extends AnyObject>(enumeration: E): (keyof E)[];
3675
+ /**
3676
+ * 获取所有枚举成员的值
3677
+ *
3678
+ * @param enumeration 枚举对象
3679
+ * @returns 值数组
3680
+ * @example
3681
+ * ```ts
3682
+ * // 重载 1: PlainObject
3683
+ * enum StringEnum { A = "a", B = "b" }
3684
+ * ObjectUtil.enumValues(StringEnum); // ["a", "b"]
3685
+ *
3686
+ * // 重载 2: AnyObject
3687
+ * enum NumberEnum { A, B }
3688
+ * const anyEnum = NumberEnum as Record<string, unknown>;
3689
+ * ObjectUtil.enumValues(anyEnum); // [0, 1]
3690
+ * ```
3691
+ */
3692
+ static enumValues<E extends PlainObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
3693
+ static enumValues<E extends AnyObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
3694
+ /**
3695
+ * 获取所有枚举成员的键/值数组
3696
+ *
3697
+ * @param enumeration 枚举对象
3698
+ * @returns 键值对数组
3699
+ * @example
3700
+ * ```ts
3701
+ * // 重载 1: PlainObject
3702
+ * enum StringEnum { A = "a", B = "b" }
3703
+ * ObjectUtil.enumEntries(StringEnum); // [["A", "a"], ["B", "b"]]
3704
+ *
3705
+ * // 重载 2: AnyObject
3706
+ * enum NumberEnum { A, B }
3707
+ * const anyEnum = NumberEnum as Record<string, unknown>;
3708
+ * ObjectUtil.enumEntries(anyEnum); // [["A", 0], ["B", 1]]
3709
+ * ```
3710
+ */
3711
+ static enumEntries<E extends PlainObject>(enumeration: E): [keyof E, E[keyof E]][];
3712
+ static enumEntries<E extends AnyObject>(enumeration: E): [keyof E, E[keyof E]][];
3713
+ }
3714
+ //#endregion
3715
+ //#region src/string/stringUtil.d.ts
3716
+ /**
3717
+ * 字符串工具类
3718
+ */
3719
+ declare class StringUtil {
3720
+ /**
3721
+ * 从字符串中提取数字字符串
3722
+ * - 移除非数字字符,保留符号和小数点
3723
+ *
3724
+ * @param input 待处理字符串
3725
+ * @returns 提取出的数字字符串
3726
+ * @example
3727
+ * ```ts
3728
+ * StringUtil.toNumber("$1,234.56"); // "1234.56"
3729
+ * StringUtil.toNumber("abc-123"); // "-123"
3730
+ * ```
3731
+ */
3732
+ static toNumber(input: string): string;
3733
+ /**
3734
+ * 将字符串转换为小写
3735
+ * - 将字符串字面量类型转换为其小写形式
3736
+ * - 当输入无效时,返回空字符串
3737
+ *
3738
+ * @param input 待处理字符串
3739
+ * @returns 转换后的小写字符串类型,如果输入无效则返回空字符串类型 ""
3740
+ * @example
3741
+ * ```ts
3742
+ * // 重载 1: 输入 string
3743
+ * StringUtil.toLowerCase("HELLO"); // "hello"
3744
+ *
3745
+ * // 重载 2: 输入 unknown
3746
+ * StringUtil.toLowerCase(null); // ""
3747
+ * ```
3748
+ */
3749
+ static toLowerCase<const T extends string>(input: T): Lowercase<T>;
3750
+ static toLowerCase(input: unknown): "";
3751
+ /**
3752
+ * 将字符串转换为大写
3753
+ * - 将字符串字面量类型转换为其大写形式
3754
+ * - 当输入无效时,返回空字符串
3755
+ *
3756
+ * @param input 待处理字符串
3757
+ * @returns 转换后的大写字符串,如果输入无效则返回空字符串
3758
+ * @example
3759
+ * ```ts
3760
+ * // 重载 1: 输入 string
3761
+ * StringUtil.toUpperCase("hello"); // "HELLO"
3762
+ *
3763
+ * // 重载 2: 输入 unknown
3764
+ * StringUtil.toUpperCase(null); // ""
3765
+ * ```
3766
+ */
3767
+ static toUpperCase<const T extends string>(input: T): Uppercase<T>;
3768
+ static toUpperCase(input: unknown): "";
3769
+ /**
3770
+ * 字符串首字母大小写
3771
+ * - 包含非西欧字母字符时,不处理
3772
+ * - 纯字母且全大写时,不处理
3773
+ * - 纯字母且非全大写时,首字母小写,其余保留
3774
+ * - 纯字母且非全大写时,首字母大写,其余保留
3775
+ *
3776
+ * @param input 待处理字符串
3777
+ * @param caseType 大小写类型
3778
+ * @returns 处理后的字符串
3779
+ * @example
3780
+ * ```ts
3781
+ * StringUtil.toInitialCase("Hello", "lower"); // "hello"
3782
+ * StringUtil.toInitialCase("hello", "upper"); // "Hello"
3783
+ * ```
3784
+ */
3785
+ static toInitialCase(input: string, caseType?: "lower" | "upper" | undefined): string;
3786
+ /**
3787
+ * 将路径转换为 POSIX 风格
3788
+ * - 统一使用正斜杠 (/)
3789
+ * - 可选移除 Windows 盘符 (如 C:)
3790
+ * - 可选移除开头的斜杠
3791
+ * - 规范化连续斜杠为单个斜杠
3792
+ *
3793
+ * @param input 待处理字符串
3794
+ * @param removeLeadingSlash 是否移除开头斜杠,默认为 `false`。如果移除了盘符,路径通常会以 / 开头,此参数可控制是否保留该 /
3795
+ * @returns 转换后的路径,如果输入无效则返回空字符串
3796
+ *
3797
+ * @example
3798
+ * ```ts
3799
+ * StringUtil.toPosix("C:\\Windows\\System32"); // 默认: "/Windows/System32" (移除了 C: 并标准化)
3800
+ *
3801
+ * StringUtil.toPosix("C:\\Windows\\System32", true); // 移除开头斜杠: "Windows/System32"
3802
+ *
3803
+ * StringUtil.toPosix("\\\\server\\share\\file.txt"); // UNC 路径: "/server/share/file.txt"
3804
+ *
3805
+ * StringUtil.toPosix("folder\\subfolder\\file.txt"); // 相对路径: "folder/subfolder/file.txt"
3806
+ * ```
3807
+ */
3808
+ static toPosix(input: string | null | undefined, removeLeadingSlash?: boolean): string;
3809
+ /**
3810
+ * 处理 JSON 字符串
3811
+ *
3812
+ * @param input 待处理字符串
3813
+ * @param fallback 回退值
3814
+ * @returns 解析后的对象 或 回退值
3815
+ * @example
3816
+ * ```ts
3817
+ * // 重载 1: 无 fallback
3818
+ * StringUtil.toJson<{ a: number }>("{\"a\":1}"); // { a: 1 }
3819
+ * StringUtil.toJson("invalid"); // undefined
3820
+ *
3821
+ * // 重载 2: 有 fallback
3822
+ * StringUtil.toJson<{ a: number }>("invalid", { a: 0 }); // { a: 0 }
3823
+ * ```
3824
+ */
3825
+ static toJson<D extends AnyObject = AnyObject>(input: string | null | undefined): D | undefined;
3826
+ static toJson<D extends AnyObject = AnyObject>(input: string | null | undefined, fallback: D): D;
3827
+ /**
3828
+ * 字符串分割为数组
3829
+ * - 按指定分隔符分割字符串,并转换类型
3830
+ *
3831
+ * @param input 待处理字符串
3832
+ * @param valueType 数组中每一项的类型,默认为 "number"
3833
+ * @param splitSymbol 分隔符,默认为 `,`
3834
+ * @returns 分割后的数组
3835
+ * @example
3836
+ * ```ts
3837
+ * // 重载 1: valueType = "number" (默认)
3838
+ * StringUtil.toValues("1,2,3"); // [1, 2, 3]
3839
+ *
3840
+ * // 重载 2: valueType = "string"
3841
+ * StringUtil.toValues("a-b-c", "string", "-"); // ["a", "b", "c"]
3842
+ * ```
3843
+ */
3844
+ static toValues(input: string | null | undefined, valueType?: "number" | undefined, splitSymbol?: string | undefined): number[];
3845
+ static toValues(input: string | null | undefined, valueType: "string", splitSymbol?: string | undefined): string[];
3846
+ /**
3847
+ * 从字符串中裁切掉所有的前缀和后缀字符
3848
+ *
3849
+ * @param input 待处理字符串
3850
+ * @param charsToTrim 裁切字符,默认为 `" "`
3851
+ * @returns 裁切后的字符串
3852
+ * @example
3853
+ * ```ts
3854
+ * StringUtil.trim(" hello "); // "hello"
3855
+ * StringUtil.trim("__hello__", "_"); // "hello"
3856
+ * ```
3857
+ */
3858
+ static trim(input: string | null | undefined, charsToTrim?: string): string;
3859
+ /**
3860
+ * 截取字符串
3861
+ * - 支持自定义省略符,不会截断在汉字中间(因为JS字符串本身按字符处理)
3862
+ *
3863
+ * @param input 待处理字符串
3864
+ * @param maxLength 最大长度 (包含省略符)
3865
+ * @param ellipsis 省略符,默认为 `...`
3866
+ * @returns 截取后的字符串
3867
+ * @example
3868
+ * ```ts
3869
+ * StringUtil.truncate("hello world", 8); // "hello..."
3870
+ * ```
3871
+ */
3872
+ static truncate(input: string, maxLength: number, ellipsis?: string): string;
3873
+ /**
3874
+ * 字符串模板替换
3875
+ * - 使用对象的属性值替换字符串中的 {{key}} 模板
3876
+ *
3877
+ * @param input 待处理字符串
3878
+ * @param template 模板对象
3879
+ * @param regex 模板匹配正则 (默认: `\{\{(.+?)\}\}`)
3880
+ * @returns 替换后的字符串
3881
+ * @example
3882
+ * ```ts
3883
+ * StringUtil.template("Hello {{name}}", { name: "World" }); // "Hello World"
3884
+ * ```
3885
+ */
3886
+ static template(input: string, template: PlainObject, regex?: RegExp): string;
3887
+ /**
3888
+ * 字符串替换
3889
+ * - 替换第一个匹配项
3890
+ *
3891
+ * @param input 待处理字符串
3892
+ * @param search 匹配项
3893
+ * @param replacement 替换项
3894
+ * @returns 替换后的字符串
3895
+ * @example
3896
+ * ```ts
3897
+ * StringUtil.replace("hello world", "world", "context"); // "hello context"
3898
+ * ```
3899
+ */
3900
+ static replace<I extends string, S extends string, R extends string>(input: I, search: S, replacement: R): Replace<I, S, R>;
3901
+ }
3902
+ //#endregion
3903
+ //#region src/theme/themeUtil.d.ts
3904
+ /**
3905
+ * 主题工具类
3906
+ */
3907
+ declare class ThemeUtil {
3908
+ /**
3909
+ * 固定主题类型(仅亮色/暗色)
3910
+ *
3911
+ * @example
3912
+ * ```ts
3913
+ * ThemeUtil.THEME.LIGHT; // "light"
3914
+ * ThemeUtil.THEME.DARK; // "dark"
3915
+ * ```
3916
+ */
3917
+ static readonly THEME: {
3918
+ readonly LIGHT: "light";
3919
+ readonly DARK: "dark";
3920
+ };
3921
+ /**
3922
+ * 主题模式(支持跟随系统)
3923
+ *
3924
+ * @example
3925
+ * ```ts
3926
+ * ThemeUtil.THEME_MODE.SYSTEM; // "system"
3927
+ * ThemeUtil.THEME_MODE.DARK; // "dark"
3928
+ * ```
3929
+ */
3930
+ static readonly THEME_MODE: {
3931
+ readonly LIGHT: "light";
3932
+ readonly DARK: "dark";
3933
+ readonly SYSTEM: "system";
3934
+ };
3935
+ }
3936
+ //#endregion
3937
+ //#region src/theme/index.type.d.ts
3938
+ type THEME_TYPE = ValueOf<typeof ThemeUtil.THEME>;
3939
+ type THEME_MODE_TYPE = ValueOf<typeof ThemeUtil.THEME_MODE>;
3940
+ //#endregion
3941
+ //#region src/tree/index.type.d.ts
3942
+ type RowKey = "id";
3943
+ type ParentIdKey = "parentId";
3944
+ type ChildrenKey = "children";
3945
+ type Strategy = "pre" | "post" | "breadth";
3946
+ interface BaseCallbackMeta<T> {
3947
+ depth: number;
3948
+ parents?: T[] | undefined;
3949
+ }
3950
+ interface BaseOptions<T, CK extends string> {
3951
+ childrenKey?: CK;
3952
+ strategy?: Strategy;
3953
+ getChildrenKey?: ((row: T, meta: BaseCallbackMeta<T>) => CK) | undefined;
3954
+ }
3955
+ interface RowsToTreeOptions<RK extends string = RowKey, PK extends string = ParentIdKey, CK extends string = ChildrenKey> {
3956
+ rowKey?: RK;
3957
+ parentIdKey?: PK;
3958
+ childrenKey?: CK;
3959
+ }
3960
+ type TreeToRowsOptions<T extends AnyObject, CK extends string = ChildrenKey> = TreeForeachOptions<T, CK>;
3961
+ type TreeFindOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
3962
+ type TreeFindCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
3963
+ type TreeForeachOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
3964
+ type TreeForeachCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => void;
3965
+ type TreeFilterOptions<T extends AnyObject, CK extends string = ChildrenKey> = BaseOptions<T, CK>;
3966
+ type TreeFilterCallback<T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => boolean;
3967
+ type TreeMapOptions<T extends AnyObject, CK extends string> = BaseOptions<T, CK>;
3968
+ type TreeMapCallback<R extends AnyObject, T extends AnyObject> = (row: T, meta: BaseCallbackMeta<T>) => R;
3969
+ //#endregion
3970
+ //#region src/tree/treeUtil.d.ts
3971
+ /**
3972
+ * 树结构工具类
3973
+ */
3974
+ declare class TreeUtil {
3975
+ /**
3976
+ * 行结构 转 树结构
3977
+ * - 将平铺的数组转换为树形结构
3978
+ *
3979
+ * @param rows 行数据数组
3980
+ * @param options 配置项
3981
+ * @returns 树结构数组
3982
+ * @example
3983
+ * ```ts
3984
+ * const rows = [
3985
+ * { id: 1, parentId: null },
3986
+ * { id: 2, parentId: 1 },
3987
+ * ];
3988
+ * TreeUtil.rowsToTree(rows); // [{ id: 1, parentId: null, children: [{ id: 2, parentId: 1 }] }]
3989
+ * ```
3990
+ */
3991
+ static rowsToTree<T extends AnyObject = AnyObject, CK extends string = ChildrenKey, R = TreeLike<T, CK>, RK extends string = RowKey, PK extends string = ParentIdKey>(rows: T[], options?: RowsToTreeOptions<RK, PK, CK> | undefined): R[];
3992
+ /**
3993
+ * 树结构 转 行结构
3994
+ * - 将树形结构扁平化为数组
3995
+ *
3996
+ * @param tree 树结构数据 (单个节点或节点数组)
3997
+ * @param options 配置项
3998
+ * @returns 扁平化后的数组
3999
+ * @example
4000
+ * ```ts
4001
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
4002
+ * TreeUtil.treeToRows(tree); // [{ id: 1, children: undefined }, { id: 2, children: undefined }]
4003
+ * ```
4004
+ */
4005
+ static treeToRows<T extends AnyObject, CK extends string = ChildrenKey, R extends AnyObject = SetOptional<T, CK>>(tree: T | T[], options?: TreeToRowsOptions<T, CK>): R[];
4006
+ /**
4007
+ * 遍历树节点
4008
+ *
4009
+ * @param tree 树结构数据
4010
+ * @param callback 回调函数
4011
+ * @param options 配置项
4012
+ * @example
4013
+ * ```ts
4014
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
4015
+ * const ids: number[] = [];
4016
+ * TreeUtil.forEach(tree, (node) => ids.push(node.id)); // ids: [1, 2] (pre-order default)
4017
+ * ```
4018
+ */
4019
+ static forEach<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeForeachCallback<T>, options?: TreeForeachOptions<T, CK>): void;
4020
+ /**
4021
+ * 查找树节点
4022
+ * - 返回第一个回调返回 true 的节点
4023
+ *
4024
+ * @param tree 树结构数据
4025
+ * @param callback 回调函数
4026
+ * @param options 配置项
4027
+ * @returns 找到的节点,未找到则返回 undefined
4028
+ * @example
4029
+ * ```ts
4030
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
4031
+ * TreeUtil.find(tree, (node) => node.id === 2); // { id: 2, ... }
4032
+ * ```
4033
+ */
4034
+ static find<T extends AnyObject, CK extends string = ChildrenKey>(tree: T | T[], callback: TreeFindCallback<T>, options?: TreeFindOptions<T, CK>): T | undefined;
4035
+ /**
4036
+ * 过滤树节点
4037
+ * - 返回新的树结构,包含所有回调返回 true 的节点
4038
+ * - 如果父节点被过滤,则其子节点也会被过滤 (pre 策略下)
4039
+ *
4040
+ * @param tree 树结构数据
4041
+ * @param callback 回调函数
4042
+ * @param options 配置项 (childrenKey, strategy等)
4043
+ * @returns 过滤后的树结构数组
4044
+ * @example
4045
+ * ```ts
4046
+ * const tree = [{ id: 1, visible: true, children: [{ id: 2, visible: false }] }];
4047
+ *
4048
+ * // 重载 1: 传入树数组
4049
+ * TreeUtil.filter(tree, (node) => node.visible); // [{ id: 1, visible: true, children: [] }]
4050
+ *
4051
+ * // 重载 2: 传入单个树节点
4052
+ * TreeUtil.filter(tree[0], (node) => node.visible); // { id: 1, visible: true, children: [] }
4053
+ * ```
4054
+ */
4055
+ static filter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T[];
4056
+ static filter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T;
4057
+ /**
4058
+ * 映射树节点
4059
+ * - 返回新的树结构,保持层级关系
4060
+ *
4061
+ * @param tree 树结构数据
4062
+ * @param callback 回调函数 (返回映射后的节点内容)
4063
+ * @param options 配置项
4064
+ * @returns 映射后的树结构数组
4065
+ * @example
4066
+ * ```ts
4067
+ * const tree = [{ id: 1, val: 10, children: [{ id: 2, val: 20 }] }];
4068
+ *
4069
+ * // 重载 1: 传入树数组
4070
+ * TreeUtil.map(tree, (node) => ({ ...node, val: node.val * 2 }));
4071
+ * // [{ id: 1, val: 20, children: [{ id: 2, val: 40 }] }]
4072
+ *
4073
+ * // 重载 2: 传入单个树节点
4074
+ * TreeUtil.map(tree[0], (node) => ({ ...node, val: node.val * 2 }));
4075
+ * // { id: 1, val: 20, children: [{ id: 2, val: 40 }] }
4076
+ * ```
4077
+ */
4078
+ static map<R extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeMapCallback<R, T>, options?: TreeMapOptions<T, CK>): TreeLike<R, CK>[];
4079
+ static map<R extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T, callback: TreeMapCallback<R, T>, options?: TreeMapOptions<T, CK>): TreeLike<R, CK>;
4080
+ }
4081
+ //#endregion
4082
+ //#region src/type/index.type.d.ts
4083
+ interface Class<T, Arguments extends unknown[] = unknown[]> {
4084
+ new (...arguments_: Arguments): T;
4085
+ prototype: Pick<T, keyof T>;
4086
+ }
4087
+ //#endregion
4088
+ //#region src/type/typeUtil.d.ts
4089
+ /**
4090
+ * 类型工具类
4091
+ */
4092
+ declare class TypeUtil {
4093
+ private static readonly PROTOTYPE_TAGS;
4094
+ private static readonly TYPED_ARRAY_TAGS;
4095
+ /**
4096
+ * 获取值的 [[Prototype]] 标签
4097
+ *
4098
+ * @param value - 任意 JavaScript 值
4099
+ * @returns 标准化的类型标签字符串
4100
+ */
4101
+ private static getPrototypeString;
4102
+ private static isConstructable;
4103
+ /**
4104
+ * 检查 value 是否为 string 类型
4105
+ *
4106
+ * @param value 待检查值
4107
+ * @param checkEmpty 是否检查空字符串
4108
+ * @returns 是否为字符串
4109
+ * @example
4110
+ * ```ts
4111
+ * TypeUtil.isString("abc"); // true
4112
+ * TypeUtil.isString(""); // true
4113
+ * TypeUtil.isString("", true); // false
4114
+ * ```
4115
+ */
4116
+ static isString(value: unknown, checkEmpty?: boolean): value is string;
4117
+ /**
4118
+ * 检查 value 是否为 number 类型
4119
+ * - 默认会调用 `TypeUtil.isNaN`(内部基于 `Number.isNaN`)过滤掉 `NaN`
4120
+ *
4121
+ * @param value 待检查值
4122
+ * @param checkNaN 是否检查 `NaN`,默认为 `true`
4123
+ * @returns 是否为 number
4124
+ * @example
4125
+ * ```ts
4126
+ * TypeUtil.isNumber(1); // true
4127
+ * TypeUtil.isNumber(NaN); // false (default)
4128
+ * TypeUtil.isNumber(NaN, false); // true
4129
+ * ```
4130
+ */
4131
+ static isNumber(value: unknown, checkNaN?: boolean): value is number;
4132
+ /**
4133
+ * 检查 value 是否为 NaN
4134
+ * - 禁止使用全局 `isNaN`,其会先进行隐式数字转换,可能导致误判(例如 `isNaN("foo") === true`)
4135
+ * - 使用 `Number.isNaN` 仅在值本身就是 `NaN` 时返回 `true`,语义更严格且更安全
4136
+ *
4137
+ * @param value 待检查值
4138
+ * @returns 是否为 NaN
4139
+ * @example
4140
+ * ```ts
4141
+ * TypeUtil.isNaN(NaN); // true
4142
+ * ```
4143
+ */
4144
+ static isNaN(value: unknown): value is number;
4145
+ /**
4146
+ * 检查 value 是否为整数
4147
+ *
4148
+ * @param value 待检查值
4149
+ * @param checkSafe 是否附加安全整数检查
4150
+ * @returns 是否为整数
4151
+ * @example
4152
+ * ```ts
4153
+ * TypeUtil.isInteger(1); // true
4154
+ * TypeUtil.isInteger(1.1); // false
4155
+ * ```
4156
+ */
4157
+ static isInteger(value: unknown, checkSafe?: boolean): value is number;
4158
+ /**
4159
+ * 检查 value 是否为正整数
4160
+ * - 此函数中 `0` 不被视为正整数
4161
+ *
4162
+ * @param value 待检查值
4163
+ * @param checkSafe 是否附加安全整数检查
4164
+ * @example
4165
+ * ```ts
4166
+ * TypeUtil.isPositiveInteger(1); // true
4167
+ * TypeUtil.isPositiveInteger(0); // false
4168
+ * ```
4169
+ */
4170
+ static isPositiveInteger(value: unknown, checkSafe?: boolean): value is number;
4171
+ /**
4172
+ * 检查 value 是否为负整数
4173
+ * - 此函数中 `0` 不被视为负整数
4174
+ *
4175
+ * @param value 待检查值
4176
+ * @param checkSafe 是否附加安全整数检查
4177
+ * @example
4178
+ * ```ts
4179
+ * TypeUtil.isNegativeInteger(-1); // true
4180
+ * TypeUtil.isNegativeInteger(0); // false
4181
+ * ```
4182
+ */
4183
+ static isNegativeInteger(value: unknown, checkSafe?: boolean): value is number;
4184
+ /**
4185
+ * 检查 value 是否为 Infinity
4186
+ * - 排除 `NaN`
4187
+ *
4188
+ * @param value 待检查值
4189
+ * @example
4190
+ * ```ts
4191
+ * TypeUtil.isInfinity(Infinity); // true
4192
+ * TypeUtil.isInfinity(1); // false
4193
+ * ```
4194
+ */
4195
+ static isInfinity(value: unknown): value is number;
4196
+ /**
4197
+ * 检查 value 是否类似 Infinity
4198
+ * - 排除 `NaN`
4199
+ *
4200
+ * @param value 待检查值
4201
+ * @example
4202
+ * ```ts
4203
+ * TypeUtil.isInfinityLike("Infinity"); // true
4204
+ * TypeUtil.isInfinityLike("123"); // false
4205
+ * ```
4206
+ */
4207
+ static isInfinityLike(value: unknown): boolean;
4208
+ /**
4209
+ * 检查 value 是否为 Boolean
4210
+ * @param value 待检查值
4211
+ * @returns 是否为 Boolean
4212
+ * @example
4213
+ * ```ts
4214
+ * TypeUtil.isBoolean(false); // true
4215
+ * ```
4216
+ */
4217
+ static isBoolean(value: unknown): value is boolean;
4218
+ /**
4219
+ * 检查 value 是否为 BigInt
4220
+ * @param value 待检查值
4221
+ * @returns 是否为 BigInt
4222
+ * @example
4223
+ * ```ts
4224
+ * TypeUtil.isBigInt(1n); // true
4225
+ * ```
4226
+ */
4227
+ static isBigInt(value: unknown): value is bigint;
4228
+ /**
4229
+ * 检查 value 是否为 Symbol
4230
+ * @param value 待检查值
4231
+ * @returns 是否为 Symbol
4232
+ * @example
4233
+ * ```ts
4234
+ * TypeUtil.isSymbol(Symbol("a")); // true
4235
+ * ```
4236
+ */
4237
+ static isSymbol(value: unknown): value is symbol;
4238
+ /**
4239
+ * 检查 value 是否为 undefined
4240
+ * @param value 待检查值
4241
+ * @returns 是否为 undefined
4242
+ * @example
4243
+ * ```ts
4244
+ * TypeUtil.isUndefined(undefined); // true
4245
+ * ```
4246
+ */
4247
+ static isUndefined(value: unknown): value is undefined;
4248
+ /**
4249
+ * 检查 value 是否为 null
4250
+ * @param value 待检查值
4251
+ * @returns 是否为 null
4252
+ * @example
4253
+ * ```ts
4254
+ * TypeUtil.isNull(null); // true
4255
+ * ```
4256
+ */
4257
+ static isNull(value: unknown): value is null;
4258
+ /**
4259
+ * 检查 value 是否为 Function
4260
+ * @param value 待检查值
4261
+ * @returns 是否为 Function
4262
+ * @example
4263
+ * ```ts
4264
+ * TypeUtil.isFunction(() => {}); // true
4265
+ * ```
4266
+ */
4267
+ static isFunction(value: unknown): value is AnyFunction;
4268
+ /**
4269
+ * 检查 value 是否为 AsyncFunction
4270
+ * @param value 待检查值
4271
+ * @returns 是否为 AsyncFunction
4272
+ * @example
4273
+ * ```ts
4274
+ * TypeUtil.isAsyncFunction(async () => {}); // true
4275
+ * ```
4276
+ */
4277
+ static isAsyncFunction(value: unknown): value is AnyAsyncFunction;
4278
+ /**
4279
+ * 检查 value 是否为 GeneratorFunction
4280
+ * @param value 待检查值
4281
+ * @returns 是否为 GeneratorFunction
4282
+ * @example
4283
+ * ```ts
4284
+ * TypeUtil.isGeneratorFunction(function * a () {}); // true
4285
+ * ```
4286
+ */
4287
+ static isGeneratorFunction(value: unknown): value is AnyGeneratorFunction;
4288
+ /**
4289
+ * 检查 value 是否为 AsyncGeneratorFunction
4290
+ * @param value 待检查值
4291
+ * @returns 是否为 AsyncGeneratorFunction
4292
+ * @example
4293
+ * ```ts
4294
+ * TypeUtil.isAsyncGeneratorFunction(async function * a () {}); // true
4295
+ * ```
4296
+ */
4297
+ static isAsyncGeneratorFunction(value: unknown): value is AnyAsyncGeneratorFunction;
4298
+ /**
4299
+ * 检查 value 是否为 Promise
4300
+ * @param value 待检查值
4301
+ * @returns 是否为 Promise
4302
+ * @example
4303
+ * ```ts
4304
+ * TypeUtil.isPromise(Promise.resolve(1)); // true
4305
+ * ```
4306
+ */
4307
+ static isPromise(value: unknown): value is Promise<unknown>;
4308
+ /**
4309
+ * 检查 value 是否为 PromiseLike
4310
+ * - 可识别拥有 then 方法的非 Promise 对象
4311
+ * @param value 待检查值
4312
+ * @returns 是否为 PromiseLike
4313
+ * @example
4314
+ * ```ts
4315
+ * TypeUtil.isPromiseLike({ then: () => {} }); // true
4316
+ * ```
4317
+ */
4318
+ static isPromiseLike(value: unknown): value is PromiseLike<unknown>;
4319
+ /**
4320
+ * 判断是否为普通对象类型
4321
+ * - 可选是否检查原型为 `Object.prototype`,防止原型链污染
4322
+ *
4323
+ * @param value 待检查值
4324
+ * @param prototypeCheck 是否进行原型检查,默认 `true`
4325
+ * @returns 是否为 Plain Object (当 checkPrototype=true) 或 object
4326
+ * @example
4327
+ * ```ts
4328
+ * TypeUtil.isObject({}); // true
4329
+ * TypeUtil.isObject([]); // false
4330
+ * TypeUtil.isObject(new Date()); // false
4331
+ * TypeUtil.isObject(new Date(), false); // true
4332
+ * TypeUtil.isObject(Object.create(null)) // false
4333
+ * TypeUtil.isObject(Object.create(null), false) // true
4334
+ * ```
4335
+ */
4336
+ static isObject(value: unknown, prototypeCheck?: boolean): value is Record<PropertyKey, unknown>;
4337
+ /**
4338
+ * 判断一个对象是否为有效的枚举
4339
+ * - 枚举成员不能为空
4340
+ * - 枚举成员的键不能具有数值名
4341
+ * - 枚举成员的值必须类型一致且为 `string` 或 `number` 类型
4342
+ * - 枚举成员的值不能重复
4343
+ * - 枚举成员的值必须全部为双向映射或非双向映射
4344
+ *
4345
+ * @param enumeration 待检查值
4346
+ * @returns [是否为有效的枚举, 是否为双向枚举]
4347
+ * @example
4348
+ * ```ts
4349
+ * enum A { X, Y }
4350
+ * TypeUtil.isEnumeration(A); // [true, true]
4351
+ * ```
4352
+ */
4353
+ static isEnumeration(enumeration: PlainObject): [boolean, boolean];
4354
+ /**
4355
+ * 检查 value 是否为 Class
4356
+ *
4357
+ * @param value 待检查值
4358
+ * @returns 是否为 Class
4359
+ * @example
4360
+ * ```ts
4361
+ * class A {}
4362
+ * TypeUtil.isClass(A); // true
4363
+ * TypeUtil.isClass(() => {}); // false
4364
+ * ```
4365
+ */
4366
+ static isClass(value: unknown): value is Class<AnyObject>;
4367
+ /**
4368
+ * 检查 value 是否为数组
4369
+ *
4370
+ * @param value 待检查值
4371
+ * @returns 是否为数组
4372
+ * @example
4373
+ * ```ts
4374
+ * TypeUtil.isArray([]); // true
4375
+ * ```
4376
+ */
4377
+ static isArray(value: unknown): value is unknown[];
4378
+ /**
4379
+ * 检查 value 是否为 TypedArray
4380
+ *
4381
+ * @param value 待检查值
4382
+ * @returns 是否为 TypedArray
4383
+ * @example
4384
+ * ```ts
4385
+ * TypeUtil.isTypedArray(new Int8Array()); // true
4386
+ * ```
4387
+ */
4388
+ static isTypedArray(value: unknown): value is TypedArray;
4389
+ /**
4390
+ * 检查 value 是否为 Map
4391
+ * @param value 待检查值
4392
+ * @returns 是否为 Map
4393
+ * @example
4394
+ * ```ts
4395
+ * TypeUtil.isMap(new Map()); // true
4396
+ * ```
4397
+ */
4398
+ static isMap(value: unknown): value is Map<unknown, unknown>;
4399
+ /**
4400
+ * 检查 value 是否为 WeakMap
4401
+ * @param value 待检查值
4402
+ * @returns 是否为 WeakMap
4403
+ * @example
4404
+ * ```ts
4405
+ * TypeUtil.isWeakMap(new WeakMap()); // true
4406
+ * ```
4407
+ */
4408
+ static isWeakMap(value: unknown): value is WeakMap<AnyObject, unknown>;
4409
+ /**
4410
+ * 检查 value 是否为 Set
4411
+ * @param value 待检查值
4412
+ * @returns 是否为 Set
4413
+ * @example
4414
+ * ```ts
4415
+ * TypeUtil.isSet(new Set()); // true
4416
+ * ```
4417
+ */
4418
+ static isSet(value: unknown): value is Set<unknown>;
4419
+ /**
4420
+ * 检查 value 是否为 WeakSet
4421
+ * @param value 待检查值
4422
+ * @returns 是否为 WeakSet
4423
+ * @example
4424
+ * ```ts
4425
+ * TypeUtil.isWeakSet(new WeakSet()); // true
4426
+ * ```
4427
+ */
4428
+ static isWeakSet(value: unknown): value is WeakSet<AnyObject>;
4429
+ /**
4430
+ * 检查 value 是否为 Blob
4431
+ * @param value 待检查值
4432
+ * @returns 是否为 Blob
4433
+ * @example
4434
+ * ```ts
4435
+ * TypeUtil.isBlob(new Blob(["a"])); // true
4436
+ * ```
4437
+ */
4438
+ static isBlob(value: unknown): value is Blob;
4439
+ /**
4440
+ * 检查 value 是否为 File
4441
+ * @param value 待检查值
4442
+ * @returns 是否为 File
4443
+ * @example
4444
+ * ```ts
4445
+ * TypeUtil.isFile(new File(["a"], "a.txt")); // true
4446
+ * ```
4447
+ */
4448
+ static isFile(value: unknown): value is File;
4449
+ /**
4450
+ * 检查 value 是否为 ReadableStream
4451
+ * - Uses `Object.prototype.toString` where supported (modern browsers, Node.js ≥18).
4452
+ * - Falls back to duck-typing in older environments.
4453
+ * - Resistant to basic forgery, but not 100% secure in all polyfill scenarios.
4454
+ * - ⚠️ Note: In older Node.js (<18) or with non-compliant polyfills, this may return false positives or negatives.
4455
+ *
4456
+ * @param value 待检查值
4457
+ * @returns 是否为 ReadableStream
4458
+ * @example
4459
+ * ```ts
4460
+ * TypeUtil.isReadableStream(new ReadableStream()); // true
4461
+ * ```
4462
+ */
4463
+ static isReadableStream(value: unknown): value is ReadableStream;
4464
+ /**
4465
+ * 检查 value 是否为 Window
4466
+ * @param value 待检查值
4467
+ * @returns 是否为 Window
4468
+ * @example
4469
+ * ```ts
4470
+ * TypeUtil.isWindow(window); // true
4471
+ * ```
4472
+ */
4473
+ static isWindow(value: unknown): value is Window;
4474
+ /**
4475
+ * 检查 value 是否为 HTMLIFrameElement
4476
+ * @param value 待检查值
4477
+ * @returns 是否为 HTMLIFrameElement
4478
+ * @example
4479
+ * ```ts
4480
+ * TypeUtil.isIframe(document.createElement("iframe")); // true
4481
+ * ```
4482
+ */
4483
+ static isIframe(value: unknown): value is HTMLIFrameElement;
4484
+ /**
4485
+ * 检查 value 是否为 Date 对象
4486
+ *
4487
+ * @param value 待检查值
4488
+ * @param invalidCheck 是否要求日期有效(非 Invalid Date)。默认 true
4489
+ * - true: 仅当是有效 Date 对象时返回 true(排除 new Date('invalid'))
4490
+ * - false: 只要 [[Prototype]] 是 Date 即返回 true(包含 Invalid Date)
4491
+ * @returns 是否为 Date 对象,根据 invalidCheck 返回不同语义的 Date 判定
4492
+ *
4493
+ * @example
4494
+ * ```ts
4495
+ * TypeUtil.isDate(new Date()); // true
4496
+ * TypeUtil.isDate(new Date('invalid')); // false
4497
+ * TypeUtil.isDate(new Date('invalid'), false); // true
4498
+ * TypeUtil.isDate(null); // false
4499
+ * TypeUtil.isDate({}); // false
4500
+ * ```
4501
+ */
4502
+ static isDate(value: unknown, invalidCheck?: boolean): value is Date;
4503
+ /**
4504
+ * 检查 value 是否为 Error 对象
4505
+ * @param value 待检查值
4506
+ * @returns 是否为 Error
4507
+ * @example
4508
+ * ```ts
4509
+ * TypeUtil.isError(new Error("x")); // true
4510
+ * ```
4511
+ */
4512
+ static isError(value: unknown): value is Error;
4513
+ /**
4514
+ * 检查 value 是否为 RegExp
4515
+ * @param value 待检查值
4516
+ * @returns 是否为 RegExp
4517
+ * @example
4518
+ * ```ts
4519
+ * TypeUtil.isRegExp(/a/); // true
4520
+ * ```
4521
+ */
4522
+ static isRegExp(value: unknown): value is RegExp;
4523
+ /**
4524
+ * 检查 value 是否为 WebSocket
4525
+ * @param value 待检查值
4526
+ * @returns 是否为 WebSocket
4527
+ * @example
4528
+ * ```ts
4529
+ * TypeUtil.isWebSocket(new WebSocket("wss://echo.websocket.events")); // true
4530
+ * ```
4531
+ */
4532
+ static isWebSocket(value: unknown): value is WebSocket;
4533
+ /**
4534
+ * 检查 value 是否为 URLSearchParams
4535
+ * @param value 待检查值
4536
+ * @returns 是否为 URLSearchParams
4537
+ * @example
4538
+ * ```ts
4539
+ * TypeUtil.isURLSearchParams(new URLSearchParams("a=1")); // true
4540
+ * ```
4541
+ */
4542
+ static isURLSearchParams(value: unknown): value is URLSearchParams;
4543
+ /**
4544
+ * 检查 value 是否为 AbortSignal
4545
+ * @param value 待检查值
4546
+ * @returns 是否为 AbortSignal
4547
+ * @example
4548
+ * ```ts
4549
+ * TypeUtil.isAbortSignal(new AbortController().signal); // true
4550
+ * ```
4551
+ */
4552
+ static isAbortSignal(value: unknown): value is AbortSignal;
4553
+ /**
4554
+ * 检查 value 是否为可迭代对象 (Iterable)
4555
+ * @param value 待检查值
4556
+ * @returns 是否为 Iterable
4557
+ * @example
4558
+ * ```ts
4559
+ * TypeUtil.isIterable([1, 2]); // true
4560
+ * ```
4561
+ */
4562
+ static isIterable(value: unknown): value is {
4563
+ [Symbol.iterator]: () => Iterator<unknown>;
4564
+ };
4565
+ /**
4566
+ * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
4567
+ * @param value 待检查值
4568
+ * @returns 是否为 Falsy
4569
+ * @example
4570
+ * ```ts
4571
+ * TypeUtil.isFalsy(0); // true
4572
+ * ```
4573
+ */
4574
+ static isFalsy(value: unknown): value is false | 0 | "" | null | undefined;
4575
+ /**
4576
+ * 检查 value 是否为 FalsyLike 值
4577
+ * - 包含字符串形式的 `"null"`、`"undefined"`、`"false"`、`"0"` 等
4578
+ *
4579
+ * @param value 待检查值
4580
+ * @returns 是否为 FalsyLike
4581
+ * @example
4582
+ * ```ts
4583
+ * TypeUtil.isFalsyLike("false"); // true
4584
+ * TypeUtil.isFalsyLike("hello"); // false
4585
+ * ```
4586
+ */
4587
+ static isFalsyLike(value: unknown): boolean;
4588
+ }
4589
+ //#endregion
4590
+ //#region src/validate/validateUtil.d.ts
4591
+ /**
4592
+ * 验证工具类
4593
+ */
4594
+ declare class ValidateUtil {
4595
+ static _phone: RegExp;
4596
+ /**
4597
+ * 验证是否为手机号码
4598
+ * @example
4599
+ * ```ts
4600
+ * ValidateUtil.isPhone("13800138000"); // true
4601
+ * ```
4602
+ */
4603
+ static isPhone(input: string): boolean;
4604
+ static _telephone: RegExp;
4605
+ /**
4606
+ * 验证是否为固定电话
4607
+ * @example
4608
+ * ```ts
4609
+ * ValidateUtil.isTelephone("010-12345678"); // true
4610
+ * ```
4611
+ */
4612
+ static isTelephone(input: string): boolean;
4613
+ static _IMEI: RegExp;
4614
+ /**
4615
+ * 验证是否为移动设备识别码
4616
+ * @example
4617
+ * ```ts
4618
+ * ValidateUtil.isIMEI("490154203237518"); // true
4619
+ * ```
4620
+ */
4621
+ static isIMEI(input: string): boolean;
4622
+ static _email: RegExp;
4623
+ /**
4624
+ * 验证是否为电子邮箱
4625
+ * @example
4626
+ * ```ts
4627
+ * ValidateUtil.isEmail("dev@example.com"); // true
4628
+ * ```
4629
+ */
4630
+ static isEmail(input: string): boolean;
4631
+ static _link: RegExp;
4632
+ /**
4633
+ * 验证是否为 http(s) 链接
4634
+ * @example
4635
+ * ```ts
4636
+ * ValidateUtil.isHttpLink("https://example.com/path"); // true
4637
+ * ```
4638
+ */
4639
+ static isHttpLink(input: string): boolean;
4640
+ static _portLink: RegExp;
4641
+ /**
4642
+ * 验证是否为端口号链接
4643
+ * @example
4644
+ * ```ts
4645
+ * ValidateUtil.isPortLink("http://example.com:8080"); // true
4646
+ * ```
4647
+ */
4648
+ static isPortLink(input: string): boolean;
4649
+ static _thunderLink: RegExp;
4650
+ /**
4651
+ * 验证是否为迅雷链接
4652
+ * @example
4653
+ * ```ts
4654
+ * ValidateUtil.isThunderLink("thunder://QUFodHRwOi8vZXhhbXBsZS5jb20vZmlsZQ=="); // true
4655
+ * ```
4656
+ */
4657
+ static isThunderLink(input: string): boolean;
4658
+ static _uscc: RegExp;
4659
+ /**
4660
+ * 验证是否为统一社会信用代码
4661
+ * @example
4662
+ * ```ts
4663
+ * ValidateUtil.isUSCC("91350100M000100Y43"); // true
4664
+ * ```
4665
+ */
4666
+ static isUSCC(input: string): boolean;
4667
+ static _usccs: RegExp;
4668
+ /**
4669
+ * 验证是否为统一社会信用代码 - 15位/18位/20位数字/字母
4670
+ * @example
4671
+ * ```ts
4672
+ * ValidateUtil.isUSCCS("91350100M000100Y43"); // true
4673
+ * ```
4674
+ */
4675
+ static isUSCCS(input: string): boolean;
4676
+ static _dirPathWindows: RegExp;
4677
+ /**
4678
+ * 验证是否为 Windows 系统文件夹路径
4679
+ * @example
4680
+ * ```ts
4681
+ * ValidateUtil.isDirPathWindows("C:\\Users\\pawover\\"); // true
4682
+ * ```
4683
+ */
4684
+ static isDirPathWindows(input: string): boolean;
4685
+ static _filePathWindows: RegExp;
4686
+ /**
4687
+ * 验证是否为 Windows 系统文件路径
4688
+ * @example
4689
+ * ```ts
4690
+ * ValidateUtil.isFilePathWindows("C:\\Users\\pawover\\a.txt"); // true
4691
+ * ```
4692
+ */
4693
+ static isFilePathWindows(input: string): boolean;
4694
+ static _dirPathLinux: RegExp;
4695
+ /**
4696
+ * 验证是否为 Linux 系统文件夹路径
4697
+ * @example
4698
+ * ```ts
4699
+ * ValidateUtil.isDirPathLinux("/usr/local/"); // true
4700
+ * ```
4701
+ */
4702
+ static isDirPathLinux(input: string): boolean;
4703
+ static _filePathLinux: RegExp;
4704
+ /**
4705
+ * 验证是否为 Linux 系统文件路径
4706
+ * @example
4707
+ * ```ts
4708
+ * ValidateUtil.isFilePathLinux("/usr/local/bin/node"); // true
4709
+ * ```
4710
+ */
4711
+ static isFilePathLinux(input: string): boolean;
4712
+ static _EVCarNumber: RegExp;
4713
+ /**
4714
+ * 验证是否为新能源车牌号
4715
+ * @example
4716
+ * ```ts
4717
+ * ValidateUtil.isEVCarNumber("粤AD12345"); // true
4718
+ * ```
4719
+ */
4720
+ static isEVCarNumber(input: string): boolean;
4721
+ static _GVCarNumber: RegExp;
4722
+ /**
4723
+ * 验证是否为燃油车车牌号
4724
+ * @example
4725
+ * ```ts
4726
+ * ValidateUtil.isGVCarNumber("粤B12345"); // true
4727
+ * ```
4728
+ */
4729
+ static isGVCarNumber(input: string): boolean;
4730
+ static _chineseName: RegExp;
4731
+ /**
4732
+ * 验证是否为中文姓名
4733
+ * @example
4734
+ * ```ts
4735
+ * ValidateUtil.isChineseName("张三"); // true
4736
+ * ```
4737
+ */
4738
+ static isChineseName(input: string): boolean;
4739
+ static _chineseId: RegExp;
4740
+ /**
4741
+ * 验证是否为中国身份证号
4742
+ * @example
4743
+ * ```ts
4744
+ * ValidateUtil.isChineseID("11010519491231002X"); // true
4745
+ * ```
4746
+ */
4747
+ static isChineseID(input: string): boolean;
4748
+ static _chineseProvince: RegExp;
4749
+ /**
4750
+ * 验证是否为中国省份
4751
+ * @example
4752
+ * ```ts
4753
+ * ValidateUtil.isChineseProvince("浙江"); // true
4754
+ * ```
4755
+ */
4756
+ static isChineseProvince(input: string): boolean;
4757
+ static _chineseNation: RegExp;
4758
+ /**
4759
+ * 验证是否为中华民族
4760
+ * @example
4761
+ * ```ts
4762
+ * ValidateUtil.isChineseNation("汉族"); // true
4763
+ * ```
4764
+ */
4765
+ static isChineseNation(input: string): boolean;
4766
+ static _letter: RegExp;
4767
+ /**
4768
+ * 验证是否只包含字母
4769
+ * @example
4770
+ * ```ts
4771
+ * ValidateUtil.isLetter("abcDEF"); // true
4772
+ * ```
4773
+ */
4774
+ static isLetter(input: string): boolean;
4775
+ static _letterLowercase: RegExp;
4776
+ /**
4777
+ * 验证是否只包含小写字母
4778
+ * @example
4779
+ * ```ts
4780
+ * ValidateUtil.isLetterLowercase("abc"); // true
4781
+ * ```
4782
+ */
4783
+ static isLetterLowercase(input: string): boolean;
4784
+ static _letterUppercase: RegExp;
4785
+ /**
4786
+ * 验证是否只包含大写字母
4787
+ * @example
4788
+ * ```ts
4789
+ * ValidateUtil.isLetterUppercase("ABC"); // true
4790
+ * ```
4791
+ */
4792
+ static isLetterUppercase(input: string): boolean;
4793
+ static _letterOmit: RegExp;
4794
+ /**
4795
+ * 验证是否不包含字母
4796
+ * @example
4797
+ * ```ts
4798
+ * ValidateUtil.isLetterOmit("123_-"); // true
4799
+ * ```
4800
+ */
4801
+ static isLetterOmit(input: string): boolean;
4802
+ static _LetterAndNumber: RegExp;
4803
+ /**
4804
+ * 验证是否为数字和字母组合
4805
+ * @example
4806
+ * ```ts
4807
+ * ValidateUtil.isLetterAndNumber("A1B2"); // true
4808
+ * ```
4809
+ */
4810
+ static isLetterAndNumber(input: string): boolean;
4811
+ static _signedFloat: RegExp;
4812
+ /**
4813
+ * 验证是否为有符号浮点数
4814
+ * @example
4815
+ * ```ts
4816
+ * ValidateUtil.isSignedFloat("-12.34"); // true
4817
+ * ```
4818
+ */
4819
+ static isSignedFloat(input: string): boolean;
4820
+ static _unsignedFloat: RegExp;
4821
+ /**
4822
+ * 验证是否为无符号浮点数
4823
+ * @example
4824
+ * ```ts
4825
+ * ValidateUtil.isUnsignedFloat("12.34"); // true
4826
+ * ```
4827
+ */
4828
+ static isUnsignedFloat(input: string): boolean;
4829
+ static _signedInteger: RegExp;
4830
+ /**
4831
+ * 验证是否为有符号整数
4832
+ * @example
4833
+ * ```ts
4834
+ * ValidateUtil.isSignedInteger("-12"); // true
4835
+ * ```
4836
+ */
4837
+ static isSignedInteger(input: string): boolean;
4838
+ static _unsignedInteger: RegExp;
4839
+ /**
4840
+ * 验证是否为无符号整数
4841
+ * @example
4842
+ * ```ts
4843
+ * ValidateUtil.isUnsignedInteger("12"); // true
4844
+ * ```
4845
+ */
4846
+ static isUnsignedInteger(input: string): boolean;
4847
+ static _spaceInclude: RegExp;
4848
+ /**
4849
+ * 验证是否包含空格
4850
+ * @example
4851
+ * ```ts
4852
+ * ValidateUtil.isSpaceInclude("a b"); // true
4853
+ * ```
4854
+ */
4855
+ static isSpaceInclude(input: string): boolean;
4856
+ static _spaceStart: RegExp;
4857
+ /**
4858
+ * 验证是否以空格开头
4859
+ * @example
4860
+ * ```ts
4861
+ * ValidateUtil.isSpaceStart(" abc"); // true
4862
+ * ```
4863
+ */
4864
+ static isSpaceStart(input: string): boolean;
4865
+ static _spaceEnd: RegExp;
4866
+ /**
4867
+ * 验证是否以空格结尾
4868
+ * @example
4869
+ * ```ts
4870
+ * ValidateUtil.isSpaceEnd("abc "); // true
4871
+ * ```
4872
+ */
4873
+ static isSpaceEnd(input: string): boolean;
4874
+ /**
4875
+ * 验证是否以空格开头或结尾
4876
+ * @example
4877
+ * ```ts
4878
+ * ValidateUtil.isSpaceStartOrEnd(" abc"); // true
4879
+ * ```
4880
+ */
4881
+ static isSpaceStartOrEnd(input: string): boolean;
4882
+ }
4883
+ //#endregion
4884
+ export { ArrayUtil, DateTimeUtil, EnvUtil, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, type THEME_MODE_TYPE, type THEME_TYPE, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };