@qhr123/sa2kit 0.1.1

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 (51) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +113 -0
  3. package/dist/chunk-3R73CUAY.js +80 -0
  4. package/dist/chunk-3R73CUAY.js.map +1 -0
  5. package/dist/chunk-4JTIYLS6.js +88 -0
  6. package/dist/chunk-4JTIYLS6.js.map +1 -0
  7. package/dist/chunk-6PRFP5EG.js +171 -0
  8. package/dist/chunk-6PRFP5EG.js.map +1 -0
  9. package/dist/chunk-C7VOMO3L.mjs +77 -0
  10. package/dist/chunk-C7VOMO3L.mjs.map +1 -0
  11. package/dist/chunk-KQGP6BTS.mjs +165 -0
  12. package/dist/chunk-KQGP6BTS.mjs.map +1 -0
  13. package/dist/chunk-M7CA3DTF.mjs +86 -0
  14. package/dist/chunk-M7CA3DTF.mjs.map +1 -0
  15. package/dist/chunk-WFWG4UZF.mjs +334 -0
  16. package/dist/chunk-WFWG4UZF.mjs.map +1 -0
  17. package/dist/chunk-WO3H4BMN.js +342 -0
  18. package/dist/chunk-WO3H4BMN.js.map +1 -0
  19. package/dist/hooks/index.d.mts +30 -0
  20. package/dist/hooks/index.d.ts +30 -0
  21. package/dist/hooks/index.js +17 -0
  22. package/dist/hooks/index.js.map +1 -0
  23. package/dist/hooks/index.mjs +4 -0
  24. package/dist/hooks/index.mjs.map +1 -0
  25. package/dist/index.d.mts +5 -0
  26. package/dist/index.d.ts +5 -0
  27. package/dist/index.js +71 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +6 -0
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/logger/index.d.mts +125 -0
  32. package/dist/logger/index.d.ts +125 -0
  33. package/dist/logger/index.js +28 -0
  34. package/dist/logger/index.js.map +1 -0
  35. package/dist/logger/index.mjs +3 -0
  36. package/dist/logger/index.mjs.map +1 -0
  37. package/dist/storage/index.d.mts +20 -0
  38. package/dist/storage/index.d.ts +20 -0
  39. package/dist/storage/index.js +12 -0
  40. package/dist/storage/index.js.map +1 -0
  41. package/dist/storage/index.mjs +3 -0
  42. package/dist/storage/index.mjs.map +1 -0
  43. package/dist/types-BaZccpvk.d.mts +48 -0
  44. package/dist/types-BaZccpvk.d.ts +48 -0
  45. package/dist/utils/index.d.mts +170 -0
  46. package/dist/utils/index.d.ts +170 -0
  47. package/dist/utils/index.js +37 -0
  48. package/dist/utils/index.js.map +1 -0
  49. package/dist/utils/index.mjs +4 -0
  50. package/dist/utils/index.mjs.map +1 -0
  51. package/package.json +106 -0
@@ -0,0 +1,170 @@
1
+ /**
2
+ * 时间格式化工具
3
+ */
4
+ declare const formatTime: {
5
+ /**
6
+ * 将秒数转换为 MM:SS 格式
7
+ */
8
+ toMinutesSeconds(seconds: number): string;
9
+ /**
10
+ * 将秒数转换为 HH:MM:SS 格式
11
+ */
12
+ toHoursMinutesSeconds(seconds: number): string;
13
+ /**
14
+ * 格式化日期为用户友好的格式
15
+ */
16
+ formatDate(date: string | Date, locale?: string): string;
17
+ };
18
+
19
+ /**
20
+ * 验证工具
21
+ */
22
+ declare const validators: {
23
+ /**
24
+ * 验证邮箱格式
25
+ */
26
+ isValidEmail(email: string): boolean;
27
+ /**
28
+ * 验证密码强度
29
+ */
30
+ isValidPassword(password: string): {
31
+ isValid: boolean;
32
+ errors: string[];
33
+ };
34
+ /**
35
+ * 验证用户名格式
36
+ */
37
+ isValidUsername(username: string): boolean;
38
+ /**
39
+ * 验证文件大小
40
+ */
41
+ isValidFileSize(size: number, maxSize: number): boolean;
42
+ /**
43
+ * 验证文件类型
44
+ */
45
+ isValidFileType(type: string, supportedTypes: string[]): boolean;
46
+ /**
47
+ * 验证 URL 格式
48
+ */
49
+ isValidUrl(url: string): boolean;
50
+ };
51
+
52
+ /**
53
+ * 文件处理工具
54
+ */
55
+ declare const fileUtils: {
56
+ /**
57
+ * 格式化文件大小
58
+ */
59
+ formatFileSize(bytes: number): string;
60
+ /**
61
+ * 获取文件扩展名
62
+ */
63
+ getFileExtension(filename: string): string;
64
+ /**
65
+ * 生成唯一文件名
66
+ */
67
+ generateUniqueFileName(originalName: string): string;
68
+ /**
69
+ * 验证文件名是否有效
70
+ */
71
+ isValidFilename(filename: string): boolean;
72
+ };
73
+
74
+ /**
75
+ * 数组和对象工具
76
+ */
77
+ declare const arrayUtils: {
78
+ /**
79
+ * 数组去重
80
+ */
81
+ unique<T>(array: T[]): T[];
82
+ /**
83
+ * 数组分组
84
+ */
85
+ groupBy<T>(array: T[], key: keyof T): Record<string, T[]>;
86
+ /**
87
+ * 数组分页
88
+ */
89
+ paginate<T>(array: T[], page: number, limit: number): {
90
+ data: T[];
91
+ total: number;
92
+ page: number;
93
+ pages: number;
94
+ hasNext: boolean;
95
+ hasPrev: boolean;
96
+ };
97
+ /**
98
+ * 数组随机排序
99
+ */
100
+ shuffle<T>(array: T[]): T[];
101
+ };
102
+
103
+ /**
104
+ * 字符串工具
105
+ */
106
+ declare const stringUtils: {
107
+ /**
108
+ * 截断文本
109
+ */
110
+ truncate(text: string, length: number, suffix?: string): string;
111
+ /**
112
+ * 首字母大写
113
+ */
114
+ capitalize(text: string): string;
115
+ /**
116
+ * 驼峰转下划线
117
+ */
118
+ camelToSnake(text: string): string;
119
+ /**
120
+ * 下划线转驼峰
121
+ */
122
+ snakeToCamel(text: string): string;
123
+ /**
124
+ * 生成随机字符串
125
+ */
126
+ generateRandom(length: number): string;
127
+ };
128
+
129
+ /**
130
+ * 调试工具
131
+ */
132
+ declare const debugUtils: {
133
+ /**
134
+ * 安全的 JSON 序列化
135
+ */
136
+ safeStringify(obj: any): string;
137
+ /**
138
+ * 性能计时器
139
+ */
140
+ createTimer(label?: string): {
141
+ end: () => number;
142
+ };
143
+ /**
144
+ * 内存使用情况(仅在 Node.js 环境)
145
+ */
146
+ getMemoryUsage(): Record<string, string> | null;
147
+ };
148
+
149
+ /**
150
+ * 错误处理工具
151
+ */
152
+ declare const errorUtils: {
153
+ /**
154
+ * 创建标准化的错误对象
155
+ */
156
+ createError(code: string, message: string, details?: any): Error & {
157
+ code: string;
158
+ details?: any;
159
+ };
160
+ /**
161
+ * 安全的错误信息提取
162
+ */
163
+ extractErrorMessage(error: unknown): string;
164
+ /**
165
+ * 错误重试机制
166
+ */
167
+ retry<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T>;
168
+ };
169
+
170
+ export { arrayUtils, debugUtils, errorUtils, fileUtils, formatTime, stringUtils, validators };
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ var chunkWO3H4BMN_js = require('../chunk-WO3H4BMN.js');
4
+ require('../chunk-6PRFP5EG.js');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "arrayUtils", {
9
+ enumerable: true,
10
+ get: function () { return chunkWO3H4BMN_js.arrayUtils; }
11
+ });
12
+ Object.defineProperty(exports, "debugUtils", {
13
+ enumerable: true,
14
+ get: function () { return chunkWO3H4BMN_js.debugUtils; }
15
+ });
16
+ Object.defineProperty(exports, "errorUtils", {
17
+ enumerable: true,
18
+ get: function () { return chunkWO3H4BMN_js.errorUtils; }
19
+ });
20
+ Object.defineProperty(exports, "fileUtils", {
21
+ enumerable: true,
22
+ get: function () { return chunkWO3H4BMN_js.fileUtils; }
23
+ });
24
+ Object.defineProperty(exports, "formatTime", {
25
+ enumerable: true,
26
+ get: function () { return chunkWO3H4BMN_js.formatTime; }
27
+ });
28
+ Object.defineProperty(exports, "stringUtils", {
29
+ enumerable: true,
30
+ get: function () { return chunkWO3H4BMN_js.stringUtils; }
31
+ });
32
+ Object.defineProperty(exports, "validators", {
33
+ enumerable: true,
34
+ get: function () { return chunkWO3H4BMN_js.validators; }
35
+ });
36
+ //# sourceMappingURL=index.js.map
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ export { arrayUtils, debugUtils, errorUtils, fileUtils, formatTime, stringUtils, validators } from '../chunk-WFWG4UZF.mjs';
2
+ import '../chunk-KQGP6BTS.mjs';
3
+ //# sourceMappingURL=index.mjs.map
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@qhr123/sa2kit",
3
+ "version": "0.1.1",
4
+ "description": "A modern, type-safe React utility library with cross-platform support",
5
+ "keywords": [
6
+ "react",
7
+ "typescript",
8
+ "utils",
9
+ "logger",
10
+ "storage",
11
+ "hooks",
12
+ "cross-platform"
13
+ ],
14
+ "author": "qxdqhr",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/qxdqhr/sa2kit"
19
+ },
20
+ "homepage": "https://github.com/qxdqhr/sa2kit#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/qxdqhr/sa2kit/issues"
23
+ },
24
+ "main": "./dist/index.js",
25
+ "module": "./dist/index.mjs",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.mjs",
31
+ "require": "./dist/index.js"
32
+ },
33
+ "./logger": {
34
+ "types": "./dist/logger/index.d.ts",
35
+ "import": "./dist/logger/index.mjs",
36
+ "require": "./dist/logger/index.js"
37
+ },
38
+ "./utils": {
39
+ "types": "./dist/utils/index.d.ts",
40
+ "import": "./dist/utils/index.mjs",
41
+ "require": "./dist/utils/index.js"
42
+ },
43
+ "./hooks": {
44
+ "types": "./dist/hooks/index.d.ts",
45
+ "import": "./dist/hooks/index.mjs",
46
+ "require": "./dist/hooks/index.js"
47
+ },
48
+ "./storage": {
49
+ "types": "./dist/storage/index.d.ts",
50
+ "import": "./dist/storage/index.mjs",
51
+ "require": "./dist/storage/index.js"
52
+ }
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "README.md",
57
+ "LICENSE"
58
+ ],
59
+ "scripts": {
60
+ "dev": "tsup --watch",
61
+ "build": "tsup",
62
+ "type-check": "tsc --noEmit",
63
+ "lint": "eslint src --ext .ts,.tsx",
64
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
65
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
66
+ "format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
67
+ "test": "vitest run",
68
+ "test:watch": "vitest",
69
+ "test:ui": "vitest --ui",
70
+ "test:coverage": "vitest --coverage",
71
+ "clean": "rm -rf dist",
72
+ "prepublishOnly": "pnpm run build && pnpm run test",
73
+ "publish:beta": "npm publish --tag beta --access public",
74
+ "publish:latest": "npm publish --access public"
75
+ },
76
+ "peerDependencies": {
77
+ "react": ">=18.0.0"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "react": {
81
+ "optional": true
82
+ }
83
+ },
84
+ "devDependencies": {
85
+ "@types/node": "^20.0.0",
86
+ "@types/react": "^18.2.0",
87
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
88
+ "@typescript-eslint/parser": "^6.19.0",
89
+ "@vitest/ui": "^1.2.0",
90
+ "@testing-library/react": "^14.0.0",
91
+ "eslint": "^8.56.0",
92
+ "eslint-config-prettier": "^9.1.0",
93
+ "eslint-plugin-react": "^7.33.2",
94
+ "eslint-plugin-react-hooks": "^4.6.0",
95
+ "jsdom": "^23.0.0",
96
+ "prettier": "^3.1.1",
97
+ "tsup": "^8.0.0",
98
+ "typescript": "^5.3.3",
99
+ "vitest": "^1.2.0"
100
+ },
101
+ "engines": {
102
+ "node": ">=18.0.0"
103
+ },
104
+ "packageManager": "pnpm@9.15.2"
105
+ }
106
+