@meng-xi/vite-plugin 0.1.4 → 0.1.5
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.
- package/README-en.md +8 -8
- package/README.md +7 -7
- package/dist/common/format/index.cjs +1 -1
- package/dist/common/format/index.d.cts +1 -130
- package/dist/common/format/index.d.mts +1 -130
- package/dist/common/format/index.d.ts +1 -130
- package/dist/common/format/index.mjs +1 -1
- package/dist/common/fs/index.cjs +1 -1
- package/dist/common/fs/index.d.cts +1 -89
- package/dist/common/fs/index.d.mts +1 -89
- package/dist/common/fs/index.d.ts +1 -89
- package/dist/common/fs/index.mjs +1 -1
- package/dist/common/html/index.cjs +2 -2
- package/dist/common/html/index.d.cts +4 -315
- package/dist/common/html/index.d.mts +4 -315
- package/dist/common/html/index.d.ts +4 -315
- package/dist/common/html/index.mjs +2 -2
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +7 -11
- package/dist/common/index.d.mts +7 -11
- package/dist/common/index.d.ts +7 -11
- package/dist/common/index.mjs +1 -1
- package/dist/common/script/index.cjs +1 -1
- package/dist/common/script/index.d.cts +1 -44
- package/dist/common/script/index.d.mts +1 -44
- package/dist/common/script/index.d.ts +1 -44
- package/dist/common/script/index.mjs +1 -1
- package/dist/common/ui/index.cjs +1 -1
- package/dist/common/ui/index.d.cts +1 -111
- package/dist/common/ui/index.d.mts +1 -111
- package/dist/common/ui/index.d.ts +1 -111
- package/dist/common/ui/index.mjs +1 -1
- package/dist/common/validation/index.cjs +1 -1
- package/dist/common/validation/index.d.cts +2 -80
- package/dist/common/validation/index.d.mts +2 -80
- package/dist/common/validation/index.d.ts +2 -80
- package/dist/common/validation/index.mjs +1 -1
- package/dist/factory/index.cjs +1 -1
- package/dist/factory/index.d.cts +1 -1
- package/dist/factory/index.d.mts +1 -1
- package/dist/factory/index.d.ts +1 -1
- package/dist/factory/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -12
- package/dist/index.d.mts +10 -12
- package/dist/index.d.ts +10 -12
- package/dist/index.mjs +1 -1
- package/dist/logger/index.d.cts +92 -1
- package/dist/logger/index.d.mts +92 -1
- package/dist/logger/index.d.ts +92 -1
- package/dist/plugins/autoImport/index.cjs +17 -0
- package/dist/plugins/autoImport/index.d.cts +291 -0
- package/dist/plugins/autoImport/index.d.mts +291 -0
- package/dist/plugins/autoImport/index.d.ts +291 -0
- package/dist/plugins/autoImport/index.mjs +17 -0
- package/dist/plugins/buildProgress/index.cjs +2 -2
- package/dist/plugins/buildProgress/index.d.cts +1 -1
- package/dist/plugins/buildProgress/index.d.mts +1 -1
- package/dist/plugins/buildProgress/index.d.ts +1 -1
- package/dist/plugins/buildProgress/index.mjs +2 -2
- package/dist/plugins/bundleAnalyzer/index.cjs +11 -11
- package/dist/plugins/bundleAnalyzer/index.d.cts +1 -1
- package/dist/plugins/bundleAnalyzer/index.d.mts +1 -1
- package/dist/plugins/bundleAnalyzer/index.d.ts +1 -1
- package/dist/plugins/bundleAnalyzer/index.mjs +18 -18
- package/dist/plugins/compressAssets/index.cjs +1 -1
- package/dist/plugins/compressAssets/index.d.cts +1 -1
- package/dist/plugins/compressAssets/index.d.mts +1 -1
- package/dist/plugins/compressAssets/index.d.ts +1 -1
- package/dist/plugins/compressAssets/index.mjs +1 -1
- package/dist/plugins/copyFile/index.cjs +1 -1
- package/dist/plugins/copyFile/index.d.cts +1 -1
- package/dist/plugins/copyFile/index.d.mts +1 -1
- package/dist/plugins/copyFile/index.d.ts +1 -1
- package/dist/plugins/copyFile/index.mjs +1 -1
- package/dist/plugins/envGuard/index.cjs +11 -11
- package/dist/plugins/envGuard/index.d.cts +101 -2
- package/dist/plugins/envGuard/index.d.mts +101 -2
- package/dist/plugins/envGuard/index.d.ts +101 -2
- package/dist/plugins/envGuard/index.mjs +8 -8
- package/dist/plugins/faviconManager/index.cjs +1 -1
- package/dist/plugins/faviconManager/index.d.cts +1 -1
- package/dist/plugins/faviconManager/index.d.mts +1 -1
- package/dist/plugins/faviconManager/index.d.ts +1 -1
- package/dist/plugins/faviconManager/index.mjs +1 -1
- package/dist/plugins/generateRouter/index.cjs +4 -4
- package/dist/plugins/generateRouter/index.d.cts +1 -1
- package/dist/plugins/generateRouter/index.d.mts +1 -1
- package/dist/plugins/generateRouter/index.d.ts +1 -1
- package/dist/plugins/generateRouter/index.mjs +4 -4
- package/dist/plugins/generateVersion/index.cjs +1 -1
- package/dist/plugins/generateVersion/index.d.cts +1 -1
- package/dist/plugins/generateVersion/index.d.mts +1 -1
- package/dist/plugins/generateVersion/index.d.ts +1 -1
- package/dist/plugins/generateVersion/index.mjs +1 -1
- package/dist/plugins/htmlInject/index.cjs +7 -1
- package/dist/plugins/htmlInject/index.d.cts +2 -2
- package/dist/plugins/htmlInject/index.d.mts +2 -2
- package/dist/plugins/htmlInject/index.d.ts +2 -2
- package/dist/plugins/htmlInject/index.mjs +7 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +3 -3
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.mjs +1 -1
- package/dist/plugins/loadingManager/index.cjs +26 -26
- package/dist/plugins/loadingManager/index.d.cts +1 -1
- package/dist/plugins/loadingManager/index.d.mts +1 -1
- package/dist/plugins/loadingManager/index.d.ts +1 -1
- package/dist/plugins/loadingManager/index.mjs +11 -11
- package/dist/plugins/versionUpdateChecker/index.cjs +2 -2
- package/dist/plugins/versionUpdateChecker/index.d.cts +1 -1
- package/dist/plugins/versionUpdateChecker/index.d.mts +1 -1
- package/dist/plugins/versionUpdateChecker/index.d.ts +1 -1
- package/dist/plugins/versionUpdateChecker/index.mjs +3 -3
- package/dist/shared/vite-plugin.B8FuZce1.d.cts +45 -0
- package/dist/shared/vite-plugin.B8FuZce1.d.mts +45 -0
- package/dist/shared/vite-plugin.B8FuZce1.d.ts +45 -0
- package/dist/shared/{vite-plugin.FfJ-Wwfu.d.cts → vite-plugin.BI9taN75.d.cts} +1 -22
- package/dist/shared/{vite-plugin.FfJ-Wwfu.d.mts → vite-plugin.BI9taN75.d.mts} +1 -22
- package/dist/shared/{vite-plugin.FfJ-Wwfu.d.ts → vite-plugin.BI9taN75.d.ts} +1 -22
- package/dist/shared/vite-plugin.BPFqtmWa.mjs +1 -0
- package/dist/shared/vite-plugin.CnOy46d3.cjs +1 -0
- package/package.json +6 -16
- package/dist/common/compress/index.cjs +0 -1
- package/dist/common/compress/index.d.cts +0 -23
- package/dist/common/compress/index.d.mts +0 -23
- package/dist/common/compress/index.d.ts +0 -23
- package/dist/common/compress/index.mjs +0 -1
- package/dist/common/object/index.cjs +0 -1
- package/dist/common/object/index.d.cts +0 -30
- package/dist/common/object/index.d.mts +0 -30
- package/dist/common/object/index.d.ts +0 -30
- package/dist/common/object/index.mjs +0 -1
- package/dist/common/path/index.cjs +0 -1
- package/dist/common/path/index.d.cts +0 -22
- package/dist/common/path/index.d.mts +0 -22
- package/dist/common/path/index.d.ts +0 -22
- package/dist/common/path/index.mjs +0 -1
- package/dist/shared/vite-plugin.BCuhU1au.mjs +0 -7
- package/dist/shared/vite-plugin.BrI73DHA.cjs +0 -7
- package/dist/shared/vite-plugin.CLr0ttuO.d.cts +0 -135
- package/dist/shared/vite-plugin.CLr0ttuO.d.mts +0 -135
- package/dist/shared/vite-plugin.CLr0ttuO.d.ts +0 -135
- package/dist/shared/vite-plugin.CmtcnItg.d.cts +0 -261
- package/dist/shared/vite-plugin.CmtcnItg.d.mts +0 -261
- package/dist/shared/vite-plugin.CmtcnItg.d.ts +0 -261
- package/dist/shared/vite-plugin.DnFDPjNf.mjs +0 -1
- package/dist/shared/vite-plugin.Dumot0up.mjs +0 -1
- package/dist/shared/vite-plugin.soT9a-KD.cjs +0 -1
- package/dist/shared/vite-plugin.vwox4bU0.cjs +0 -1
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 终端 UI 工具模块
|
|
3
|
-
*
|
|
4
|
-
* @module common/ui/terminal
|
|
5
|
-
* @description 提供终端 ANSI 转义码处理、Spinner 动画帧和字符串清理等工具函数,
|
|
6
|
-
* 用于在终端中实现彩色输出、光标控制和进度动画等功能。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Spinner 动画帧序列
|
|
10
|
-
*
|
|
11
|
-
* @description 根据操作系统平台自动选择合适的动画帧:
|
|
12
|
-
* - Windows:使用 ASCII 字符 `|`, `/`, `-`, `\`,确保在传统终端中正常显示
|
|
13
|
-
* - 其他平台:使用 Unicode Braille 字符 `⠋`-`⠏`,视觉效果更流畅
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* let frameIndex = 0
|
|
18
|
-
* setInterval(() => {
|
|
19
|
-
* process.stdout.write(`\r${SPINNER_FRAMES[frameIndex]} Loading...`)
|
|
20
|
-
* frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length
|
|
21
|
-
* }, 80)
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare const SPINNER_FRAMES: string[];
|
|
25
1
|
/**
|
|
26
2
|
* ANSI 转义码工具集
|
|
27
|
-
*
|
|
28
|
-
* @description 提供常用的终端 ANSI 转义码常量和彩色文本包装函数,
|
|
29
|
-
* 用于在终端中实现文本着色、光标控制和行清理等操作。
|
|
30
|
-
*
|
|
31
|
-
* @property reset - 将光标重置到行首(`\x1b[0G`)
|
|
32
|
-
* @property clearLine - 清除当前行内容(`\x1b[2K`)
|
|
33
|
-
* @property hideCursor - 隐藏终端光标(`\x1b[?25l`)
|
|
34
|
-
* @property showCursor - 显示终端光标(`\x1b[?25h`)
|
|
35
|
-
* @property green - 将文本包装为绿色
|
|
36
|
-
* @property cyan - 将文本包装为青色
|
|
37
|
-
* @property gray - 将文本包装为灰色
|
|
38
|
-
* @property bold - 将文本包装为粗体
|
|
39
|
-
* @property red - 将文本包装为红色
|
|
40
|
-
* @property yellow - 将文本包装为黄色
|
|
41
|
-
* @property magenta - 将文本包装为品红色
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* // 彩色输出
|
|
46
|
-
* console.log(ANSI.green('✓') + ' 构建成功')
|
|
47
|
-
* console.log(ANSI.red('✗') + ' 构建失败')
|
|
48
|
-
* console.log(ANSI.bold(ANSI.cyan('信息:')) + ' 正在处理...')
|
|
49
|
-
*
|
|
50
|
-
* // 光标控制
|
|
51
|
-
* process.stdout.write(ANSI.hideCursor)
|
|
52
|
-
* // ... 动画逻辑 ...
|
|
53
|
-
* process.stdout.write(ANSI.showCursor)
|
|
54
|
-
*
|
|
55
|
-
* // 行清理与重写
|
|
56
|
-
* process.stdout.write(ANSI.clearLine + ANSI.reset + ANSI.green('完成'))
|
|
57
|
-
* ```
|
|
58
3
|
*/
|
|
59
4
|
declare const ANSI: {
|
|
60
5
|
/** 将光标重置到行首 */
|
|
@@ -65,68 +10,13 @@ declare const ANSI: {
|
|
|
65
10
|
hideCursor: string;
|
|
66
11
|
/** 显示终端光标 */
|
|
67
12
|
showCursor: string;
|
|
68
|
-
/**
|
|
69
|
-
* 将文本包装为绿色
|
|
70
|
-
* @param t - 要着色的文本
|
|
71
|
-
* @returns 包含绿色 ANSI 转义码的字符串
|
|
72
|
-
*/
|
|
73
13
|
green: (t: string) => string;
|
|
74
|
-
/**
|
|
75
|
-
* 将文本包装为青色
|
|
76
|
-
* @param t - 要着色的文本
|
|
77
|
-
* @returns 包含青色 ANSI 转义码的字符串
|
|
78
|
-
*/
|
|
79
14
|
cyan: (t: string) => string;
|
|
80
|
-
/**
|
|
81
|
-
* 将文本包装为灰色
|
|
82
|
-
* @param t - 要着色的文本
|
|
83
|
-
* @returns 包含灰色 ANSI 转义码的字符串
|
|
84
|
-
*/
|
|
85
15
|
gray: (t: string) => string;
|
|
86
|
-
/**
|
|
87
|
-
* 将文本包装为粗体
|
|
88
|
-
* @param t - 要加粗的文本
|
|
89
|
-
* @returns 包含粗体 ANSI 转义码的字符串
|
|
90
|
-
*/
|
|
91
16
|
bold: (t: string) => string;
|
|
92
|
-
/**
|
|
93
|
-
* 将文本包装为红色
|
|
94
|
-
* @param t - 要着色的文本
|
|
95
|
-
* @returns 包含红色 ANSI 转义码的字符串
|
|
96
|
-
*/
|
|
97
17
|
red: (t: string) => string;
|
|
98
|
-
/**
|
|
99
|
-
* 将文本包装为黄色
|
|
100
|
-
* @param t - 要着色的文本
|
|
101
|
-
* @returns 包含黄色 ANSI 转义码的字符串
|
|
102
|
-
*/
|
|
103
18
|
yellow: (t: string) => string;
|
|
104
|
-
/**
|
|
105
|
-
* 将文本包装为品红色
|
|
106
|
-
* @param t - 要着色的文本
|
|
107
|
-
* @returns 包含品红色 ANSI 转义码的字符串
|
|
108
|
-
*/
|
|
109
19
|
magenta: (t: string) => string;
|
|
110
20
|
};
|
|
111
|
-
/**
|
|
112
|
-
* 移除字符串中的所有 ANSI 转义码
|
|
113
|
-
*
|
|
114
|
-
* @param str - 可能包含 ANSI 转义码的字符串
|
|
115
|
-
* @returns 不包含任何 ANSI 转义码的纯文本字符串
|
|
116
|
-
*
|
|
117
|
-
* @description 使用正则表达式匹配并移除所有形如 `\x1b[...m` 的 ANSI 转义序列,
|
|
118
|
-
* 常用于计算文本实际显示宽度或将彩色输出转为纯文本。
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* const colored = ANSI.green('hello') + ' ' + ANSI.red('world')
|
|
123
|
-
* stripAnsi(colored) // 'hello world'
|
|
124
|
-
*
|
|
125
|
-
* // 计算终端显示宽度
|
|
126
|
-
* const text = ANSI.bold(ANSI.cyan('状态:')) + ' 完成'
|
|
127
|
-
* stripAnsi(text).length // 7 (不含转义码的实际字符数)
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
declare function stripAnsi(str: string): string;
|
|
131
21
|
|
|
132
|
-
export { ANSI
|
|
22
|
+
export { ANSI };
|
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 终端 UI 工具模块
|
|
3
|
-
*
|
|
4
|
-
* @module common/ui/terminal
|
|
5
|
-
* @description 提供终端 ANSI 转义码处理、Spinner 动画帧和字符串清理等工具函数,
|
|
6
|
-
* 用于在终端中实现彩色输出、光标控制和进度动画等功能。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Spinner 动画帧序列
|
|
10
|
-
*
|
|
11
|
-
* @description 根据操作系统平台自动选择合适的动画帧:
|
|
12
|
-
* - Windows:使用 ASCII 字符 `|`, `/`, `-`, `\`,确保在传统终端中正常显示
|
|
13
|
-
* - 其他平台:使用 Unicode Braille 字符 `⠋`-`⠏`,视觉效果更流畅
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* let frameIndex = 0
|
|
18
|
-
* setInterval(() => {
|
|
19
|
-
* process.stdout.write(`\r${SPINNER_FRAMES[frameIndex]} Loading...`)
|
|
20
|
-
* frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length
|
|
21
|
-
* }, 80)
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare const SPINNER_FRAMES: string[];
|
|
25
1
|
/**
|
|
26
2
|
* ANSI 转义码工具集
|
|
27
|
-
*
|
|
28
|
-
* @description 提供常用的终端 ANSI 转义码常量和彩色文本包装函数,
|
|
29
|
-
* 用于在终端中实现文本着色、光标控制和行清理等操作。
|
|
30
|
-
*
|
|
31
|
-
* @property reset - 将光标重置到行首(`\x1b[0G`)
|
|
32
|
-
* @property clearLine - 清除当前行内容(`\x1b[2K`)
|
|
33
|
-
* @property hideCursor - 隐藏终端光标(`\x1b[?25l`)
|
|
34
|
-
* @property showCursor - 显示终端光标(`\x1b[?25h`)
|
|
35
|
-
* @property green - 将文本包装为绿色
|
|
36
|
-
* @property cyan - 将文本包装为青色
|
|
37
|
-
* @property gray - 将文本包装为灰色
|
|
38
|
-
* @property bold - 将文本包装为粗体
|
|
39
|
-
* @property red - 将文本包装为红色
|
|
40
|
-
* @property yellow - 将文本包装为黄色
|
|
41
|
-
* @property magenta - 将文本包装为品红色
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* // 彩色输出
|
|
46
|
-
* console.log(ANSI.green('✓') + ' 构建成功')
|
|
47
|
-
* console.log(ANSI.red('✗') + ' 构建失败')
|
|
48
|
-
* console.log(ANSI.bold(ANSI.cyan('信息:')) + ' 正在处理...')
|
|
49
|
-
*
|
|
50
|
-
* // 光标控制
|
|
51
|
-
* process.stdout.write(ANSI.hideCursor)
|
|
52
|
-
* // ... 动画逻辑 ...
|
|
53
|
-
* process.stdout.write(ANSI.showCursor)
|
|
54
|
-
*
|
|
55
|
-
* // 行清理与重写
|
|
56
|
-
* process.stdout.write(ANSI.clearLine + ANSI.reset + ANSI.green('完成'))
|
|
57
|
-
* ```
|
|
58
3
|
*/
|
|
59
4
|
declare const ANSI: {
|
|
60
5
|
/** 将光标重置到行首 */
|
|
@@ -65,68 +10,13 @@ declare const ANSI: {
|
|
|
65
10
|
hideCursor: string;
|
|
66
11
|
/** 显示终端光标 */
|
|
67
12
|
showCursor: string;
|
|
68
|
-
/**
|
|
69
|
-
* 将文本包装为绿色
|
|
70
|
-
* @param t - 要着色的文本
|
|
71
|
-
* @returns 包含绿色 ANSI 转义码的字符串
|
|
72
|
-
*/
|
|
73
13
|
green: (t: string) => string;
|
|
74
|
-
/**
|
|
75
|
-
* 将文本包装为青色
|
|
76
|
-
* @param t - 要着色的文本
|
|
77
|
-
* @returns 包含青色 ANSI 转义码的字符串
|
|
78
|
-
*/
|
|
79
14
|
cyan: (t: string) => string;
|
|
80
|
-
/**
|
|
81
|
-
* 将文本包装为灰色
|
|
82
|
-
* @param t - 要着色的文本
|
|
83
|
-
* @returns 包含灰色 ANSI 转义码的字符串
|
|
84
|
-
*/
|
|
85
15
|
gray: (t: string) => string;
|
|
86
|
-
/**
|
|
87
|
-
* 将文本包装为粗体
|
|
88
|
-
* @param t - 要加粗的文本
|
|
89
|
-
* @returns 包含粗体 ANSI 转义码的字符串
|
|
90
|
-
*/
|
|
91
16
|
bold: (t: string) => string;
|
|
92
|
-
/**
|
|
93
|
-
* 将文本包装为红色
|
|
94
|
-
* @param t - 要着色的文本
|
|
95
|
-
* @returns 包含红色 ANSI 转义码的字符串
|
|
96
|
-
*/
|
|
97
17
|
red: (t: string) => string;
|
|
98
|
-
/**
|
|
99
|
-
* 将文本包装为黄色
|
|
100
|
-
* @param t - 要着色的文本
|
|
101
|
-
* @returns 包含黄色 ANSI 转义码的字符串
|
|
102
|
-
*/
|
|
103
18
|
yellow: (t: string) => string;
|
|
104
|
-
/**
|
|
105
|
-
* 将文本包装为品红色
|
|
106
|
-
* @param t - 要着色的文本
|
|
107
|
-
* @returns 包含品红色 ANSI 转义码的字符串
|
|
108
|
-
*/
|
|
109
19
|
magenta: (t: string) => string;
|
|
110
20
|
};
|
|
111
|
-
/**
|
|
112
|
-
* 移除字符串中的所有 ANSI 转义码
|
|
113
|
-
*
|
|
114
|
-
* @param str - 可能包含 ANSI 转义码的字符串
|
|
115
|
-
* @returns 不包含任何 ANSI 转义码的纯文本字符串
|
|
116
|
-
*
|
|
117
|
-
* @description 使用正则表达式匹配并移除所有形如 `\x1b[...m` 的 ANSI 转义序列,
|
|
118
|
-
* 常用于计算文本实际显示宽度或将彩色输出转为纯文本。
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* const colored = ANSI.green('hello') + ' ' + ANSI.red('world')
|
|
123
|
-
* stripAnsi(colored) // 'hello world'
|
|
124
|
-
*
|
|
125
|
-
* // 计算终端显示宽度
|
|
126
|
-
* const text = ANSI.bold(ANSI.cyan('状态:')) + ' 完成'
|
|
127
|
-
* stripAnsi(text).length // 7 (不含转义码的实际字符数)
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
declare function stripAnsi(str: string): string;
|
|
131
21
|
|
|
132
|
-
export { ANSI
|
|
22
|
+
export { ANSI };
|
|
@@ -1,60 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 终端 UI 工具模块
|
|
3
|
-
*
|
|
4
|
-
* @module common/ui/terminal
|
|
5
|
-
* @description 提供终端 ANSI 转义码处理、Spinner 动画帧和字符串清理等工具函数,
|
|
6
|
-
* 用于在终端中实现彩色输出、光标控制和进度动画等功能。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Spinner 动画帧序列
|
|
10
|
-
*
|
|
11
|
-
* @description 根据操作系统平台自动选择合适的动画帧:
|
|
12
|
-
* - Windows:使用 ASCII 字符 `|`, `/`, `-`, `\`,确保在传统终端中正常显示
|
|
13
|
-
* - 其他平台:使用 Unicode Braille 字符 `⠋`-`⠏`,视觉效果更流畅
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* let frameIndex = 0
|
|
18
|
-
* setInterval(() => {
|
|
19
|
-
* process.stdout.write(`\r${SPINNER_FRAMES[frameIndex]} Loading...`)
|
|
20
|
-
* frameIndex = (frameIndex + 1) % SPINNER_FRAMES.length
|
|
21
|
-
* }, 80)
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare const SPINNER_FRAMES: string[];
|
|
25
1
|
/**
|
|
26
2
|
* ANSI 转义码工具集
|
|
27
|
-
*
|
|
28
|
-
* @description 提供常用的终端 ANSI 转义码常量和彩色文本包装函数,
|
|
29
|
-
* 用于在终端中实现文本着色、光标控制和行清理等操作。
|
|
30
|
-
*
|
|
31
|
-
* @property reset - 将光标重置到行首(`\x1b[0G`)
|
|
32
|
-
* @property clearLine - 清除当前行内容(`\x1b[2K`)
|
|
33
|
-
* @property hideCursor - 隐藏终端光标(`\x1b[?25l`)
|
|
34
|
-
* @property showCursor - 显示终端光标(`\x1b[?25h`)
|
|
35
|
-
* @property green - 将文本包装为绿色
|
|
36
|
-
* @property cyan - 将文本包装为青色
|
|
37
|
-
* @property gray - 将文本包装为灰色
|
|
38
|
-
* @property bold - 将文本包装为粗体
|
|
39
|
-
* @property red - 将文本包装为红色
|
|
40
|
-
* @property yellow - 将文本包装为黄色
|
|
41
|
-
* @property magenta - 将文本包装为品红色
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* // 彩色输出
|
|
46
|
-
* console.log(ANSI.green('✓') + ' 构建成功')
|
|
47
|
-
* console.log(ANSI.red('✗') + ' 构建失败')
|
|
48
|
-
* console.log(ANSI.bold(ANSI.cyan('信息:')) + ' 正在处理...')
|
|
49
|
-
*
|
|
50
|
-
* // 光标控制
|
|
51
|
-
* process.stdout.write(ANSI.hideCursor)
|
|
52
|
-
* // ... 动画逻辑 ...
|
|
53
|
-
* process.stdout.write(ANSI.showCursor)
|
|
54
|
-
*
|
|
55
|
-
* // 行清理与重写
|
|
56
|
-
* process.stdout.write(ANSI.clearLine + ANSI.reset + ANSI.green('完成'))
|
|
57
|
-
* ```
|
|
58
3
|
*/
|
|
59
4
|
declare const ANSI: {
|
|
60
5
|
/** 将光标重置到行首 */
|
|
@@ -65,68 +10,13 @@ declare const ANSI: {
|
|
|
65
10
|
hideCursor: string;
|
|
66
11
|
/** 显示终端光标 */
|
|
67
12
|
showCursor: string;
|
|
68
|
-
/**
|
|
69
|
-
* 将文本包装为绿色
|
|
70
|
-
* @param t - 要着色的文本
|
|
71
|
-
* @returns 包含绿色 ANSI 转义码的字符串
|
|
72
|
-
*/
|
|
73
13
|
green: (t: string) => string;
|
|
74
|
-
/**
|
|
75
|
-
* 将文本包装为青色
|
|
76
|
-
* @param t - 要着色的文本
|
|
77
|
-
* @returns 包含青色 ANSI 转义码的字符串
|
|
78
|
-
*/
|
|
79
14
|
cyan: (t: string) => string;
|
|
80
|
-
/**
|
|
81
|
-
* 将文本包装为灰色
|
|
82
|
-
* @param t - 要着色的文本
|
|
83
|
-
* @returns 包含灰色 ANSI 转义码的字符串
|
|
84
|
-
*/
|
|
85
15
|
gray: (t: string) => string;
|
|
86
|
-
/**
|
|
87
|
-
* 将文本包装为粗体
|
|
88
|
-
* @param t - 要加粗的文本
|
|
89
|
-
* @returns 包含粗体 ANSI 转义码的字符串
|
|
90
|
-
*/
|
|
91
16
|
bold: (t: string) => string;
|
|
92
|
-
/**
|
|
93
|
-
* 将文本包装为红色
|
|
94
|
-
* @param t - 要着色的文本
|
|
95
|
-
* @returns 包含红色 ANSI 转义码的字符串
|
|
96
|
-
*/
|
|
97
17
|
red: (t: string) => string;
|
|
98
|
-
/**
|
|
99
|
-
* 将文本包装为黄色
|
|
100
|
-
* @param t - 要着色的文本
|
|
101
|
-
* @returns 包含黄色 ANSI 转义码的字符串
|
|
102
|
-
*/
|
|
103
18
|
yellow: (t: string) => string;
|
|
104
|
-
/**
|
|
105
|
-
* 将文本包装为品红色
|
|
106
|
-
* @param t - 要着色的文本
|
|
107
|
-
* @returns 包含品红色 ANSI 转义码的字符串
|
|
108
|
-
*/
|
|
109
19
|
magenta: (t: string) => string;
|
|
110
20
|
};
|
|
111
|
-
/**
|
|
112
|
-
* 移除字符串中的所有 ANSI 转义码
|
|
113
|
-
*
|
|
114
|
-
* @param str - 可能包含 ANSI 转义码的字符串
|
|
115
|
-
* @returns 不包含任何 ANSI 转义码的纯文本字符串
|
|
116
|
-
*
|
|
117
|
-
* @description 使用正则表达式匹配并移除所有形如 `\x1b[...m` 的 ANSI 转义序列,
|
|
118
|
-
* 常用于计算文本实际显示宽度或将彩色输出转为纯文本。
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* const colored = ANSI.green('hello') + ' ' + ANSI.red('world')
|
|
123
|
-
* stripAnsi(colored) // 'hello world'
|
|
124
|
-
*
|
|
125
|
-
* // 计算终端显示宽度
|
|
126
|
-
* const text = ANSI.bold(ANSI.cyan('状态:')) + ' 完成'
|
|
127
|
-
* stripAnsi(text).length // 7 (不含转义码的实际字符数)
|
|
128
|
-
* ```
|
|
129
|
-
*/
|
|
130
|
-
declare function stripAnsi(str: string): string;
|
|
131
21
|
|
|
132
|
-
export { ANSI
|
|
22
|
+
export { ANSI };
|
package/dist/common/ui/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const B=
|
|
1
|
+
const B={reset:"\x1B[0G",clearLine:"\x1B[2K",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",green:x=>`\x1B[32m${x}\x1B[39m`,cyan:x=>`\x1B[36m${x}\x1B[39m`,gray:x=>`\x1B[90m${x}\x1B[39m`,bold:x=>`\x1B[1m${x}\x1B[22m`,red:x=>`\x1B[31m${x}\x1B[39m`,yellow:x=>`\x1B[33m${x}\x1B[39m`,magenta:x=>`\x1B[35m${x}\x1B[39m`};export{B as ANSI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const validator=require("../../shared/vite-plugin.Bcg6RW2N.cjs"),
|
|
1
|
+
"use strict";const validator=require("../../shared/vite-plugin.Bcg6RW2N.cjs");function validateGlobalName(u,t){if(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`${t} "${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`${t} "${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}}function validateNoScriptInTemplate(u,t){if(u&&/<script\b/i.test(u))throw new Error(`${t} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function validateCallbackFields(u,t,o){for(const i of t){const r=u[i];if(r!==void 0&&typeof r!="string")throw new Error(`${o}.${i} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u7C7B\u578B`);if(r&&/<script\b/i.test(r))throw new Error(`${o}.${i} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}exports.Validator=validator.Validator,exports.validateCallbackFields=validateCallbackFields,exports.validateGlobalName=validateGlobalName,exports.validateNoScriptInTemplate=validateNoScriptInTemplate;
|
|
@@ -1,94 +1,16 @@
|
|
|
1
1
|
export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.cjs';
|
|
2
|
-
export { E as EnvFieldRule, a as EnvType, b as EnvValidationResult, S as STRING_LIKE_TYPES, v as validateEnvironment, c as validateLength, d as validateRange, e as validateType, f as validateValue } from '../../shared/vite-plugin.CmtcnItg.cjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param name - 全局变量名
|
|
8
|
-
* @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
|
|
9
|
-
* @throws 当名称不合法时抛出带字段上下文的错误
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* validateGlobalName('__LOADING_MANAGER__', 'globalName')
|
|
14
|
-
* validateGlobalName('__APP_VERSION__', 'defineName')
|
|
15
|
-
* ```
|
|
4
|
+
* 验证全局变量名的合法性
|
|
16
5
|
*/
|
|
17
6
|
declare function validateGlobalName(name: string | undefined, fieldName: string): void;
|
|
18
7
|
/**
|
|
19
8
|
* 验证模板字符串不包含 script 标签(XSS 防护)
|
|
20
|
-
*
|
|
21
|
-
* @param template - 模板字符串
|
|
22
|
-
* @param fieldName - 字段名称,用于错误消息上下文
|
|
23
|
-
* @throws 当模板包含 `<script>` 标签时抛出错误
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
|
|
28
|
-
* validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
|
|
29
|
-
* ```
|
|
30
9
|
*/
|
|
31
10
|
declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
|
|
32
11
|
/**
|
|
33
12
|
* 验证回调字段不包含 script 标签
|
|
34
|
-
*
|
|
35
|
-
* @param callbacks - 回调配置对象
|
|
36
|
-
* @param fields - 需要验证的回调字段名数组
|
|
37
|
-
* @param objectName - 回调所属对象名称,用于错误消息上下文
|
|
38
|
-
* @throws 当回调字段非字符串类型时抛出错误
|
|
39
|
-
* @throws 当回调字符串包含 `<script>` 标签时抛出错误
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
|
|
44
|
-
* validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
|
|
45
|
-
* ```
|
|
46
13
|
*/
|
|
47
14
|
declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
|
|
48
|
-
/**
|
|
49
|
-
* 验证数值为非负数
|
|
50
|
-
*
|
|
51
|
-
* @param value - 待验证的数值
|
|
52
|
-
* @param fieldName - 字段名称,用于错误消息
|
|
53
|
-
* @throws 当值存在但不是数字或为负数时抛出错误
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* validateNonNegativeNumber(100, 'zIndex')
|
|
58
|
-
* validateNonNegativeNumber(-1, 'duration') // 抛出错误
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* 验证嵌套配置项的 duration 合法性
|
|
64
|
-
*
|
|
65
|
-
* @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
|
|
66
|
-
* @param errorMsg - 验证失败时的错误提示信息
|
|
67
|
-
* @throws 当 duration 存在但不是非负数时抛出错误
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
declare function validateNestedDuration(config: {
|
|
75
|
-
enabled?: boolean;
|
|
76
|
-
duration?: number;
|
|
77
|
-
} | undefined, errorMsg: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* 验证字符串值是否在允许的枚举列表中
|
|
80
|
-
*
|
|
81
|
-
* @param value - 待验证的值
|
|
82
|
-
* @param allowedValues - 允许的值列表
|
|
83
|
-
* @param fieldName - 字段名称,用于错误消息
|
|
84
|
-
* @throws 当值存在但不在允许列表中时抛出错误
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
|
|
89
|
-
* validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
|
|
93
15
|
|
|
94
|
-
export { validateCallbackFields,
|
|
16
|
+
export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate };
|
|
@@ -1,94 +1,16 @@
|
|
|
1
1
|
export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.mjs';
|
|
2
|
-
export { E as EnvFieldRule, a as EnvType, b as EnvValidationResult, S as STRING_LIKE_TYPES, v as validateEnvironment, c as validateLength, d as validateRange, e as validateType, f as validateValue } from '../../shared/vite-plugin.CmtcnItg.mjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param name - 全局变量名
|
|
8
|
-
* @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
|
|
9
|
-
* @throws 当名称不合法时抛出带字段上下文的错误
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* validateGlobalName('__LOADING_MANAGER__', 'globalName')
|
|
14
|
-
* validateGlobalName('__APP_VERSION__', 'defineName')
|
|
15
|
-
* ```
|
|
4
|
+
* 验证全局变量名的合法性
|
|
16
5
|
*/
|
|
17
6
|
declare function validateGlobalName(name: string | undefined, fieldName: string): void;
|
|
18
7
|
/**
|
|
19
8
|
* 验证模板字符串不包含 script 标签(XSS 防护)
|
|
20
|
-
*
|
|
21
|
-
* @param template - 模板字符串
|
|
22
|
-
* @param fieldName - 字段名称,用于错误消息上下文
|
|
23
|
-
* @throws 当模板包含 `<script>` 标签时抛出错误
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
|
|
28
|
-
* validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
|
|
29
|
-
* ```
|
|
30
9
|
*/
|
|
31
10
|
declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
|
|
32
11
|
/**
|
|
33
12
|
* 验证回调字段不包含 script 标签
|
|
34
|
-
*
|
|
35
|
-
* @param callbacks - 回调配置对象
|
|
36
|
-
* @param fields - 需要验证的回调字段名数组
|
|
37
|
-
* @param objectName - 回调所属对象名称,用于错误消息上下文
|
|
38
|
-
* @throws 当回调字段非字符串类型时抛出错误
|
|
39
|
-
* @throws 当回调字符串包含 `<script>` 标签时抛出错误
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
|
|
44
|
-
* validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
|
|
45
|
-
* ```
|
|
46
13
|
*/
|
|
47
14
|
declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
|
|
48
|
-
/**
|
|
49
|
-
* 验证数值为非负数
|
|
50
|
-
*
|
|
51
|
-
* @param value - 待验证的数值
|
|
52
|
-
* @param fieldName - 字段名称,用于错误消息
|
|
53
|
-
* @throws 当值存在但不是数字或为负数时抛出错误
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```typescript
|
|
57
|
-
* validateNonNegativeNumber(100, 'zIndex')
|
|
58
|
-
* validateNonNegativeNumber(-1, 'duration') // 抛出错误
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
|
|
62
|
-
/**
|
|
63
|
-
* 验证嵌套配置项的 duration 合法性
|
|
64
|
-
*
|
|
65
|
-
* @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
|
|
66
|
-
* @param errorMsg - 验证失败时的错误提示信息
|
|
67
|
-
* @throws 当 duration 存在但不是非负数时抛出错误
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
declare function validateNestedDuration(config: {
|
|
75
|
-
enabled?: boolean;
|
|
76
|
-
duration?: number;
|
|
77
|
-
} | undefined, errorMsg: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* 验证字符串值是否在允许的枚举列表中
|
|
80
|
-
*
|
|
81
|
-
* @param value - 待验证的值
|
|
82
|
-
* @param allowedValues - 允许的值列表
|
|
83
|
-
* @param fieldName - 字段名称,用于错误消息
|
|
84
|
-
* @throws 当值存在但不在允许列表中时抛出错误
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
|
|
89
|
-
* validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
|
|
93
15
|
|
|
94
|
-
export { validateCallbackFields,
|
|
16
|
+
export { validateCallbackFields, validateGlobalName, validateNoScriptInTemplate };
|