@meng-xi/vite-plugin 0.0.9 → 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.
- package/README-en.md +467 -269
- package/README.md +451 -254
- package/dist/common/format/index.cjs +1 -0
- package/dist/common/format/index.d.cts +156 -0
- package/dist/common/format/index.d.mts +156 -0
- package/dist/common/format/index.d.ts +156 -0
- package/dist/common/format/index.mjs +1 -0
- package/dist/common/fs/index.cjs +1 -0
- package/dist/common/fs/index.d.cts +150 -0
- package/dist/common/fs/index.d.mts +150 -0
- package/dist/common/fs/index.d.ts +150 -0
- package/dist/common/fs/index.mjs +1 -0
- package/dist/common/html/index.cjs +2 -0
- package/dist/common/html/index.d.cts +109 -0
- package/dist/common/html/index.d.mts +109 -0
- package/dist/common/html/index.d.ts +109 -0
- package/dist/common/html/index.mjs +2 -0
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +7 -318
- package/dist/common/index.d.mts +7 -318
- package/dist/common/index.d.ts +7 -318
- package/dist/common/index.mjs +1 -1
- package/dist/common/object/index.cjs +1 -0
- package/dist/common/object/index.d.cts +30 -0
- package/dist/common/object/index.d.mts +30 -0
- package/dist/common/object/index.d.ts +30 -0
- package/dist/common/object/index.mjs +1 -0
- package/dist/common/script/index.cjs +1 -0
- package/dist/common/script/index.d.cts +54 -0
- package/dist/common/script/index.d.mts +54 -0
- package/dist/common/script/index.d.ts +54 -0
- package/dist/common/script/index.mjs +1 -0
- package/dist/common/validation/index.cjs +1 -0
- package/dist/common/validation/index.d.cts +93 -0
- package/dist/common/validation/index.d.mts +93 -0
- package/dist/common/validation/index.d.ts +93 -0
- package/dist/common/validation/index.mjs +1 -0
- 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 +15 -3
- package/dist/index.d.mts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.mjs +1 -1
- package/dist/plugins/buildProgress/index.cjs +2 -0
- package/dist/plugins/buildProgress/index.d.cts +187 -0
- package/dist/plugins/buildProgress/index.d.mts +187 -0
- package/dist/plugins/buildProgress/index.d.ts +187 -0
- package/dist/plugins/buildProgress/index.mjs +2 -0
- package/dist/plugins/copyFile/index.cjs +1 -0
- package/dist/plugins/copyFile/index.d.cts +78 -0
- package/dist/plugins/copyFile/index.d.mts +78 -0
- package/dist/plugins/copyFile/index.d.ts +78 -0
- package/dist/plugins/copyFile/index.mjs +1 -0
- package/dist/plugins/faviconManager/index.cjs +1 -0
- package/dist/plugins/faviconManager/index.d.cts +143 -0
- package/dist/plugins/faviconManager/index.d.mts +143 -0
- package/dist/plugins/faviconManager/index.d.ts +143 -0
- package/dist/plugins/faviconManager/index.mjs +1 -0
- package/dist/plugins/generateRouter/index.cjs +35 -0
- package/dist/plugins/generateRouter/index.d.cts +215 -0
- package/dist/plugins/generateRouter/index.d.mts +215 -0
- package/dist/plugins/generateRouter/index.d.ts +215 -0
- package/dist/plugins/generateRouter/index.mjs +35 -0
- package/dist/plugins/generateVersion/index.cjs +1 -0
- package/dist/plugins/generateVersion/index.d.cts +184 -0
- package/dist/plugins/generateVersion/index.d.mts +184 -0
- package/dist/plugins/generateVersion/index.d.ts +184 -0
- package/dist/plugins/generateVersion/index.mjs +1 -0
- package/dist/plugins/htmlInject/index.cjs +7 -0
- package/dist/plugins/htmlInject/index.d.cts +278 -0
- package/dist/plugins/htmlInject/index.d.mts +278 -0
- package/dist/plugins/htmlInject/index.d.ts +278 -0
- package/dist/plugins/htmlInject/index.mjs +7 -0
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +10 -1520
- package/dist/plugins/index.d.mts +10 -1520
- package/dist/plugins/index.d.ts +10 -1520
- package/dist/plugins/index.mjs +1 -1
- package/dist/plugins/loadingManager/index.cjs +487 -0
- package/dist/plugins/loadingManager/index.d.cts +769 -0
- package/dist/plugins/loadingManager/index.d.mts +769 -0
- package/dist/plugins/loadingManager/index.d.ts +769 -0
- package/dist/plugins/loadingManager/index.mjs +487 -0
- package/dist/plugins/versionUpdateChecker/index.cjs +185 -0
- package/dist/plugins/versionUpdateChecker/index.d.cts +200 -0
- package/dist/plugins/versionUpdateChecker/index.d.mts +200 -0
- package/dist/plugins/versionUpdateChecker/index.d.ts +200 -0
- package/dist/plugins/versionUpdateChecker/index.mjs +185 -0
- package/dist/shared/vite-plugin.Bcg6RW2N.cjs +3 -0
- package/dist/shared/{vite-plugin.CiHfwMiN.d.cts → vite-plugin.DRRlWY8P.d.cts} +50 -0
- package/dist/shared/{vite-plugin.CiHfwMiN.d.mts → vite-plugin.DRRlWY8P.d.mts} +50 -0
- package/dist/shared/{vite-plugin.CiHfwMiN.d.ts → vite-plugin.DRRlWY8P.d.ts} +50 -0
- package/dist/shared/{vite-plugin.B88RyRN8.mjs → vite-plugin.DcExl6jd.mjs} +2 -2
- package/package.json +72 -2
- package/dist/shared/vite-plugin.BI4kA-bR.mjs +0 -526
- package/dist/shared/vite-plugin.Ba9646wL.cjs +0 -1
- package/dist/shared/vite-plugin.C3ejdBNf.mjs +0 -1
- package/dist/shared/vite-plugin.CawoITTT.cjs +0 -1
- package/dist/shared/vite-plugin.CsdNNQ-4.cjs +0 -526
- package/dist/shared/vite-plugin.DSb6XzBn.mjs +0 -1
- package/dist/shared/vite-plugin.IGZeStMa.cjs +0 -3
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
|
|
5
|
+
*
|
|
6
|
+
* @param name - 全局变量名
|
|
7
|
+
* @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
|
|
8
|
+
* @throws 当名称不合法时抛出带字段上下文的错误
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* validateGlobalName('__LOADING_MANAGER__', 'globalName')
|
|
13
|
+
* validateGlobalName('__APP_VERSION__', 'defineName')
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function validateGlobalName(name: string | undefined, fieldName: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 验证模板字符串不包含 script 标签(XSS 防护)
|
|
19
|
+
*
|
|
20
|
+
* @param template - 模板字符串
|
|
21
|
+
* @param fieldName - 字段名称,用于错误消息上下文
|
|
22
|
+
* @throws 当模板包含 `<script>` 标签时抛出错误
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
|
|
27
|
+
* validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* 验证回调字段不包含 script 标签
|
|
33
|
+
*
|
|
34
|
+
* @param callbacks - 回调配置对象
|
|
35
|
+
* @param fields - 需要验证的回调字段名数组
|
|
36
|
+
* @param objectName - 回调所属对象名称,用于错误消息上下文
|
|
37
|
+
* @throws 当回调字段非字符串类型时抛出错误
|
|
38
|
+
* @throws 当回调字符串包含 `<script>` 标签时抛出错误
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
|
|
43
|
+
* validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* 验证数值为非负数
|
|
49
|
+
*
|
|
50
|
+
* @param value - 待验证的数值
|
|
51
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
52
|
+
* @throws 当值存在但不是数字或为负数时抛出错误
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* validateNonNegativeNumber(100, 'zIndex')
|
|
57
|
+
* validateNonNegativeNumber(-1, 'duration') // 抛出错误
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* 验证嵌套配置项的 duration 合法性
|
|
63
|
+
*
|
|
64
|
+
* @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
|
|
65
|
+
* @param errorMsg - 验证失败时的错误提示信息
|
|
66
|
+
* @throws 当 duration 存在但不是非负数时抛出错误
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function validateNestedDuration(config: {
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
duration?: number;
|
|
76
|
+
} | undefined, errorMsg: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* 验证字符串值是否在允许的枚举列表中
|
|
79
|
+
*
|
|
80
|
+
* @param value - 待验证的值
|
|
81
|
+
* @param allowedValues - 允许的值列表
|
|
82
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
83
|
+
* @throws 当值存在但不在允许列表中时抛出错误
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
|
|
88
|
+
* validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
|
|
92
|
+
|
|
93
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
|
|
5
|
+
*
|
|
6
|
+
* @param name - 全局变量名
|
|
7
|
+
* @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
|
|
8
|
+
* @throws 当名称不合法时抛出带字段上下文的错误
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* validateGlobalName('__LOADING_MANAGER__', 'globalName')
|
|
13
|
+
* validateGlobalName('__APP_VERSION__', 'defineName')
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function validateGlobalName(name: string | undefined, fieldName: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 验证模板字符串不包含 script 标签(XSS 防护)
|
|
19
|
+
*
|
|
20
|
+
* @param template - 模板字符串
|
|
21
|
+
* @param fieldName - 字段名称,用于错误消息上下文
|
|
22
|
+
* @throws 当模板包含 `<script>` 标签时抛出错误
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
|
|
27
|
+
* validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* 验证回调字段不包含 script 标签
|
|
33
|
+
*
|
|
34
|
+
* @param callbacks - 回调配置对象
|
|
35
|
+
* @param fields - 需要验证的回调字段名数组
|
|
36
|
+
* @param objectName - 回调所属对象名称,用于错误消息上下文
|
|
37
|
+
* @throws 当回调字段非字符串类型时抛出错误
|
|
38
|
+
* @throws 当回调字符串包含 `<script>` 标签时抛出错误
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
|
|
43
|
+
* validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* 验证数值为非负数
|
|
49
|
+
*
|
|
50
|
+
* @param value - 待验证的数值
|
|
51
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
52
|
+
* @throws 当值存在但不是数字或为负数时抛出错误
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* validateNonNegativeNumber(100, 'zIndex')
|
|
57
|
+
* validateNonNegativeNumber(-1, 'duration') // 抛出错误
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* 验证嵌套配置项的 duration 合法性
|
|
63
|
+
*
|
|
64
|
+
* @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
|
|
65
|
+
* @param errorMsg - 验证失败时的错误提示信息
|
|
66
|
+
* @throws 当 duration 存在但不是非负数时抛出错误
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function validateNestedDuration(config: {
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
duration?: number;
|
|
76
|
+
} | undefined, errorMsg: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* 验证字符串值是否在允许的枚举列表中
|
|
79
|
+
*
|
|
80
|
+
* @param value - 待验证的值
|
|
81
|
+
* @param allowedValues - 允许的值列表
|
|
82
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
83
|
+
* @throws 当值存在但不在允许列表中时抛出错误
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
|
|
88
|
+
* validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
|
|
92
|
+
|
|
93
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export { V as Validator } from '../../shared/vite-plugin.DRRlWY8P.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 验证全局变量名的合法性(包装 validateIdentifierName,附加字段上下文信息)
|
|
5
|
+
*
|
|
6
|
+
* @param name - 全局变量名
|
|
7
|
+
* @param fieldName - 字段名称,用于错误消息上下文(如 'globalName'、'defineName')
|
|
8
|
+
* @throws 当名称不合法时抛出带字段上下文的错误
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* validateGlobalName('__LOADING_MANAGER__', 'globalName')
|
|
13
|
+
* validateGlobalName('__APP_VERSION__', 'defineName')
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare function validateGlobalName(name: string | undefined, fieldName: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 验证模板字符串不包含 script 标签(XSS 防护)
|
|
19
|
+
*
|
|
20
|
+
* @param template - 模板字符串
|
|
21
|
+
* @param fieldName - 字段名称,用于错误消息上下文
|
|
22
|
+
* @throws 当模板包含 `<script>` 标签时抛出错误
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* validateNoScriptInTemplate('<div>safe</div>', 'customTemplate')
|
|
27
|
+
* validateNoScriptInTemplate(options.customPromptTemplate, 'customPromptTemplate')
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function validateNoScriptInTemplate(template: string | undefined, fieldName: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* 验证回调字段不包含 script 标签
|
|
33
|
+
*
|
|
34
|
+
* @param callbacks - 回调配置对象
|
|
35
|
+
* @param fields - 需要验证的回调字段名数组
|
|
36
|
+
* @param objectName - 回调所属对象名称,用于错误消息上下文
|
|
37
|
+
* @throws 当回调字段非字符串类型时抛出错误
|
|
38
|
+
* @throws 当回调字符串包含 `<script>` 标签时抛出错误
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* validateCallbackFields(callbacks, ['onShow', 'onHide'], 'callbacks')
|
|
43
|
+
* validateCallbackFields(options, ['onUpdateAvailable', 'onRefresh'], 'callbacks')
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
declare function validateCallbackFields(callbacks: Record<string, any>, fields: string[], objectName: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* 验证数值为非负数
|
|
49
|
+
*
|
|
50
|
+
* @param value - 待验证的数值
|
|
51
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
52
|
+
* @throws 当值存在但不是数字或为负数时抛出错误
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* validateNonNegativeNumber(100, 'zIndex')
|
|
57
|
+
* validateNonNegativeNumber(-1, 'duration') // 抛出错误
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function validateNonNegativeNumber(value: number | undefined, fieldName: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* 验证嵌套配置项的 duration 合法性
|
|
63
|
+
*
|
|
64
|
+
* @param config - 嵌套配置对象(包含 enabled 和 duration 字段)
|
|
65
|
+
* @param errorMsg - 验证失败时的错误提示信息
|
|
66
|
+
* @throws 当 duration 存在但不是非负数时抛出错误
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* validateNestedDuration({ enabled: true, duration: 300 }, 'minDisplayTime.duration 必须是非负数')
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare function validateNestedDuration(config: {
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
duration?: number;
|
|
76
|
+
} | undefined, errorMsg: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* 验证字符串值是否在允许的枚举列表中
|
|
79
|
+
*
|
|
80
|
+
* @param value - 待验证的值
|
|
81
|
+
* @param allowedValues - 允许的值列表
|
|
82
|
+
* @param fieldName - 字段名称,用于错误消息
|
|
83
|
+
* @throws 当值存在但不在允许列表中时抛出错误
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* validateEnumValue('center', ['center', 'top', 'bottom'], 'position')
|
|
88
|
+
* validateEnumValue('modal', ['modal', 'banner', 'toast'], 'promptStyle')
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
declare function validateEnumValue(value: string | undefined, allowedValues: string[], fieldName: string): void;
|
|
92
|
+
|
|
93
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{V as Validator}from"../../shared/vite-plugin.DcExl6jd.mjs";import{containsScriptTag as e,validateIdentifierName as n}from"../script/index.mjs";function a(u,t){if(u)try{n(u)}catch(o){throw new Error(`${t} ${o.message}`)}}function f(u,t){if(u&&e(u))throw new Error(`${t} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}function d(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&&e(r))throw new Error(`${o}.${i} \u4E0D\u5141\u8BB8\u5305\u542B <script> \u6807\u7B7E`)}}function c(u,t){if(u!==void 0&&(typeof u!="number"||u<0))throw new Error(`${t} \u5FC5\u987B\u662F\u975E\u8D1F\u6570`)}function l(u,t){if(u?.duration!==void 0&&(typeof u.duration!="number"||u.duration<0))throw new Error(t)}function B(u,t,o){if(u&&!t.includes(u))throw new Error(`${o} \u5FC5\u987B\u662F ${t.join(", ")}`)}export{d as validateCallbackFields,B as validateEnumValue,a as validateGlobalName,l as validateNestedDuration,f as validateNoScriptInTemplate,c as validateNonNegativeNumber};
|
package/dist/factory/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const index=require("../shared/vite-plugin.
|
|
1
|
+
"use strict";const logger_index=require("../logger/index.cjs"),common_object_index=require("../common/object/index.cjs"),validator=require("../shared/vite-plugin.Bcg6RW2N.cjs");class BasePlugin{options;logger;validator;viteConfig=null;constructor(e,o){this.options=this.mergeOptions(e),this.logger=this.initLogger(o),this.validator=new validator.Validator(this.options),this.safeExecuteSync(()=>this.validateOptions(),"\u63D2\u4EF6\u914D\u7F6E\u9A8C\u8BC1")}getDefaultOptions(){return{}}mergeOptions(e){const o={enabled:!0,verbose:!0,errorStrategy:"throw"},t=this.getDefaultOptions();return common_object_index.deepMerge(o,t,e)}initLogger(e){return logger_index.Logger.create({name:this.getPluginName(),enabled:this.options.verbose,...e}).createPluginLogger(this.getPluginName())}validateOptions(){}getEnforce(){}onConfigResolved(e){this.viteConfig=e,this.logger.info("\u914D\u7F6E\u89E3\u6790\u5B8C\u6210\uFF0C\u63D2\u4EF6\u5DF2\u521D\u59CB\u5316")}destroy(){logger_index.Logger.unregister(this.getPluginName())}safeExecuteSync(e,o){try{return e()}catch(t){return this.handleError(t,o)}}async safeExecute(e,o){try{return await e()}catch(t){return this.handleError(t,o)}}handleError(e,o){let t=`${o}: `;switch(e instanceof Error?t+=e.message:typeof e=="string"?t+=e:t+=String(e),this.options.errorStrategy){case"throw":throw this.logger.error(t),e;case"log":case"ignore":this.logger.error(t);return;default:throw this.logger.error(t),e}}toPlugin(){const e={name:this.getPluginName(),enforce:this.getEnforce()};this.addPluginHooks(e);const o=e.configResolved;e.configResolved=n=>{this.options.enabled&&(this.onConfigResolved(n),typeof o=="function"&&o(n))};const t=this,r=e.closeBundle;return e.closeBundle=function(){typeof r=="function"&&r.call(this),t.destroy()},e}}function createPluginFactory(i,e){return o=>{const t=e?e(o):o,r=new i(t),n=r.toPlugin();return n.pluginInstance=r,n}}exports.BasePlugin=BasePlugin,exports.createPluginFactory=createPluginFactory;
|
package/dist/factory/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
2
|
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.cjs';
|
|
3
|
-
import { V as Validator } from '../shared/vite-plugin.
|
|
3
|
+
import { V as Validator } from '../shared/vite-plugin.DRRlWY8P.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 带插件实例引用的 Vite 插件类型
|
package/dist/factory/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
2
|
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.mjs';
|
|
3
|
-
import { V as Validator } from '../shared/vite-plugin.
|
|
3
|
+
import { V as Validator } from '../shared/vite-plugin.DRRlWY8P.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 带插件实例引用的 Vite 插件类型
|
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
2
|
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.js';
|
|
3
|
-
import { V as Validator } from '../shared/vite-plugin.
|
|
3
|
+
import { V as Validator } from '../shared/vite-plugin.DRRlWY8P.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 带插件实例引用的 Vite 插件类型
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{Logger as s}from"../logger/index.mjs";import{deepMerge as u}from"../common/object/index.mjs";import{V as g}from"../shared/vite-plugin.DcExl6jd.mjs";class a{options;logger;validator;viteConfig=null;constructor(t,o){this.options=this.mergeOptions(t),this.logger=this.initLogger(o),this.validator=new g(this.options),this.safeExecuteSync(()=>this.validateOptions(),"\u63D2\u4EF6\u914D\u7F6E\u9A8C\u8BC1")}getDefaultOptions(){return{}}mergeOptions(t){const o={enabled:!0,verbose:!0,errorStrategy:"throw"},e=this.getDefaultOptions();return u(o,e,t)}initLogger(t){return s.create({name:this.getPluginName(),enabled:this.options.verbose,...t}).createPluginLogger(this.getPluginName())}validateOptions(){}getEnforce(){}onConfigResolved(t){this.viteConfig=t,this.logger.info("\u914D\u7F6E\u89E3\u6790\u5B8C\u6210\uFF0C\u63D2\u4EF6\u5DF2\u521D\u59CB\u5316")}destroy(){s.unregister(this.getPluginName())}safeExecuteSync(t,o){try{return t()}catch(e){return this.handleError(e,o)}}async safeExecute(t,o){try{return await t()}catch(e){return this.handleError(e,o)}}handleError(t,o){let e=`${o}: `;switch(t instanceof Error?e+=t.message:typeof t=="string"?e+=t:e+=String(t),this.options.errorStrategy){case"throw":throw this.logger.error(e),t;case"log":case"ignore":this.logger.error(e);return;default:throw this.logger.error(e),t}}toPlugin(){const t={name:this.getPluginName(),enforce:this.getEnforce()};this.addPluginHooks(t);const o=t.configResolved;t.configResolved=n=>{this.options.enabled&&(this.onConfigResolved(n),typeof o=="function"&&o(n))};const e=this,r=t.closeBundle;return t.closeBundle=function(){typeof r=="function"&&r.call(this),e.destroy()},t}}function l(i,t){return o=>{const e=t?t(o):o,r=new i(e),n=r.toPlugin();return n.pluginInstance=r,n}}export{a as BasePlugin,l as createPluginFactory};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const common_fs_index=require("./common/fs/index.cjs"),common_format_index=require("./common/format/index.cjs"),common_html_index=require("./common/html/index.cjs"),common_object_index=require("./common/object/index.cjs"),common_script_index=require("./common/script/index.cjs"),validator=require("./shared/vite-plugin.Bcg6RW2N.cjs"),common_validation_index=require("./common/validation/index.cjs"),factory_index=require("./factory/index.cjs"),logger_index=require("./logger/index.cjs"),plugins_buildProgress_index=require("./plugins/buildProgress/index.cjs"),plugins_copyFile_index=require("./plugins/copyFile/index.cjs"),plugins_faviconManager_index=require("./plugins/faviconManager/index.cjs"),plugins_generateRouter_index=require("./plugins/generateRouter/index.cjs"),plugins_generateVersion_index=require("./plugins/generateVersion/index.cjs"),plugins_htmlInject_index=require("./plugins/htmlInject/index.cjs"),plugins_loadingManager_index=require("./plugins/loadingManager/index.cjs"),plugins_versionUpdateChecker_index=require("./plugins/versionUpdateChecker/index.cjs");require("fs"),require("path"),require("crypto"),require("node:path"),exports.checkSourceExists=common_fs_index.checkSourceExists,exports.copySourceToTarget=common_fs_index.copySourceToTarget,exports.ensureTargetDir=common_fs_index.ensureTargetDir,exports.fileExists=common_fs_index.fileExists,exports.readDirRecursive=common_fs_index.readDirRecursive,exports.readFileContent=common_fs_index.readFileContent,exports.readFileSync=common_fs_index.readFileSync,exports.runWithConcurrency=common_fs_index.runWithConcurrency,exports.shouldUpdateFile=common_fs_index.shouldUpdateFile,exports.writeFileContent=common_fs_index.writeFileContent,exports.escapeHtmlAttr=common_format_index.escapeHtmlAttr,exports.formatDate=common_format_index.formatDate,exports.generateRandomHash=common_format_index.generateRandomHash,exports.getDateFormatParams=common_format_index.getDateFormatParams,exports.padNumber=common_format_index.padNumber,exports.parseTemplate=common_format_index.parseTemplate,exports.stripJsonComments=common_format_index.stripJsonComments,exports.toCamelCase=common_format_index.toCamelCase,exports.toPascalCase=common_format_index.toPascalCase,exports.injectBeforeTag=common_html_index.injectBeforeTag,exports.injectBeforeTagWithFallback=common_html_index.injectBeforeTagWithFallback,exports.injectHeadAndBody=common_html_index.injectHeadAndBody,exports.injectHtmlByPriority=common_html_index.injectHtmlByPriority,exports.deepMerge=common_object_index.deepMerge,exports.containsScriptTag=common_script_index.containsScriptTag,exports.makeCallback=common_script_index.makeCallback,exports.validateIdentifierName=common_script_index.validateIdentifierName,exports.Validator=validator.Validator,exports.validateCallbackFields=common_validation_index.validateCallbackFields,exports.validateEnumValue=common_validation_index.validateEnumValue,exports.validateGlobalName=common_validation_index.validateGlobalName,exports.validateNestedDuration=common_validation_index.validateNestedDuration,exports.validateNoScriptInTemplate=common_validation_index.validateNoScriptInTemplate,exports.validateNonNegativeNumber=common_validation_index.validateNonNegativeNumber,exports.BasePlugin=factory_index.BasePlugin,exports.createPluginFactory=factory_index.createPluginFactory,exports.Logger=logger_index.Logger,exports.buildProgress=plugins_buildProgress_index.buildProgress,exports.copyFile=plugins_copyFile_index.copyFile,exports.faviconManager=plugins_faviconManager_index.faviconManager,exports.generateRouter=plugins_generateRouter_index.generateRouter,exports.generateVersion=plugins_generateVersion_index.generateVersion,exports.htmlInject=plugins_htmlInject_index.htmlInject,exports.loadingManager=plugins_loadingManager_index.loadingManager,exports.versionUpdateChecker=plugins_versionUpdateChecker_index.versionUpdateChecker;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { CopyOptions, CopyResult, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, writeFileContent } from './common/fs/index.cjs';
|
|
2
|
+
export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './common/format/index.cjs';
|
|
3
|
+
export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './common/html/index.cjs';
|
|
4
|
+
export { deepMerge } from './common/object/index.cjs';
|
|
5
|
+
export { containsScriptTag, makeCallback, validateIdentifierName } from './common/script/index.cjs';
|
|
6
|
+
export { V as Validator } from './shared/vite-plugin.DRRlWY8P.cjs';
|
|
7
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './common/validation/index.cjs';
|
|
3
8
|
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.cjs';
|
|
4
9
|
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.cjs';
|
|
5
|
-
export {
|
|
10
|
+
export { BuildPhase, BuildProgressOptions, ProgressFormat, ProgressTheme, buildProgress } from './plugins/buildProgress/index.cjs';
|
|
11
|
+
export { CopyFileOptions, copyFile } from './plugins/copyFile/index.cjs';
|
|
12
|
+
export { FaviconManagerOptions, Icon, faviconManager } from './plugins/faviconManager/index.cjs';
|
|
13
|
+
export { GenerateRouterOptions, NameStrategy, OutputFormat, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, generateRouter } from './plugins/generateRouter/index.cjs';
|
|
14
|
+
export { GenerateVersionOptions, OutputType, VersionFormat, VersionInfo, generateVersion } from './plugins/generateVersion/index.cjs';
|
|
15
|
+
export { ConditionType, HtmlInjectOptions, InjectCondition, InjectPosition, InjectRule, InjectionLogEntry, SecurityConfig, SelectorMatch, htmlInject } from './plugins/htmlInject/index.cjs';
|
|
16
|
+
export { AutoBindMode, AutoHideOn, DebounceHide, DelayShow, LoadingCallbacks, LoadingManager, LoadingManagerOptions, LoadingPosition, LoadingStyle, MinDisplayTime, RequestFilter, SpinnerType, TransitionConfig, loadingManager } from './plugins/loadingManager/index.cjs';
|
|
17
|
+
export { PromptStyle, VersionSource, VersionUpdateCheckerOptions, versionUpdateChecker } from './plugins/versionUpdateChecker/index.cjs';
|
|
6
18
|
import 'vite';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { CopyOptions, CopyResult, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, writeFileContent } from './common/fs/index.mjs';
|
|
2
|
+
export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './common/format/index.mjs';
|
|
3
|
+
export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './common/html/index.mjs';
|
|
4
|
+
export { deepMerge } from './common/object/index.mjs';
|
|
5
|
+
export { containsScriptTag, makeCallback, validateIdentifierName } from './common/script/index.mjs';
|
|
6
|
+
export { V as Validator } from './shared/vite-plugin.DRRlWY8P.mjs';
|
|
7
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './common/validation/index.mjs';
|
|
3
8
|
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.mjs';
|
|
4
9
|
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.mjs';
|
|
5
|
-
export {
|
|
10
|
+
export { BuildPhase, BuildProgressOptions, ProgressFormat, ProgressTheme, buildProgress } from './plugins/buildProgress/index.mjs';
|
|
11
|
+
export { CopyFileOptions, copyFile } from './plugins/copyFile/index.mjs';
|
|
12
|
+
export { FaviconManagerOptions, Icon, faviconManager } from './plugins/faviconManager/index.mjs';
|
|
13
|
+
export { GenerateRouterOptions, NameStrategy, OutputFormat, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, generateRouter } from './plugins/generateRouter/index.mjs';
|
|
14
|
+
export { GenerateVersionOptions, OutputType, VersionFormat, VersionInfo, generateVersion } from './plugins/generateVersion/index.mjs';
|
|
15
|
+
export { ConditionType, HtmlInjectOptions, InjectCondition, InjectPosition, InjectRule, InjectionLogEntry, SecurityConfig, SelectorMatch, htmlInject } from './plugins/htmlInject/index.mjs';
|
|
16
|
+
export { AutoBindMode, AutoHideOn, DebounceHide, DelayShow, LoadingCallbacks, LoadingManager, LoadingManagerOptions, LoadingPosition, LoadingStyle, MinDisplayTime, RequestFilter, SpinnerType, TransitionConfig, loadingManager } from './plugins/loadingManager/index.mjs';
|
|
17
|
+
export { PromptStyle, VersionSource, VersionUpdateCheckerOptions, versionUpdateChecker } from './plugins/versionUpdateChecker/index.mjs';
|
|
6
18
|
import 'vite';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { CopyOptions, CopyResult, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, writeFileContent } from './common/fs/index.js';
|
|
2
|
+
export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './common/format/index.js';
|
|
3
|
+
export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './common/html/index.js';
|
|
4
|
+
export { deepMerge } from './common/object/index.js';
|
|
5
|
+
export { containsScriptTag, makeCallback, validateIdentifierName } from './common/script/index.js';
|
|
6
|
+
export { V as Validator } from './shared/vite-plugin.DRRlWY8P.js';
|
|
7
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './common/validation/index.js';
|
|
3
8
|
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.js';
|
|
4
9
|
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.js';
|
|
5
|
-
export {
|
|
10
|
+
export { BuildPhase, BuildProgressOptions, ProgressFormat, ProgressTheme, buildProgress } from './plugins/buildProgress/index.js';
|
|
11
|
+
export { CopyFileOptions, copyFile } from './plugins/copyFile/index.js';
|
|
12
|
+
export { FaviconManagerOptions, Icon, faviconManager } from './plugins/faviconManager/index.js';
|
|
13
|
+
export { GenerateRouterOptions, NameStrategy, OutputFormat, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, generateRouter } from './plugins/generateRouter/index.js';
|
|
14
|
+
export { GenerateVersionOptions, OutputType, VersionFormat, VersionInfo, generateVersion } from './plugins/generateVersion/index.js';
|
|
15
|
+
export { ConditionType, HtmlInjectOptions, InjectCondition, InjectPosition, InjectRule, InjectionLogEntry, SecurityConfig, SelectorMatch, htmlInject } from './plugins/htmlInject/index.js';
|
|
16
|
+
export { AutoBindMode, AutoHideOn, DebounceHide, DelayShow, LoadingCallbacks, LoadingManager, LoadingManagerOptions, LoadingPosition, LoadingStyle, MinDisplayTime, RequestFilter, SpinnerType, TransitionConfig, loadingManager } from './plugins/loadingManager/index.js';
|
|
17
|
+
export { PromptStyle, VersionSource, VersionUpdateCheckerOptions, versionUpdateChecker } from './plugins/versionUpdateChecker/index.js';
|
|
6
18
|
import 'vite';
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{checkSourceExists,copySourceToTarget,ensureTargetDir,fileExists,readDirRecursive,readFileContent,readFileSync,runWithConcurrency,shouldUpdateFile,writeFileContent}from"./common/fs/index.mjs";export{escapeHtmlAttr,formatDate,generateRandomHash,getDateFormatParams,padNumber,parseTemplate,stripJsonComments,toCamelCase,toPascalCase}from"./common/format/index.mjs";export{injectBeforeTag,injectBeforeTagWithFallback,injectHeadAndBody,injectHtmlByPriority}from"./common/html/index.mjs";export{deepMerge}from"./common/object/index.mjs";export{containsScriptTag,makeCallback,validateIdentifierName}from"./common/script/index.mjs";export{V as Validator}from"./shared/vite-plugin.DcExl6jd.mjs";export{validateCallbackFields,validateEnumValue,validateGlobalName,validateNestedDuration,validateNoScriptInTemplate,validateNonNegativeNumber}from"./common/validation/index.mjs";export{BasePlugin,createPluginFactory}from"./factory/index.mjs";export{Logger}from"./logger/index.mjs";export{buildProgress}from"./plugins/buildProgress/index.mjs";export{copyFile}from"./plugins/copyFile/index.mjs";export{faviconManager}from"./plugins/faviconManager/index.mjs";export{generateRouter}from"./plugins/generateRouter/index.mjs";export{generateVersion}from"./plugins/generateVersion/index.mjs";export{htmlInject}from"./plugins/htmlInject/index.mjs";export{loadingManager}from"./plugins/loadingManager/index.mjs";export{versionUpdateChecker}from"./plugins/versionUpdateChecker/index.mjs";import"fs";import"path";import"crypto";import"node:path";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const factory_index=require("../../factory/index.cjs");require("../../logger/index.cjs"),require("../../common/object/index.cjs"),require("../../shared/vite-plugin.Bcg6RW2N.cjs");const SPINNER_FRAMES=process.platform==="win32"?["|","/","-","\\"]:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],ANSI={reset:"\x1B[0G",clearLine:"\x1B[2K",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",green:i=>`\x1B[32m${i}\x1B[39m`,cyan:i=>`\x1B[36m${i}\x1B[39m`,gray:i=>`\x1B[90m${i}\x1B[39m`,bold:i=>`\x1B[1m${i}\x1B[22m`},DEFAULT_THEME={completeColor:ANSI.green,incompleteColor:ANSI.gray,percentageColor:ANSI.bold,phaseColor:ANSI.cyan,moduleColor:ANSI.gray},PHASE_LABELS={idle:"\u7B49\u5F85\u4E2D",config:"\u8BFB\u53D6\u914D\u7F6E",resolve:"\u89E3\u6790\u6A21\u5757",transform:"\u8F6C\u6362\u6A21\u5757",bundle:"\u6253\u5305\u4E2D",write:"\u5199\u5165\u6587\u4EF6",done:"\u6784\u5EFA\u5B8C\u6210"};class o extends factory_index.BasePlugin{totalModules=0;transformedModules=0;currentModule="";phase="idle";spinnerIndex=0;spinnerTimer=null;isDev=!1;theme=DEFAULT_THEME;lastPercentage=0;static ANSI_REGEX=/\x1b\[[0-9;]*m/g;static stripAnsi(e){return e.replace(o.ANSI_REGEX,"")}getDefaultOptions(){return{width:30,format:"bar",completeChar:"\u2588",incompleteChar:"\u2591",clearOnComplete:!0,showModuleName:!0}}validateOptions(){this.validator.field("width").number().minValue(1).field("format").enum(["bar","spinner","minimal"]).field("completeChar").string().field("incompleteChar").string().field("clearOnComplete").boolean().field("showModuleName").boolean().validate()}getPluginName(){return"build-progress"}onConfigResolved(e){super.onConfigResolved(e),this.theme=this.options.theme||DEFAULT_THEME}getPercentage(){if(this.phase==="done")return this.lastPercentage=100;if(this.phase==="config")return this.lastPercentage=5;if(this.phase==="resolve")return this.lastPercentage=10;if(this.totalModules===0)return this.lastPercentage=15;const e=Math.min(this.transformedModules/this.totalModules*70,70),t=this.phase==="bundle"?10:0,s=this.phase==="write"?5:0,n=Math.min(Math.floor(15+e+t+s),99);return this.lastPercentage=Math.max(n,this.lastPercentage),this.lastPercentage}renderBar(e){const t=this.options.width||30,s=this.options.completeChar||"\u2588",n=this.options.incompleteChar||"\u2591",r=Math.round(e/100*t),u=t-r;return this.theme.completeColor(s.repeat(r))+this.theme.incompleteColor(n.repeat(u))}renderSpinner(){const e=SPINNER_FRAMES[this.spinnerIndex%SPINNER_FRAMES.length];return this.spinnerIndex++,this.theme.phaseColor(e)}render(e){const t=this.options.format||"bar",s=this.theme.phaseColor(PHASE_LABELS[this.phase]),n=this.theme.percentageColor(`${e}%`);let r="";if(t==="bar"?r=`${this.renderSpinner()} ${s} ${this.renderBar(e)} ${n}`:t==="spinner"?r=`${this.renderSpinner()} ${s} ${n}`:r=`${s} ${n}`,this.options.showModuleName&&this.currentModule&&this.phase==="transform"){const u=o.stripAnsi(r).length,l=Math.max((process.stdout.columns||80)-u-3,20),a=this.currentModule.length>l?"..."+this.currentModule.slice(-l+3):this.currentModule;r+=` ${this.theme.moduleColor(a)}`}return r}update(){if(!process.stdout.isTTY)return;const e=this.getPercentage(),t=this.render(e);this.safeExecuteSync(()=>{process.stdout.write(ANSI.clearLine+ANSI.reset+t)},"\u66F4\u65B0\u8FDB\u5EA6\u663E\u793A")}startSpinner(){this.spinnerTimer||process.stdout.isTTY&&(this.spinnerTimer=setInterval(()=>this.update(),80))}stopSpinner(){this.spinnerTimer&&(clearInterval(this.spinnerTimer),this.spinnerTimer=null)}complete(){if(this.phase="done",this.stopSpinner(),!process.stdout.isTTY){this.logger.success("\u6784\u5EFA\u5B8C\u6210");return}if(this.options.clearOnComplete)this.safeExecuteSync(()=>{process.stdout.write(ANSI.clearLine+ANSI.reset)},"\u6E05\u9664\u8FDB\u5EA6\u884C");else{const e=this.render(100);this.safeExecuteSync(()=>{process.stdout.write(ANSI.clearLine+ANSI.reset+e+`
|
|
2
|
+
`)},"\u8F93\u51FA\u5B8C\u6210\u8FDB\u5EA6")}this.safeExecuteSync(()=>{process.stdout.write(ANSI.showCursor)},"\u6062\u590D\u5149\u6807\u663E\u793A")}addPluginHooks(e){e.config=(t,{command:s})=>(this.isDev=s==="serve",null),e.configResolved=()=>{this.options.enabled&&(this.phase="config",process.stdout.isTTY&&this.safeExecuteSync(()=>{process.stdout.write(ANSI.hideCursor)},"\u9690\u85CF\u5149\u6807"),this.startSpinner())},e.buildStart=()=>{this.options.enabled&&(this.phase="resolve",this.totalModules=0,this.transformedModules=0)},e.resolveId={handler:t=>{this.options.enabled&&(t.includes("node_modules")||t.includes(".virtual")||this.totalModules++)}},e.transform={handler:(t,s)=>{this.options.enabled&&(s.includes("node_modules")||s.includes(".virtual")||(this.phase="transform",this.transformedModules++,this.currentModule=s))}},e.writeBundle=()=>{this.options.enabled&&(this.phase="write",this.update())},e.closeBundle=()=>{this.options.enabled&&this.complete()},e.buildEnd=()=>{this.options.enabled&&(this.isDev||(this.phase="bundle",this.update()))},e.configureServer=()=>{this.options.enabled&&this.isDev&&this.complete()}}destroy(){super.destroy(),this.stopSpinner(),process.stdout.isTTY&&this.safeExecuteSync(()=>{process.stdout.write(ANSI.showCursor)},"\u6062\u590D\u5149\u6807\u663E\u793A")}}const buildProgress=factory_index.createPluginFactory(o);exports.buildProgress=buildProgress;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { BasePluginOptions, PluginFactory } from '../../factory/index.cjs';
|
|
2
|
+
import 'vite';
|
|
3
|
+
import '../../shared/vite-plugin.CLr0ttuO.cjs';
|
|
4
|
+
import '../../shared/vite-plugin.DRRlWY8P.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 进度条显示格式类型
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* - 'bar': 完整进度条模式,显示旋转动画 + 阶段标签 + 进度条 + 百分比 + 模块名
|
|
11
|
+
* - 'spinner': 旋转动画模式,显示旋转动画 + 阶段标签 + 百分比
|
|
12
|
+
* - 'minimal': 精简模式,仅显示阶段标签 + 百分比
|
|
13
|
+
*/
|
|
14
|
+
type ProgressFormat = 'bar' | 'spinner' | 'minimal';
|
|
15
|
+
/**
|
|
16
|
+
* 构建进度插件的配置选项接口
|
|
17
|
+
*
|
|
18
|
+
* @interface BuildProgressOptions
|
|
19
|
+
*/
|
|
20
|
+
interface BuildProgressOptions extends BasePluginOptions {
|
|
21
|
+
/**
|
|
22
|
+
* 进度条宽度(字符数)
|
|
23
|
+
*
|
|
24
|
+
* @default 30
|
|
25
|
+
*/
|
|
26
|
+
width?: number;
|
|
27
|
+
/**
|
|
28
|
+
* 进度条显示格式
|
|
29
|
+
*
|
|
30
|
+
* @default 'bar'
|
|
31
|
+
*/
|
|
32
|
+
format?: ProgressFormat;
|
|
33
|
+
/**
|
|
34
|
+
* 已完成部分的填充字符
|
|
35
|
+
*
|
|
36
|
+
* @default '█'
|
|
37
|
+
* @example '█'、'■'、'='
|
|
38
|
+
*/
|
|
39
|
+
completeChar?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 未完成部分的填充字符
|
|
42
|
+
*
|
|
43
|
+
* @default '░'
|
|
44
|
+
* @example '░'、'□'、'-'
|
|
45
|
+
*/
|
|
46
|
+
incompleteChar?: string;
|
|
47
|
+
/**
|
|
48
|
+
* 构建完成后是否清除进度条
|
|
49
|
+
*
|
|
50
|
+
* @default true
|
|
51
|
+
* @description 设为 false 时,构建完成后保留 100% 进度条在终端中
|
|
52
|
+
*/
|
|
53
|
+
clearOnComplete?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 是否显示当前正在处理的模块名称
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
* @description 仅在 transform 阶段显示,模块名超长时自动截断
|
|
59
|
+
*/
|
|
60
|
+
showModuleName?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* 自定义颜色主题
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* 每个属性是一个接受字符串并返回带 ANSI 颜色码字符串的函数。
|
|
66
|
+
* 未提供的属性将使用默认主题。
|
|
67
|
+
*/
|
|
68
|
+
theme?: ProgressTheme;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 进度条颜色主题接口
|
|
72
|
+
*
|
|
73
|
+
* @interface ProgressTheme
|
|
74
|
+
* @description 定义进度条各部分的颜色渲染函数,每个函数接受文本并返回带 ANSI 颜色码的字符串
|
|
75
|
+
*/
|
|
76
|
+
interface ProgressTheme {
|
|
77
|
+
/**
|
|
78
|
+
* 已完成部分的颜色渲染函数
|
|
79
|
+
*
|
|
80
|
+
* @param text - 需要着色的文本
|
|
81
|
+
* @returns 带 ANSI 颜色码的字符串
|
|
82
|
+
*/
|
|
83
|
+
completeColor: (text: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* 未完成部分的颜色渲染函数
|
|
86
|
+
*
|
|
87
|
+
* @param text - 需要着色的文本
|
|
88
|
+
* @returns 带 ANSI 颜色码的字符串
|
|
89
|
+
*/
|
|
90
|
+
incompleteColor: (text: string) => string;
|
|
91
|
+
/**
|
|
92
|
+
* 百分比数字的颜色渲染函数
|
|
93
|
+
*
|
|
94
|
+
* @param text - 需要着色的文本
|
|
95
|
+
* @returns 带 ANSI 颜色码的字符串
|
|
96
|
+
*/
|
|
97
|
+
percentageColor: (text: string) => string;
|
|
98
|
+
/**
|
|
99
|
+
* 阶段标签的颜色渲染函数
|
|
100
|
+
*
|
|
101
|
+
* @param text - 需要着色的文本
|
|
102
|
+
* @returns 带 ANSI 颜色码的字符串
|
|
103
|
+
*/
|
|
104
|
+
phaseColor: (text: string) => string;
|
|
105
|
+
/**
|
|
106
|
+
* 模块名称的颜色渲染函数
|
|
107
|
+
*
|
|
108
|
+
* @param text - 需要着色的文本
|
|
109
|
+
* @returns 带 ANSI 颜色码的字符串
|
|
110
|
+
*/
|
|
111
|
+
moduleColor: (text: string) => string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* 构建阶段类型
|
|
115
|
+
*
|
|
116
|
+
* @description
|
|
117
|
+
* - 'idle': 空闲状态,插件尚未开始工作
|
|
118
|
+
* - 'config': 读取配置阶段
|
|
119
|
+
* - 'resolve': 解析模块依赖阶段
|
|
120
|
+
* - 'transform': 转换模块阶段
|
|
121
|
+
* - 'bundle': 打包阶段(仅生产构建)
|
|
122
|
+
* - 'write': 写入文件阶段
|
|
123
|
+
* - 'done': 构建完成
|
|
124
|
+
*/
|
|
125
|
+
type BuildPhase = 'idle' | 'config' | 'resolve' | 'transform' | 'bundle' | 'write' | 'done';
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 构建进度条插件
|
|
129
|
+
*
|
|
130
|
+
* @param {BuildProgressOptions} options - 插件配置选项
|
|
131
|
+
* @returns {Plugin} 一个 Vite 插件实例
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* // 基本使用 - 默认进度条格式
|
|
136
|
+
* buildProgress()
|
|
137
|
+
*
|
|
138
|
+
* // 旋转动画格式
|
|
139
|
+
* buildProgress({
|
|
140
|
+
* format: 'spinner'
|
|
141
|
+
* })
|
|
142
|
+
*
|
|
143
|
+
* // 精简格式
|
|
144
|
+
* buildProgress({
|
|
145
|
+
* format: 'minimal'
|
|
146
|
+
* })
|
|
147
|
+
*
|
|
148
|
+
* // 自定义进度条外观
|
|
149
|
+
* buildProgress({
|
|
150
|
+
* width: 40,
|
|
151
|
+
* completeChar: '■',
|
|
152
|
+
* incompleteChar: '□',
|
|
153
|
+
* clearOnComplete: false
|
|
154
|
+
* })
|
|
155
|
+
*
|
|
156
|
+
* // 自定义颜色主题
|
|
157
|
+
* buildProgress({
|
|
158
|
+
* theme: {
|
|
159
|
+
* completeColor: (t) => `\x1b[32m${t}\x1b[39m`,
|
|
160
|
+
* incompleteColor: (t) => `\x1b[90m${t}\x1b[39m`,
|
|
161
|
+
* percentageColor: (t) => `\x1b[1m${t}\x1b[22m`,
|
|
162
|
+
* phaseColor: (t) => `\x1b[36m${t}\x1b[39m`,
|
|
163
|
+
* moduleColor: (t) => `\x1b[90m${t}\x1b[39m`
|
|
164
|
+
* }
|
|
165
|
+
* })
|
|
166
|
+
*
|
|
167
|
+
* // 禁用模块名显示
|
|
168
|
+
* buildProgress({
|
|
169
|
+
* showModuleName: false
|
|
170
|
+
* })
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @remarks
|
|
174
|
+
* 该插件在 Vite 构建过程中实时显示终端进度条,支持三种显示格式:
|
|
175
|
+
* - bar: 完整进度条(默认),包含旋转动画、阶段标签、进度条和百分比
|
|
176
|
+
* - spinner: 旋转动画模式,仅显示动画、阶段标签和百分比
|
|
177
|
+
* - minimal: 精简模式,仅显示阶段标签和百分比
|
|
178
|
+
*
|
|
179
|
+
* 进度计算基于 Vite 构建生命周期:
|
|
180
|
+
* 1. config 阶段(5%)→ resolve 阶段(10%)→ transform 阶段(15%-85%)→ bundle 阶段(+10%)→ write 阶段(+5%)→ 完成(100%)
|
|
181
|
+
*
|
|
182
|
+
* 在非 TTY 终端环境下(如 CI/CD),自动降级为日志输出模式。
|
|
183
|
+
*/
|
|
184
|
+
declare const buildProgress: PluginFactory<BuildProgressOptions, BuildProgressOptions>;
|
|
185
|
+
|
|
186
|
+
export { buildProgress };
|
|
187
|
+
export type { BuildPhase, BuildProgressOptions, ProgressFormat, ProgressTheme };
|