@pawover/kit 0.0.0-alpha.9 → 0.0.0-beta.2

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 (83) hide show
  1. package/dist/enums.d.ts +25 -0
  2. package/dist/enums.d.ts.map +1 -0
  3. package/dist/enums.js +25 -0
  4. package/dist/enums.js.map +1 -0
  5. package/dist/hooks-alova.d.ts +23 -0
  6. package/dist/hooks-alova.d.ts.map +1 -0
  7. package/dist/hooks-alova.js +39 -0
  8. package/dist/hooks-alova.js.map +1 -0
  9. package/dist/hooks-react.d.ts +89 -0
  10. package/dist/hooks-react.d.ts.map +1 -0
  11. package/dist/hooks-react.js +340 -0
  12. package/dist/hooks-react.js.map +1 -0
  13. package/dist/index.d.ts +2445 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +1430 -1
  16. package/dist/index.js.map +1 -0
  17. package/dist/patches-fetchEventSource.d.ts +806 -0
  18. package/dist/patches-fetchEventSource.d.ts.map +1 -0
  19. package/dist/patches-fetchEventSource.js +315 -0
  20. package/dist/patches-fetchEventSource.js.map +1 -0
  21. package/dist/vite.d.ts +13 -0
  22. package/dist/vite.d.ts.map +1 -0
  23. package/dist/vite.js +23 -0
  24. package/dist/vite.js.map +1 -0
  25. package/dist/zod.d.ts +105 -0
  26. package/dist/zod.d.ts.map +1 -0
  27. package/dist/zod.js +138 -0
  28. package/dist/zod.js.map +1 -0
  29. package/metadata.json +160 -0
  30. package/package.json +51 -35
  31. package/dist/enums/index.js +0 -20
  32. package/dist/hooks/react/index.js +0 -5
  33. package/dist/hooks/react/useCreation.js +0 -19
  34. package/dist/hooks/react/useLatest.js +0 -13
  35. package/dist/hooks/react/useMount.js +0 -29
  36. package/dist/hooks/react/useResponsive.js +0 -59
  37. package/dist/hooks/react/useUnmount.js +0 -18
  38. package/dist/types/enums/index.d.ts +0 -20
  39. package/dist/types/hooks/react/index.d.ts +0 -5
  40. package/dist/types/hooks/react/useCreation.d.ts +0 -10
  41. package/dist/types/hooks/react/useLatest.d.ts +0 -8
  42. package/dist/types/hooks/react/useMount.d.ts +0 -11
  43. package/dist/types/hooks/react/useResponsive.d.ts +0 -16
  44. package/dist/types/hooks/react/useUnmount.d.ts +0 -7
  45. package/dist/types/index.d.ts +0 -1
  46. package/dist/types/utils/array.d.ts +0 -76
  47. package/dist/types/utils/clone.d.ts +0 -13
  48. package/dist/types/utils/index.d.ts +0 -7
  49. package/dist/types/utils/object.d.ts +0 -54
  50. package/dist/types/utils/string.d.ts +0 -15
  51. package/dist/types/utils/to.d.ts +0 -5
  52. package/dist/types/utils/tree/index.d.ts +0 -6
  53. package/dist/types/utils/tree/rowsToTree.d.ts +0 -10
  54. package/dist/types/utils/tree/treeFilter.d.ts +0 -6
  55. package/dist/types/utils/tree/treeFind.d.ts +0 -8
  56. package/dist/types/utils/tree/treeForEach.d.ts +0 -5
  57. package/dist/types/utils/tree/treeMap.d.ts +0 -6
  58. package/dist/types/utils/tree/treeToRows.d.ts +0 -9
  59. package/dist/types/utils/tree/types.d.ts +0 -24
  60. package/dist/types/utils/typeof.d.ts +0 -37
  61. package/dist/types/zod/index.d.ts +0 -3
  62. package/dist/types/zod/primitive.d.ts +0 -32
  63. package/dist/types/zod/validator/input.d.ts +0 -27
  64. package/dist/types/zod/validator/societal.d.ts +0 -39
  65. package/dist/utils/array.js +0 -196
  66. package/dist/utils/clone.js +0 -75
  67. package/dist/utils/index.js +0 -7
  68. package/dist/utils/object.js +0 -149
  69. package/dist/utils/string.js +0 -73
  70. package/dist/utils/to.js +0 -16
  71. package/dist/utils/tree/index.js +0 -6
  72. package/dist/utils/tree/rowsToTree.js +0 -35
  73. package/dist/utils/tree/treeFilter.js +0 -92
  74. package/dist/utils/tree/treeFind.js +0 -82
  75. package/dist/utils/tree/treeForEach.js +0 -60
  76. package/dist/utils/tree/treeMap.js +0 -79
  77. package/dist/utils/tree/treeToRows.js +0 -13
  78. package/dist/utils/tree/types.js +0 -10
  79. package/dist/utils/typeof.js +0 -149
  80. package/dist/zod/index.js +0 -3
  81. package/dist/zod/primitive.js +0 -32
  82. package/dist/zod/validator/input.js +0 -39
  83. package/dist/zod/validator/societal.js +0 -57
