@pawover/kit 0.0.1 → 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.
@@ -1,240 +1,4 @@
1
1
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
2
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/_internal/globalThis.mjs
3
- const globalThis_ = typeof globalThis === "object" && globalThis || typeof window === "object" && window || typeof self === "object" && self || typeof global === "object" && global || (function() {
4
- return this;
5
- })() || Function("return this")();
6
- //#endregion
7
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/function/noop.mjs
8
- function noop() {}
9
- //#endregion
10
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
11
- function isPrimitive(value) {
12
- return value == null || typeof value !== "object" && typeof value !== "function";
13
- }
14
- //#endregion
15
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
16
- function isTypedArray(x) {
17
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
18
- }
19
- //#endregion
20
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/object/clone.mjs
21
- function clone(obj) {
22
- if (isPrimitive(obj)) return obj;
23
- if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
24
- const prototype = Object.getPrototypeOf(obj);
25
- if (prototype == null) return Object.assign(Object.create(prototype), obj);
26
- const Constructor = prototype.constructor;
27
- if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj);
28
- if (obj instanceof RegExp) {
29
- const newRegExp = new Constructor(obj);
30
- newRegExp.lastIndex = obj.lastIndex;
31
- return newRegExp;
32
- }
33
- if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0));
34
- if (obj instanceof Error) {
35
- let newError;
36
- if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause });
37
- else newError = new Constructor(obj.message, { cause: obj.cause });
38
- newError.stack = obj.stack;
39
- Object.assign(newError, obj);
40
- return newError;
41
- }
42
- if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, {
43
- type: obj.type,
44
- lastModified: obj.lastModified
45
- });
46
- if (typeof obj === "object") return Object.assign(Object.create(prototype), obj);
47
- return obj;
48
- }
49
- //#endregion
50
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
51
- function getSymbols(object) {
52
- return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
53
- }
54
- //#endregion
55
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
56
- function getTag(value) {
57
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
58
- return Object.prototype.toString.call(value);
59
- }
60
- //#endregion
61
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/compat/_internal/tags.mjs
62
- const regexpTag = "[object RegExp]";
63
- const stringTag = "[object String]";
64
- const numberTag = "[object Number]";
65
- const booleanTag = "[object Boolean]";
66
- const symbolTag = "[object Symbol]";
67
- const dateTag = "[object Date]";
68
- const mapTag = "[object Map]";
69
- const setTag = "[object Set]";
70
- const arrayTag = "[object Array]";
71
- const functionTag = "[object Function]";
72
- const arrayBufferTag = "[object ArrayBuffer]";
73
- const objectTag = "[object Object]";
74
- const errorTag = "[object Error]";
75
- const dataViewTag = "[object DataView]";
76
- const uint8ArrayTag = "[object Uint8Array]";
77
- const uint8ClampedArrayTag = "[object Uint8ClampedArray]";
78
- const uint16ArrayTag = "[object Uint16Array]";
79
- const uint32ArrayTag = "[object Uint32Array]";
80
- const bigUint64ArrayTag = "[object BigUint64Array]";
81
- const int8ArrayTag = "[object Int8Array]";
82
- const int16ArrayTag = "[object Int16Array]";
83
- const int32ArrayTag = "[object Int32Array]";
84
- const bigInt64ArrayTag = "[object BigInt64Array]";
85
- const float32ArrayTag = "[object Float32Array]";
86
- const float64ArrayTag = "[object Float64Array]";
87
- //#endregion
88
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isBuffer.mjs
89
- function isBuffer(x) {
90
- return typeof globalThis_.Buffer !== "undefined" && globalThis_.Buffer.isBuffer(x);
91
- }
92
- //#endregion
93
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
94
- function isPlainObject(value) {
95
- if (!value || typeof value !== "object") return false;
96
- const proto = Object.getPrototypeOf(value);
97
- if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
98
- return Object.prototype.toString.call(value) === "[object Object]";
99
- }
100
- //#endregion
101
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/_internal/isEqualsSameValueZero.mjs
102
- function isEqualsSameValueZero(value, other) {
103
- return value === other || Number.isNaN(value) && Number.isNaN(other);
104
- }
105
- //#endregion
106
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
107
- function isEqualWith(a, b, areValuesEqual) {
108
- return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
109
- }
110
- function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
111
- const result = areValuesEqual(a, b, property, aParent, bParent, stack);
112
- if (result !== void 0) return result;
113
- if (typeof a === typeof b) switch (typeof a) {
114
- case "bigint":
115
- case "string":
116
- case "boolean":
117
- case "symbol":
118
- case "undefined": return a === b;
119
- case "number": return a === b || Object.is(a, b);
120
- case "function": return a === b;
121
- case "object": return areObjectsEqual(a, b, stack, areValuesEqual);
122
- }
123
- return areObjectsEqual(a, b, stack, areValuesEqual);
124
- }
125
- function areObjectsEqual(a, b, stack, areValuesEqual) {
126
- if (Object.is(a, b)) return true;
127
- let aTag = getTag(a);
128
- let bTag = getTag(b);
129
- if (aTag === "[object Arguments]") aTag = objectTag;
130
- if (bTag === "[object Arguments]") bTag = objectTag;
131
- if (aTag !== bTag) return false;
132
- switch (aTag) {
133
- case stringTag: return a.toString() === b.toString();
134
- case numberTag: return isEqualsSameValueZero(a.valueOf(), b.valueOf());
135
- case booleanTag:
136
- case dateTag:
137
- case symbolTag: return Object.is(a.valueOf(), b.valueOf());
138
- case regexpTag: return a.source === b.source && a.flags === b.flags;
139
- case functionTag: return a === b;
140
- }
141
- stack = stack ?? /* @__PURE__ */ new Map();
142
- const aStack = stack.get(a);
143
- const bStack = stack.get(b);
144
- if (aStack != null && bStack != null) return aStack === b;
145
- stack.set(a, b);
146
- stack.set(b, a);
147
- try {
148
- switch (aTag) {
149
- case mapTag:
150
- if (a.size !== b.size) return false;
151
- for (const [key, value] of a.entries()) if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) return false;
152
- return true;
153
- case setTag: {
154
- if (a.size !== b.size) return false;
155
- const aValues = Array.from(a.values());
156
- const bValues = Array.from(b.values());
157
- for (let i = 0; i < aValues.length; i++) {
158
- const aValue = aValues[i];
159
- const index = bValues.findIndex((bValue) => {
160
- return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual);
161
- });
162
- if (index === -1) return false;
163
- bValues.splice(index, 1);
164
- }
165
- return true;
166
- }
167
- case arrayTag:
168
- case uint8ArrayTag:
169
- case uint8ClampedArrayTag:
170
- case uint16ArrayTag:
171
- case uint32ArrayTag:
172
- case bigUint64ArrayTag:
173
- case int8ArrayTag:
174
- case int16ArrayTag:
175
- case int32ArrayTag:
176
- case bigInt64ArrayTag:
177
- case float32ArrayTag:
178
- case float64ArrayTag:
179
- if (isBuffer(a) !== isBuffer(b)) return false;
180
- if (a.length !== b.length) return false;
181
- for (let i = 0; i < a.length; i++) if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) return false;
182
- return true;
183
- case arrayBufferTag:
184
- if (a.byteLength !== b.byteLength) return false;
185
- return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
186
- case dataViewTag:
187
- if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) return false;
188
- return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
189
- case errorTag: return a.name === b.name && a.message === b.message;
190
- case objectTag: {
191
- if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b))) return false;
192
- const aKeys = [...Object.keys(a), ...getSymbols(a)];
193
- const bKeys = [...Object.keys(b), ...getSymbols(b)];
194
- if (aKeys.length !== bKeys.length) return false;
195
- for (let i = 0; i < aKeys.length; i++) {
196
- const propKey = aKeys[i];
197
- const aProp = a[propKey];
198
- if (!Object.hasOwn(b, propKey)) return false;
199
- const bProp = b[propKey];
200
- if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) return false;
201
- }
202
- return true;
203
- }
204
- default: return false;
205
- }
206
- } finally {
207
- stack.delete(a);
208
- stack.delete(b);
209
- }
210
- }
211
- //#endregion
212
- //#region ../../node_modules/.pnpm/es-toolkit@1.46.1/node_modules/es-toolkit/dist/predicate/isEqual.mjs
213
- function isEqual(a, b) {
214
- return isEqualWith(a, b, noop);
215
- }
216
- //#endregion
217
- //#region src/react/useCreation.ts
218
- /**
219
- * 确保实例不会被重复创建
220
- *
221
- * @param factory
222
- * @param deps
223
- */
224
- function useCreation(factory, deps) {
225
- const { current } = useRef({
226
- deps,
227
- result: void 0,
228
- isInitialized: false
229
- });
230
- if (current.isInitialized === false || !isEqual(current.deps, deps)) {
231
- current.deps = deps;
232
- current.result = factory();
233
- current.isInitialized = true;
234
- }
235
- return current.result;
236
- }
237
- //#endregion
238
2
  //#region src/react/useLatest.ts
