@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,125 @@
1
+ /**
2
+ * 日志级别
3
+ */
4
+ declare enum LogLevel {
5
+ DEBUG = 0,
6
+ INFO = 1,
7
+ WARN = 2,
8
+ ERROR = 3,
9
+ NONE = 4
10
+ }
11
+ /**
12
+ * 日志条目
13
+ */
14
+ interface LogEntry {
15
+ level: LogLevel;
16
+ message: string;
17
+ timestamp: Date;
18
+ data?: any;
19
+ context?: string;
20
+ error?: Error;
21
+ }
22
+ /**
23
+ * 日志适配器接口
24
+ * 不同平台实现不同的日志输出方式
25
+ */
26
+ interface LoggerAdapter {
27
+ /**
28
+ * 输出日志
29
+ */
30
+ log(entry: LogEntry): void;
31
+ /**
32
+ * 批量输出日志(可选)
33
+ */
34
+ logBatch?(entries: LogEntry[]): void;
35
+ }
36
+ /**
37
+ * 日志配置
38
+ */
39
+ interface LoggerConfig {
40
+ /**
41
+ * 最小日志级别
42
+ * 只有大于等于此级别的日志才会输出
43
+ */
44
+ minLevel: LogLevel;
45
+ /**
46
+ * 是否启用时间戳
47
+ */
48
+ enableTimestamp?: boolean;
49
+ /**
50
+ * 是否启用上下文(模块名)
51
+ */
52
+ enableContext?: boolean;
53
+ /**
54
+ * 环境(development/production)
55
+ */
56
+ environment?: 'development' | 'production';
57
+ /**
58
+ * 自定义适配器
59
+ */
60
+ adapter?: LoggerAdapter;
61
+ }
62
+
63
+ /**
64
+ * 统一日志管理类
65
+ */
66
+ declare class Logger {
67
+ private config;
68
+ private adapter;
69
+ private context?;
70
+ constructor(config?: Partial<LoggerConfig>, context?: string);
71
+ /**
72
+ * 创建带上下文的子 Logger
73
+ */
74
+ createChild(context: string): Logger;
75
+ /**
76
+ * 调试日志
77
+ */
78
+ debug(message: string, data?: any): void;
79
+ /**
80
+ * 信息日志
81
+ */
82
+ info(message: string, data?: any): void;
83
+ /**
84
+ * 警告日志
85
+ */
86
+ warn(message: string, data?: any): void;
87
+ /**
88
+ * 错误日志
89
+ */
90
+ error(message: string, error?: Error | any): void;
91
+ /**
92
+ * 核心日志方法
93
+ */
94
+ private log;
95
+ /**
96
+ * 设置日志级别
97
+ */
98
+ setLevel(level: LogLevel): void;
99
+ /**
100
+ * 获取当前日志级别
101
+ */
102
+ getLevel(): LogLevel;
103
+ }
104
+ /**
105
+ * 默认全局 Logger 实例
106
+ */
107
+ declare const logger: Logger;
108
+ /**
109
+ * 创建带上下文的 Logger
110
+ */
111
+ declare function createLogger(context: string, config?: Partial<LoggerConfig>): Logger;
112
+
113
+ /**
114
+ * 控制台日志适配器
115
+ * 使用 console.info/warn/error 输出日志
116
+ */
117
+ declare class ConsoleLoggerAdapter implements LoggerAdapter {
118
+ private readonly colors;
119
+ log(entry: LogEntry): void;
120
+ private formatTimestamp;
121
+ private getLevelName;
122
+ private colorize;
123
+ }
124
+
125
+ export { ConsoleLoggerAdapter, type LogEntry, LogLevel, Logger, type LoggerAdapter, type LoggerConfig, createLogger, logger };
@@ -0,0 +1,125 @@
1
+ /**
2
+ * 日志级别
3
+ */
4
+ declare enum LogLevel {
5
+ DEBUG = 0,
6
+ INFO = 1,
7
+ WARN = 2,
8
+ ERROR = 3,
9
+ NONE = 4
10
+ }
11
+ /**
12
+ * 日志条目
13
+ */
14
+ interface LogEntry {
15
+ level: LogLevel;
16
+ message: string;
17
+ timestamp: Date;
18
+ data?: any;
19
+ context?: string;
20
+ error?: Error;
21
+ }
22
+ /**
23
+ * 日志适配器接口
24
+ * 不同平台实现不同的日志输出方式
25
+ */
26
+ interface LoggerAdapter {
27
+ /**
28
+ * 输出日志
29
+ */
30
+ log(entry: LogEntry): void;
31
+ /**
32
+ * 批量输出日志(可选)
33
+ */
34
+ logBatch?(entries: LogEntry[]): void;
35
+ }
36
+ /**
37
+ * 日志配置
38
+ */
39
+ interface LoggerConfig {
40
+ /**
41
+ * 最小日志级别
42
+ * 只有大于等于此级别的日志才会输出
43
+ */
44
+ minLevel: LogLevel;
45
+ /**
46
+ * 是否启用时间戳
47
+ */
48
+ enableTimestamp?: boolean;
49
+ /**
50
+ * 是否启用上下文(模块名)
51
+ */
52
+ enableContext?: boolean;
53
+ /**
54
+ * 环境(development/production)
55
+ */
56
+ environment?: 'development' | 'production';
57
+ /**
58
+ * 自定义适配器
59
+ */
60
+ adapter?: LoggerAdapter;
61
+ }
62
+
63
+ /**
64
+ * 统一日志管理类
65
+ */
66
+ declare class Logger {
67
+ private config;
68
+ private adapter;
69
+ private context?;
70
+ constructor(config?: Partial<LoggerConfig>, context?: string);
71
+ /**
72
+ * 创建带上下文的子 Logger
73
+ */
74
+ createChild(context: string): Logger;
75
+ /**
76
+ * 调试日志
77
+ */
78
+ debug(message: string, data?: any): void;
79
+ /**
80
+ * 信息日志
81
+ */
82
+ info(message: string, data?: any): void;
83
+ /**
84
+ * 警告日志
85
+ */
86
+ warn(message: string, data?: any): void;
87
+ /**
88
+ * 错误日志
89
+ */
90
+ error(message: string, error?: Error | any): void;
91
+ /**
92
+ * 核心日志方法
93
+ */
94
+ private log;
95
+ /**
96
+ * 设置日志级别
97
+ */
98
+ setLevel(level: LogLevel): void;
99
+ /**
100
+ * 获取当前日志级别
101
+ */
102
+ getLevel(): LogLevel;
103
+ }
104
+ /**
105
+ * 默认全局 Logger 实例
106
+ */
107
+ declare const logger: Logger;
108
+ /**
109
+ * 创建带上下文的 Logger
110
+ */
111
+ declare function createLogger(context: string, config?: Partial<LoggerConfig>): Logger;
112
+
113
+ /**
114
+ * 控制台日志适配器
115
+ * 使用 console.info/warn/error 输出日志
116
+ */
117
+ declare class ConsoleLoggerAdapter implements LoggerAdapter {
118
+ private readonly colors;
119
+ log(entry: LogEntry): void;
120
+ private formatTimestamp;
121
+ private getLevelName;
122
+ private colorize;
123
+ }
124
+
125
+ export { ConsoleLoggerAdapter, type LogEntry, LogLevel, Logger, type LoggerAdapter, type LoggerConfig, createLogger, logger };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var chunk6PRFP5EG_js = require('../chunk-6PRFP5EG.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "ConsoleLoggerAdapter", {
8
+ enumerable: true,
9
+ get: function () { return chunk6PRFP5EG_js.ConsoleLoggerAdapter; }
10
+ });
11
+ Object.defineProperty(exports, "LogLevel", {
12
+ enumerable: true,
13
+ get: function () { return chunk6PRFP5EG_js.LogLevel; }
14
+ });
15
+ Object.defineProperty(exports, "Logger", {
16
+ enumerable: true,
17
+ get: function () { return chunk6PRFP5EG_js.Logger; }
18
+ });
19
+ Object.defineProperty(exports, "createLogger", {
20
+ enumerable: true,
21
+ get: function () { return chunk6PRFP5EG_js.createLogger; }
22
+ });
23
+ Object.defineProperty(exports, "logger", {
24
+ enumerable: true,
25
+ get: function () { return chunk6PRFP5EG_js.logger; }
26
+ });
27
+ //# sourceMappingURL=index.js.map
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,3 @@
1
+ export { ConsoleLoggerAdapter, LogLevel, Logger, createLogger, logger } from '../chunk-KQGP6BTS.mjs';
2
+ //# sourceMappingURL=index.mjs.map
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,20 @@
1
+ import { S as StorageAdapter } from '../types-BaZccpvk.mjs';
2
+ export { a as StorageChangeEvent } from '../types-BaZccpvk.mjs';
3
+
4
+ /**
5
+ * Web 平台存储适配器 (localStorage)
6
+ */
7
+
8
+ declare class WebStorageAdapter implements StorageAdapter {
9
+ getItem(key: string): Promise<string | null>;
10
+ setItem(key: string, value: string): Promise<void>;
11
+ removeItem(key: string): Promise<void>;
12
+ clear(): Promise<void>;
13
+ addChangeListener(callback: (key: string, value: string | null) => void): () => void;
14
+ /**
15
+ * 触发自定义事件,通知同标签页的其他组件
16
+ */
17
+ dispatchChange(key: string, value: string | null): void;
18
+ }
19
+
20
+ export { StorageAdapter, WebStorageAdapter };
@@ -0,0 +1,20 @@
1
+ import { S as StorageAdapter } from '../types-BaZccpvk.js';
2
+ export { a as StorageChangeEvent } from '../types-BaZccpvk.js';
3
+
4
+ /**
5
+ * Web 平台存储适配器 (localStorage)
6
+ */
7
+
8
+ declare class WebStorageAdapter implements StorageAdapter {
9
+ getItem(key: string): Promise<string | null>;
10
+ setItem(key: string, value: string): Promise<void>;
11
+ removeItem(key: string): Promise<void>;
12
+ clear(): Promise<void>;
13
+ addChangeListener(callback: (key: string, value: string | null) => void): () => void;
14
+ /**
15
+ * 触发自定义事件,通知同标签页的其他组件
16
+ */
17
+ dispatchChange(key: string, value: string | null): void;
18
+ }
19
+
20
+ export { StorageAdapter, WebStorageAdapter };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var chunk4JTIYLS6_js = require('../chunk-4JTIYLS6.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "WebStorageAdapter", {
8
+ enumerable: true,
9
+ get: function () { return chunk4JTIYLS6_js.WebStorageAdapter; }
10
+ });
11
+ //# sourceMappingURL=index.js.map
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,3 @@
1
+ export { WebStorageAdapter } from '../chunk-M7CA3DTF.mjs';
2
+ //# sourceMappingURL=index.mjs.map
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 存储适配器类型定义
3
+ */
4
+ /**
5
+ * 存储适配器接口
6
+ * 用于抽象不同平台的本地存储实现
7
+ */
8
+ interface StorageAdapter {
9
+ /**
10
+ * 获取存储的值
11
+ * @param key 存储键
12
+ * @returns 存储的值,不存在则返回 null
13
+ */
14
+ getItem(key: string): Promise<string | null>;
15
+ /**
16
+ * 设置存储的值
17
+ * @param key 存储键
18
+ * @param value 要存储的值
19
+ */
20
+ setItem(key: string, value: string): Promise<void>;
21
+ /**
22
+ * 删除存储的值
23
+ * @param key 存储键
24
+ */
25
+ removeItem(key: string): Promise<void>;
26
+ /**
27
+ * 清空所有存储(可选)
28
+ */
29
+ clear?(): Promise<void>;
30
+ /**
31
+ * 监听存储变化(可选,部分平台支持)
32
+ */
33
+ addChangeListener?(callback: (key: string, value: string | null) => void): () => void;
34
+ /**
35
+ * 移除存储变化监听器(可选)
36
+ */
37
+ removeChangeListener?(callback: (key: string, value: string | null) => void): void;
38
+ }
39
+ /**
40
+ * 存储事件
41
+ */
42
+ interface StorageChangeEvent {
43
+ key: string;
44
+ value: any;
45
+ oldValue?: any;
46
+ }
47
+
48
+ export type { StorageAdapter as S, StorageChangeEvent as a };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 存储适配器类型定义
3
+ */
4
+ /**
5
+ * 存储适配器接口
6
+ * 用于抽象不同平台的本地存储实现
7
+ */
8
+ interface StorageAdapter {
9
+ /**
10
+ * 获取存储的值
11
+ * @param key 存储键
12
+ * @returns 存储的值,不存在则返回 null
13
+ */
14
+ getItem(key: string): Promise<string | null>;
15
+ /**
16
+ * 设置存储的值
17
+ * @param key 存储键
18
+ * @param value 要存储的值
19
+ */
20
+ setItem(key: string, value: string): Promise<void>;
21
+ /**
22
+ * 删除存储的值
23
+ * @param key 存储键
24
+ */
25
+ removeItem(key: string): Promise<void>;
26
+ /**
27
+ * 清空所有存储(可选)
28
+ */
29
+ clear?(): Promise<void>;
30
+ /**
31
+ * 监听存储变化(可选,部分平台支持)
32
+ */
33
+ addChangeListener?(callback: (key: string, value: string | null) => void): () => void;
34
+ /**
35
+ * 移除存储变化监听器(可选)
36
+ */
37
+ removeChangeListener?(callback: (key: string, value: string | null) => void): void;
38
+ }
39
+ /**
40
+ * 存储事件
41
+ */
42
+ interface StorageChangeEvent {
43
+ key: string;
44
+ value: any;
45
+ oldValue?: any;
46
+ }
47
+
48
+ export type { StorageAdapter as S, StorageChangeEvent as a };
@@ -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 };