@@ -1,13 +0,0 @@
1
- import { treeForEach } from "./treeForEach";
2
- /**
3
- * 树结构 转 行结构
4
- */
5
- export function treeToRows(tree, options = {}) {
6
- const { childrenKey = "children" } = options;
7
- const result = [];
8
- if (!tree) {
9
- return result;
10
- }
11
- treeForEach(tree, (t) => result.push({ ...t, [childrenKey]: undefined }), options);
12
- return result;
13
- }
@@ -1,10 +0,0 @@
1
- import { isFunction } from "../typeof";
2
- export function getFinalChildrenKey(tree, meta, options) {
3
- if (isFunction(options.getChildrenKey)) {
4
- const dynamicChildrenKey = options.getChildrenKey(tree, meta);
5
- if (dynamicChildrenKey && dynamicChildrenKey !== null) {
6
- return dynamicChildrenKey;
7
- }
8
- }
9
- return options.childrenKey;
10
- }
@@ -1,149 +0,0 @@
1
- const prototypes = {
2
- string: "[object String]",
3
- number: "[object Number]",
4
- boolean: "[object Boolean]",
5
- object: "[object Object]",
6
- array: "[object Array]",
7
- bigInt: "[object BigInt]",
8
- symbol: "[object Symbol]",
9
- function: "[object Function]",
10
- generatorFunction: "[object GeneratorFunction]",
11
- asyncFunction: "[object AsyncFunction]",
12
- promise: "[object Promise]",
13
- null: "[object Null]",
14
- undefined: "[object Undefined]",
15
- date: "[object Date]",
16
- regExp: "[object RegExp]",
17
- error: "[object Error]",
18
- file: "[object File]",
19
- map: "[object Map]",
20
- weakMap: "[object WeakMap]",
21
- set: "[object Set]",
22
- weakSet: "[object WeakSet]",
23
- window: "[object Window]",
24
- webSocket: "[object WebSocket]",
25
- URLSearchParams: "[object URLSearchParams]",
26
- };
27
- function resolvePrototypeString(value) {
28
- return Object.prototype.toString.call(value);
29
- }
30
- export function isString(value) {
31
- return resolvePrototypeString(value) === prototypes.string;
32
- }
33
- export function isNumber(value) {
34
- return resolvePrototypeString(value) === prototypes.number;
35
- }
36
- export function isBoolean(value) {
37
- return resolvePrototypeString(value) === prototypes.boolean;
38
- }
39
- export function isObject(value) {
40
- return resolvePrototypeString(value) === prototypes.object;
41
- }
42
- export function isArray(value) {
43
- return resolvePrototypeString(value) === prototypes.array;
44
- }
45
- export function isBigInt(value) {
46
- return resolvePrototypeString(value) === prototypes.bigInt;
47
- }
48
- export function isSymbol(value) {
49
- return resolvePrototypeString(value) === prototypes.symbol;
50
- }
51
- export function isFunction(value) {
52
- const prototypeList = [prototypes.function, prototypes.generatorFunction, prototypes.asyncFunction];
53
- return prototypeList.includes(resolvePrototypeString(value));
54
- }
55
- export function isGeneratorFunction(value) {
56
- return resolvePrototypeString(value) === prototypes.generatorFunction;
57
- }
58
- export function isAsyncFunction(value) {
59
- return resolvePrototypeString(value) === prototypes.asyncFunction;
60
- }
61
- export function isPromise(value) {
62
- return resolvePrototypeString(value) === prototypes.promise;
63
- }
64
- export function isPromiseLike(value) {
65
- return isPromise(value) || (isObject(value) && isFunction(value["then"]));
66
- }
67
- export function isNull(value) {
68
- return resolvePrototypeString(value) === prototypes.null;
69
- }
70
- export function isUndefined(value) {
71
- return resolvePrototypeString(value) === prototypes.undefined;
72
- }
73
- export function isDate(value) {
74
- return resolvePrototypeString(value) === prototypes.date;
75
- }
76
- export function isRegExp(value) {
77
- return resolvePrototypeString(value) === prototypes.regExp;
78
- }
79
- export function isError(value) {
80
- return resolvePrototypeString(value) === prototypes.error;
81
- }
82
- export function isFile(value) {
83
- return resolvePrototypeString(value) === prototypes.file;
84
- }
85
- export function isMap(value) {
86
- return resolvePrototypeString(value) === prototypes.map;
87
- }
88
- export function isWeakMap(value) {
89
- return resolvePrototypeString(value) === prototypes.weakMap;
90
- }
91
- export function isSet(value) {
92
- return resolvePrototypeString(value) === prototypes.set;
93
- }
94
- export function isWeakSet(value) {
95
- return resolvePrototypeString(value) === prototypes.weakSet;
96
- }
97
- export function isWindow(value) {
98
- return resolvePrototypeString(value) === prototypes.window;
99
- }
100
- export function isWebSocket(value) {
101
- return resolvePrototypeString(value) === prototypes.webSocket;
102
- }
103
- export function isURLSearchParams(value) {
104
- return resolvePrototypeString(value) === prototypes.URLSearchParams;
105
- }
106
- export function isClass(value) {
107
- return resolvePrototypeString(value).startsWith("class ");
108
- }
109
- export function isInteger(value) {
110
- return Number.isInteger(value);
111
- }
112
- export function isIterable(value) {
113
- return isObject(value) && Symbol.iterator in value;
114
- }
115
- /**
116
- * 判断给定的值是否相等
117
- * @reference https://github.com/radashi-org/radashi/blob/main/src/typed/isEqual.ts
118
- *
119
- * @param {T} x
120
- * @param {T} y
121
- */
122
- export function isEqual(x, y) {
123
- if (Object.is(x, y)) {
124
- return true;
125
- }
126
- if (x instanceof Date && y instanceof Date) {
127
- return x.getTime() === y.getTime();
128
- }
129
- if (x instanceof RegExp && y instanceof RegExp) {
130
- return x.toString() === y.toString();
131
- }
132
- if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) {
133
- return false;
134
- }
135
- const keysX = Reflect.ownKeys(x);
136
- const keysY = Reflect.ownKeys(y);
137
- if (keysX.length !== keysY.length) {
138
- return false;
139
- }
140
- for (const key of keysX) {
141
- if (!Reflect.has(y, key)) {
142
- return false;
143
- }
144
- if (!isEqual(x[key], y[key])) {
145
- return false;
146
- }
147
- }
148
- return true;
149
- }
package/dist/zod/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from "./primitive";
2
- export * from "./validator/input";
3
- export * from "./validator/societal";
@@ -1,32 +0,0 @@
1
- import { z } from "zod";
2
- /** 空 */
3
- export const empty = z.union([z.null(), z.undefined()]);
4
- /** 字符串 */
5
- export const string = z.string();
6
- /** 字符串-空 */
7
- export const stringEmpty = z.literal("").nullish();
8
- /** 字符串-非空 */
9
- export const stringNoEmpty = z.string().min(1);
10
- /** 字符串-可空 */
11
- export const stringAllowEmpty = z.string().nullish();
12
- /** 数字 */
13
- export const number = z.number();
14
- /** 数字-可空 */
15
- export const numberAllowEmpty = number.nullish();
16
- /** 整数 */
17
- export const int = z.number().int({ error: "应为整数" });
18
- /** 整数-可空 */
19
- export const intAllowEmpty = int.nullish();
20
- /** 自然数 */
21
- export const natural = int.nonnegative({ error: "应为非负数" });
22
- /** 自然数-可空 */
23
- export const naturalAllowEmpty = natural.nullish();
24
- /** 布尔值 */
25
- export const boolean = z.boolean();
26
- /** 布尔值-可空 */
27
- export const booleanAllowEmpty = z.boolean().nullish();
28
- export const bigint = z.bigint();
29
- export const symbol = z.symbol();
30
- export const any = z.any();
31
- export const unknown = z.unknown();
32
- export const never = z.never();
@@ -1,39 +0,0 @@
1
- import { z } from "zod";
2
- const _alphabet = /^[a-z]+$/i;
3
- /** 字母 */
4
- export const alphabet = z.string().regex(_alphabet, { error: "应为字母" });
5
- const _alphabetLowercase = /^[a-z]+$/;
6
- /** 小写字母 */
7
- export const alphabetLowercase = z.string().regex(_alphabetLowercase, { error: "应为小写字母" });
8
- const _alphabetUppercase = /^[A-Z]+$/;
9
- /** 大写字母 */
10
- export const alphabetUppercase = z.string().regex(_alphabetUppercase, { error: "应为大写字母" });
11
- const _alphabetOmit = /^[^A-Z]*$/i;
12
- /** 不包含字母 */
13
- export const alphabetOmit = z.string().regex(_alphabetOmit, { error: "应不包含字母" });
14
- const _numberAlphabet = /^[A-Z0-9]+$/i;
15
- /** 数字和字母 */
16
- export const numberAlphabet = z.string().regex(_numberAlphabet, { error: "应为数字和字母组合" });
17
- const _stringSignedDecimalismFloat = /^[+-]?(\d+(\.\d+)?|\.\d+)$/;
18
- /** 有符号十进制浮点数字符串 */
19
- export const stringSignedDecimalismFloat = z.string().regex(_stringSignedDecimalismFloat, { error: "应为十进制数字" });
20
- const _stringUnsignedDecimalismFloat = /^\+?(\d+(\.\d+)?|\.\d+)$/;
21
- /** 无符号十进制浮点数字符串 */
22
- export const stringUnsignedDecimalismFloat = z.string().regex(_stringUnsignedDecimalismFloat, { error: "应为十进制正数" });
23
- const _stringSignedDecimalismInt = /^[+-]?\d+$/;
24
- /** 有符号十进制整数字符串 */
25
- export const stringSignedDecimalismInt = z.string().regex(_stringSignedDecimalismInt, { error: "应为十进制整数" });
26
- const _stringUnsignedDecimalismInt = /^\+?\d+$/;
27
- /** 无符号十进制整数字符串 */
28
- export const stringUnsignedDecimalismInt = z.string().regex(_stringUnsignedDecimalismInt, { error: "应为十进制正整数" });
29
- const _spaceInclude = /^[^ ]+$/;
30
- /** 包含空格 */
31
- export const spaceInclude = z.string().regex(_spaceInclude, { error: "应不包含空格" });
32
- const _spaceStart = /^\S/g;
33
- /** 首空格 */
34
- export const spaceStart = z.string().regex(_spaceStart, { error: "应不包含首空格" });
35
- const _spaceEnd = /\s$/g;
36
- /** 尾空格 */
37
- export const spaceEnd = z.string().regex(_spaceEnd, { error: "应不包含尾空格" });
38
- /** 首尾空格 */
39
- export const spaceStartEnd = spaceStart.and(spaceEnd);
@@ -1,57 +0,0 @@
1
- import { z } from "zod";
2
- const _phone = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
3
- /** 手机号码 */
4
- export const phone = z.string().regex(_phone, { error: "手机号码格式错误" });
5
- const _telephone = /0\d{2,3}-\d{7,9}$/;
6
- /** 固定电话 */
7
- export const telephone = z.string().regex(_telephone, { error: "电话号码格式错误" });
8
- const _email = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\])|(([a-z\-0-9]+\.)+[a-z]{2,}))$/i;
9
- /** 电子邮箱 */
10
- export const email = z.string().regex(_email, { error: "电子邮箱格式错误" });
11
- const _chineseName = /^[一-龢][一·-龢]*$/;
12
- /** 中文姓名 */
13
- export const chineseName = z.string().regex(_chineseName, { error: "应为中文姓名" });
14
- /** 手机机身码 */
15
- export const IMEI = z.string().regex(/^\d{15,17}$/, { error: "手机机身码格式错误" });
16
- const _ID = /^\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;
17
- /** 身份证号 */
18
- export const ID = z.string().regex(_ID, { error: "身份证号格式错误" });
19
- const _link = /^(((ht|f)tps?):\/\/)?(([\w-]+(\.[\w-]+)*\.[a-z]{2,6})|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/\S*)?$/;
20
- /** 链接 */
21
- export const link = z.string().regex(_link, { error: "链接格式错误" });
22
- const _linkPort = /^((ht|f)tps?:\/\/)?[\w-]+(\.[\w-]+)+:\d{1,5}\/?$/;
23
- /** 端口号网址 */
24
- export const linkPort = z.string().regex(_linkPort, { error: "网址格式错误" });
25
- const _USCC_S = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
26
- /** 统一社会信用代码 */
27
- export const USCC_S = z.string().regex(_USCC_S, { error: "统一社会信用代码格式错误" });
28
- const _USCC = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
29
- /** 统一社会信用代码 - 15位/18位/20位数字/字母 */
30
- export const USCC = z.string().regex(_USCC, { error: "统一社会信用代码格式错误" });
31
- const _thunder = /^thunderx?:\/\/[a-zA-Z\d]+=$/;
32
- /** 迅雷链接 */
33
- export const thunder = z.string().regex(_thunder, { error: "迅雷链接格式错误" });
34
- const _dirPathWindows = /^[a-z]:\\(?:\w+\\?)*$/i;
35
- /** windows 文件夹路径 */
36
- export const dirPathWindows = z.string().regex(_dirPathWindows, { error: "路径格式错误" });
37
- const _filePathWindows = /^[a-z]:\\(?:\w+\\)*\w+\.\w+$/i;
38
- /** windows 文件路径 */
39
- export const filePathWindows = z.string().regex(_filePathWindows, { error: "路径格式错误" });
40
- const _dirPathLinux = /^\/(?:[^/]+\/)*$/;
41
- /** linux 文件夹路径 */
42
- export const dirPathLinux = z.string().regex(_dirPathLinux, { error: "路径格式错误" });
43
- const _filePathLinux = /^\/(?:[^/]+\/)*[^/]+$/;
44
- /** linux 文件路径 */
45
- export const filePathLinux = z.string().regex(_filePathLinux, { error: "路径格式错误" });
46
- const _carCodeGreen = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))\d{4})|(\d{5}[DF]))$/;
47
- /** 车牌号 新能源 */
48
- export const carCodeGreen = z.string().regex(_carCodeGreen, { error: "车牌号格式错误" });
49
- const _carCodeNotGreen = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]$/;
50
- /** 车牌号 非新能源 */
51
- export const carCodeNotGreen = z.string().regex(_carCodeNotGreen, { error: "车牌号格式错误" });
52
- const _chinaProvince = /^安徽|澳门|北京|重庆|福建|甘肃|广东|广西|贵州|海南|河北|河南|黑龙江|湖北|湖南|吉林|江苏|江西|辽宁|内蒙古|宁夏|青海|山东|山西|陕西|上海|四川|台湾|天津|西藏|香港|新疆|云南|浙江$/;
53
- /** 中国省份 */
54
- export const chinaProvince = z.string().regex(_chinaProvince, { error: "应为中国省份" });
55
- const _nation = /^汉族|蒙古族|回族|藏族|维吾尔族|苗族|彝族|壮族|布依族|朝鲜族|满族|侗族|瑶族|白族|土家族|哈尼族|哈萨克族|傣族|黎族|傈僳族|佤族|畲族|高山族|拉祜族|水族|东乡族|纳西族|景颇族|柯尔克孜族|土族|达斡尔族|仫佬族|羌族|布朗族|撒拉族|毛南族|仡佬族|锡伯族|阿昌族|普米族|塔吉克族|怒族|乌孜别克族|俄罗斯族|鄂温克族|德昂族|保安族|裕固族|京族|塔塔尔族|独龙族|鄂伦春族|赫哲族|门巴族|珞巴族|基诺族|其它未识别民族|外国人入中国籍$/;
56
- /** 民族 */
57
- export const nation = z.string().regex(_nation, { error: "应为民族" });