239
3
  /**
240
4
  * 返回当前最新值的 Hook
@@ -247,7 +11,7 @@ function useLatest(value) {
247
11
  return ref;
248
12
  }
249
13
  //#endregion
250
- //#region ../utils/dist/string-DCWqoW4P.js
14
+ //#region ../utils/dist/string-C_OCj9Lg.js
251
15
  function _typeof(o) {
252
16
  "@babel/helpers - typeof";
253
17
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -317,9 +81,10 @@ var TypeUtil = class {
317
81
  }
318
82
  /**
319
83
  * 检查 value 是否为 number 类型
84
+ * - 默认会调用 `TypeUtil.isNaN`(内部基于 `Number.isNaN`)过滤掉 `NaN`
320
85
  *
321
86
  * @param value 待检查值
322
- * @param checkNaN 是否排除 `NaN`,默认为 `true`
87
+ * @param checkNaN 是否检查 `NaN`,默认为 `true`
323
88
  * @returns 是否为 number
324
89
  * @example
325
90
  * ```ts
@@ -333,9 +98,15 @@ var TypeUtil = class {
333
98
  }
334
99
  /**
335
100
  * 检查 value 是否为 NaN
101
+ * - 禁止使用全局 `isNaN`,其会先进行隐式数字转换,可能导致误判(例如 `isNaN("foo") === true`)
102
+ * - 使用 `Number.isNaN` 仅在值本身就是 `NaN` 时返回 `true`,语义更严格且更安全
336
103
  *
337
104
  * @param value 待检查值
338
105
  * @returns 是否为 NaN
106
+ * @example
107
+ * ```ts
108
+ * TypeUtil.isNaN(NaN); // true
109
+ * ```
339
110
  */
