@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,1741 @@
1
+ import { n as TypeUtil, r as _defineProperty, t as StringUtil } from "./string-C_OCj9Lg.js";
2
+ //#region src/array/arrayUtil.ts
3
+ /**
4
+ * 数组工具类
5
+ */
6
+ var ArrayUtil = class {
7
+ static cast(candidate, checkEmpty = true) {
8
+ if (checkEmpty && (TypeUtil.isUndefined(candidate) || TypeUtil.isNull(candidate))) return [];
9
+ return TypeUtil.isArray(candidate) ? [...candidate] : [candidate];
10
+ }
11
+ static first(initialList, fallback) {
12
+ if (!TypeUtil.isArray(initialList) || initialList.length === 0) return fallback;
13
+ return initialList[0];
14
+ }
15
+ static last(initialList, fallback) {
16
+ if (!TypeUtil.isArray(initialList) || initialList.length === 0) return fallback;
17
+ return initialList[initialList.length - 1];
18
+ }
19
+ /**
20
+ * 数组竞选
21
+ * - 返回在匹配函数的比较条件中获胜的最终项目,适用于更复杂的最小值/最大值计算
22
+ *
23
+ * @param initialList 数组
24
+ * @param match 匹配函数
25
+ * @returns 获胜的元素,如果数组为空或参数无效则返回 `null`
26
+ * @example
27
+ * ```ts
28
+ * const list = [1, 10, 5];
29
+ * ArrayUtil.compete(list, (a, b) => (a > b ? a : b)); // 10
30
+ * ArrayUtil.compete(list, (a, b) => (a < b ? a : b)); // 1
31
+ * ```
32
+ */
33
+ static compete(initialList, match) {
34
+ if (!TypeUtil.isArray(initialList) || initialList.length === 0 || !TypeUtil.isFunction(match)) return null;
35
+ return initialList.reduce(match);
36
+ }
37
+ /**
38
+ * 统计数组的项目出现次数
39
+ * - 通过给定的标识符匹配函数,返回一个对象,其中键是回调函数返回的 key 值,每个值是一个整数,表示该 key 出现的次数
40
+ *
41
+ * @param initialList 初始数组
42
+ * @param match 匹配函数
43
+ * @returns 统计对象
44
+ * @example
45
+ * ```ts
46
+ * const list = ["a", "b", "a", "c"];
47
+ * ArrayUtil.count(list, (x) => x); // { a: 2, b: 1, c: 1 }
48
+ *
49
+ * const users = [{ id: 1, group: "A" }, { id: 2, group: "B" }, { id: 3, group: "A" }];
50
+ * ArrayUtil.count(users, (u) => u.group); // { A: 2, B: 1 }
51
+ * ```
52
+ */
53
+ static count(initialList, match) {
54
+ if (!TypeUtil.isArray(initialList) || !TypeUtil.isFunction(match)) return {};
55
+ return initialList.reduce((prev, curr, index) => {
56
+ const id = match(curr, index).toString();
57
+ prev[id] = (prev[id] ?? 0) + 1;
58
+ return prev;
59
+ }, {});
60
+ }
61
+ /**
62
+ * 获取数组差集
63
+ * - 返回在 `initialList` 中存在,但在 `diffList` 中不存在的元素
64
+ *
65
+ * @param initialList 初始数组
66
+ * @param diffList 对比数组
67
+ * @param match 匹配函数
68
+ * @returns 差集数组
69
+ * @example
70
+ * ```ts
71
+ * ArrayUtil.difference([1, 2, 3], [2, 3, 4]); // [1]
72
+ * ArrayUtil.difference([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 1 }]
73
+ * ```
74
+ */
75
+ static difference(initialList, diffList, match) {
76
+ if (!TypeUtil.isArray(initialList) && !TypeUtil.isArray(diffList)) return [];
77
+ if (!TypeUtil.isArray(initialList) || !initialList.length) return [];
78
+ if (!TypeUtil.isArray(diffList) || !diffList.length) return [...initialList];
79
+ if (!TypeUtil.isFunction(match)) {
80
+ const arraySet = new Set(diffList);
81
+ return Array.from(new Set(initialList.filter((item) => !arraySet.has(item))));
82
+ }
83
+ const map = /* @__PURE__ */ new Map();
84
+ diffList.forEach((item, index) => {
85
+ map.set(match(item, index), true);
86
+ });
87
+ return initialList.filter((item, index) => !map.get(match(item, index)));
88
+ }
89
+ static intersection(initialList, diffList, match) {
90
+ if (!TypeUtil.isArray(initialList) || !TypeUtil.isArray(diffList)) return [];
91
+ if (!initialList.length || !diffList.length) return [];
92
+ if (!TypeUtil.isFunction(match)) {
93
+ const diffSet = new Set(diffList);
94
+ return initialList.filter((item) => diffSet.has(item));
95
+ }
96
+ const diffKeys = new Set(diffList.map((item, index) => match(item, index)));
97
+ return initialList.filter((item, index) => diffKeys.has(match(item, index)));
98
+ }
99
+ static merge(initialList, mergeList, match) {
100
+ if (!TypeUtil.isArray(initialList)) return [];
101
+ if (!TypeUtil.isArray(mergeList)) return [...initialList];
102
+ if (!TypeUtil.isFunction(match)) return Array.from(new Set([...initialList, ...mergeList]));
103
+ const keys = /* @__PURE__ */ new Map();
104
+ mergeList.forEach((item, index) => {
105
+ keys.set(match(item, index), item);
106
+ });
107
+ return initialList.map((prevItem, index) => {
108
+ const key = match(prevItem, index);
109
+ return keys.has(key) ? keys.get(key) : prevItem;
110
+ });
111
+ }
112
+ static pick(initialList, filter, mapper) {
113
+ if (!TypeUtil.isArray(initialList)) return [];
114
+ if (!TypeUtil.isFunction(filter)) return [...initialList];
115
+ const hasMapper = TypeUtil.isFunction(mapper);
116
+ return initialList.reduce((prev, curr, index) => {
117
+ if (!filter(curr, index)) return prev;
118
+ if (hasMapper) prev.push(mapper(curr, index));
119
+ else prev.push(curr);
120
+ return prev;
121
+ }, []);
122
+ }
123
+ static replace(initialList, newItem, match) {
124
+ if (!TypeUtil.isArray(initialList) || !initialList.length) return [];
125
+ if (!TypeUtil.isFunction(match)) return [...initialList];
126
+ for (let i = 0; i < initialList.length; i++) {
127
+ const item = initialList[i];
128
+ if (match(item, i)) return [
129
+ ...initialList.slice(0, i),
130
+ newItem,
131
+ ...initialList.slice(i + 1, initialList.length)
132
+ ];
133
+ }
134
+ return [...initialList];
135
+ }
136
+ /**
137
+ * 数组项替换并移动
138
+ * - 在给定的数组中,替换并移动符合匹配函数结果的项目
139
+ * - 只替换和移动第一个匹配项
140
+ * - 未匹配时,根据 `position` 在指定位置插入 `newItem`
141
+ *
142
+ * @param initialList 初始数组
143
+ * @param newItem 替换项
144
+ * @param match 匹配函数
145
+ * @param position 移动位置,可选 `start` | `end` | 索引位置, 默认为 `end`
146
+ * @returns
147
+ * @example
148
+ * ```ts
149
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, 0); // [5, 1, 3, 4]
150
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, 2); // [1, 3, 5, 4]
151
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2, "start"); // [5, 1, 3, 4]
152
+ * ArrayUtil.replaceMove([1, 2, 3, 4], 5, (n) => n === 2); // [1, 3, 4, 5]
153
+ * ```
154
+ */
155
+ static replaceMove(initialList, newItem, match, position) {
156
+ if (!TypeUtil.isArray(initialList)) return [];
157
+ if (!initialList.length) return [newItem];
158
+ if (!TypeUtil.isFunction(match)) return [...initialList];
159
+ const result = [...initialList];
160
+ const matchIndex = initialList.findIndex(match);
161
+ if (matchIndex !== -1) result.splice(matchIndex, 1);
162
+ if (position === "start") result.unshift(newItem);
163
+ else if (position === 0 || TypeUtil.isPositiveInteger(position, false)) result.splice(Math.min(position, result.length), 0, newItem);
164
+ else result.push(newItem);
165
+ return result;
166
+ }
167
+ /**
168
+ * 数组切分
169
+ * - 将数组以指定的长度切分后,组合在高维数组中
170
+ *
171
+ * @param initialList 初始数组
172
+ * @param size 分割尺寸,默认 `10`
173
+ * @returns 切分后的二维数组
174
+ * @example
175
+ * ```ts
176
+ * ArrayUtil.split([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
177
+ * ```
178
+ */
179
+ static split(initialList, size = 10) {
180
+ if (!TypeUtil.isArray(initialList)) return [];
181
+ if (!TypeUtil.isPositiveInteger(size, false)) return [];
182
+ const count = Math.ceil(initialList.length / size);
183
+ return Array.from({ length: count }).fill(null).map((_c, i) => {
184
+ return initialList.slice(i * size, i * size + size);
185
+ });
186
+ }
187
+ /**
188
+ * 数组分组过滤
189
+ * - 给定一个数组和一个条件,返回一个由两个数组组成的元组,其中第一个数组包含所有满足条件的项,第二个数组包含所有不满足条件的项
190
+ *
191
+ * @param initialList 初始数组
192
+ * @param match 条件匹配函数
193
+ * @returns [满足条件的项[], 不满足条件的项[]]
194
+ * @example
195
+ * ```ts
196
+ * ArrayUtil.fork([1, 2, 3, 4], (n) => n % 2 === 0); // [[2, 4], [1, 3]]
197
+ * ```
198
+ */
199
+ static fork(initialList, match) {
200
+ const forked = [[], []];
201
+ if (TypeUtil.isArray(initialList)) initialList.forEach((item, index) => {
202
+ forked[match(item, index) ? 0 : 1].push(item);
203
+ });
204
+ return forked;
205
+ }
206
+ /**
207
+ * 数组解压
208
+ * - `ArrayUtil.zip` 的反向操作
209
+ *
210
+ * @param arrayList 压缩后的数组
211
+ * @returns 解压后的二维数组
212
+ * @example
213
+ * ```ts
214
+ * ArrayUtil.unzip([[1, "a"], [2, "b"]]); // [[1, 2], ["a", "b"]]
215
+ * ```
216
+ */
217
+ static unzip(arrayList) {
218
+ if (!TypeUtil.isArray(arrayList) || !arrayList.length) return [];
219
+ const out = new Array(arrayList.reduce((max, arr) => Math.max(max, arr.length), 0));
220
+ let index = 0;
221
+ const get = (array) => array[index];
222
+ for (; index < out.length; index++) out[index] = Array.from(arrayList, get);
223
+ return out;
224
+ }
225
+ static zip(...arrays) {
226
+ return this.unzip(arrays);
227
+ }
228
+ static zipToObject(keys, values) {
229
+ const result = {};
230
+ if (!TypeUtil.isArray(keys) || !keys.length) return result;
231
+ const getValue = TypeUtil.isFunction(values) ? values : TypeUtil.isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
232
+ return keys.reduce((acc, key, idx) => {
233
+ acc[key] = getValue(key, idx);
234
+ return acc;
235
+ }, result);
236
+ }
237
+ };
238
+ //#endregion
239
+ //#region src/dateTime/dateTimeUtil.ts
240
+ var _DateTimeUtil;
241
+ /**
242
+ * 日期工具类
243
+ */
244
+ var DateTimeUtil = class {
245
+ /**
246
+ * 获取当前时区信息
247
+ *
248
+ * @returns 时区信息对象 (UTC偏移和时区名称)
249
+ * @example
250
+ * ```ts
251
+ * DateTimeUtil.getTimeZone(); // { UTC: "UTC+8", timeZone: "Asia/Shanghai" }
252
+ * ```
253
+ */
254
+ static getTimeZone() {
255
+ const hour = 0 - (/* @__PURE__ */ new Date()).getTimezoneOffset() / this.MINUTE_PER_HOUR;
256
+ return {
257
+ UTC: "UTC" + (hour >= 0 ? "+" + hour : hour),
258
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
259
+ };
260
+ }
261
+ };
262
+ _DateTimeUtil = DateTimeUtil;
263
+ _defineProperty(DateTimeUtil, "MILLISECONDS_PER_SECOND", 1e3);
264
+ _defineProperty(DateTimeUtil, "SECOND_PER_MINUTE", 60);
265
+ _defineProperty(DateTimeUtil, "MINUTE_PER_HOUR", 60);
266
+ _defineProperty(DateTimeUtil, "SECOND_PER_HOUR", _DateTimeUtil.SECOND_PER_MINUTE ** 2);
267
+ _defineProperty(DateTimeUtil, "HOUR_PER_DAY", 24);
268
+ _defineProperty(DateTimeUtil, "SECOND_PER_DAY", _DateTimeUtil.SECOND_PER_HOUR * _DateTimeUtil.HOUR_PER_DAY);
269
+ _defineProperty(DateTimeUtil, "DAY_PER_WEEK", 7);
270
+ _defineProperty(DateTimeUtil, "DAY_PER_MONTH", 30);
271
+ _defineProperty(DateTimeUtil, "DAY_PER_YEAR", 365);
272
+ _defineProperty(DateTimeUtil, "MONTH_PER_YEAR", 12);
273
+ _defineProperty(DateTimeUtil, "WEEK_PER_YEAR", 52);
274
+ _defineProperty(DateTimeUtil, "WEEK_PER_MONTH", 4);
275
+ _defineProperty(DateTimeUtil, "FORMAT", {
276
+ ISO_DATE: "yyyy-MM-dd",
277
+ ISO_TIME: "HH:mm:ss",
278
+ ISO_DATE_TIME: "yyyy-MM-dd HH:mm:ss",
279
+ ISO_DATE_TIME_MS: "yyyy-MM-dd HH:mm:ss.SSS",
280
+ ISO_DATETIME_TZ: "yyyy-MM-dd'T'HH:mm:ssXXX",
281
+ ISO_DATETIME_TZ_MS: "yyyy-MM-dd'T'HH:mm:ss.SSSXXX",
282
+ US_DATE: "MM/dd/yyyy",
283
+ US_DATE_TIME: "MM/dd/yyyy HH:mm:ss",
284
+ US_DATE_SHORT_YEAR: "MM/dd/yy",
285
+ EU_DATE: "dd/MM/yyyy",
286
+ EU_DATE_TIME: "dd/MM/yyyy HH:mm:ss",
287
+ CN_DATE: "yyyy年MM月dd日",
288
+ CN_DATE_TIME: "yyyy年MM月dd日 HH时mm分ss秒",
289
+ CN_DATE_WEEKDAY: "yyyy年MM月dd日 EEE",
290
+ CN_WEEKDAY_FULL: "EEEE",
291
+ SHORT_DATE: "yy-MM-dd",
292
+ SHORT_DATE_SLASH: "yy/MM/dd",
293
+ MONTH_DAY: "MM-dd",
294
+ MONTH_DAY_CN: "MM月dd日",
295
+ DATE_WITH_WEEKDAY_SHORT: "yyyy-MM-dd (EEE)",
296
+ DATE_WITH_WEEKDAY_FULL: "yyyy-MM-dd (EEEE)",
297
+ TIME_24: "HH:mm:ss",
298
+ TIME_24_NO_SEC: "HH:mm",
299
+ TIME_12: "hh:mm:ss a",
300
+ TIME_12_NO_SEC: "hh:mm a",
301
+ TIMESTAMP: "yyyyMMddHHmmss",
302
+ TIMESTAMP_MS: "yyyyMMddHHmmssSSS",
303
+ RFC2822: "EEE, dd MMM yyyy HH:mm:ss xxx",
304
+ READABLE_DATE: "MMM dd, yyyy",
305
+ READABLE_DATE_TIME: "MMM dd, yyyy HH:mm",
306
+ COMPACT_DATETIME: "yyyyMMdd_HHmmss"
307
+ });
308
+ //#endregion
309
+ //#region src/env/envUtil.ts
310
+ /**
311
+ * 环境检查工具类
312
+ */
313
+ var EnvUtil = class {
314
+ /**
315
+ * 检测是否处于浏览器环境
316
+ *
317
+ * @returns 是否为浏览器环境
318
+ * @example
319
+ * ```ts
320
+ * EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
321
+ * ```
322
+ */
323
+ static isBrowser() {
324
+ return this._isBrowser;
325
+ }
326
+ /**
327
+ * 检测是否处于 Web Worker 环境
328
+ *
329
+ * @returns 是否为 Web Worker 环境
330
+ * @example
331
+ * ```ts
332
+ * EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
333
+ * ```
334
+ */
335
+ static isWebWorker() {
336
+ return this._isWebWorker;
337
+ }
338
+ /**
339
+ * 检测是否处于 React Native 环境
340
+ *
341
+ * @returns 是否为 React Native 环境
342
+ * @example
343
+ * ```ts
344
+ * EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
345
+ * ```
346
+ */
347
+ static isReactNative() {
348
+ return this._isReactNative;
349
+ }
350
+ /**
351
+ * 检查是否在 iframe 环境中
352
+ *
353
+ * @returns 是否在 iframe 中
354
+ * @example
355
+ * ```ts
356
+ * EnvUtil.isIframe(); // true: 当前页面在 iframe 中
357
+ * ```
358
+ */
359
+ static isIframe() {
360
+ if (typeof window === "undefined") return false;
361
+ try {
362
+ return window.top !== window.self;
363
+ } catch (error) {
364
+ if (error.name === "SecurityError") return true;
365
+ return false;
366
+ }
367
+ }
368
+ /**
369
+ * 检测当前设备是否为桌面设备
370
+ *
371
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
372
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
373
+ * @param dpi - 标准 DPI 基准(默认 160)
374
+ * @returns 是否为桌面设备
375
+ * @example
376
+ * ```ts
377
+ * // 假设 window.innerWidth = 1920
378
+ * EnvUtil.isDesktop(); // true
379
+ *
380
+ * // 自定义阈值
381
+ * EnvUtil.isDesktop(1440, 13); // 更严格的桌面检测
382
+ * ```
383
+ */
384
+ static isDesktop(minWidth = 1200, minScreenSize = 10, dpi = 160) {
385
+ if (typeof window === "undefined" || !TypeUtil.isPositiveInteger(minWidth) || !TypeUtil.isPositiveInteger(minScreenSize)) return false;
386
+ if (window.innerWidth < minWidth) return false;
387
+ try {
388
+ const widthPx = window.screen.width;
389
+ const heightPx = window.screen.height;
390
+ const DPI = dpi * (window.devicePixelRatio || 1);
391
+ const widthInch = widthPx / DPI;
392
+ const heightInch = heightPx / DPI;
393
+ return Math.sqrt(widthInch ** 2 + heightInch ** 2) >= minScreenSize;
394
+ } catch {
395
+ return true;
396
+ }
397
+ }
398
+ /**
399
+ * 检测当前设备是否为 Windows 桌面设备
400
+ *
401
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
402
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
403
+ * @param dpi - 标准 DPI 基准(默认 160)
404
+ * @returns 是否为 Windows 桌面设备
405
+ * @example
406
+ * ```ts
407
+ * // UA contains Windows
408
+ * EnvUtil.isWindowsDesktop(); // true
409
+ * ```
410
+ */
411
+ static isWindowsDesktop(minWidth = 1200, minScreenSize = 10, dpi = 160) {
412
+ if (typeof navigator === "undefined" || !navigator.userAgent) return false;
413
+ return /Windows/i.test(navigator.userAgent) && this.isDesktop(minWidth, minScreenSize, dpi);
414
+ }
415
+ /**
416
+ * 检测当前设备是否为 macOS 桌面设备
417
+ *
418
+ * @param minWidth - 桌面设备最小宽度(默认 1200px)
419
+ * @param minScreenSize - 桌面设备最小屏幕尺寸(默认 10英寸)
420
+ * @param dpi - 标准 DPI 基准(默认 160)
421
+ * @returns 是否为 macOS 桌面设备
422
+ * @example
423
+ * ```ts
424
+ * // UA contains Macintosh
425
+ * EnvUtil.isMacOSDesktop(); // true
426
+ * ```
427
+ */
428
+ static isMacOSDesktop(minWidth = 1200, minScreenSize = 10, dpi = 160) {
429
+ if (typeof navigator === "undefined" || !navigator.userAgent) return false;
430
+ return /Macintosh/i.test(navigator.userAgent) && this.isDesktop(minWidth, minScreenSize, dpi);
431
+ }
432
+ /**
433
+ * 检测当前设备是否为移动设备
434
+ *
435
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
436
+ * @param dpi - 标准 DPI 基准(默认 160)
437
+ * @returns 是否为移动设备
438
+ * @example
439
+ * ```ts
440
+ * // 假设 window.innerWidth = 500
441
+ * EnvUtil.isMobile(); // true
442
+ * ```
443
+ */
444
+ static isMobile(maxWidth = 768, dpi = 160) {
445
+ if (typeof window === "undefined" || !TypeUtil.isPositiveInteger(maxWidth)) return false;
446
+ if (window.innerWidth >= maxWidth) return false;
447
+ try {
448
+ const widthPx = window.screen.width;
449
+ const heightPx = window.screen.height;
450
+ const DPI = dpi * (window.devicePixelRatio || 1);
451
+ const widthInch = widthPx / DPI;
452
+ const heightInch = heightPx / DPI;
453
+ return Math.sqrt(widthInch ** 2 + heightInch ** 2) < 7;
454
+ } catch {
455
+ return true;
456
+ }
457
+ }
458
+ /**
459
+ * 检测当前设备是否为IOS移动设备
460
+ *
461
+ * @param maxWidth - 移动设备最大宽度(默认 768px)
462
+ * @param dpi - 标准 DPI 基准(默认 160)
463
+ * @returns 是否为 iOS 移动设备 (iPhone/iPod)
464
+ * @example
465
+ * ```ts
466
+ * // UA contains iPhone
467
+ * EnvUtil.isIOSMobile(); // true
468
+ * ```
469
+ */
470
+ static isIOSMobile(maxWidth = 768, dpi = 160) {
471
+ if (typeof navigator === "undefined" || !navigator.userAgent) return false;
472
+ return /iPhone|iPad|iPod/i.test(navigator.userAgent) && this.isMobile(maxWidth, dpi);
473
+ }
474
+ /**
475
+ * 检测当前设备是否为平板
476
+ *
477
+ * @param minWidth - 平板最小宽度(默认 768px)
478
+ * @param maxWidth - 平板最大宽度(默认 1200px)
479
+ * @param dpi - 标准 DPI 基准(默认 160)
480
+ * @returns 是否为平板设备
481
+ * @example
482
+ * ```ts
483
+ * // 假设 window.innerWidth = 1000
484
+ * EnvUtil.isTablet(); // true
485
+ * ```
486
+ */
487
+ static isTablet(minWidth = 768, maxWidth = 1200, dpi = 160) {
488
+ if (typeof window === "undefined" || !TypeUtil.isPositiveInteger(minWidth) || !TypeUtil.isPositiveInteger(maxWidth)) return false;
489
+ const width = window.innerWidth;
490
+ const isWithinWidthRange = width >= minWidth && width <= maxWidth;
491
+ try {
492
+ const widthPx = window.screen.width;
493
+ const heightPx = window.screen.height;
494
+ const DPI = dpi * (window.devicePixelRatio || 1);
495
+ const widthInch = widthPx / DPI;
496
+ const heightInch = heightPx / DPI;
497
+ const screenInches = Math.sqrt(widthInch ** 2 + heightInch ** 2);
498
+ return isWithinWidthRange || screenInches >= 7;
499
+ } catch {
500
+ return isWithinWidthRange;
501
+ }
502
+ }
503
+ };
504
+ _defineProperty(EnvUtil, "_isBrowser", typeof window !== "undefined" && TypeUtil.isFunction(window?.document?.createElement));
505
+ _defineProperty(EnvUtil, "_isWebWorker", typeof window === "undefined" && typeof self !== "undefined" && "importScripts" in self);
506
+ _defineProperty(EnvUtil, "_isReactNative", typeof navigator !== "undefined" && navigator.product === "ReactNative");
507
+ //#endregion
508
+ //#region src/function/functionUtil.ts
509
+ /**
510
+ * 函数工具类
511
+ */
512
+ var FunctionUtil = class {
513
+ /**
514
+ *将 Promise 转换为 `[err, result]` 格式,方便 async/await 错误处理
515
+ *
516
+ * @param promise 待处理的 Promise
517
+ * @param errorExt 附加到 error 对象的扩展信息(注意:如果原 error 是 Error 实例,扩展属性可能会覆盖或无法正确合并非枚举属性)
518
+ * @returns `[err, null]` 或 `[null, data]`
519
+ * @example
520
+ * ```ts
521
+ * const [err, data] = await FunctionUtil.to(someAsyncFunc());
522
+ * ```
523
+ */
524
+ static to(promise, errorExt) {
525
+ return promise.then((data) => [null, data]).catch((err) => {
526
+ if (errorExt) {
527
+ const parsedError = {
528
+ name: "",
529
+ message: "",
530
+ stack: ""
531
+ };
532
+ if (err instanceof Error) {
533
+ parsedError.message = err.message;
534
+ parsedError.name = err.name;
535
+ parsedError.stack = err.stack;
536
+ Object.getOwnPropertyNames(err).forEach((key) => {
537
+ if (!(key in parsedError)) parsedError[key] = err[key];
538
+ });
539
+ } else Object.assign(parsedError, err);
540
+ Object.assign(parsedError, errorExt);
541
+ return [parsedError, void 0];
542
+ }
543
+ return [err ? err : /* @__PURE__ */ new Error("defaultError"), void 0];
544
+ });
545
+ }
546
+ /**
547
+ * 将 Arguments 对象转换为数组
548
+ *
549
+ * ⚠️ 注意:TypeScript 官方推荐使用 rest parameters (...args) 替代 arguments
550
+ * 本函数仅用于处理遗留代码或特殊场景(如装饰器中需保留 this 绑定)
551
+ *
552
+ * @param args Arguments 对象(必须为类数组对象)
553
+ * @param start 起始索引(可选,默认为 0)
554
+ * @returns 转换后的数组,元素类型为 T
555
+ *
556
+ * @throws TypeError 如果 args 为 null 或 undefined
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * // 遗留代码场景
561
+ * function legacyFn(a: number, b: string) {
562
+ * const argsArray = FunctionUtil.toArgs(arguments);
563
+ * // argsArray: unknown[]
564
+ * }
565
+ *
566
+ * // 现代替代方案(推荐)
567
+ * function modernFn(a: number, b: string, ...rest: unknown[]) {
568
+ * // rest 已经是数组,无需 toArgs
569
+ * }
570
+ *
571
+ * // 参数截取
572
+ * function skipFirst(...args: unknown[]) {
573
+ * const rest = FunctionUtil.toArgs(arguments, 1);
574
+ * // rest: unknown[],跳过第一个参数
575
+ * }
576
+ * ```
577
+ */
578
+ static toArgs(args, start) {
579
+ if (args === null) throw new TypeError(`function [toArgs] Expected parameter [args] to be a arguments object, got ${typeof args}`);
580
+ const array = Array.from(args);
581
+ return TypeUtil.isNumber(start) ? array.slice(start) : array;
582
+ }
583
+ /**
584
+ * 将同步或异步函数统一包装为 Promise
585
+ * - 自动捕获同步异常
586
+ *
587
+ * @param fn 返回值可为同步值或 Promise 的函数
588
+ * @returns 标准化的 Promise
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * // 同步函数
593
+ * FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
594
+ *
595
+ * // 异步函数
596
+ * FunctionUtil.toPromise(async () => await fetchData()).then(data => ...);
597
+ *
598
+ * // 异常处理
599
+ * FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
600
+ * ```
601
+ */
602
+ static toPromise(fn) {
603
+ try {
604
+ return Promise.resolve(fn());
605
+ } catch (error) {
606
+ return Promise.reject(error);
607
+ }
608
+ }
609
+ };
610
+ //#endregion
611
+ //#region src/mime/mimeUtil.ts
612
+ /**
613
+ * MIME 工具类
614
+ */
615
+ var MimeUtil = class {};
616
+ _defineProperty(MimeUtil, "MIME", {
617
+ /** 普通文本文件 */
618
+ TEXT: "text/plain",
619
+ /** 超文本标记语言文档 */
620
+ HTML: "text/html",
621
+ /** 层叠样式表文件 */
622
+ CSS: "text/css",
623
+ /** 逗号分隔值文件(表格数据) */
624
+ CSV: "text/csv",
625
+ /** 制表符分隔值文件 */
626
+ TSV: "text/tab-separated-values",
627
+ /** XML 文档 */
628
+ XML: "text/xml",
629
+ /** XHTML 文档(XML 严格格式的 HTML) */
630
+ XHTML: "application/xhtml+xml",
631
+ /** JavaScript 文件 */
632
+ JS: "text/javascript",
633
+ /** TypeScript 文件 */
634
+ TS: "text/typescript",
635
+ /** Python 文件 */
636
+ PY: "text/x-python",
637
+ /** Shell 脚本 (.sh) */
638
+ SH: "text/x-sh",
639
+ /** C 语言源文件 */
640
+ C: "text/x-c",
641
+ /** C++ 源文件 */
642
+ CPP: "text/x-c++",
643
+ /** C# 源文件 */
644
+ CSHARP: "text/x-csharp",
645
+ /** Java 源文件 */
646
+ JAVA: "text/x-java",
647
+ /** Go 源文件 */
648
+ GO: "text/x-go",
649
+ /** Rust 源文件 */
650
+ RUST: "text/x-rust",
651
+ /** PHP 文件 */
652
+ PHP: "text/x-php",
653
+ /** Ruby 文件 */
654
+ RUBY: "text/x-ruby",
655
+ /** Swift 源文件 */
656
+ SWIFT: "text/x-swift",
657
+ /** YAML 文档 */
658
+ YAML: "text/vnd.yaml",
659
+ /** TOML 文档 */
660
+ TOML: "text/x-toml",
661
+ /** SQL 脚本 */
662
+ SQL: "text/x-sql",
663
+ /** Markdown 格式文档 */
664
+ MARKDOWN: "text/markdown",
665
+ /** 富文本格式文档(.rtf) */
666
+ RTF: "application/rtf",
667
+ /** iCalendar 日历格式(.ics) */
668
+ CALENDAR: "text/calendar",
669
+ /** JPEG 图像(.jpg/.jpeg) */
670
+ JPEG: "image/jpeg",
671
+ /** PNG 图像(无损压缩,支持透明) */
672
+ PNG: "image/png",
673
+ /** GIF 图像(支持动画) */
674
+ GIF: "image/gif",
675
+ /** Windows 位图(.bmp) */
676
+ BMP: "image/bmp",
677
+ /** SVG 向量图形(.svg) */
678
+ SVG: "image/svg+xml",
679
+ /** APNG 动态图像(.apng) */
680
+ APNG: "image/apng",
681
+ /** AVIF 图像(高效压缩) */
682
+ AVIF: "image/avif",
683
+ /** 图标文件格式(.ico) */
684
+ ICO: "image/vnd.microsoft.icon",
685
+ /** WebP 图像(高效压缩) */
686
+ WEBP: "image/webp",
687
+ /** TIFF 图像(.tif/.tiff) */
688
+ TIFF: "image/tiff",
689
+ /** HEIC 图像(高效编码) */
690
+ HEIC: "image/heic",
691
+ /** Adobe Photoshop 文件(.psd) */
692
+ PSD: "image/vnd.adobe.photoshop",
693
+ /** MP3 音频(.mp3) */
694
+ MP3: "audio/mpeg",
695
+ /** AAC 音频(.aac) */
696
+ AAC: "audio/aac",
697
+ /** MIDI 音乐文件(.mid/.midi) */
698
+ MIDI: "audio/midi",
699
+ /** OGG 音频(.oga) */
700
+ OGG_AUDIO: "audio/ogg",
701
+ /** Opus 音频(.opus) */
702
+ OPUS: "audio/opus",
703
+ /** WAV 音频(.wav) */
704
+ WAV: "audio/wav",
705
+ /** RealAudio 音频(.ra/.ram) */
706
+ REAL_AUDIO: "audio/x-pn-realaudio",
707
+ /** MP4 视频(.mp4) */
708
+ MP4: "video/mp4",
709
+ /** MPEG 视频(.mpeg/.mpg) */
710
+ MPEG: "video/mpeg",
711
+ /** OGG 视频(.ogv) */
712
+ OGG_VIDEO: "video/ogg",
713
+ /** AVI 视频(.avi) */
714
+ AVI: "video/x-msvideo",
715
+ /** 3GPP 视频(.3gp) */
716
+ THREE_GPP: "video/3gpp",
717
+ /** 3GPP2 视频(.3g2) */
718
+ THREE_GPP2: "video/3gpp2",
719
+ /** WebM 视频(.webm) */
720
+ WEBM: "video/webm",
721
+ /** PDF 文档 */
722
+ PDF: "application/pdf",
723
+ /** Word 97-2003 文档(.doc) */
724
+ DOC: "application/msword",
725
+ /** Word 2007+ 文档(.docx) */
726
+ DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
727
+ /** Excel 2007+ 工作簿(.xlsx) */
728
+ XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
729
+ /** 启用宏的Excel工作簿(.xlsm) */
730
+ XLSM: "application/vnd.ms-excel.sheet.macroEnabled.12",
731
+ /** Excel模板文件(.xltx) */
732
+ XLTX: "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
733
+ /** PowerPoint 2007+ 演示文稿(.pptx) */
734
+ PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
735
+ /** PowerPoint 97-2003 演示文稿(.ppt) */
736
+ PPT: "application/vnd.ms-powerpoint",
737
+ /** OpenDocument 文本文档(.odt) */
738
+ ODT: "application/vnd.oasis.opendocument.text",
739
+ /** OpenDocument 表格文档(.ods) */
740
+ ODS: "application/vnd.oasis.opendocument.spreadsheet",
741
+ /** OpenDocument 演示文稿(.odp) */
742
+ ODP: "application/vnd.oasis.opendocument.presentation",
743
+ /** EPUB 电子书(.epub) */
744
+ EPUB: "application/epub+zip",
745
+ /** Kindle 电子书(.azw) */
746
+ AZW: "application/vnd.amazon.ebook",
747
+ /** ZIP 压缩文件(.zip) */
748
+ ZIP: "application/zip",
749
+ /** GZIP 压缩文件(.gz) */
750
+ GZIP: "application/gzip",
751
+ /** GZIP 压缩文件(旧格式) */
752
+ X_GZIP: "application/x-gzip",
753
+ /** TAR 归档文件(.tar) */
754
+ TAR: "application/x-tar",
755
+ /** BZip 归档(.bz) */
756
+ BZIP: "application/x-bzip",
757
+ /** BZip2 归档(.bz2) */
758
+ BZIP2: "application/x-bzip2",
759
+ /** 7-Zip 压缩文件(.7z) */
760
+ SEVEN_Z: "application/x-7z-compressed",
761
+ /** RAR 压缩文件(.rar) */
762
+ RAR: "application/vnd.rar",
763
+ /** 通用二进制数据(默认类型) */
764
+ OCTET_STREAM: "application/octet-stream",
765
+ /** JSON 数据格式(.json) */
766
+ JSON: "application/json",
767
+ /** JSON-LD 格式(.jsonld) */
768
+ LD_JSON: "application/ld+json",
769
+ /** Java 归档文件(.jar) */
770
+ JAR: "application/java-archive",
771
+ /** WebAssembly 二进制指令格式(.wasm) */
772
+ WASM: "application/wasm",
773
+ /** MS 嵌入式 OpenType 字体(.eot) */
774
+ EOT: "application/vnd.ms-fontobject",
775
+ /** OpenType 字体(.otf) */
776
+ OTF: "font/otf",
777
+ /** WOFF 字体(.woff) */
778
+ WOFF: "font/woff",
779
+ /** WOFF2 字体(.woff2) */
780
+ WOFF2: "font/woff2",
781
+ /** TrueType 字体(.ttf) */
782
+ TTF: "font/ttf",
783
+ /** Excel 97-2003 工作簿(.xls) */
784
+ XLS: "application/vnd.ms-excel",
785
+ /** Microsoft XPS 文档(.xps) */
786
+ XPS: "application/vnd.ms-xpsdocument",
787
+ /** Word 启用宏文档(.docm) */
788
+ DOCM: "application/vnd.ms-word.document.macroEnabled.12"
789
+ });
790
+ //#endregion
791
+ //#region src/number/numberUtil.ts
792
+ /**
793
+ * 数字工具类
794
+ */
795
+ var NumberUtil = class {
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, interval, includeLeft = true, includeRight = false) {
811
+ if (!TypeUtil.isNumber(input) || TypeUtil.isInfinity(input)) throw new Error("function [within] Expected parameter [input] to be a finite number.");
812
+ if (!TypeUtil.isArray(interval) || interval.length !== 2) throw new Error("function [within] Expected parameter [interval] to be a tuple with 2 numbers.");
813
+ const [left, right] = interval;
814
+ if (left > right) throw new Error(`Invalid interval: left (${left}) must be <= right (${right}).`);
815
+ if (includeLeft && includeRight) return input >= left && input <= right;
816
+ else if (includeLeft) return input >= left && input < right;
817
+ else if (includeRight) return input > left && input <= right;
818
+ else return input > left && input < right;
819
+ }
820
+ };
821
+ //#endregion
822
+ //#region src/object/objectUtil.ts
823
+ /**
824
+ * 对象工具类
825
+ */
826
+ var ObjectUtil = class {
827
+ static keys(value) {
828
+ return Object.keys(value);
829
+ }
830
+ static values(value) {
831
+ return Object.values(value);
832
+ }
833
+ static entries(value) {
834
+ return Object.entries(value);
835
+ }
836
+ /**
837
+ * 映射对象条目
838
+ * - 将对象的键值对映射为新的键值对
839
+ *
840
+ * @param plainObject 对象
841
+ * @param toEntry 映射函数
842
+ * @returns 映射后的新对象
843
+ * @example
844
+ * ```ts
845
+ * const obj = { a: 1, b: 2 };
846
+ *
847
+ * ObjectUtil.entriesMap(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
848
+ *
849
+ * ObjectUtil.entriesMap(obj, (k, v) => [`prefix_${String(k)}`, `${v}x`]); // { prefix_a: "1x", prefix_b: "2x" }
850
+ * ```
851
+ */
852
+ static entriesMap(plainObject, toEntry) {
853
+ const defaultResult = {};
854
+ if (!TypeUtil.isObject(plainObject)) return defaultResult;
855
+ return this.entries(plainObject).reduce((acc, [key, value]) => {
856
+ const [newKey, newValue] = toEntry(key, value);
857
+ acc[newKey] = newValue;
858
+ return acc;
859
+ }, defaultResult);
860
+ }
861
+ static pick(obj, keys) {
862
+ const result = {};
863
+ if (!TypeUtil.isObject(obj)) return result;
864
+ if (!TypeUtil.isArray(keys)) return obj;
865
+ return keys.reduce((acc, key) => {
866
+ if (key in obj) acc[key] = obj[key];
867
+ return acc;
868
+ }, result);
869
+ }
870
+ static omit(obj, keys) {
871
+ const result = {};
872
+ if (!TypeUtil.isObject(obj)) return result;
873
+ if (!TypeUtil.isArray(keys)) return obj;
874
+ const keysToOmit = new Set(keys);
875
+ return Object.keys(obj).reduce((acc, key) => {
876
+ if (!keysToOmit.has(key)) acc[key] = obj[key];
877
+ return acc;
878
+ }, result);
879
+ }
880
+ static invert(obj) {
881
+ const result = {};
882
+ if (!TypeUtil.isObject(obj)) return result;
883
+ for (const [k, v] of this.entries(obj)) if (TypeUtil.isString(v) || TypeUtil.isNumber(v) || TypeUtil.isSymbol(v)) result[v] = k;
884
+ return result;
885
+ }
886
+ static crush(obj) {
887
+ if (!obj) return {};
888
+ function crushReducer(crushed, value, path) {
889
+ if (TypeUtil.isObject(value) || TypeUtil.isArray(value)) for (const [prop, propValue] of Object.entries(value)) crushReducer(crushed, propValue, path ? `${path}.${prop}` : prop);
890
+ else crushed[path] = value;
891
+ return crushed;
892
+ }
893
+ return crushReducer({}, obj, "");
894
+ }
895
+ static enumKeys(enumeration) {
896
+ const [isEnum, isBidirectionalEnum] = TypeUtil.isEnumeration(enumeration);
897
+ if (!isEnum) throw Error("function [enumKeys] expected parameter to be a enum, and requires at least one member");
898
+ const keys = this.keys(enumeration);
899
+ if (isBidirectionalEnum) return keys.splice(keys.length / 2, keys.length / 2);
900
+ return keys;
901
+ }
902
+ static enumValues(enumeration) {
903
+ const [isEnum, isBidirectionalEnum] = TypeUtil.isEnumeration(enumeration);
904
+ if (!isEnum) throw Error("function [enumValues] expected parameter to be a enum, and requires at least one member");
905
+ const values = this.values(enumeration);
906
+ if (isBidirectionalEnum) return values.splice(values.length / 2, values.length / 2);
907
+ return values;
908
+ }
909
+ static enumEntries(enumeration) {
910
+ const [isEnum, isBidirectionalEnum] = TypeUtil.isEnumeration(enumeration);
911
+ if (!isEnum) throw Error("function [enumEntries] expected parameter to be a enum, and requires at least one member");
912
+ const entries = this.entries(enumeration);
913
+ if (isBidirectionalEnum) return entries.splice(entries.length / 2, entries.length / 2);
914
+ return entries;
915
+ }
916
+ };
917
+ //#endregion
918
+ //#region src/theme/themeUtil.ts
919
+ /**
920
+ * 主题工具类
921
+ */
922
+ var ThemeUtil = class {};
923
+ _defineProperty(ThemeUtil, "THEME", {
924
+ LIGHT: "light",
925
+ DARK: "dark"
926
+ });
927
+ _defineProperty(ThemeUtil, "THEME_MODE", {
928
+ LIGHT: "light",
929
+ DARK: "dark",
930
+ SYSTEM: "system"
931
+ });
932
+ //#endregion
933
+ //#region src/tree/utils.ts
934
+ function getFinalChildrenKey(tree, meta, options) {
935
+ if (TypeUtil.isFunction(options.getChildrenKey)) {
936
+ const dynamicChildrenKey = options.getChildrenKey(tree, meta);
937
+ if (dynamicChildrenKey && dynamicChildrenKey !== null) return dynamicChildrenKey;
938
+ }
939
+ return options.childrenKey;
940
+ }
941
+ //#endregion
942
+ //#region src/tree/filter.ts
943
+ function preImpl$3(row, callback, options) {
944
+ if (!callback(row, options)) return;
945
+ const finalChildrenKey = getFinalChildrenKey(row, options, options);
946
+ const children = row[finalChildrenKey];
947
+ let newChildren;
948
+ if (TypeUtil.isArray(children)) {
949
+ const nextLevelOptions = {
950
+ ...options,
951
+ parents: [...options.parents, row],
952
+ depth: options.depth + 1
953
+ };
954
+ newChildren = children.map((c) => preImpl$3(c, callback, nextLevelOptions)).filter((c) => !!c);
955
+ }
956
+ return {
957
+ ...row,
958
+ [finalChildrenKey]: newChildren
959
+ };
960
+ }
961
+ function postImpl$3(row, callback, options) {
962
+ const finalChildrenKey = getFinalChildrenKey(row, options, options);
963
+ const children = row[finalChildrenKey];
964
+ let newChildren;
965
+ if (TypeUtil.isArray(children)) {
966
+ const nextLevelOptions = {
967
+ ...options,
968
+ parents: [...options.parents, row],
969
+ depth: options.depth + 1
970
+ };
971
+ newChildren = children.map((c) => preImpl$3(c, callback, nextLevelOptions)).filter((c) => !!c);
972
+ }
973
+ if (!callback(row, options)) return;
974
+ return {
975
+ ...row,
976
+ [finalChildrenKey]: newChildren
977
+ };
978
+ }
979
+ function breadthImpl$3(row, callback, options) {
980
+ const queue = [{
981
+ queueRow: row,
982
+ queueOptions: options
983
+ }];
984
+ const resultCache = /* @__PURE__ */ new WeakMap();
985
+ const newNodeCache = /* @__PURE__ */ new WeakMap();
986
+ const childrenKeyCache = /* @__PURE__ */ new WeakMap();
987
+ let result;
988
+ const runQueue = () => {
989
+ if (queue.length === 0) return result;
990
+ const { queueRow, queueOptions } = queue.shift();
991
+ const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
992
+ const children = queueRow[finalChildrenKey];
993
+ if (TypeUtil.isArray(children)) {
994
+ const nextLevelOptions = {
995
+ ...queueOptions,
996
+ parents: [...queueOptions.parents, queueRow],
997
+ depth: queueOptions.depth + 1
998
+ };
999
+ const subQueueItems = children.map((queueRow) => ({
1000
+ queueRow,
1001
+ queueOptions: nextLevelOptions
1002
+ }));
1003
+ queue.push(...subQueueItems);
1004
+ }
1005
+ const parent = ArrayUtil.last(queueOptions.parents);
1006
+ const isTopNode = queueOptions.depth === 0;
1007
+ const parentResult = parent && resultCache.get(parent);
1008
+ if (!isTopNode && !parentResult) return runQueue();
1009
+ const callbackResult = callback(queueRow, queueOptions);
1010
+ if (isTopNode && !callbackResult) return;
1011
+ const newNode = {
1012
+ ...queueRow,
1013
+ [finalChildrenKey]: void 0
1014
+ };
1015
+ if (isTopNode) result = newNode;
1016
+ resultCache.set(queueRow, callbackResult);
1017
+ newNodeCache.set(queueRow, newNode);
1018
+ childrenKeyCache.set(queueRow, finalChildrenKey);
1019
+ if (callbackResult && parent) {
1020
+ const parentNewNode = newNodeCache.get(parent);
1021
+ const parentChildrenKey = childrenKeyCache.get(parent);
1022
+ if (parentNewNode && parentChildrenKey) {
1023
+ if (!parentNewNode[parentChildrenKey]) parentNewNode[parentChildrenKey] = [];
1024
+ parentNewNode[parentChildrenKey].push(newNode);
1025
+ }
1026
+ }
1027
+ return runQueue();
1028
+ };
1029
+ return runQueue();
1030
+ }
1031
+ const treeFilterStrategies = {
1032
+ pre: preImpl$3,
1033
+ post: postImpl$3,
1034
+ breadth: breadthImpl$3
1035
+ };
1036
+ //#endregion
1037
+ //#region src/tree/find.ts
1038
+ function preImpl$2(row, callback, options) {
1039
+ if (callback(row, options)) return row;
1040
+ const children = row[getFinalChildrenKey(row, options, options)];
1041
+ if (TypeUtil.isArray(children)) for (const child of children) {
1042
+ const result = preImpl$2(child, callback, {
1043
+ ...options,
1044
+ parents: [...options.parents, row],
1045
+ depth: options.depth + 1
1046
+ });
1047
+ if (result) return result;
1048
+ }
1049
+ }
1050
+ function postImpl$2(row, callback, options) {
1051
+ const children = row[getFinalChildrenKey(row, options, options)];
1052
+ if (TypeUtil.isArray(children)) for (const child of children) {
1053
+ const result = postImpl$2(child, callback, {
1054
+ ...options,
1055
+ parents: [...options.parents, row],
1056
+ depth: options.depth + 1
1057
+ });
1058
+ if (result) return result;
1059
+ }
1060
+ if (callback(row, options)) return row;
1061
+ }
1062
+ function breadthImpl$2(row, callback, options) {
1063
+ const queue = [{
1064
+ queueRow: row,
1065
+ queueOptions: options
1066
+ }];
1067
+ const runQueue = () => {
1068
+ if (queue.length === 0) return;
1069
+ const { queueRow, queueOptions } = queue.shift();
1070
+ const children = queueRow[getFinalChildrenKey(queueRow, queueOptions, queueOptions)];
1071
+ if (TypeUtil.isArray(children)) {
1072
+ const nextLevelOptions = {
1073
+ ...queueOptions,
1074
+ parents: [...queueOptions.parents, queueRow],
1075
+ depth: queueOptions.depth + 1
1076
+ };
1077
+ const subQueueItems = children.map((queueRow) => ({
1078
+ queueRow,
1079
+ queueOptions: nextLevelOptions
1080
+ }));
1081
+ queue.push(...subQueueItems);
1082
+ }
1083
+ if (callback(queueRow, queueOptions)) return queueRow;
1084
+ return runQueue();
1085
+ };
1086
+ return runQueue();
1087
+ }
1088
+ const treeFindStrategies = {
1089
+ pre: preImpl$2,
1090
+ post: postImpl$2,
1091
+ breadth: breadthImpl$2
1092
+ };
1093
+ //#endregion
1094
+ //#region src/tree/forEach.ts
1095
+ function preImpl$1(row, callback, options) {
1096
+ callback(row, options);
1097
+ const children = row[getFinalChildrenKey(row, options, options)];
1098
+ if (TypeUtil.isArray(children)) {
1099
+ const nextLevelOptions = {
1100
+ ...options,
1101
+ parents: [...options.parents, row],
1102
+ depth: options.depth + 1
1103
+ };
1104
+ for (const child of children) preImpl$1(child, callback, nextLevelOptions);
1105
+ }
1106
+ }
1107
+ function postImpl$1(row, callback, options) {
1108
+ const children = row[getFinalChildrenKey(row, options, options)];
1109
+ if (TypeUtil.isArray(children)) {
1110
+ const nextLevelOptions = {
1111
+ ...options,
1112
+ parents: [...options.parents, row],
1113
+ depth: options.depth + 1
1114
+ };
1115
+ for (const child of children) postImpl$1(child, callback, nextLevelOptions);
1116
+ }
1117
+ callback(row, options);
1118
+ }
1119
+ function breadthImpl$1(row, callback, options) {
1120
+ const queue = [{
1121
+ queueRow: row,
1122
+ queueOptions: options
1123
+ }];
1124
+ const runQueue = () => {
1125
+ if (queue.length === 0) return;
1126
+ const { queueRow, queueOptions } = queue.shift();
1127
+ const children = queueRow[getFinalChildrenKey(queueRow, queueOptions, queueOptions)];
1128
+ if (TypeUtil.isArray(children)) {
1129
+ const nextLevelOptions = {
1130
+ ...queueOptions,
1131
+ parents: [...queueOptions.parents, queueRow],
1132
+ depth: queueOptions.depth + 1
1133
+ };
1134
+ const subQueueItems = children.map((queueRow) => ({
1135
+ queueRow,
1136
+ queueOptions: nextLevelOptions
1137
+ }));
1138
+ queue.push(...subQueueItems);
1139
+ }
1140
+ callback(queueRow, queueOptions);
1141
+ runQueue();
1142
+ };
1143
+ runQueue();
1144
+ }
1145
+ const treeForEachStrategies = {
1146
+ pre: preImpl$1,
1147
+ post: postImpl$1,
1148
+ breadth: breadthImpl$1
1149
+ };
1150
+ //#endregion
1151
+ //#region src/tree/map.ts
1152
+ function preImpl(row, callback, options) {
1153
+ const finalChildrenKey = getFinalChildrenKey(row, options, options);
1154
+ const result = callback(row, options);
1155
+ const children = row[finalChildrenKey];
1156
+ let newChildren;
1157
+ if (TypeUtil.isArray(children)) {
1158
+ const nextLevelOptions = {
1159
+ ...options,
1160
+ parents: [...options.parents, row],
1161
+ depth: options.depth + 1
1162
+ };
1163
+ newChildren = children.map((c) => preImpl(c, callback, nextLevelOptions));
1164
+ }
1165
+ return {
1166
+ ...result,
1167
+ [finalChildrenKey]: newChildren
1168
+ };
1169
+ }
1170
+ function postImpl(row, callback, options) {
1171
+ const finalChildrenKey = getFinalChildrenKey(row, options, options);
1172
+ const children = row[finalChildrenKey];
1173
+ let newChildren;
1174
+ if (TypeUtil.isArray(children)) {
1175
+ const nextLevelOptions = {
1176
+ ...options,
1177
+ parents: [...options.parents, row],
1178
+ depth: options.depth + 1
1179
+ };
1180
+ newChildren = children.map((c) => postImpl(c, callback, nextLevelOptions));
1181
+ }
1182
+ return {
1183
+ ...callback(row, options),
1184
+ [finalChildrenKey]: newChildren
1185
+ };
1186
+ }
1187
+ function breadthImpl(row, callback, options) {
1188
+ const queue = [{
1189
+ queueRow: row,
1190
+ queueOptions: options
1191
+ }];
1192
+ const cache = /* @__PURE__ */ new WeakMap();
1193
+ const childrenKeyCache = /* @__PURE__ */ new WeakMap();
1194
+ let result;
1195
+ const runQueue = () => {
1196
+ if (queue.length === 0) return result;
1197
+ const { queueRow, queueOptions } = queue.shift();
1198
+ const finalChildrenKey = getFinalChildrenKey(queueRow, queueOptions, queueOptions);
1199
+ const children = queueRow[finalChildrenKey];
1200
+ if (TypeUtil.isArray(children)) {
1201
+ const nextLevelOptions = {
1202
+ ...queueOptions,
1203
+ parents: [...queueOptions.parents, queueRow],
1204
+ depth: queueOptions.depth + 1
1205
+ };
1206
+ const subQueueItems = children.map((queueRow) => ({
1207
+ queueRow,
1208
+ queueOptions: nextLevelOptions
1209
+ }));
1210
+ queue.push(...subQueueItems);
1211
+ }
1212
+ const res = callback(queueRow, queueOptions);
1213
+ cache.set(queueRow, res);
1214
+ childrenKeyCache.set(queueRow, finalChildrenKey);
1215
+ const parent = ArrayUtil.last(queueOptions.parents);
1216
+ if (parent) {
1217
+ const newParent = cache.get(parent);
1218
+ const parentChildrenKey = childrenKeyCache.get(parent);
1219
+ if (newParent && parentChildrenKey) if (newParent[parentChildrenKey]) newParent[parentChildrenKey].push(res);
1220
+ else newParent[parentChildrenKey] = [res];
1221
+ }
1222
+ if (queueOptions.depth === 0) result = res;
1223
+ return runQueue();
1224
+ };
1225
+ return runQueue();
1226
+ }
1227
+ const treeMapStrategies = {
1228
+ pre: preImpl,
1229
+ post: postImpl,
1230
+ breadth: breadthImpl
1231
+ };
1232
+ //#endregion
1233
+ //#region src/tree/treeUtil.ts
1234
+ /**
1235
+ * 树结构工具类
1236
+ */
1237
+ var TreeUtil = class {
1238
+ /**
1239
+ * 行结构 转 树结构
1240
+ * - 将平铺的数组转换为树形结构
1241
+ *
1242
+ * @param rows 行数据数组
1243
+ * @param options 配置项
1244
+ * @returns 树结构数组
1245
+ * @example
1246
+ * ```ts
1247
+ * const rows = [
1248
+ * { id: 1, parentId: null },
1249
+ * { id: 2, parentId: 1 },
1250
+ * ];
1251
+ * TreeUtil.rowsToTree(rows); // [{ id: 1, parentId: null, children: [{ id: 2, parentId: 1 }] }]
1252
+ * ```
1253
+ */
1254
+ static rowsToTree(rows, options) {
1255
+ const { parentIdKey = "parentId", rowKey = "id", childrenKey = "children" } = options || {};
1256
+ const result = [];
1257
+ const map = /* @__PURE__ */ new Map();
1258
+ for (const row of rows) {
1259
+ const id = row[rowKey];
1260
+ if (!map.get(id)) map.set(id, row);
1261
+ }
1262
+ for (const row of rows) {
1263
+ const parentId = row[parentIdKey];
1264
+ const parent = map.get(parentId);
1265
+ if (!parent || !parentId) {
1266
+ result.push(row);
1267
+ continue;
1268
+ }
1269
+ const siblings = parent[childrenKey];
1270
+ if (TypeUtil.isNull(siblings) || TypeUtil.isUndefined(siblings)) parent[childrenKey] = [row];
1271
+ else if (Array.isArray(siblings)) siblings.push(row);
1272
+ else {
1273
+ const message = `The key "${childrenKey.toString()}" in parent item is not an array.`;
1274
+ throw new Error(message);
1275
+ }
1276
+ }
1277
+ return result;
1278
+ }
1279
+ /**
1280
+ * 树结构 转 行结构
1281
+ * - 将树形结构扁平化为数组
1282
+ *
1283
+ * @param tree 树结构数据 (单个节点或节点数组)
1284
+ * @param options 配置项
1285
+ * @returns 扁平化后的数组
1286
+ * @example
1287
+ * ```ts
1288
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
1289
+ * TreeUtil.treeToRows(tree); // [{ id: 1, children: undefined }, { id: 2, children: undefined }]
1290
+ * ```
1291
+ */
1292
+ static treeToRows(tree, options = {}) {
1293
+ const { childrenKey = "children" } = options;
1294
+ const result = [];
1295
+ if (!tree) return result;
1296
+ this.forEach(tree, (t) => result.push({
1297
+ ...t,
1298
+ [childrenKey]: void 0
1299
+ }), options);
1300
+ return result;
1301
+ }
1302
+ /**
1303
+ * 遍历树节点
1304
+ *
1305
+ * @param tree 树结构数据
1306
+ * @param callback 回调函数
1307
+ * @param options 配置项
1308
+ * @example
1309
+ * ```ts
1310
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
1311
+ * const ids: number[] = [];
1312
+ * TreeUtil.forEach(tree, (node) => ids.push(node.id)); // ids: [1, 2] (pre-order default)
1313
+ * ```
1314
+ */
1315
+ static forEach(tree, callback, options = {}) {
1316
+ const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
1317
+ const traversalMethod = treeForEachStrategies[strategy];
1318
+ const innerOptions = {
1319
+ childrenKey,
1320
+ depth: 0,
1321
+ parents: [],
1322
+ getChildrenKey
1323
+ };
1324
+ if (TypeUtil.isArray(tree)) for (const row of tree) traversalMethod(row, callback, innerOptions);
1325
+ else traversalMethod(tree, callback, innerOptions);
1326
+ }
1327
+ /**
1328
+ * 查找树节点
1329
+ * - 返回第一个回调返回 true 的节点
1330
+ *
1331
+ * @param tree 树结构数据
1332
+ * @param callback 回调函数
1333
+ * @param options 配置项
1334
+ * @returns 找到的节点,未找到则返回 undefined
1335
+ * @example
1336
+ * ```ts
1337
+ * const tree = [{ id: 1, children: [{ id: 2 }] }];
1338
+ * TreeUtil.find(tree, (node) => node.id === 2); // { id: 2, ... }
1339
+ * ```
1340
+ */
1341
+ static find(tree, callback, options = {}) {
1342
+ const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
1343
+ const traversalMethod = treeFindStrategies[strategy];
1344
+ const innerOptions = {
1345
+ childrenKey,
1346
+ depth: 0,
1347
+ parents: [],
1348
+ getChildrenKey
1349
+ };
1350
+ if (TypeUtil.isArray(tree)) {
1351
+ for (const row of tree) {
1352
+ const result = traversalMethod(row, callback, innerOptions);
1353
+ if (result) return result;
1354
+ }
1355
+ return;
1356
+ }
1357
+ return traversalMethod(tree, callback, innerOptions);
1358
+ }
1359
+ static filter(tree, callback, options = {}) {
1360
+ const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
1361
+ const traversalMethod = treeFilterStrategies[strategy];
1362
+ const innerOptions = {
1363
+ childrenKey,
1364
+ depth: 0,
1365
+ parents: [],
1366
+ getChildrenKey
1367
+ };
1368
+ return TypeUtil.isArray(tree) ? tree.map((row) => traversalMethod(row, callback, innerOptions)).filter((t) => !!t) : traversalMethod(tree, callback, innerOptions) || [];
1369
+ }
1370
+ static map(tree, callback, options = {}) {
1371
+ const { childrenKey = "children", strategy = "pre", getChildrenKey } = options;
1372
+ const traversalMethod = treeMapStrategies[strategy];
1373
+ const innerOptions = {
1374
+ childrenKey,
1375
+ depth: 0,
1376
+ parents: [],
1377
+ getChildrenKey
1378
+ };
1379
+ return TypeUtil.isArray(tree) ? tree.map((row) => traversalMethod(row, callback, innerOptions)) : traversalMethod(tree, callback, innerOptions);
1380
+ }
1381
+ };
1382
+ //#endregion
1383
+ //#region src/validate/validateUtil.ts
1384
+ /**
1385
+ * 验证工具类
1386
+ */
1387
+ var ValidateUtil = class {
1388
+ /**
1389
+ * 验证是否为手机号码
1390
+ * @example
1391
+ * ```ts
1392
+ * ValidateUtil.isPhone("13800138000"); // true
1393
+ * ```
1394
+ */
1395
+ static isPhone(input) {
1396
+ return this._phone.test(input.toString());
1397
+ }
1398
+ /**
1399
+ * 验证是否为固定电话
1400
+ * @example
1401
+ * ```ts
1402
+ * ValidateUtil.isTelephone("010-12345678"); // true
1403
+ * ```
1404
+ */
1405
+ static isTelephone(input) {
1406
+ return this._telephone.test(input.toString());
1407
+ }
1408
+ /**
1409
+ * 验证是否为移动设备识别码
1410
+ * @example
1411
+ * ```ts
1412
+ * ValidateUtil.isIMEI("490154203237518"); // true
1413
+ * ```
1414
+ */
1415
+ static isIMEI(input) {
1416
+ return this._IMEI.test(input.toString());
1417
+ }
1418
+ /**
1419
+ * 验证是否为电子邮箱
1420
+ * @example
1421
+ * ```ts
1422
+ * ValidateUtil.isEmail("dev@example.com"); // true
1423
+ * ```
1424
+ */
1425
+ static isEmail(input) {
1426
+ return this._email.test(input.toString());
1427
+ }
1428
+ /**
1429
+ * 验证是否为 http(s) 链接
1430
+ * @example
1431
+ * ```ts
1432
+ * ValidateUtil.isHttpLink("https://example.com/path"); // true
1433
+ * ```
1434
+ */
1435
+ static isHttpLink(input) {
1436
+ return this._link.test(input.toString());
1437
+ }
1438
+ /**
1439
+ * 验证是否为端口号链接
1440
+ * @example
1441
+ * ```ts
1442
+ * ValidateUtil.isPortLink("http://example.com:8080"); // true
1443
+ * ```
1444
+ */
1445
+ static isPortLink(input) {
1446
+ return this._portLink.test(input.toString());
1447
+ }
1448
+ /**
1449
+ * 验证是否为迅雷链接
1450
+ * @example
1451
+ * ```ts
1452
+ * ValidateUtil.isThunderLink("thunder://QUFodHRwOi8vZXhhbXBsZS5jb20vZmlsZQ=="); // true
1453
+ * ```
1454
+ */
1455
+ static isThunderLink(input) {
1456
+ return this._thunderLink.test(input.toString());
1457
+ }
1458
+ /**
1459
+ * 验证是否为统一社会信用代码
1460
+ * @example
1461
+ * ```ts
1462
+ * ValidateUtil.isUSCC("91350100M000100Y43"); // true
1463
+ * ```
1464
+ */
1465
+ static isUSCC(input) {
1466
+ return this._uscc.test(input.toString());
1467
+ }
1468
+ /**
1469
+ * 验证是否为统一社会信用代码 - 15位/18位/20位数字/字母
1470
+ * @example
1471
+ * ```ts
1472
+ * ValidateUtil.isUSCCS("91350100M000100Y43"); // true
1473
+ * ```
1474
+ */
1475
+ static isUSCCS(input) {
1476
+ return this._usccs.test(input.toString());
1477
+ }
1478
+ /**
1479
+ * 验证是否为 Windows 系统文件夹路径
1480
+ * @example
1481
+ * ```ts
1482
+ * ValidateUtil.isDirPathWindows("C:\\Users\\pawover\\"); // true
1483
+ * ```
1484
+ */
1485
+ static isDirPathWindows(input) {
1486
+ return this._dirPathWindows.test(input.toString());
1487
+ }
1488
+ /**
1489
+ * 验证是否为 Windows 系统文件路径
1490
+ * @example
1491
+ * ```ts
1492
+ * ValidateUtil.isFilePathWindows("C:\\Users\\pawover\\a.txt"); // true
1493
+ * ```
1494
+ */
1495
+ static isFilePathWindows(input) {
1496
+ return this._filePathWindows.test(input.toString());
1497
+ }
1498
+ /**
1499
+ * 验证是否为 Linux 系统文件夹路径
1500
+ * @example
1501
+ * ```ts
1502
+ * ValidateUtil.isDirPathLinux("/usr/local/"); // true
1503
+ * ```
1504
+ */
1505
+ static isDirPathLinux(input) {
1506
+ return this._dirPathLinux.test(input.toString());
1507
+ }
1508
+ /**
1509
+ * 验证是否为 Linux 系统文件路径
1510
+ * @example
1511
+ * ```ts
1512
+ * ValidateUtil.isFilePathLinux("/usr/local/bin/node"); // true
1513
+ * ```
1514
+ */
1515
+ static isFilePathLinux(input) {
1516
+ return this._filePathLinux.test(input.toString());
1517
+ }
1518
+ /**
1519
+ * 验证是否为新能源车牌号
1520
+ * @example
1521
+ * ```ts
1522
+ * ValidateUtil.isEVCarNumber("粤AD12345"); // true
1523
+ * ```
1524
+ */
1525
+ static isEVCarNumber(input) {
1526
+ return this._EVCarNumber.test(input.toString());
1527
+ }
1528
+ /**
1529
+ * 验证是否为燃油车车牌号
1530
+ * @example
1531
+ * ```ts
1532
+ * ValidateUtil.isGVCarNumber("粤B12345"); // true
1533
+ * ```
1534
+ */
1535
+ static isGVCarNumber(input) {
1536
+ return this._GVCarNumber.test(input.toString());
1537
+ }
1538
+ /**
1539
+ * 验证是否为中文姓名
1540
+ * @example
1541
+ * ```ts
1542
+ * ValidateUtil.isChineseName("张三"); // true
1543
+ * ```
1544
+ */
1545
+ static isChineseName(input) {
1546
+ return this._chineseName.test(input.toString());
1547
+ }
1548
+ /**
1549
+ * 验证是否为中国身份证号
1550
+ * @example
1551
+ * ```ts
1552
+ * ValidateUtil.isChineseID("11010519491231002X"); // true
1553
+ * ```
1554
+ */
1555
+ static isChineseID(input) {
1556
+ return this._chineseId.test(input.toString());
1557
+ }
1558
+ /**
1559
+ * 验证是否为中国省份
1560
+ * @example
1561
+ * ```ts
1562
+ * ValidateUtil.isChineseProvince("浙江"); // true
1563
+ * ```
1564
+ */
1565
+ static isChineseProvince(input) {
1566
+ return this._chineseProvince.test(input.toString());
1567
+ }
1568
+ /**
1569
+ * 验证是否为中华民族
1570
+ * @example
1571
+ * ```ts
1572
+ * ValidateUtil.isChineseNation("汉族"); // true
1573
+ * ```
1574
+ */
1575
+ static isChineseNation(input) {
1576
+ return this._chineseNation.test(input.toString());
1577
+ }
1578
+ /**
1579
+ * 验证是否只包含字母
1580
+ * @example
1581
+ * ```ts
1582
+ * ValidateUtil.isLetter("abcDEF"); // true
1583
+ * ```
1584
+ */
1585
+ static isLetter(input) {
1586
+ return this._letter.test(input.toString());
1587
+ }
1588
+ /**
1589
+ * 验证是否只包含小写字母
1590
+ * @example
1591
+ * ```ts
1592
+ * ValidateUtil.isLetterLowercase("abc"); // true
1593
+ * ```
1594
+ */
1595
+ static isLetterLowercase(input) {
1596
+ return this._letterLowercase.test(input.toString());
1597
+ }
1598
+ /**
1599
+ * 验证是否只包含大写字母
1600
+ * @example
1601
+ * ```ts
1602
+ * ValidateUtil.isLetterUppercase("ABC"); // true
1603
+ * ```
1604
+ */
1605
+ static isLetterUppercase(input) {
1606
+ return this._letterUppercase.test(input.toString());
1607
+ }
1608
+ /**
1609
+ * 验证是否不包含字母
1610
+ * @example
1611
+ * ```ts
1612
+ * ValidateUtil.isLetterOmit("123_-"); // true
1613
+ * ```
1614
+ */
1615
+ static isLetterOmit(input) {
1616
+ return this._letterOmit.test(input.toString());
1617
+ }
1618
+ /**
1619
+ * 验证是否为数字和字母组合
1620
+ * @example
1621
+ * ```ts
1622
+ * ValidateUtil.isLetterAndNumber("A1B2"); // true
1623
+ * ```
1624
+ */
1625
+ static isLetterAndNumber(input) {
1626
+ return this._LetterAndNumber.test(input.toString());
1627
+ }
1628
+ /**
1629
+ * 验证是否为有符号浮点数
1630
+ * @example
1631
+ * ```ts
1632
+ * ValidateUtil.isSignedFloat("-12.34"); // true
1633
+ * ```
1634
+ */
1635
+ static isSignedFloat(input) {
1636
+ return this._signedFloat.test(input.toString());
1637
+ }
1638
+ /**
1639
+ * 验证是否为无符号浮点数
1640
+ * @example
1641
+ * ```ts
1642
+ * ValidateUtil.isUnsignedFloat("12.34"); // true
1643
+ * ```
1644
+ */
1645
+ static isUnsignedFloat(input) {
1646
+ return this._unsignedFloat.test(input.toString());
1647
+ }
1648
+ /**
1649
+ * 验证是否为有符号整数
1650
+ * @example
1651
+ * ```ts
1652
+ * ValidateUtil.isSignedInteger("-12"); // true
1653
+ * ```
1654
+ */
1655
+ static isSignedInteger(input) {
1656
+ return this._signedInteger.test(input.toString());
1657
+ }
1658
+ /**
1659
+ * 验证是否为无符号整数
1660
+ * @example
1661
+ * ```ts
1662
+ * ValidateUtil.isUnsignedInteger("12"); // true
1663
+ * ```
1664
+ */
1665
+ static isUnsignedInteger(input) {
1666
+ return this._unsignedInteger.test(input.toString());
1667
+ }
1668
+ /**
1669
+ * 验证是否包含空格
1670
+ * @example
1671
+ * ```ts
1672
+ * ValidateUtil.isSpaceInclude("a b"); // true
1673
+ * ```
1674
+ */
1675
+ static isSpaceInclude(input) {
1676
+ return this._spaceInclude.test(input.toString());
1677
+ }
1678
+ /**
1679
+ * 验证是否以空格开头
1680
+ * @example
1681
+ * ```ts
1682
+ * ValidateUtil.isSpaceStart(" abc"); // true
1683
+ * ```
1684
+ */
1685
+ static isSpaceStart(input) {
1686
+ return this._spaceStart.test(input.toString());
1687
+ }
1688
+ /**
1689
+ * 验证是否以空格结尾
1690
+ * @example
1691
+ * ```ts
1692
+ * ValidateUtil.isSpaceEnd("abc "); // true
1693
+ * ```
1694
+ */
1695
+ static isSpaceEnd(input) {
1696
+ return this._spaceEnd.test(input.toString());
1697
+ }
1698
+ /**
1699
+ * 验证是否以空格开头或结尾
1700
+ * @example
1701
+ * ```ts
1702
+ * ValidateUtil.isSpaceStartOrEnd(" abc"); // true
1703
+ * ```
1704
+ */
1705
+ static isSpaceStartOrEnd(input) {
1706
+ return this.isSpaceStart(input) || this.isSpaceEnd(input);
1707
+ }
1708
+ };
1709
+ _defineProperty(ValidateUtil, "_phone", /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/);
1710
+ _defineProperty(ValidateUtil, "_telephone", /^(((0\d{2,3})-)?((\d{7,8})|(400\d{7})|(800\d{7}))(-(\d{1,4}))?)$/);
1711
+ _defineProperty(ValidateUtil, "_IMEI", /^\d{15,17}$/);
1712
+ _defineProperty(ValidateUtil, "_email", /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-0-9]+\.)+[a-z]{2,}))$/i);
1713
+ _defineProperty(ValidateUtil, "_link", /^(https?:\/\/)?(([\w-]+(\.[\w-]+)*\.[a-z]{2,6})|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/\S*)?$/i);
1714
+ _defineProperty(ValidateUtil, "_portLink", /^(https?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/i);
1715
+ _defineProperty(ValidateUtil, "_thunderLink", /^thunderx?:\/\/[a-zA-Z\d]+=$/i);
1716
+ _defineProperty(ValidateUtil, "_uscc", /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/);
1717
+ _defineProperty(ValidateUtil, "_usccs", /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/);
1718
+ _defineProperty(ValidateUtil, "_dirPathWindows", /^[a-z]:\\(?:\w+\\?)*$/i);
1719
+ _defineProperty(ValidateUtil, "_filePathWindows", /^[a-z]:\\(?:\w+\\)*\w+\.\w+$/i);
1720
+ _defineProperty(ValidateUtil, "_dirPathLinux", /^\/(?:[^\\/\s]+\/)*$/);
1721
+ _defineProperty(ValidateUtil, "_filePathLinux", /^(\/$|\/(?:[^\\/\s]+\/)*[^\\/\s]+$)/);
1722
+ _defineProperty(ValidateUtil, "_EVCarNumber", /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))\d{4})|(\d{5}[DF]))$/);
1723
+ _defineProperty(ValidateUtil, "_GVCarNumber", /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/);
1724
+ _defineProperty(ValidateUtil, "_chineseName", /^[一-龢][一·-龢]*$/);
1725
+ _defineProperty(ValidateUtil, "_chineseId", /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))([\dX])$/i);
1726
+ _defineProperty(ValidateUtil, "_chineseProvince", /^安徽|澳门|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|河南|黑龙江|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|台湾|天津|西藏|香港|新疆|云南|浙江$/);
1727
+ _defineProperty(ValidateUtil, "_chineseNation", /^汉族|蒙古族|回族|藏族|维吾尔族|苗族|彝族|壮族|布依族|朝鲜族|满族|侗族|瑶族|白族|土家族|哈尼族|哈萨克族|傣族|黎族|傈僳族|佤族|畲族|高山族|拉祜族|水族|东乡族|纳西族|景颇族|柯尔克孜族|土族|达斡尔族|仫佬族|羌族|布朗族|撒拉族|毛南族|仡佬族|锡伯族|阿昌族|普米族|塔吉克族|怒族|乌孜别克族|俄罗斯族|鄂温克族|德昂族|保安族|裕固族|京族|塔塔尔族|独龙族|鄂伦春族|赫哲族|门巴族|珞巴族|基诺族|其它未识别民族|外国人入中国籍$/);
1728
+ _defineProperty(ValidateUtil, "_letter", /^[a-z]+$/i);
1729
+ _defineProperty(ValidateUtil, "_letterLowercase", /^[a-z]+$/);
1730
+ _defineProperty(ValidateUtil, "_letterUppercase", /^[A-Z]+$/);
1731
+ _defineProperty(ValidateUtil, "_letterOmit", /^[^A-Z]*$/i);
1732
+ _defineProperty(ValidateUtil, "_LetterAndNumber", /^[A-Z0-9]+$/i);
1733
+ _defineProperty(ValidateUtil, "_signedFloat", /^[+-]?(\d+(\.\d+)?|\.\d+)$/);
1734
+ _defineProperty(ValidateUtil, "_unsignedFloat", /^\+?(\d+(\.\d+)?|\.\d+)$/);
1735
+ _defineProperty(ValidateUtil, "_signedInteger", /^[+-]?\d+$/);
1736
+ _defineProperty(ValidateUtil, "_unsignedInteger", /^\+?\d+$/);
1737
+ _defineProperty(ValidateUtil, "_spaceInclude", /\s/);
1738
+ _defineProperty(ValidateUtil, "_spaceStart", /^\s/);
1739
+ _defineProperty(ValidateUtil, "_spaceEnd", /\s$/);
1740
+ //#endregion
1741
+ export { ArrayUtil, DateTimeUtil, EnvUtil, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };