@pawover/kit 0.6.0 → 0.8.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 (121) hide show
  1. package/README.en.md +123 -0
  2. package/README.md +145 -1
  3. package/entry/eslint-rules.cjs +1 -0
  4. package/entry/eslint-rules.d.cts +1 -0
  5. package/entry/eslint-rules.d.ts +2 -0
  6. package/entry/eslint-rules.js +2 -0
  7. package/entry/hooks-alova.cjs +1 -0
  8. package/entry/hooks-alova.d.cts +1 -0
  9. package/entry/hooks-alova.d.ts +1 -0
  10. package/entry/hooks-alova.js +1 -0
  11. package/entry/hooks-react.cjs +1 -0
  12. package/entry/hooks-react.d.cts +1 -0
  13. package/entry/hooks-react.d.ts +1 -0
  14. package/entry/hooks-react.js +1 -0
  15. package/entry/index.cjs +1 -0
  16. package/entry/index.d.cts +1 -0
  17. package/entry/index.d.ts +1 -0
  18. package/entry/index.js +1 -0
  19. package/entry/math.cjs +1 -0
  20. package/entry/math.d.cts +1 -0
  21. package/entry/math.d.ts +1 -0
  22. package/entry/math.js +1 -0
  23. package/entry/types-react.cjs +1 -0
  24. package/entry/types-react.d.cts +1 -0
  25. package/entry/types-react.d.ts +1 -0
  26. package/entry/types-react.js +1 -0
  27. package/entry/types.cjs +1 -0
  28. package/entry/types.d.cts +1 -0
  29. package/entry/types.d.ts +1 -0
  30. package/entry/types.js +1 -0
  31. package/entry/vite.cjs +1 -0
  32. package/entry/vite.d.cts +1 -0
  33. package/entry/vite.d.ts +1 -0
  34. package/entry/vite.js +1 -0
  35. package/entry/zod.cjs +1 -0
  36. package/entry/zod.d.cts +1 -0
  37. package/entry/zod.d.ts +1 -0
  38. package/entry/zod.js +1 -0
  39. package/package.json +81 -96
  40. package/packages/eslint-rules/dist/core.antfu.cjs +0 -78
  41. package/packages/eslint-rules/dist/core.antfu.d.cts +0 -1
  42. package/packages/eslint-rules/dist/core.antfu.d.ts +0 -74
  43. package/packages/eslint-rules/dist/core.antfu.js +0 -79
  44. package/packages/eslint-rules/dist/core.imports.cjs +0 -59
  45. package/packages/eslint-rules/dist/core.imports.d.cts +0 -1
  46. package/packages/eslint-rules/dist/core.imports.d.ts +0 -61
  47. package/packages/eslint-rules/dist/core.imports.js +0 -59
  48. package/packages/eslint-rules/dist/core.importsSort.cjs +0 -7
  49. package/packages/eslint-rules/dist/core.importsSort.d.cts +0 -1
  50. package/packages/eslint-rules/dist/core.importsSort.d.ts +0 -7
  51. package/packages/eslint-rules/dist/core.importsSort.js +0 -7
  52. package/packages/eslint-rules/dist/core.javascript.cjs +0 -1208
  53. package/packages/eslint-rules/dist/core.javascript.d.cts +0 -1
  54. package/packages/eslint-rules/dist/core.javascript.d.ts +0 -1216
  55. package/packages/eslint-rules/dist/core.javascript.js +0 -1208
  56. package/packages/eslint-rules/dist/core.react.cjs +0 -551
  57. package/packages/eslint-rules/dist/core.react.d.cts +0 -1
  58. package/packages/eslint-rules/dist/core.react.d.ts +0 -551
  59. package/packages/eslint-rules/dist/core.react.js +0 -551
  60. package/packages/eslint-rules/dist/core.reactHooks.cjs +0 -107
  61. package/packages/eslint-rules/dist/core.reactHooks.d.cts +0 -1
  62. package/packages/eslint-rules/dist/core.reactHooks.d.ts +0 -107
  63. package/packages/eslint-rules/dist/core.reactHooks.js +0 -107
  64. package/packages/eslint-rules/dist/core.stylistic.cjs +0 -608
  65. package/packages/eslint-rules/dist/core.stylistic.d.cts +0 -1
  66. package/packages/eslint-rules/dist/core.stylistic.d.ts +0 -595
  67. package/packages/eslint-rules/dist/core.stylistic.js +0 -608
  68. package/packages/eslint-rules/dist/core.typescript.cjs +0 -905
  69. package/packages/eslint-rules/dist/core.typescript.d.cts +0 -1
  70. package/packages/eslint-rules/dist/core.typescript.d.ts +0 -917
  71. package/packages/eslint-rules/dist/core.typescript.js +0 -906
  72. package/packages/eslint-rules/dist/core.vue.cjs +0 -312
  73. package/packages/eslint-rules/dist/core.vue.d.cts +0 -1
  74. package/packages/eslint-rules/dist/core.vue.d.ts +0 -293
  75. package/packages/eslint-rules/dist/core.vue.js +0 -313
  76. package/packages/eslint-rules/dist/index.cjs +0 -126
  77. package/packages/eslint-rules/dist/index.d.cts +0 -1
  78. package/packages/eslint-rules/dist/index.d.ts +0 -113
  79. package/packages/eslint-rules/dist/index.js +0 -126
  80. package/packages/eslint-rules/dist/preset-Bk6lxNP0.cjs +0 -107
  81. package/packages/eslint-rules/dist/preset-CQJST7pW.js +0 -102
  82. package/packages/hooks/dist/alova.cjs +0 -53
  83. package/packages/hooks/dist/alova.d.cts +0 -1
  84. package/packages/hooks/dist/alova.d.ts +0 -33
  85. package/packages/hooks/dist/alova.js +0 -50
  86. package/packages/hooks/dist/index.cjs +0 -0
  87. package/packages/hooks/dist/index.d.cts +0 -1
  88. package/packages/hooks/dist/index.d.ts +0 -1
  89. package/packages/hooks/dist/index.js +0 -0
  90. package/packages/hooks/dist/react.cjs +0 -169
  91. package/packages/hooks/dist/react.d.cts +0 -1
  92. package/packages/hooks/dist/react.d.ts +0 -95
  93. package/packages/hooks/dist/react.js +0 -163
  94. package/packages/types/dist/index.cjs +0 -0
  95. package/packages/types/dist/index.d.cts +0 -1
  96. package/packages/types/dist/index.d.ts +0 -271
  97. package/packages/types/dist/index.js +0 -0
  98. package/packages/types/dist/react.cjs +0 -0
  99. package/packages/types/dist/react.d.cts +0 -1
  100. package/packages/types/dist/react.d.ts +0 -64
  101. package/packages/types/dist/react.js +0 -0
  102. package/packages/utils/dist/index.cjs +0 -2300
  103. package/packages/utils/dist/index.d.cts +0 -1
  104. package/packages/utils/dist/index.d.ts +0 -2740
  105. package/packages/utils/dist/index.js +0 -2287
  106. package/packages/utils/dist/math-BznvO4qI.cjs +0 -1029
  107. package/packages/utils/dist/math-DRbCtLQH.js +0 -1012
  108. package/packages/utils/dist/math.cjs +0 -3
  109. package/packages/utils/dist/math.d.cts +0 -1
  110. package/packages/utils/dist/math.d.ts +0 -60
  111. package/packages/utils/dist/math.js +0 -2
  112. package/packages/utils/dist/vite.cjs +0 -44
  113. package/packages/utils/dist/vite.d.cts +0 -1
  114. package/packages/utils/dist/vite.d.ts +0 -28
  115. package/packages/utils/dist/vite.js +0 -43
  116. package/packages/zod/dist/index.cjs +0 -91
  117. package/packages/zod/dist/index.d.cts +0 -1
  118. package/packages/zod/dist/index.d.ts +0 -57
  119. package/packages/zod/dist/index.js +0 -61
  120. /package/{packages/hooks/dist/metadata.json → entry/hooks-metadata.json} +0 -0
  121. /package/{packages/utils/dist → entry}/metadata.json +0 -0
@@ -1,271 +0,0 @@
1
- import { Split, TupleToUnion } from "type-fest";
2
- //#region src/advancedRecord.d.ts
3
- /**
4
- * 高级记录模式
5
- *
6
- * 由必选/可选标记(`"?"` | `"!"`)与读写权限标记(`"W"` | `"R"`)组成的二元组,用于控制 `AdvancedRecord` 的字段形态。
7
- *
8
- * @example
9
- * ```ts
10
- * // 必选且可读写
11
- * const mode: AdvancedRecordMode = ["!", "W"];
12
- * // 可选且只读
13
- * const readonlyMode: AdvancedRecordMode = ["?", "R"];
14
- * ```
15
- */
16
- type AdvancedRecordMode = ["?" | "!", "W" | "R"];
17
- /**
18
- * 高级记录(Advanced Record)
19
- *
20
- * 按模式组合生成指定键集合的映射类型,可控制字段的必选/可选与只读/可写。
21
- *
22
- * @template K 键集合
23
- * @template A 值类型
24
- * @template mode 记录模式(默认必选且可读写)
25
- *
26
- * @example
27
- * ```ts
28
- * // 默认模式:必选且可读写
29
- * type A = AdvancedRecord<"id" | "name", string>;
30
- * // { id: string; name: string }
31
- *
32
- * // 可选且只读
33
- * type B = AdvancedRecord<"id", string, ["?", "R"]>;
34
- * // { readonly id?: string }
35
- * ```
36
- */
37
- type AdvancedRecord<K extends PropertyKey, A = unknown, mode extends AdvancedRecordMode = ["!", "W"]> = {
38
- "!": {
39
- R: { readonly [P in K]: A; };
40
- W: { [P in K]: A; };
41
- };
42
- "?": {
43
- R: { readonly [P in K]?: A; };
44
- W: { [P in K]?: A; };
45
- };
46
- }[mode[0]][mode[1]];
47
- //#endregion
48
- //#region src/api.d.ts
49
- /** 字母表 */
50
- type ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
51
- /** 单个字母 */
52
- type Letter = TupleToUnion<Split<ALPHABET, "">>;
53
- /** 有效字符 */
54
- type ValidChar = Letter | "_";
55
- /**
56
- * API 命名检查
57
- *
58
- * 递归校验命名仅包含大写字母与下划线,并剥离尾随下划线;遇到非法字符时返回空字符串。
59
- *
60
- * @template N 待检查的命名
61
- * @template P 内部递归累计结果(由编译器推导,无需传入)
62
- *
63
- * @returns 剥离尾随下划线后的合法命名;包含非法字符时为 `""`
64
- *
65
- * @example
66
- * ```ts
67
- * type A = ApiNameCheck<"GET_USER">; // "GET_USER"
68
- * type B = ApiNameCheck<"GET_USER_">; // "GET_USER"(尾随下划线被剥离)
69
- * type C = ApiNameCheck<"getUser">; // ""(小写字符非法)
70
- * ```
71
- */
72
- type ApiNameCheck<N extends string, P extends string = ""> = N extends `${infer L extends ValidChar}${infer R}` ? ApiNameCheck<R, `${P}${L}`> : P extends `${infer S}_` ? S : P;
73
- //#endregion
74
- //#region src/global.d.ts
75
- /**
76
- * 原始类型
77
- *
78
- * TypeScript 中的全部原始值类型集合。
79
- *
80
- * @example
81
- * ```ts
82
- * const a: Primitive = "str";
83
- * const b: Primitive = 42;
84
- * const c: Primitive = null;
85
- * ```
86
- */
87
- type Primitive = null | undefined | string | number | boolean | symbol | bigint;
88
- /**
89
- * 任意对象类型
90
- *
91
- * 以索引签名描述任意键值对对象,键类型默认为 `PropertyKey`,值类型默认为 `any`。
92
- *
93
- * @template K 键类型
94
- * @template T 值类型
95
- *
96
- * @example
97
- * ```ts
98
- * const obj: AnyObject = { a: 1, b: "2" };
99
- * const numObj: AnyObject<"id", number> = { id: 1 };
100
- * ```
101
- */
102
- type AnyObject<K extends PropertyKey = PropertyKey, T = any> = Record<K, T>;
103
- /**
104
- * 普通对象类型
105
- *
106
- * 以索引签名描述普通对象,值类型默认为 `unknown`,比 `AnyObject` 更严格。
107
- *
108
- * @template K 键类型
109
- * @template T 值类型
110
- *
111
- * @example
112
- * ```ts
113
- * const obj: PlainObject = { a: 1 };
114
- * const strMap: PlainObject<string, string> = { key: "value" };
115
- * ```
116
- */
117
- type PlainObject<K extends PropertyKey = PropertyKey, T = unknown> = Record<K, T>;
118
- /**
119
- * 描述树类型
120
- *
121
- * 递归结构:每个节点都包含子树节点数组(子节点键名默认为 `children`)。
122
- *
123
- * @template T 节点基础类型(需为对象类型)
124
- * @template CK 子节点键名
125
- *
126
- * @example
127
- * ```ts
128
- * interface Node {
129
- * id: number;
130
- * name: string;
131
- * }
132
- * const tree: TreeLike<Node> = {
133
- * id: 1,
134
- * name: "root",
135
- * children: [{ id: 2, name: "leaf", children: [] }],
136
- * };
137
- * ```
138
- */
139
- type TreeLike<T extends AnyObject, CK extends string = "children"> = T & Record<CK, TreeLike<T, CK>[]>;
140
- /**
141
- * 描述可选子节点树类型
142
- *
143
- * 递归结构:每个节点都可省略子节点键(子节点键名默认为 `children`)。
144
- *
145
- * @template T 节点基础类型(需为对象类型)
146
- * @template CK 子节点键名
147
- *
148
- * @example
149
- * ```ts
150
- * interface Node {
151
- * id: number;
152
- * name: string;
153
- * }
154
- * const leaf: TreeLikeOptionalChildren<Node> = { id: 2, name: "leaf" };
155
- * const root: TreeLikeOptionalChildren<Node> = {
156
- * id: 1,
157
- * name: "root",
158
- * children: [leaf],
159
- * };
160
- * ```
161
- */
162
- type TreeLikeOptionalChildren<T extends AnyObject, CK extends string = "children"> = T & { [K in CK]?: TreeLikeOptionalChildren<T, CK>[]; };
163
- /**
164
- * 描述函数类型
165
- *
166
- * 任意参数与任意返回值的函数类型。
167
- *
168
- * @template P 参数元组类型
169
- * @template R 返回值类型
170
- *
171
- * @example
172
- * ```ts
173
- * const fn: AnyFunction = (a, b) => a + b;
174
- * const strFn: AnyFunction<[string], string> = (s) => s.toUpperCase();
175
- * ```
176
- */
177
- type AnyFunction<P extends any[] = any[], R = any> = (...arg: P) => R;
178
- /**
179
- * 描述异步函数类型
180
- *
181
- * 任意参数且返回 Promise 的函数类型。
182
- *
183
- * @template P 参数元组类型
184
- * @template R 返回值类型
185
- *
186
- * @example
187
- * ```ts
188
- * const fn: AnyAsyncFunction = async () => {};
189
- * const fetchFn: AnyAsyncFunction<[string], number> = async (url) => (await fetch(url)).status;
190
- * ```
191
- */
192
- type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promise<R>;
193
- /**
194
- * 描述生成器函数类型
195
- *
196
- * 任意参数且返回 Generator 的函数类型。
197
- *
198
- * @template P 参数元组类型
199
- * @template T 产出值类型
200
- * @template R 返回值类型
201
- * @template N 下一传入值类型
202
- *
203
- * @example
204
- * ```ts
205
- * const fn: AnyGeneratorFunction<[], number> = function* () {
206
- * yield 1;
207
- * };
208
- * ```
209
- */
210
- type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
211
- /**
212
- * 描述异步生成器函数类型
213
- *
214
- * 任意参数且返回 AsyncGenerator 的函数类型。
215
- *
216
- * @template P 参数元组类型
217
- * @template T 产出值类型
218
- * @template R 返回值类型
219
- * @template N 下一传入值类型
220
- *
221
- * @example
222
- * ```ts
223
- * const fn: AnyAsyncGeneratorFunction<[], number> = async function* () {
224
- * yield 1;
225
- * };
226
- * ```
227
- */
228
- type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
229
- /**
230
- * 描述无返回值函数
231
- *
232
- * 不接受参数且返回 `void` 的函数类型。
233
- *
234
- * @example
235
- * ```ts
236
- * const fn: VoidFunction = () => {
237
- * console.log("hello");
238
- * };
239
- * ```
240
- */
241
- type VoidFunction = () => void;
242
- /**
243
- * 判断是否为原始类型
244
- *
245
- * 若 `T` 为原始类型则结果为 `true`,否则为 `false`。
246
- *
247
- * @template T 待判断的类型
248
- *
249
- * @example
250
- * ```ts
251
- * type A = IsPrimitive<string>; // true
252
- * type B = IsPrimitive<{ a: 1 }>; // false
253
- * ```
254
- */
255
- type IsPrimitive<T> = T extends Primitive ? true : false;
256
- /**
257
- * 判断是否具有索引签名
258
- *
259
- * 若 `T` 可被字符串索引(具有 string 索引签名)则结果为 `true`,否则为 `false`。
260
- *
261
- * @template T 待判断的类型
262
- *
263
- * @example
264
- * ```ts
265
- * type A = HasStringIndex<Record<string, number>>; // true
266
- * type B = HasStringIndex<{ a: 1 }>; // false
267
- * ```
268
- */
269
- type HasStringIndex<T> = string extends keyof T ? true : false;
270
- //#endregion
271
- export type { AdvancedRecord, AdvancedRecordMode, AnyAsyncFunction, AnyAsyncGeneratorFunction, AnyFunction, AnyGeneratorFunction, AnyObject, ApiNameCheck, HasStringIndex, IsPrimitive, PlainObject, Primitive, TreeLike, TreeLikeOptionalChildren, VoidFunction };
File without changes
File without changes
@@ -1 +0,0 @@
1
- export type * from './react.d.ts'
@@ -1,64 +0,0 @@
1
- import { ReactNode, RefObject } from "react";
2
- //#region src/react.d.ts
3
- /**
4
- * 只读 Props 类型
5
- *
6
- * 将任意属性集合转换为只读的组件 Props 类型。
7
- *
8
- * @template P 属性集合
9
- *
10
- * @example
11
- * ```ts
12
- * interface MyProps {
13
- * title: string;
14
- * }
15
- * const props: Props<MyProps> = { title: "hello" };
16
- * // props.title = "x"; // ❌ 只读,无法修改
17
- * ```
18
- */
19
- type Props<P = unknown> = Readonly<P>;
20
- /**
21
- * 含 children 的只读 Props 类型
22
- *
23
- * 在只读 Props 基础上增加可选的 `children` 属性。
24
- *
25
- * @template P 属性集合
26
- *
27
- * @example
28
- * ```ts
29
- * interface MyProps {
30
- * title: string;
31
- * }
32
- * const props: PropsWithChildren<MyProps> = {
33
- * title: "hello",
34
- * children: <span>content</span>,
35
- * };
36
- * ```
37
- */
38
- type PropsWithChildren<P = unknown> = Readonly<P> & {
39
- readonly children?: ReactNode | undefined;
40
- };
41
- /**
42
- * 含 ref 的只读 Props 类型
43
- *
44
- * 在只读 Props 基础上增加可选的 `ref` 属性。
45
- *
46
- * @template P 属性集合
47
- * @template R ref 指向的 DOM 元素类型
48
- *
49
- * @example
50
- * ```ts
51
- * interface MyProps {
52
- * title: string;
53
- * }
54
- * const props: PropsWithRef<MyProps, HTMLDivElement> = {
55
- * title: "hello",
56
- * ref: useRef<HTMLDivElement>(null),
57
- * };
58
- * ```
59
- */
60
- type PropsWithRef<P = unknown, R = unknown> = Readonly<P> & {
61
- readonly ref?: RefObject<R> | undefined;
62
- };
63
- //#endregion
64
- export { Props, PropsWithChildren, PropsWithRef };
File without changes