@pawover/kit 0.4.2 → 0.6.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 (74) hide show
  1. package/package.json +166 -29
  2. package/packages/eslint-rules/dist/core.antfu.cjs +78 -0
  3. package/packages/eslint-rules/dist/core.antfu.d.cts +1 -0
  4. package/packages/eslint-rules/dist/core.antfu.d.ts +74 -0
  5. package/packages/eslint-rules/dist/core.antfu.js +79 -0
  6. package/packages/eslint-rules/dist/core.imports.cjs +59 -0
  7. package/packages/eslint-rules/dist/core.imports.d.cts +1 -0
  8. package/packages/eslint-rules/dist/core.imports.d.ts +61 -0
  9. package/packages/eslint-rules/dist/core.imports.js +59 -0
  10. package/packages/eslint-rules/dist/core.importsSort.cjs +7 -0
  11. package/packages/eslint-rules/dist/core.importsSort.d.cts +1 -0
  12. package/packages/eslint-rules/dist/core.importsSort.d.ts +7 -0
  13. package/packages/eslint-rules/dist/core.importsSort.js +7 -0
  14. package/packages/eslint-rules/dist/core.javascript.cjs +1208 -0
  15. package/packages/eslint-rules/dist/core.javascript.d.cts +1 -0
  16. package/packages/eslint-rules/dist/core.javascript.d.ts +1216 -0
  17. package/packages/eslint-rules/dist/core.javascript.js +1208 -0
  18. package/packages/eslint-rules/dist/core.react.cjs +551 -0
  19. package/packages/eslint-rules/dist/core.react.d.cts +1 -0
  20. package/packages/eslint-rules/dist/core.react.d.ts +551 -0
  21. package/packages/eslint-rules/dist/core.react.js +551 -0
  22. package/packages/eslint-rules/dist/core.reactHooks.cjs +107 -0
  23. package/packages/eslint-rules/dist/core.reactHooks.d.cts +1 -0
  24. package/packages/eslint-rules/dist/core.reactHooks.d.ts +107 -0
  25. package/packages/eslint-rules/dist/core.reactHooks.js +107 -0
  26. package/packages/eslint-rules/dist/core.stylistic.cjs +608 -0
  27. package/packages/eslint-rules/dist/core.stylistic.d.cts +1 -0
  28. package/packages/eslint-rules/dist/core.stylistic.d.ts +595 -0
  29. package/packages/eslint-rules/dist/core.stylistic.js +608 -0
  30. package/packages/eslint-rules/dist/core.typescript.cjs +905 -0
  31. package/packages/eslint-rules/dist/core.typescript.d.cts +1 -0
  32. package/packages/eslint-rules/dist/core.typescript.d.ts +917 -0
  33. package/packages/eslint-rules/dist/core.typescript.js +906 -0
  34. package/packages/eslint-rules/dist/core.vue.cjs +312 -0
  35. package/packages/eslint-rules/dist/core.vue.d.cts +1 -0
  36. package/packages/eslint-rules/dist/core.vue.d.ts +293 -0
  37. package/packages/eslint-rules/dist/core.vue.js +313 -0
  38. package/packages/eslint-rules/dist/index.cjs +126 -0
  39. package/packages/eslint-rules/dist/index.d.cts +1 -0
  40. package/packages/eslint-rules/dist/index.d.ts +113 -0
  41. package/packages/eslint-rules/dist/index.js +126 -0
  42. package/packages/eslint-rules/dist/preset-Bk6lxNP0.cjs +107 -0
  43. package/packages/eslint-rules/dist/preset-CQJST7pW.js +102 -0
  44. package/packages/hooks/dist/alova.cjs +53 -0
  45. package/packages/hooks/dist/alova.d.cts +1 -0
  46. package/packages/hooks/dist/index.cjs +0 -0
  47. package/packages/hooks/dist/index.d.cts +1 -0
  48. package/packages/hooks/dist/react.cjs +169 -0
  49. package/packages/hooks/dist/react.d.cts +1 -0
  50. package/packages/hooks/dist/react.d.ts +2 -60
  51. package/packages/hooks/dist/react.js +2 -2441
  52. package/packages/types/dist/index.cjs +0 -0
  53. package/packages/types/dist/index.d.cts +1 -0
  54. package/packages/types/dist/index.d.ts +271 -0
  55. package/packages/types/dist/index.js +0 -0
  56. package/packages/types/dist/react.cjs +0 -0
  57. package/packages/types/dist/react.d.cts +1 -0
  58. package/packages/types/dist/react.d.ts +64 -0
  59. package/packages/types/dist/react.js +0 -0
  60. package/packages/utils/dist/index.cjs +2300 -0
  61. package/packages/utils/dist/index.d.cts +1 -0
  62. package/packages/utils/dist/index.d.ts +156 -2721
  63. package/packages/utils/dist/index.js +122 -35
  64. package/packages/utils/dist/math-BznvO4qI.cjs +1029 -0
  65. package/packages/utils/dist/{math-B5PyWuKn.js → math-DRbCtLQH.js} +31 -27
  66. package/packages/utils/dist/math.cjs +3 -0
  67. package/packages/utils/dist/math.d.cts +1 -0
  68. package/packages/utils/dist/math.d.ts +3 -0
  69. package/packages/utils/dist/math.js +1 -1
  70. package/packages/utils/dist/vite.cjs +44 -0
  71. package/packages/utils/dist/vite.d.cts +1 -0
  72. package/packages/utils/dist/vite.js +12 -8
  73. package/packages/zod/dist/index.cjs +91 -0
  74. package/packages/zod/dist/index.d.cts +1 -0