340
111
  static isNaN(value) {
341
112
  return Number.isNaN(value);
@@ -346,6 +117,11 @@ var TypeUtil = class {
346
117
  * @param value 待检查值
347
118
  * @param checkSafe 是否附加安全整数检查
348
119
  * @returns 是否为整数
120
+ * @example
121
+ * ```ts
122
+ * TypeUtil.isInteger(1); // true
123
+ * TypeUtil.isInteger(1.1); // false
124
+ * ```
349
125
  */
350
126
  static isInteger(value, checkSafe = true) {
351
127
  const check = Number.isInteger(value);
@@ -357,6 +133,11 @@ var TypeUtil = class {
357
133
  *
358
134
  * @param value 待检查值
359
135
  * @param checkSafe 是否附加安全整数检查
136
+ * @example
137
+ * ```ts
138
+ * TypeUtil.isPositiveInteger(1); // true
139
+ * TypeUtil.isPositiveInteger(0); // false
140
+ * ```
360
141
  */
361
142
  static isPositiveInteger(value, checkSafe = true) {
362
143
  return this.isInteger(value, checkSafe) && value > 0;
@@ -367,6 +148,11 @@ var TypeUtil = class {
367
148
  *
368
149
  * @param value 待检查值
369
150
  * @param checkSafe 是否附加安全整数检查
151
+ * @example
152
+ * ```ts
153
+ * TypeUtil.isNegativeInteger(-1); // true
154
+ * TypeUtil.isNegativeInteger(0); // false
155
+ * ```
370
156
  */
371
157
  static isNegativeInteger(value, checkSafe = true) {
372
158
  return this.isInteger(value, checkSafe) && value < 0;
@@ -376,6 +162,11 @@ var TypeUtil = class {
376
162
  * - 排除 `NaN`
377
163
  *
378
164
  * @param value 待检查值
165
+ * @example
166
+ * ```ts
167
+ * TypeUtil.isInfinity(Infinity); // true
168
+ * TypeUtil.isInfinity(1); // false
169
+ * ```
379
170
  */
380
171
  static isInfinity(value) {
381
172
  return this.isNumber(value) && (Number.POSITIVE_INFINITY === value || Number.NEGATIVE_INFINITY === value);
@@ -385,6 +176,11 @@ var TypeUtil = class {
385
176
  * - 排除 `NaN`
386
177
  *
387
178
  * @param value 待检查值
179
+ * @example
180
+ * ```ts
181
+ * TypeUtil.isInfinityLike("Infinity"); // true
182
+ * TypeUtil.isInfinityLike("123"); // false
183
+ * ```
388
184
  */
389
185
  static isInfinityLike(value) {
390
186
  const check = this.isInfinity(value);
@@ -403,6 +199,10 @@ var TypeUtil = class {
403
199
  * 检查 value 是否为 Boolean
404
200
  * @param value 待检查值
405
201
  * @returns 是否为 Boolean
202
+ * @example
203
+ * ```ts
204
+ * TypeUtil.isBoolean(false); // true
205
+ * ```
406
206
  */
407
207
  static isBoolean(value) {
408
208
  return typeof value === "boolean";
@@ -411,6 +211,10 @@ var TypeUtil = class {
411
211
  * 检查 value 是否为 BigInt
412
212
  * @param value 待检查值
413
213
  * @returns 是否为 BigInt
214
+ * @example
215
+ * ```ts
216
+ * TypeUtil.isBigInt(1n); // true
217
+ * ```
414
218
  */
415
219
  static isBigInt(value) {
416
220
  return typeof value === "bigint";
@@ -419,6 +223,10 @@ var TypeUtil = class {
419
223
  * 检查 value 是否为 Symbol
420
224
  * @param value 待检查值
421
225
  * @returns 是否为 Symbol
226
+ * @example
227
+ * ```ts
228
+ * TypeUtil.isSymbol(Symbol("a")); // true
229
+ * ```
422
230
  */
423
231
  static isSymbol(value) {
424
232
  return typeof value === "symbol";
@@ -427,6 +235,10 @@ var TypeUtil = class {
427
235
  * 检查 value 是否为 undefined
428
236
  * @param value 待检查值
429
237
  * @returns 是否为 undefined
238
+ * @example
239
+ * ```ts
240
+ * TypeUtil.isUndefined(undefined); // true
241
+ * ```
430
242
  */
431
243
  static isUndefined(value) {
432
244
  return typeof value === "undefined";
@@ -435,6 +247,10 @@ var TypeUtil = class {
435
247
  * 检查 value 是否为 null
436
248
  * @param value 待检查值
437
249
  * @returns 是否为 null
250
+ * @example
251
+ * ```ts
252
+ * TypeUtil.isNull(null); // true
253
+ * ```
438
254
  */
439
255
  static isNull(value) {
440
256
  return value === null;
@@ -443,6 +259,10 @@ var TypeUtil = class {
443
259
  * 检查 value 是否为 Function
444
260
  * @param value 待检查值
445
261
  * @returns 是否为 Function
262
+ * @example
263
+ * ```ts
264
+ * TypeUtil.isFunction(() => {}); // true
265
+ * ```
446
266
  */
447
267
  static isFunction(value) {
448
268
  return typeof value === "function";
@@ -451,6 +271,10 @@ var TypeUtil = class {
451
271
  * 检查 value 是否为 AsyncFunction
452
272
  * @param value 待检查值
453
273
  * @returns 是否为 AsyncFunction
274
+ * @example
275
+ * ```ts
276
+ * TypeUtil.isAsyncFunction(async () => {}); // true
277
+ * ```
454
278
  */
455
279
  static isAsyncFunction(value) {
456
280
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ASYNC_FUNCTION;
@@ -459,6 +283,10 @@ var TypeUtil = class {
459
283
  * 检查 value 是否为 GeneratorFunction
460
284
  * @param value 待检查值
461
285
  * @returns 是否为 GeneratorFunction
286
+ * @example
287
+ * ```ts
288
+ * TypeUtil.isGeneratorFunction(function * a () {}); // true
289
+ * ```
462
290
  */
463
291
  static isGeneratorFunction(value) {
464
292
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.GENERATOR_FUNCTION;
@@ -467,6 +295,10 @@ var TypeUtil = class {
467
295
  * 检查 value 是否为 AsyncGeneratorFunction
468
296
  * @param value 待检查值
469
297
  * @returns 是否为 AsyncGeneratorFunction
298
+ * @example
299
+ * ```ts
300
+ * TypeUtil.isAsyncGeneratorFunction(async function * a () {}); // true
301
+ * ```
470
302
  */
471
303
  static isAsyncGeneratorFunction(value) {
472
304
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ASYNC_GENERATOR_FUNCTION;
@@ -475,8 +307,12 @@ var TypeUtil = class {
475
307
  * 检查 value 是否为 Promise
476
308
  * @param value 待检查值
477
309
  * @returns 是否为 Promise
478
- */
479
- static isPromise(value) {
310
+ * @example
311
+ * ```ts
312
+ * TypeUtil.isPromise(Promise.resolve(1)); // true
313
+ * ```
314
+ */
315
+ static isPromise(value) {
480
316
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.PROMISE;
481
317
  }
482
318
  /**
@@ -484,6 +320,10 @@ var TypeUtil = class {
484
320
  * - 可识别拥有 then 方法的非 Promise 对象
485
321
  * @param value 待检查值
486
322
  * @returns 是否为 PromiseLike
323
+ * @example
324
+ * ```ts
325
+ * TypeUtil.isPromiseLike({ then: () => {} }); // true
326
+ * ```
487
327
  */
488
328
  static isPromiseLike(value) {
489
329
  return this.isPromise(value) || this.isObject(value, false) && this.isFunction(value["then"]);
@@ -519,6 +359,11 @@ var TypeUtil = class {
519
359
  *
520
360
  * @param enumeration 待检查值
521
361
  * @returns [是否为有效的枚举, 是否为双向枚举]
362
+ * @example
363
+ * ```ts
364
+ * enum A { X, Y }
365
+ * TypeUtil.isEnumeration(A); // [true, true]
366
+ * ```
522
367
  */
523
368
  static isEnumeration(enumeration) {
524
369
  if (typeof enumeration !== "object" || enumeration === null) return [false, false];
@@ -600,6 +445,10 @@ var TypeUtil = class {
600
445
  * 检查 value 是否为 Map
601
446
  * @param value 待检查值
602
447
  * @returns 是否为 Map
448
+ * @example
449
+ * ```ts
450
+ * TypeUtil.isMap(new Map()); // true
451
+ * ```
603
452
  */
604
453
  static isMap(value) {
605
454
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.MAP;
@@ -608,6 +457,10 @@ var TypeUtil = class {
608
457
  * 检查 value 是否为 WeakMap
609
458
  * @param value 待检查值
610
459
  * @returns 是否为 WeakMap
460
+ * @example
461
+ * ```ts
462
+ * TypeUtil.isWeakMap(new WeakMap()); // true
463
+ * ```
611
464
  */
612
465
  static isWeakMap(value) {
613
466
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEAK_MAP;
@@ -616,6 +469,10 @@ var TypeUtil = class {
616
469
  * 检查 value 是否为 Set
617
470
  * @param value 待检查值
618
471
  * @returns 是否为 Set
472
+ * @example
473
+ * ```ts
474
+ * TypeUtil.isSet(new Set()); // true
475
+ * ```
619
476
  */
620
477
  static isSet(value) {
621
478
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.SET;
@@ -624,6 +481,10 @@ var TypeUtil = class {
624
481
  * 检查 value 是否为 WeakSet
625
482
  * @param value 待检查值
626
483
  * @returns 是否为 WeakSet
484
+ * @example
485
+ * ```ts
486
+ * TypeUtil.isWeakSet(new WeakSet()); // true
487
+ * ```
627
488
  */
628
489
  static isWeakSet(value) {
629
490
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEAK_SET;
@@ -632,6 +493,10 @@ var TypeUtil = class {
632
493
  * 检查 value 是否为 Blob
633
494
  * @param value 待检查值
634
495
  * @returns 是否为 Blob
496
+ * @example
497
+ * ```ts
498
+ * TypeUtil.isBlob(new Blob(["a"])); // true
499
+ * ```
635
500
  */
636
501
  static isBlob(value) {
637
502
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.BLOB;
@@ -640,6 +505,10 @@ var TypeUtil = class {
640
505
  * 检查 value 是否为 File
641
506
  * @param value 待检查值
642
507
  * @returns 是否为 File
508
+ * @example
509
+ * ```ts
510
+ * TypeUtil.isFile(new File(["a"], "a.txt")); // true
511
+ * ```
643
512
  */
644
513
  static isFile(value) {
645
514
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.FILE;
@@ -653,6 +522,10 @@ var TypeUtil = class {
653
522
  *
654
523
  * @param value 待检查值
655
524
  * @returns 是否为 ReadableStream
525
+ * @example
526
+ * ```ts
527
+ * TypeUtil.isReadableStream(new ReadableStream()); // true
528
+ * ```
656
529
  */
657
530
  static isReadableStream(value) {
658
531
  if (this.getPrototypeString(value) === this.PROTOTYPE_TAGS.READABLE_STREAM) return true;
@@ -662,6 +535,10 @@ var TypeUtil = class {
662
535
  * 检查 value 是否为 Window
663
536
  * @param value 待检查值
664
537
  * @returns 是否为 Window
538
+ * @example
539
+ * ```ts
540
+ * TypeUtil.isWindow(window); // true
541
+ * ```
665
542
  */
666
543
  static isWindow(value) {
667
544
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WINDOW;
@@ -670,6 +547,10 @@ var TypeUtil = class {
670
547
  * 检查 value 是否为 HTMLIFrameElement
671
548
  * @param value 待检查值
672
549
  * @returns 是否为 HTMLIFrameElement
550
+ * @example
551
+ * ```ts
552
+ * TypeUtil.isIframe(document.createElement("iframe")); // true
553
+ * ```
673
554
  */
674
555
  static isIframe(value) {
675
556
  if (typeof window === "undefined") return false;
@@ -708,6 +589,10 @@ var TypeUtil = class {
708
589
  * 检查 value 是否为 Error 对象
709
590
  * @param value 待检查值
710
591
  * @returns 是否为 Error
592
+ * @example
593
+ * ```ts
594
+ * TypeUtil.isError(new Error("x")); // true
595
+ * ```
711
596
  */
712
597
  static isError(value) {
713
598
  return value instanceof Error || this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ERROR;
@@ -716,6 +601,10 @@ var TypeUtil = class {
716
601
  * 检查 value 是否为 RegExp
717
602
  * @param value 待检查值
718
603
  * @returns 是否为 RegExp
604
+ * @example
605
+ * ```ts
606
+ * TypeUtil.isRegExp(/a/); // true
607
+ * ```
719
608
  */
720
609
  static isRegExp(value) {
721
610
  if (typeof value !== "object" || value === null) return false;
@@ -730,6 +619,10 @@ var TypeUtil = class {
730
619
  * 检查 value 是否为 WebSocket
731
620
  * @param value 待检查值
732
621
  * @returns 是否为 WebSocket
622
+ * @example
623
+ * ```ts
624
+ * TypeUtil.isWebSocket(new WebSocket("wss://echo.websocket.events")); // true
625
+ * ```
733
626
  */
734
627
  static isWebSocket(value) {
735
628
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEB_SOCKET;
@@ -738,6 +631,10 @@ var TypeUtil = class {
738
631
  * 检查 value 是否为 URLSearchParams
739
632
  * @param value 待检查值
740
633
  * @returns 是否为 URLSearchParams
634
+ * @example
635
+ * ```ts
636
+ * TypeUtil.isURLSearchParams(new URLSearchParams("a=1")); // true
637
+ * ```
741
638
  */
742
639
  static isURLSearchParams(value) {
743
640
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.URL_SEARCH_PARAMS;
@@ -746,6 +643,10 @@ var TypeUtil = class {
746
643
  * 检查 value 是否为 AbortSignal
747
644
  * @param value 待检查值
748
645
  * @returns 是否为 AbortSignal
646
+ * @example
647
+ * ```ts
648
+ * TypeUtil.isAbortSignal(new AbortController().signal); // true
649
+ * ```
749
650
  */
750
651
  static isAbortSignal(value) {
751
652
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ABORT_SIGNAL;
@@ -754,6 +655,10 @@ var TypeUtil = class {
754
655
  * 检查 value 是否为可迭代对象 (Iterable)
755
656
  * @param value 待检查值
756
657
  * @returns 是否为 Iterable
658
+ * @example
659
+ * ```ts
660
+ * TypeUtil.isIterable([1, 2]); // true
661
+ * ```
757
662
  */
758
663
  static isIterable(value) {
759
664
  return !!value && typeof value[Symbol.iterator] === "function";
@@ -762,11 +667,27 @@ var TypeUtil = class {
762
667
  * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
763
668
  * @param value 待检查值
764
669
  * @returns 是否为 Falsy
670
+ * @example
671
+ * ```ts
672
+ * TypeUtil.isFalsy(0); // true
673
+ * ```
765
674
  */
766
675
  static isFalsy(value) {
767
676
  if (this.isNaN(value) || this.isNull(value) || this.isUndefined(value)) return true;
768
677
  return value === false || value === 0 || value === 0n || value === "";
769
678
  }
679
+ /**
680
+ * 检查 value 是否为 FalsyLike 值
681
+ * - 包含字符串形式的 `"null"`、`"undefined"`、`"false"`、`"0"` 等
682
+ *
683
+ * @param value 待检查值
684
+ * @returns 是否为 FalsyLike
685
+ * @example
686
+ * ```ts
687
+ * TypeUtil.isFalsyLike("false"); // true
688
+ * TypeUtil.isFalsyLike("hello"); // false
689
+ * ```
690
+ */
770
691
  static isFalsyLike(value) {
771
692
  if (this.isFalsy(value)) return true;
772
693
  return typeof value === "string" && (value === "null" || value === "undefined" || value === "NaN" || value === "false" || value === "0" || value === "-0" || value === "0n");
@@ -1337,17 +1258,50 @@ _defineProperty(DateTimeUtil, "FORMAT", {
1337
1258
  * 环境检查工具类
1338
1259
  */
1339
1260
  var EnvUtil = class {
1261
+ /**
1262
+ * 检测是否处于浏览器环境
1263
+ *
1264
+ * @returns 是否为浏览器环境
1265
+ * @example
1266
+ * ```ts
1267
+ * EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
1268
+ * ```
1269
+ */
1340
1270
  static isBrowser() {
1341
1271
  return this._isBrowser;
1342
1272
  }
1273
+ /**
1274
+ * 检测是否处于 Web Worker 环境
1275
+ *
1276
+ * @returns 是否为 Web Worker 环境
1277
+ * @example
1278
+ * ```ts
1279
+ * EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
1280
+ * ```
1281
+ */
1343
1282
  static isWebWorker() {
1344
1283
  return this._isWebWorker;
1345
1284
  }
1285
+ /**
1286
+ * 检测是否处于 React Native 环境
1287
+ *
1288
+ * @returns 是否为 React Native 环境
1289
+ * @example
1290
+ * ```ts
1291
+ * EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
1292
+ * ```
1293
+ */
1346
1294
  static isReactNative() {
1347
1295
  return this._isReactNative;
1348
1296
  }
1349
1297
  /**
1350
1298
  * 检查是否在 iframe 环境中
1299
+ *
1300
+ * @returns 是否在 iframe 中
1301
+ * @example
1302
+ * ```ts
1303
+ * EnvUtil.isIframe(); // true: 当前页面在 iframe 中
1304
+ * ```
1351
1305
  */
1352
1306
  static isIframe() {
1353
1307
  if (typeof window === "undefined") return false;
@@ -1516,8 +1470,38 @@ _defineProperty(MimeUtil, "MIME", {
1516
1470
  XML: "text/xml",
1517
1471
  /** XHTML 文档(XML 严格格式的 HTML) */
1518
1472
  XHTML: "application/xhtml+xml",
1519
- /** JavaScript 脚本文件(标准推荐) */
1473
+ /** JavaScript 文件 */
1520
1474
  JS: "text/javascript",
1475
+ /** TypeScript 文件 */
1476
+ TS: "text/typescript",
1477
+ /** Python 文件 */
1478
+ PY: "text/x-python",
1479
+ /** Shell 脚本 (.sh) */
1480
+ SH: "text/x-sh",
1481
+ /** C 语言源文件 */
1482
+ C: "text/x-c",
1483
+ /** C++ 源文件 */
1484
+ CPP: "text/x-c++",
1485
+ /** C# 源文件 */
1486
+ CSHARP: "text/x-csharp",
1487
+ /** Java 源文件 */
1488
+ JAVA: "text/x-java",
1489
+ /** Go 源文件 */
1490
+ GO: "text/x-go",
1491
+ /** Rust 源文件 */
1492
+ RUST: "text/x-rust",
1493
+ /** PHP 文件 */
1494
+ PHP: "text/x-php",
1495
+ /** Ruby 文件 */
1496
+ RUBY: "text/x-ruby",
1497
+ /** Swift 源文件 */
1498
+ SWIFT: "text/x-swift",
1499
+ /** YAML 文档 */
1500
+ YAML: "text/vnd.yaml",
1501
+ /** TOML 文档 */
1502
+ TOML: "text/x-toml",
1503
+ /** SQL 脚本 */
1504
+ SQL: "text/x-sql",
1521
1505
  /** Markdown 格式文档 */
1522
1506
  MARKDOWN: "text/markdown",
1523
1507
  /** 富文本格式文档(.rtf) */
@@ -1542,6 +1526,12 @@ _defineProperty(MimeUtil, "MIME", {
1542
1526
  ICO: "image/vnd.microsoft.icon",
1543
1527
  /** WebP 图像(高效压缩) */
1544
1528
  WEBP: "image/webp",
1529
+ /** TIFF 图像(.tif/.tiff) */
1530
+ TIFF: "image/tiff",
1531
+ /** HEIC 图像(高效编码) */
1532
+ HEIC: "image/heic",
1533
+ /** Adobe Photoshop 文件(.psd) */
1534
+ PSD: "image/vnd.adobe.photoshop",
1545
1535
  /** MP3 音频(.mp3) */
1546
1536
  MP3: "audio/mpeg",
1547
1537
  /** AAC 音频(.aac) */
@@ -1610,6 +1600,8 @@ _defineProperty(MimeUtil, "MIME", {
1610
1600
  BZIP2: "application/x-bzip2",
1611
1601
  /** 7-Zip 压缩文件(.7z) */
1612
1602
  SEVEN_Z: "application/x-7z-compressed",
1603
+ /** RAR 压缩文件(.rar) */
1604
+ RAR: "application/vnd.rar",
1613
1605
  /** 通用二进制数据(默认类型) */
1614
1606
  OCTET_STREAM: "application/octet-stream",
1615
1607
  /** JSON 数据格式(.json) */
@@ -1618,10 +1610,18 @@ _defineProperty(MimeUtil, "MIME", {
1618
1610
  LD_JSON: "application/ld+json",
1619
1611
  /** Java 归档文件(.jar) */
1620
1612
  JAR: "application/java-archive",
1613
+ /** WebAssembly 二进制指令格式(.wasm) */
1614
+ WASM: "application/wasm",
1621
1615
  /** MS 嵌入式 OpenType 字体(.eot) */
1622
1616
  EOT: "application/vnd.ms-fontobject",
1623
1617
  /** OpenType 字体(.otf) */
1624
1618
  OTF: "font/otf",
1619
+ /** WOFF 字体(.woff) */
1620
+ WOFF: "font/woff",
1621
+ /** WOFF2 字体(.woff2) */
1622
+ WOFF2: "font/woff2",
1623
+ /** TrueType 字体(.ttf) */
1624
+ TTF: "font/ttf",
1625
1625
  /** Excel 97-2003 工作簿(.xls) */
1626
1626
  XLS: "application/vnd.ms-excel",
1627
1627
  /** Microsoft XPS 文档(.xps) */
@@ -1652,7 +1652,10 @@ var ObjectUtil = class {
1652
1652
  * @example
1653
1653
  * ```ts
1654
1654
  * const obj = { a: 1, b: 2 };
1655
+ *
1655
1656
  * ObjectUtil.entriesMap(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
1657
+ *
1658
+ * ObjectUtil.entriesMap(obj, (k, v) => [`prefix_${String(k)}`, `${v}x`]); // { prefix_a: "1x", prefix_b: "2x" }
1656
1659
  * ```
1657
1660
  */
1658
1661
  static entriesMap(plainObject, toEntry) {
@@ -1739,192 +1742,320 @@ _defineProperty(ThemeUtil, "THEME_MODE", {
1739
1742
  var ValidateUtil = class {
1740
1743
  /**
1741
1744
  * 验证是否为手机号码
1745
+ * @example
1746
+ * ```ts
1747
+ * ValidateUtil.isPhone("13800138000"); // true
1748
+ * ```
1742
1749
  */
1743
1750
  static isPhone(input) {
1744
1751
  return this._phone.test(input.toString());
1745
1752
  }
1746
1753
  /**
1747
1754
  * 验证是否为固定电话
1755
+ * @example
1756
+ * ```ts
1757
+ * ValidateUtil.isTelephone("010-12345678"); // true
1758
+ * ```
1748
1759
  */
1749
1760
  static isTelephone(input) {
1750
1761
  return this._telephone.test(input.toString());
1751
1762
  }
1752
1763
  /**
1753
1764
  * 验证是否为移动设备识别码
1765
+ * @example
1766
+ * ```ts
1767
+ * ValidateUtil.isIMEI("490154203237518"); // true
1768
+ * ```
1754
1769
  */
1755
1770
  static isIMEI(input) {
1756
1771
  return this._IMEI.test(input.toString());
1757
1772
  }
1758
1773
  /**
1759
1774
  * 验证是否为电子邮箱
1775
+ * @example
1776
+ * ```ts
1777
+ * ValidateUtil.isEmail("dev@example.com"); // true
1778
+ * ```
1760
1779
  */
1761
1780
  static isEmail(input) {
1762
1781
  return this._email.test(input.toString());
1763
1782
  }
1764
1783
  /**
1765
1784
  * 验证是否为 http(s) 链接
1785
+ * @example
1786
+ * ```ts
1787
+ * ValidateUtil.isHttpLink("https://example.com/path"); // true
1788
+ * ```
1766
1789
  */
1767
1790
  static isHttpLink(input) {
1768
1791
  return this._link.test(input.toString());
1769
1792
  }
1770
1793
  /**
1771
1794
  * 验证是否为端口号链接
1795
+ * @example
1796
+ * ```ts
1797
+ * ValidateUtil.isPortLink("http://example.com:8080"); // true
1798
+ * ```
1772
1799
  */
1773
1800
  static isPortLink(input) {
1774
1801
  return this._portLink.test(input.toString());
1775
1802
  }
1776
1803
  /**
1777
1804
  * 验证是否为迅雷链接
1805
+ * @example
1806
+ * ```ts
1807
+ * ValidateUtil.isThunderLink("thunder://QUFodHRwOi8vZXhhbXBsZS5jb20vZmlsZQ=="); // true
1808
+ * ```
1778
1809
  */
1779
1810
  static isThunderLink(input) {
1780
1811
  return this._thunderLink.test(input.toString());
1781
1812
  }
1782
1813
  /**
1783
1814
  * 验证是否为统一社会信用代码
1815
+ * @example
1816
+ * ```ts
1817
+ * ValidateUtil.isUSCC("91350100M000100Y43"); // true
1818
+ * ```
1784
1819
  */
1785
1820
  static isUSCC(input) {
1786
1821
  return this._uscc.test(input.toString());
1787
1822
  }
1788
1823
  /**
1789
1824
  * 验证是否为统一社会信用代码 - 15位/18位/20位数字/字母
1825
+ * @example
1826
+ * ```ts
1827
+ * ValidateUtil.isUSCCS("91350100M000100Y43"); // true
1828
+ * ```
1790
1829
  */
1791
1830
  static isUSCCS(input) {
1792
1831
  return this._usccs.test(input.toString());
1793
1832
  }
1794
1833
  /**
1795
1834
  * 验证是否为 Windows 系统文件夹路径
1835
+ * @example
1836
+ * ```ts
1837
+ * ValidateUtil.isDirPathWindows("C:\\Users\\pawover\\"); // true
1838
+ * ```
1796
1839
  */
1797
1840
  static isDirPathWindows(input) {
1798
1841
  return this._dirPathWindows.test(input.toString());
1799
1842
  }
1800
1843
  /**
1801
1844
  * 验证是否为 Windows 系统文件路径
1845
+ * @example
1846
+ * ```ts
1847
+ * ValidateUtil.isFilePathWindows("C:\\Users\\pawover\\a.txt"); // true
1848
+ * ```
1802
1849
  */
1803
1850
  static isFilePathWindows(input) {
1804
1851
  return this._filePathWindows.test(input.toString());
1805
1852
  }
1806
1853
  /**
1807
1854
  * 验证是否为 Linux 系统文件夹路径
1855
+ * @example
1856
+ * ```ts
1857
+ * ValidateUtil.isDirPathLinux("/usr/local/"); // true
1858
+ * ```
1808
1859
  */
1809
1860
  static isDirPathLinux(input) {
1810
1861
  return this._dirPathLinux.test(input.toString());
1811
1862
  }
1812
1863
  /**
1813
1864
  * 验证是否为 Linux 系统文件路径
1865
+ * @example
1866
+ * ```ts
1867
+ * ValidateUtil.isFilePathLinux("/usr/local/bin/node"); // true
1868
+ * ```
1814
1869
  */
1815
1870
  static isFilePathLinux(input) {
1816
1871
  return this._filePathLinux.test(input.toString());
1817
1872
  }
1818
1873
  /**
1819
1874
  * 验证是否为新能源车牌号
1875
+ * @example
1876
+ * ```ts
1877
+ * ValidateUtil.isEVCarNumber("粤AD12345"); // true
1878
+ * ```
1820
1879
  */
1821
1880
  static isEVCarNumber(input) {
1822
1881
  return this._EVCarNumber.test(input.toString());
1823
1882
  }
1824
1883
  /**
1825
1884
  * 验证是否为燃油车车牌号
1885
+ * @example
1886
+ * ```ts
1887
+ * ValidateUtil.isGVCarNumber("粤B12345"); // true
1888
+ * ```
1826
1889
  */
1827
1890
  static isGVCarNumber(input) {
1828
1891
  return this._GVCarNumber.test(input.toString());
1829
1892
  }
1830
1893
  /**
1831
1894
  * 验证是否为中文姓名
1895
+ * @example
1896
+ * ```ts
1897
+ * ValidateUtil.isChineseName("张三"); // true
1898
+ * ```
1832
1899
  */
1833
1900
  static isChineseName(input) {
1834
1901
  return this._chineseName.test(input.toString());
1835
1902
  }
1836
1903
  /**
1837
1904
  * 验证是否为中国身份证号
1905
+ * @example
1906
+ * ```ts
1907
+ * ValidateUtil.isChineseID("11010519491231002X"); // true
1908
+ * ```
1838
1909
  */
1839
1910
  static isChineseID(input) {
1840
1911
  return this._chineseId.test(input.toString());
1841
1912
  }
1842
1913
  /**
1843
1914
  * 验证是否为中国省份
1915
+ * @example
1916
+ * ```ts
1917
+ * ValidateUtil.isChineseProvince("浙江"); // true
1918
+ * ```
1844
1919
  */
1845
1920
  static isChineseProvince(input) {
1846
1921
  return this._chineseProvince.test(input.toString());
1847
1922
  }
1848
1923
  /**
1849
1924
  * 验证是否为中华民族
1925
+ * @example
1926
+ * ```ts
1927
+ * ValidateUtil.isChineseNation("汉族"); // true
1928
+ * ```
1850
1929
  */
1851
1930
  static isChineseNation(input) {
1852
1931
  return this._chineseNation.test(input.toString());
1853
1932
  }
1854
1933
  /**
1855
1934
  * 验证是否只包含字母
1935
+ * @example
1936
+ * ```ts
1937
+ * ValidateUtil.isLetter("abcDEF"); // true
1938
+ * ```
1856
1939
  */
1857
1940
  static isLetter(input) {
1858
1941
  return this._letter.test(input.toString());
1859
1942
  }
1860
1943
  /**
1861
1944
  * 验证是否只包含小写字母
1945
+ * @example
1946
+ * ```ts
1947
+ * ValidateUtil.isLetterLowercase("abc"); // true
1948
+ * ```
1862
1949
  */
1863
1950
  static isLetterLowercase(input) {
1864
1951
  return this._letterLowercase.test(input.toString());
1865
1952
  }
1866
1953
  /**
1867
1954
  * 验证是否只包含大写字母
1955
+ * @example
1956
+ * ```ts
1957
+ * ValidateUtil.isLetterUppercase("ABC"); // true
1958
+ * ```
1868
1959
  */
1869
1960
  static isLetterUppercase(input) {
1870
1961
  return this._letterUppercase.test(input.toString());
1871
1962
  }
1872
1963
  /**
1873
1964
  * 验证是否不包含字母
1965
+ * @example
1966
+ * ```ts
1967
+ * ValidateUtil.isLetterOmit("123_-"); // true
1968
+ * ```
1874
1969
  */
1875
1970
  static isLetterOmit(input) {
1876
1971
  return this._letterOmit.test(input.toString());
1877
1972
  }
1878
1973
  /**
1879
1974
  * 验证是否为数字和字母组合
1975
+ * @example
1976
+ * ```ts
1977
+ * ValidateUtil.isLetterAndNumber("A1B2"); // true
1978
+ * ```
1880
1979
  */
1881
1980
  static isLetterAndNumber(input) {
1882
1981
  return this._LetterAndNumber.test(input.toString());
1883
1982
  }
1884
1983
  /**
1885
1984
  * 验证是否为有符号浮点数
1985
+ * @example
1986
+ * ```ts
1987
+ * ValidateUtil.isSignedFloat("-12.34"); // true
1988
+ * ```
1886
1989
  */
1887
1990
  static isSignedFloat(input) {
1888
1991
  return this._signedFloat.test(input.toString());
1889
1992
  }
1890
1993
  /**
1891
1994
  * 验证是否为无符号浮点数
1995
+ * @example
1996
+ * ```ts
1997
+ * ValidateUtil.isUnsignedFloat("12.34"); // true
1998
+ * ```
1892
1999
  */
1893
2000
  static isUnsignedFloat(input) {
1894
2001
  return this._unsignedFloat.test(input.toString());
1895
2002
  }
1896
2003
  /**
1897
2004
  * 验证是否为有符号整数
2005
+ * @example
2006
+ * ```ts
2007
+ * ValidateUtil.isSignedInteger("-12"); // true
2008
+ * ```
1898
2009
  */
1899
2010
  static isSignedInteger(input) {
1900
2011
  return this._signedInteger.test(input.toString());
1901
2012
  }
1902
2013
  /**
1903
2014
  * 验证是否为无符号整数
2015
+ * @example
2016
+ * ```ts
2017
+ * ValidateUtil.isUnsignedInteger("12"); // true
2018
+ * ```
1904
2019
  */
1905
2020
  static isUnsignedInteger(input) {
1906
2021
  return this._unsignedInteger.test(input.toString());
1907
2022
  }
1908
2023
  /**
1909
2024
  * 验证是否包含空格
2025
+ * @example
2026
+ * ```ts
2027
+ * ValidateUtil.isSpaceInclude("a b"); // true
2028
+ * ```
1910
2029
  */
1911
2030
  static isSpaceInclude(input) {
1912
2031
  return this._spaceInclude.test(input.toString());
1913
2032
  }
1914
2033
  /**
1915
2034
  * 验证是否以空格开头
2035
+ * @example
2036
+ * ```ts
2037
+ * ValidateUtil.isSpaceStart(" abc"); // true
2038
+ * ```
1916
2039
  */
1917
2040
  static isSpaceStart(input) {
1918
2041
  return this._spaceStart.test(input.toString());
1919
2042
  }
1920
2043
  /**
1921
2044
  * 验证是否以空格结尾
2045
+ * @example
2046
+ * ```ts
2047
+ * ValidateUtil.isSpaceEnd("abc "); // true
2048
+ * ```
1922
2049
  */
1923
2050
  static isSpaceEnd(input) {
1924
2051
  return this._spaceEnd.test(input.toString());
1925
2052
  }
1926
2053
  /**
1927
2054
  * 验证是否以空格开头或结尾
2055
+ * @example
2056
+ * ```ts
2057
+ * ValidateUtil.isSpaceStartOrEnd(" abc"); // true
2058
+ * ```
1928
2059
  */
1929
2060
  static isSpaceStartOrEnd(input) {
1930
2061
  return this.isSpaceStart(input) || this.isSpaceEnd(input);
@@ -1996,6 +2127,441 @@ function useMount(effect) {
1996
2127
  }, [effectRef]);
1997
2128
  }
1998
2129
  //#endregion
2130
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/_internal/globalThis.mjs
2131
+ const globalThis_ = typeof globalThis === "object" && globalThis || typeof window === "object" && window || typeof self === "object" && self || typeof global === "object" && global || (function() {
2132
+ return this;
2133
+ })() || Function("return this")();
2134
+ //#endregion
2135
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/function/noop.mjs
2136
+ /**
2137
+ * A no-operation function that does nothing.
2138
+ * This can be used as a placeholder or default function.
2139
+ *
2140
+ * @example
2141
+ * noop(); // Does nothing
2142
+ *
2143
+ * @returns {void} This function does not return anything.
2144
+ */
2145
+ function noop() {}
2146
+ //#endregion
2147
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
2148
+ /**
2149
+ * Checks whether a value is a JavaScript primitive.
2150
+ * JavaScript primitives include null, undefined, strings, numbers, booleans, symbols, and bigints.
2151
+ *
2152
+ * @param {unknown} value The value to check.
2153
+ * @returns {value is
2154
+ * null
2155
+ * | undefined
2156
+ * | string
2157
+ * | number
2158
+ * | boolean
2159
+ * | symbol
2160
+ * | bigint} Returns true if `value` is a primitive, false otherwise.
2161
+ *
2162
+ * @example
2163
+ * isPrimitive(null); // true
2164
+ * isPrimitive(undefined); // true
2165
+ * isPrimitive('123'); // true
2166
+ * isPrimitive(false); // true
2167
+ * isPrimitive(true); // true
2168
+ * isPrimitive(Symbol('a')); // true
2169
+ * isPrimitive(123n); // true
2170
+ * isPrimitive({}); // false
2171
+ * isPrimitive(new Date()); // false
2172
+ * isPrimitive(new Map()); // false
2173
+ * isPrimitive(new Set()); // false
2174
+ * isPrimitive([1, 2, 3]); // false
2175
+ */
2176
+ function isPrimitive(value) {
2177
+ return value == null || typeof value !== "object" && typeof value !== "function";
2178
+ }
2179
+ //#endregion
2180
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
2181
+ /**
2182
+ * Checks if a value is a TypedArray.
2183
+ * @param {unknown} x The value to check.
2184
+ * @returns {x is
2185
+ * Uint8Array
2186
+ * | Uint8ClampedArray
2187
+ * | Uint16Array
2188
+ * | Uint32Array
2189
+ * | BigUint64Array
2190
+ * | Int8Array
2191
+ * | Int16Array
2192
+ * | Int32Array
2193
+ * | BigInt64Array
2194
+ * | Float32Array
2195
+ * | Float64Array} Returns true if `x` is a TypedArray, false otherwise.
2196
+ *
2197
+ * @example
2198
+ * const arr = new Uint8Array([1, 2, 3]);
2199
+ * isTypedArray(arr); // true
2200
+ *
2201
+ * const regularArray = [1, 2, 3];
2202
+ * isTypedArray(regularArray); // false
2203
+ *
2204
+ * const buffer = new ArrayBuffer(16);
2205
+ * isTypedArray(buffer); // false
2206
+ */
2207
+ function isTypedArray(x) {
2208
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
2209
+ }
2210
+ //#endregion
2211
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/object/clone.mjs
2212
+ /**
2213
+ * Creates a shallow clone of the given object.
2214
+ *
2215
+ * @template T - The type of the object.
2216
+ * @param {T} obj - The object to clone.
2217
+ * @returns {T} - A shallow clone of the given object.
2218
+ *
2219
+ * @example
2220
+ * // Clone a primitive values
2221
+ * const num = 29;
2222
+ * const clonedNum = clone(num);
2223
+ * console.log(clonedNum); // 29
2224
+ * console.log(clonedNum === num); // true
2225
+ *
2226
+ * @example
2227
+ * // Clone an array
2228
+ * const arr = [1, 2, 3];
2229
+ * const clonedArr = clone(arr);
2230
+ * console.log(clonedArr); // [1, 2, 3]
2231
+ * console.log(clonedArr === arr); // false
2232
+ *
2233
+ * @example
2234
+ * // Clone an object
2235
+ * const obj = { a: 1, b: 'es-toolkit', c: [1, 2, 3] };
2236
+ * const clonedObj = clone(obj);
2237
+ * console.log(clonedObj); // { a: 1, b: 'es-toolkit', c: [1, 2, 3] }
2238
+ * console.log(clonedObj === obj); // false
2239
+ */
2240
+ function clone(obj) {
2241
+ if (isPrimitive(obj)) return obj;
2242
+ if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && obj instanceof SharedArrayBuffer) return obj.slice(0);
2243
+ const prototype = Object.getPrototypeOf(obj);
2244
+ if (prototype == null) return Object.assign(Object.create(prototype), obj);
2245
+ const Constructor = prototype.constructor;
2246
+ if (obj instanceof Date || obj instanceof Map || obj instanceof Set) return new Constructor(obj);
2247
+ if (obj instanceof RegExp) {
2248
+ const newRegExp = new Constructor(obj);
2249
+ newRegExp.lastIndex = obj.lastIndex;
2250
+ return newRegExp;
2251
+ }
2252
+ if (obj instanceof DataView) return new Constructor(obj.buffer.slice(0));
2253
+ if (obj instanceof Error) {
2254
+ let newError;
2255
+ if (obj instanceof AggregateError) newError = new Constructor(obj.errors, obj.message, { cause: obj.cause });
2256
+ else newError = new Constructor(obj.message, { cause: obj.cause });
2257
+ newError.stack = obj.stack;
2258
+ Object.assign(newError, obj);
2259
+ return newError;
2260
+ }
2261
+ if (typeof File !== "undefined" && obj instanceof File) return new Constructor([obj], obj.name, {
2262
+ type: obj.type,
2263
+ lastModified: obj.lastModified
2264
+ });
2265
+ if (typeof obj === "object") return Object.assign(Object.create(prototype), obj);
2266
+ return obj;
2267
+ }
2268
+ //#endregion
2269
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isBuffer.mjs
2270
+ /**
2271
+ * Checks if the given value is a Buffer instance.
2272
+ *
2273
+ * This function tests whether the provided value is an instance of Buffer.
2274
+ * It returns `true` if the value is a Buffer, and `false` otherwise.
2275
+ *
2276
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `Buffer`.
2277
+ *
2278
+ * @param {unknown} x - The value to check if it is a Buffer.
2279
+ * @returns {boolean} Returns `true` if `x` is a Buffer, else `false`.
2280
+ *
2281
+ * @example
2282
+ * const buffer = Buffer.from("test");
2283
+ * console.log(isBuffer(buffer)); // true
2284
+ *
2285
+ * const notBuffer = "not a buffer";
2286
+ * console.log(isBuffer(notBuffer)); // false
2287
+ */
2288
+ function isBuffer(x) {
2289
+ return typeof globalThis_.Buffer !== "undefined" && globalThis_.Buffer.isBuffer(x);
2290
+ }
2291
+ //#endregion
2292
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs
2293
+ function getSymbols(object) {
2294
+ return Object.getOwnPropertySymbols(object).filter((symbol) => Object.prototype.propertyIsEnumerable.call(object, symbol));
2295
+ }
2296
+ //#endregion
2297
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/compat/_internal/getTag.mjs
2298
+ /**
2299
+ * Gets the `toStringTag` of `value`.
2300
+ *
2301
+ * @private
2302
+ * @param {T} value The value to query.
2303
+ * @returns {string} Returns the `Object.prototype.toString.call` result.
2304
+ */
2305
+ function getTag(value) {
2306
+ if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
2307
+ return Object.prototype.toString.call(value);
2308
+ }
2309
+ //#endregion
2310
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/compat/_internal/tags.mjs
2311
+ const regexpTag = "[object RegExp]";
2312
+ const stringTag = "[object String]";
2313
+ const numberTag = "[object Number]";
2314
+ const booleanTag = "[object Boolean]";
2315
+ const symbolTag = "[object Symbol]";
2316
+ const dateTag = "[object Date]";
2317
+ const mapTag = "[object Map]";
2318
+ const setTag = "[object Set]";
2319
+ const arrayTag = "[object Array]";
2320
+ const functionTag = "[object Function]";
2321
+ const arrayBufferTag = "[object ArrayBuffer]";
2322
+ const objectTag = "[object Object]";
2323
+ const errorTag = "[object Error]";
2324
+ const dataViewTag = "[object DataView]";
2325
+ const uint8ArrayTag = "[object Uint8Array]";
2326
+ const uint8ClampedArrayTag = "[object Uint8ClampedArray]";
2327
+ const uint16ArrayTag = "[object Uint16Array]";
2328
+ const uint32ArrayTag = "[object Uint32Array]";
2329
+ const bigUint64ArrayTag = "[object BigUint64Array]";
2330
+ const int8ArrayTag = "[object Int8Array]";
2331
+ const int16ArrayTag = "[object Int16Array]";
2332
+ const int32ArrayTag = "[object Int32Array]";
2333
+ const bigInt64ArrayTag = "[object BigInt64Array]";
2334
+ const float32ArrayTag = "[object Float32Array]";
2335
+ const float64ArrayTag = "[object Float64Array]";
2336
+ //#endregion
2337
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
2338
+ /**
2339
+ * Checks if a given value is a plain object.
2340
+ *
2341
+ * @param {object} value - The value to check.
2342
+ * @returns {value is Record<PropertyKey, any>} - True if the value is a plain object, otherwise false.
2343
+ *
2344
+ * @example
2345
+ * ```typescript
2346
+ * // ✅👇 True
2347
+ *
2348
+ * isPlainObject({ }); // ✅
2349
+ * isPlainObject({ key: 'value' }); // ✅
2350
+ * isPlainObject({ key: new Date() }); // ✅
2351
+ * isPlainObject(new Object()); // ✅
2352
+ * isPlainObject(Object.create(null)); // ✅
2353
+ * isPlainObject({ nested: { key: true} }); // ✅
2354
+ * isPlainObject(new Proxy({}, {})); // ✅
2355
+ * isPlainObject({ [Symbol('tag')]: 'A' }); // ✅
2356
+ *
2357
+ * // ✅👇 (cross-realms, node context, workers, ...)
2358
+ * const runInNewContext = await import('node:vm').then(
2359
+ * (mod) => mod.runInNewContext
2360
+ * );
2361
+ * isPlainObject(runInNewContext('({})')); // ✅
2362
+ *
2363
+ * // ❌👇 False
2364
+ *
2365
+ * class Test { };
2366
+ * isPlainObject(new Test()) // ❌
2367
+ * isPlainObject(10); // ❌
2368
+ * isPlainObject(null); // ❌
2369
+ * isPlainObject('hello'); // ❌
2370
+ * isPlainObject([]); // ❌
2371
+ * isPlainObject(new Date()); // ❌
2372
+ * isPlainObject(new Uint8Array([1])); // ❌
2373
+ * isPlainObject(Buffer.from('ABC')); // ❌
2374
+ * isPlainObject(Promise.resolve({})); // ❌
2375
+ * isPlainObject(Object.create({})); // ❌
2376
+ * isPlainObject(new (class Cls {})); // ❌
2377
+ * isPlainObject(globalThis); // ❌,
2378
+ * ```
2379
+ */
2380
+ function isPlainObject(value) {
2381
+ if (!value || typeof value !== "object") return false;
2382
+ const proto = Object.getPrototypeOf(value);
2383
+ if (!(proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null)) return false;
2384
+ return Object.prototype.toString.call(value) === "[object Object]";
2385
+ }
2386
+ //#endregion
2387
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/_internal/isEqualsSameValueZero.mjs
2388
+ /**
2389
+ * Performs a `SameValueZero` comparison between two values to determine if they are equivalent.
2390
+ *
2391
+ * @param {any} value - The value to compare.
2392
+ * @param {any} other - The other value to compare.
2393
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2394
+ *
2395
+ * @example
2396
+ * eq(1, 1); // true
2397
+ * eq(0, -0); // true
2398
+ * eq(NaN, NaN); // true
2399
+ * eq('a', Object('a')); // false
2400
+ */
2401
+ function isEqualsSameValueZero(value, other) {
2402
+ return value === other || Number.isNaN(value) && Number.isNaN(other);
2403
+ }
2404
+ //#endregion
2405
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isEqualWith.mjs
2406
+ /**
2407
+ * Compares two values for equality using a custom comparison function.
2408
+ *
2409
+ * The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
2410
+ *
2411
+ * This function also uses the custom equality function to compare values inside objects,
2412
+ * arrays, maps, sets, and other complex structures, ensuring a deep comparison.
2413
+ *
2414
+ * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
2415
+ *
2416
+ * The custom comparison function can take up to six parameters:
2417
+ * - `x`: The value from the first object `a`.
2418
+ * - `y`: The value from the second object `b`.
2419
+ * - `property`: The property key used to get `x` and `y`.
2420
+ * - `xParent`: The parent of the first value `x`.
2421
+ * - `yParent`: The parent of the second value `y`.
2422
+ * - `stack`: An internal stack (Map) to handle circular references.
2423
+ *
2424
+ * @param {unknown} a - The first value to compare.
2425
+ * @param {unknown} b - The second value to compare.
2426
+ * @param {(x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map<any, any>) => boolean | void} areValuesEqual - A function to customize the comparison.
2427
+ * If it returns a boolean, that result will be used. If it returns undefined,
2428
+ * the default equality comparison will be used.
2429
+ * @returns {boolean} `true` if the values are equal according to the customizer, otherwise `false`.
2430
+ *
2431
+ * @example
2432
+ * const customizer = (a, b) => {
2433
+ * if (typeof a === 'string' && typeof b === 'string') {
2434
+ * return a.toLowerCase() === b.toLowerCase();
2435
+ * }
2436
+ * };
2437
+ * isEqualWith('Hello', 'hello', customizer); // true
2438
+ * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
2439
+ * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
2440
+ */
2441
+ function isEqualWith(a, b, areValuesEqual) {
2442
+ return isEqualWithImpl(a, b, void 0, void 0, void 0, void 0, areValuesEqual);
2443
+ }
2444
+ function isEqualWithImpl(a, b, property, aParent, bParent, stack, areValuesEqual) {
2445
+ const result = areValuesEqual(a, b, property, aParent, bParent, stack);
2446
+ if (result !== void 0) return result;
2447
+ if (typeof a === typeof b) switch (typeof a) {
2448
+ case "bigint":
2449
+ case "string":
2450
+ case "boolean":
2451
+ case "symbol":
2452
+ case "undefined": return a === b;
2453
+ case "number": return a === b || Object.is(a, b);
2454
+ case "function": return a === b;
2455
+ case "object": return areObjectsEqual(a, b, stack, areValuesEqual);
2456
+ }
2457
+ return areObjectsEqual(a, b, stack, areValuesEqual);
2458
+ }
2459
+ function areObjectsEqual(a, b, stack, areValuesEqual) {
2460
+ if (Object.is(a, b)) return true;
2461
+ let aTag = getTag(a);
2462
+ let bTag = getTag(b);
2463
+ if (aTag === "[object Arguments]") aTag = objectTag;
2464
+ if (bTag === "[object Arguments]") bTag = objectTag;
2465
+ if (aTag !== bTag) return false;
2466
+ switch (aTag) {
2467
+ case stringTag: return a.toString() === b.toString();
2468
+ case numberTag: return isEqualsSameValueZero(a.valueOf(), b.valueOf());
2469
+ case booleanTag:
2470
+ case dateTag:
2471
+ case symbolTag: return Object.is(a.valueOf(), b.valueOf());
2472
+ case regexpTag: return a.source === b.source && a.flags === b.flags;
2473
+ case functionTag: return a === b;
2474
+ }
2475
+ stack = stack ?? /* @__PURE__ */ new Map();
2476
+ const aStack = stack.get(a);
2477
+ const bStack = stack.get(b);
2478
+ if (aStack != null && bStack != null) return aStack === b;
2479
+ stack.set(a, b);
2480
+ stack.set(b, a);
2481
+ try {
2482
+ switch (aTag) {
2483
+ case mapTag:
2484
+ if (a.size !== b.size) return false;
2485
+ for (const [key, value] of a.entries()) if (!b.has(key) || !isEqualWithImpl(value, b.get(key), key, a, b, stack, areValuesEqual)) return false;
2486
+ return true;
2487
+ case setTag: {
2488
+ if (a.size !== b.size) return false;
2489
+ const aValues = Array.from(a.values());
2490
+ const bValues = Array.from(b.values());
2491
+ for (let i = 0; i < aValues.length; i++) {
2492
+ const aValue = aValues[i];
2493
+ const index = bValues.findIndex((bValue) => {
2494
+ return isEqualWithImpl(aValue, bValue, void 0, a, b, stack, areValuesEqual);
2495
+ });
2496
+ if (index === -1) return false;
2497
+ bValues.splice(index, 1);
2498
+ }
2499
+ return true;
2500
+ }
2501
+ case arrayTag:
2502
+ case uint8ArrayTag:
2503
+ case uint8ClampedArrayTag:
2504
+ case uint16ArrayTag:
2505
+ case uint32ArrayTag:
2506
+ case bigUint64ArrayTag:
2507
+ case int8ArrayTag:
2508
+ case int16ArrayTag:
2509
+ case int32ArrayTag:
2510
+ case bigInt64ArrayTag:
2511
+ case float32ArrayTag:
2512
+ case float64ArrayTag:
2513
+ if (isBuffer(a) !== isBuffer(b)) return false;
2514
+ if (a.length !== b.length) return false;
2515
+ for (let i = 0; i < a.length; i++) if (!isEqualWithImpl(a[i], b[i], i, a, b, stack, areValuesEqual)) return false;
2516
+ return true;
2517
+ case arrayBufferTag:
2518
+ if (a.byteLength !== b.byteLength) return false;
2519
+ return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
2520
+ case dataViewTag:
2521
+ if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) return false;
2522
+ return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
2523
+ case errorTag: return a.name === b.name && a.message === b.message;
2524
+ case objectTag: {
2525
+ if (!(areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) || isPlainObject(a) && isPlainObject(b))) return false;
2526
+ const aKeys = [...Object.keys(a), ...getSymbols(a)];
2527
+ const bKeys = [...Object.keys(b), ...getSymbols(b)];
2528
+ if (aKeys.length !== bKeys.length) return false;
2529
+ for (let i = 0; i < aKeys.length; i++) {
2530
+ const propKey = aKeys[i];
2531
+ const aProp = a[propKey];
2532
+ if (!Object.hasOwn(b, propKey)) return false;
2533
+ const bProp = b[propKey];
2534
+ if (!isEqualWithImpl(aProp, bProp, propKey, a, b, stack, areValuesEqual)) return false;
2535
+ }
2536
+ return true;
2537
+ }
2538
+ default: return false;
2539
+ }
2540
+ } finally {
2541
+ stack.delete(a);
2542
+ stack.delete(b);
2543
+ }
2544
+ }
2545
+ //#endregion
2546
+ //#region ../../node_modules/.pnpm/es-toolkit@1.47.0/node_modules/es-toolkit/dist/predicate/isEqual.mjs
2547
+ /**
2548
+ * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.
2549
+ *
2550
+ * @param {unknown} a - The first value to compare.
2551
+ * @param {unknown} b - The second value to compare.
2552
+ * @returns {boolean} `true` if the values are equal, otherwise `false`.
2553
+ *
2554
+ * @example
2555
+ * isEqual(1, 1); // true
2556
+ * isEqual({ a: 1 }, { a: 1 }); // true
2557
+ * isEqual(/abc/g, /abc/g); // true
2558
+ * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true
2559
+ * isEqual([1, 2, 3], [1, 2, 3]); // true
2560
+ */
2561
+ function isEqual(a, b) {
2562
+ return isEqualWith(a, b, noop);
2563
+ }
2564
+ //#endregion
1999
2565
  //#region src/react/useResponsive.ts
2000
2566
  /** 屏幕响应断点 token 配置 */
2001
2567
  const BREAK_POINT_TOKEN = {
@@ -2109,4 +2675,4 @@ function useTitle(title, options) {
2109
2675
  });
2110
2676
  }
2111
2677
  //#endregion
2112
- export { BREAK_POINT_TOKEN, useCreation, useLatest, useMount, useResponsive, useTitle, useUnmount };
2678
+ export { BREAK_POINT_TOKEN, useLatest, useMount, useResponsive, useTitle, useUnmount };