@@ -56,20 +56,12 @@ var TypeUtil = class {
56
56
  static getPrototypeString(value) {
57
57
  return Object.prototype.toString.call(value);
58
58
  }
59
- static isConstructable(fn) {
60
- try {
61
- Reflect.construct(fn, []);
62
- return true;
63
- } catch {
64
- return false;
65
- }
66
- }
67
59
  /**
68
60
  * 检查 value 是否为 string 类型
69
- * - 当 `checkEmpty` 为 `true` 时,会先 trim 再判断是否为空
61
+ * - 当 `checkNullish` 为 `true` 时,会先 trim 再判断是否为空
70
62
  *
71
63
  * @param value 待检查值
72
- * @param checkEmpty 是否检查空字符串(含空白字符串),默认为 `false`
64
+ * @param checkNullish 是否检查空字符串(含空白字符串),默认为 `false`
73
65
  * @returns 是否为字符串
74
66
  * @example
75
67
  * ```ts
@@ -80,8 +72,8 @@ var TypeUtil = class {
80
72
  * TypeUtil.isString(" a ", true); // true
81
73
  * ```
82
74
  */
83
- static isString(value, checkEmpty = false) {
84
- return typeof value === "string" && (!checkEmpty || value.trim().length > 0);
75
+ static isString(value, checkNullish = false) {
76
+ return typeof value === "string" && (!checkNullish || value.trim().length > 0);
85
77
  }
86
78
  /**
87
79
  * 检查 value 是否为 number 类型
@@ -448,7 +440,7 @@ var TypeUtil = class {
448
440
  * ```
449
441
  */
450
442
  static isClass(value) {
451
- return this.isFunction(value) && !this.isAsyncFunction(value) && Function.prototype.toString.call(value).startsWith("class ") && this.isConstructable(value) && value.prototype !== void 0;
443
+ return this.isFunction(value) && !this.isAsyncFunction(value) && Function.prototype.toString.call(value).startsWith("class ") && value.prototype !== void 0;
452
444
  }
453
445
  /**
454
446
  * 检查 value 是否为数组
@@ -699,7 +691,9 @@ var TypeUtil = class {
699
691
  return !!value && typeof value[Symbol.iterator] === "function";
700
692
  }
701
693
  /**
702
- * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
694
+ * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN, 0n)
695
+ * - 处理非字符串形式的 falsy;字符串形式(`"null"`、`"0"` 等)请使用 `isFalsyLike`
696
+ *
703
697
  * @param value 待检查值
704
698
  * @returns 是否为 Falsy
705
699
  * @example
@@ -708,8 +702,7 @@ var TypeUtil = class {
708
702
  * ```
709
703
  */
710
704
  static isFalsy(value) {
711
- if (this.isNaN(value) || this.isNull(value) || this.isUndefined(value)) return true;
712
- return value === false || value === 0 || value === 0n || value === "";
705
+ return this.isNaN(value) || this.isNullish(value) || value === false || value === 0 || value === 0n || value === "";
713
706
  }
714
707
  /**
715
708
  * 检查 value 是否为 FalsyLike 值
@@ -734,8 +727,8 @@ var TypeUtil = class {
734
727
  * 字符串工具类
735
728
  */
736
729
  var StringUtil = class {
737
- static cast(candidate, checkEmpty = true, trim = true) {
738
- if (checkEmpty) {
730
+ static cast(candidate, checkNullish = true, trim = true) {
731
+ if (checkNullish) {
739
732
  if (candidate === null || candidate === void 0) return "";
740
733
  if (typeof candidate === "string" && candidate.trim().length === 0) return "";
741
734
  }
@@ -790,19 +783,26 @@ var StringUtil = class {
790
783
  return input.toUpperCase();
791
784
  }
792
785
  /**
793
- * 字符串首字母大小写
794
- * - 包含非西欧字母字符时,不处理
786
+ * 调整大小写
787
+ * - 每个单词(`\S+`)独立处理
788
+ * - 包含非西欧字母字符(如 `.`、`,`、`'`、`-`)时,该词不处理
795
789
  * - 纯字母且全大写时,不处理
796
- * - 纯字母且非全大写时,首字母小写,其余保留
797
- * - 纯字母且非全大写时,首字母大写,其余保留
790
+ * - 纯字母且非全大写时:`caseType` 为 `"lower"` 则首字母小写,`"upper"` 则首字母大写,其余字符保留
791
+ * - ⚠️ 缺省 `caseType` 时不产生任何转换(no-op),需显式传 `"lower"` / `"upper"`
798
792
  *
799
793
  * @param input 待处理字符串
800
- * @param caseType 大小写类型
794
+ * @param caseType 大小写类型(缺省时无操作)
801
795
  * @returns 处理后的字符串
802
796
  * @example
803
797
  * ```ts
804
- * StringUtil.toInitialCase("Hello", "lower"); // "hello"
805
- * StringUtil.toInitialCase("hello", "upper"); // "Hello"
798
+ * // 重载 1: lower
799
+ * StringUtil.toInitialCase("Hello World", "lower"); // "hello world"
800
+ *
801
+ * // 重载 2: upper
802
+ * StringUtil.toInitialCase("hello world", "upper"); // "Hello World"
803
+ *
804
+ * // 缺省 caseType → no-op
805
+ * StringUtil.toInitialCase("Hello"); // "Hello"
806
806
  * ```
807
807
  */
808
808
  static toInitialCase(input, caseType) {
@@ -921,14 +921,15 @@ var StringUtil = class {
921
921
  static template(input, template, regex = /\{\{(.+?)\}\}/g) {
922
922
  if (!TypeUtil.isString(input, true)) return "";
923
923
  regex.lastIndex = 0;
924
+ const executor = regex.global ? regex : new RegExp(regex.source, `${regex.flags}g`);
924
925
  let result = "";
925
926
  let from = 0;
926
927
  let match;
927
- while (match = regex.exec(input)) {
928
+ while (match = executor.exec(input)) {
928
929
  const replacement = template[match[1]];
929
930
  const valueToInsert = replacement === null || replacement === void 0 ? match[0] : replacement;
930
931
  result += input.slice(from, match.index) + valueToInsert;
931
- from = regex.lastIndex;
932
+ from = executor.lastIndex;
932
933
  }
933
934
  return result + input.slice(from);
934
935
  }
@@ -990,6 +991,9 @@ var MathUtil = class MathUtil {
990
991
  /**
991
992
  * 数学表达式求值
992
993
  *
994
+ * ⚠️ 安全警告:mathjs `evaluate` 存在已知的沙箱逃逸向量,**仅限可信输入**(硬编码表达式或受控参数),
995
+ * 切勿直接用于用户提供的表达式。
996
+ *
993
997
  * @param mathJsInstance mathJs 实例
994
998
  * @param expr 表达式
995
999
  * @param scope 键值映射
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_math = require("./math-BznvO4qI.cjs");
3
+ exports.MathUtil = require_math.MathUtil;
@@ -0,0 +1 @@
1
+ export type * from './math.d.ts'
@@ -42,6 +42,9 @@ declare class MathUtil {
42
42
  /**
43
43
  * 数学表达式求值
44
44
  *
45
+ * ⚠️ 安全警告:mathjs `evaluate` 存在已知的沙箱逃逸向量,**仅限可信输入**(硬编码表达式或受控参数),
46
+ * 切勿直接用于用户提供的表达式。
47
+ *
45
48
  * @param mathJsInstance mathJs 实例
46
49
  * @param expr 表达式
47
50
  * @param scope 键值映射
@@ -1,2 +1,2 @@
1
- import { t as MathUtil } from "./math-B5PyWuKn.js";
1
+ import { t as MathUtil } from "./math-DRbCtLQH.js";
2
2
  export { MathUtil };
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/vite/viteUtil.ts
3
+ /**
4
+ * Vite 工具类
5
+ */
6
+ var ViteUtil = class {
7
+ /**
8
+ * 开发服务器反向代理配置
9
+ *
10
+ * @param proxyList 代理配置项
11
+ * @param options 追加到每个代理项的 Vite `ProxyOptions`
12
+ * @returns Vite `server.proxy` 可直接使用的配置对象
13
+ * @example
14
+ * ```ts
15
+ * ViteUtil.toProxy([
16
+ * ["/api", "http://localhost:3000"],
17
+ * ["/mock", "https://example.com"],
18
+ * ]);
19
+ * // {
20
+ * // "/api": { target: "http://localhost:3000", changeOrigin: true, ws: true, rewrite: [Function] },
21
+ * // "/mock": { target: "https://example.com", changeOrigin: true, ws: true, secure: false, rewrite: [Function] }
22
+ * // }
23
+ * ```
24
+ */
25
+ static toProxy(proxyList, options) {
26
+ const httpsRE = /^https:\/\//;
27
+ const result = {};
28
+ if (Array.isArray(proxyList)) for (const [prefix, target] of proxyList) {
29
+ const isHttps = httpsRE.test(target);
30
+ const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31
+ result[prefix] = {
32
+ target,
33
+ changeOrigin: true,
34
+ ws: true,
35
+ rewrite: (path) => path.replace(new RegExp(`^${escapedPrefix}`), ""),
36
+ ...isHttps ? { secure: false } : {},
37
+ ...options
38
+ };
39
+ }
40
+ return result;
41
+ }
42
+ };
43
+ //#endregion
44
+ exports.ViteUtil = ViteUtil;
@@ -0,0 +1 @@
1
+ export type * from './vite.d.ts'
@@ -24,14 +24,18 @@ var ViteUtil = class {
24
24
  static toProxy(proxyList, options) {
25
25
  const httpsRE = /^https:\/\//;
26
26
  const result = {};
27
- if (Array.isArray(proxyList)) for (const [prefix, target] of proxyList) result[prefix] = {
28
- target,
29
- changeOrigin: true,
30
- ws: true,
31
- rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ""),
32
- ...httpsRE.test(target) ? { secure: false } : {},
33
- ...options
34
- };
27
+ if (Array.isArray(proxyList)) for (const [prefix, target] of proxyList) {
28
+ const isHttps = httpsRE.test(target);
29
+ const escapedPrefix = prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
30
+ result[prefix] = {
31
+ target,
32
+ changeOrigin: true,
33
+ ws: true,
34
+ rewrite: (path) => path.replace(new RegExp(`^${escapedPrefix}`), ""),
35
+ ...isHttps ? { secure: false } : {},
36
+ ...options
37
+ };
38
+ }
35
39
  return result;
36
40
  }
37
41
  };
@@ -0,0 +1,91 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod = require("zod");
3
+ //#region src/server.ts
4
+ const id = zod.z.union([zod.z.string().min(1), zod.z.number()]);
5
+ const idAllowEmpty = id.nullish();
6
+ //#endregion
7
+ //#region src/type.ts
8
+ /** 空 */
9
+ const empty = zod.z.union([zod.z.null(), zod.z.undefined()]);
10
+ /** 字符串 */
11
+ const string = zod.z.string();
12
+ /** 字符串-空 */
13
+ const stringEmpty = zod.z.literal("").nullish();
14
+ /** 字符串-非空 */
15
+ const stringNoEmpty = string.min(1);
16
+ /** 字符串-可空 */
17
+ const stringAllowEmpty = string.nullish();
18
+ /** 数字 */
19
+ const number = zod.z.number();
20
+ /** 数字-可空 */
21
+ const numberAllowEmpty = number.nullish();
22
+ /** 整数 */
23
+ const integer = number.int();
24
+ /** 整数-可空 */
25
+ const integerAllowEmpty = integer.nullish();
26
+ /** 整数-正整数和零 */
27
+ const integerPositive = integer.nonnegative().int();
28
+ /** 整数-正整数和零-可空 */
29
+ const integerPositiveAllowEmpty = integerPositive.nullish();
30
+ /** 整数-负整数和零 */
31
+ const integerNegative = integer.nonpositive().int();
32
+ /** 整数-负整数和零-可空 */
33
+ const integerNegativeAllowEmpty = integerNegative.nullish();
34
+ /** 布尔值 */
35
+ const boolean = zod.z.boolean();
36
+ /** 布尔值-可空 */
37
+ const booleanAllowEmpty = boolean.nullish();
38
+ /** 大数字 */
39
+ const bigint = zod.z.bigint();
40
+ /** 大数字-可空 */
41
+ const bigintAllowEmpty = bigint.nullish();
42
+ /** 大数字-正整数和零 */
43
+ const bigintPositive = bigint.nonnegative();
44
+ /** 大数字-正整数和零-可空 */
45
+ const bigintPositiveAllowEmpty = bigintPositive.nullish();
46
+ /** 大数字-负整数和零 */
47
+ const bigintNegative = bigint.nonpositive();
48
+ /** 大数字-负整数和零-可空 */
49
+ const bigintNegativeAllowEmpty = bigintNegative.nullish();
50
+ const symbol = zod.z.symbol();
51
+ const any = zod.z.any();
52
+ const unknown = zod.z.unknown();
53
+ const never = zod.z.never();
54
+ const propertyKey = zod.z.union([
55
+ string,
56
+ number,
57
+ symbol
58
+ ]);
59
+ const anyObject = zod.z.record(propertyKey, any);
60
+ const plainObject = zod.z.record(propertyKey, unknown);
61
+ //#endregion
62
+ exports.any = any;
63
+ exports.anyObject = anyObject;
64
+ exports.bigint = bigint;
65
+ exports.bigintAllowEmpty = bigintAllowEmpty;
66
+ exports.bigintNegative = bigintNegative;
67
+ exports.bigintNegativeAllowEmpty = bigintNegativeAllowEmpty;
68
+ exports.bigintPositive = bigintPositive;
69
+ exports.bigintPositiveAllowEmpty = bigintPositiveAllowEmpty;
70
+ exports.boolean = boolean;
71
+ exports.booleanAllowEmpty = booleanAllowEmpty;
72
+ exports.empty = empty;
73
+ exports.id = id;
74
+ exports.idAllowEmpty = idAllowEmpty;
75
+ exports.integer = integer;
76
+ exports.integerAllowEmpty = integerAllowEmpty;
77
+ exports.integerNegative = integerNegative;
78
+ exports.integerNegativeAllowEmpty = integerNegativeAllowEmpty;
79
+ exports.integerPositive = integerPositive;
80
+ exports.integerPositiveAllowEmpty = integerPositiveAllowEmpty;
81
+ exports.never = never;
82
+ exports.number = number;
83
+ exports.numberAllowEmpty = numberAllowEmpty;
84
+ exports.plainObject = plainObject;
85
+ exports.propertyKey = propertyKey;
86
+ exports.string = string;
87
+ exports.stringAllowEmpty = stringAllowEmpty;
88
+ exports.stringEmpty = stringEmpty;
89
+ exports.stringNoEmpty = stringNoEmpty;
90
+ exports.symbol = symbol;
91
+ exports.unknown = unknown;
@@ -0,0 +1 @@
1
+ export type * from './index.d.ts'