@meng-xi/vite-plugin 0.1.3 → 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 +49 -775
- package/README.md +46 -770
- 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 +19 -81
- package/dist/common/html/index.d.mts +19 -81
- package/dist/common/html/index.d.ts +19 -81
- package/dist/common/html/index.mjs +2 -2
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +7 -8
- package/dist/common/index.d.mts +7 -8
- package/dist/common/index.d.ts +7 -8
- 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 -0
- package/dist/common/ui/index.d.cts +22 -0
- package/dist/common/ui/index.d.mts +22 -0
- package/dist/common/ui/index.d.ts +22 -0
- package/dist/common/ui/index.mjs +1 -0
- package/dist/common/validation/index.cjs +1 -1
- package/dist/common/validation/index.d.cts +2 -79
- package/dist/common/validation/index.d.mts +2 -79
- package/dist/common/validation/index.d.ts +2 -79
- 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 +12 -10
- package/dist/index.d.mts +12 -10
- package/dist/index.d.ts +12 -10
- 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 +21 -3
- package/dist/plugins/copyFile/index.d.mts +21 -3
- package/dist/plugins/copyFile/index.d.ts +21 -3
- package/dist/plugins/copyFile/index.mjs +1 -1
- package/dist/plugins/envGuard/index.cjs +67 -0
- package/dist/plugins/envGuard/index.d.cts +255 -0
- package/dist/plugins/envGuard/index.d.mts +255 -0
- package/dist/plugins/envGuard/index.d.ts +255 -0
- package/dist/plugins/envGuard/index.mjs +67 -0
- package/dist/plugins/faviconManager/index.cjs +1 -1
- package/dist/plugins/faviconManager/index.d.cts +44 -6
- package/dist/plugins/faviconManager/index.d.mts +44 -6
- package/dist/plugins/faviconManager/index.d.ts +44 -6
- package/dist/plugins/faviconManager/index.mjs +1 -1
- package/dist/plugins/generateRouter/index.cjs +4 -4
- package/dist/plugins/generateRouter/index.d.cts +62 -15
- package/dist/plugins/generateRouter/index.d.mts +62 -15
- package/dist/plugins/generateRouter/index.d.ts +62 -15
- package/dist/plugins/generateRouter/index.mjs +4 -4
- package/dist/plugins/generateVersion/index.cjs +1 -1
- package/dist/plugins/generateVersion/index.d.cts +13 -1
- package/dist/plugins/generateVersion/index.d.mts +13 -1
- package/dist/plugins/generateVersion/index.d.ts +13 -1
- package/dist/plugins/generateVersion/index.mjs +1 -1
- package/dist/plugins/htmlInject/index.cjs +7 -7
- package/dist/plugins/htmlInject/index.d.cts +50 -195
- package/dist/plugins/htmlInject/index.d.mts +50 -195
- package/dist/plugins/htmlInject/index.d.ts +50 -195
- package/dist/plugins/htmlInject/index.mjs +7 -7
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +5 -2
- package/dist/plugins/index.d.mts +5 -2
- package/dist/plugins/index.d.ts +5 -2
- 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 +1 -1
- 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 +1 -1
- 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.BI9taN75.d.cts +122 -0
- package/dist/shared/vite-plugin.BI9taN75.d.mts +122 -0
- package/dist/shared/vite-plugin.BI9taN75.d.ts +122 -0
- package/dist/shared/vite-plugin.BPFqtmWa.mjs +1 -0
- package/dist/shared/vite-plugin.CnOy46d3.cjs +1 -0
- package/package.json +16 -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.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
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML 单点注入结果
|
|
3
|
+
*
|
|
4
|
+
* @description 表示在 HTML 中进行单点注入操作后的结果,
|
|
5
|
+
* 包含注入后的 HTML 内容和是否成功注入的标志。
|
|
6
|
+
*/
|
|
7
|
+
interface HtmlInjectResult {
|
|
8
|
+
/** 注入后的 HTML 内容 */
|
|
9
|
+
html: string;
|
|
10
|
+
/** 是否成功注入 */
|
|
11
|
+
injected: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* HTML 双区域注入结果
|
|
15
|
+
*
|
|
16
|
+
* @description 表示在 HTML 的 head 和 body 两个区域同时注入后的结果,
|
|
17
|
+
* 包含各区域的注入状态和是否使用了回退策略。
|
|
18
|
+
*/
|
|
19
|
+
interface DualInjectResult {
|
|
20
|
+
/** 注入后的 HTML 内容 */
|
|
21
|
+
html: string;
|
|
22
|
+
/** 是否成功注入到 head 区域 */
|
|
23
|
+
headInjected: boolean;
|
|
24
|
+
/** 是否成功注入到 body 区域 */
|
|
25
|
+
bodyInjected: boolean;
|
|
26
|
+
/** body 注入是否使用了回退策略(追加到末尾) */
|
|
27
|
+
usedFallback: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HTML 注入位置类型
|
|
31
|
+
*
|
|
32
|
+
* @description 定义内容在 HTML 中可注入的所有位置:
|
|
33
|
+
* - `head-start`:`<head>` 标签开始后
|
|
34
|
+
* - `head-end`:`</head>` 标签前
|
|
35
|
+
* - `body-start`:`<body>` 标签开始后
|
|
36
|
+
* - `body-end`:`</body>` 标签前
|
|
37
|
+
* - `before-selector`:选择器匹配位置前
|
|
38
|
+
* - `after-selector`:选择器匹配位置后
|
|
39
|
+
* - `replace-selector`:替换选择器匹配的内容
|
|
40
|
+
*/
|
|
41
|
+
type InjectPosition = 'head-start' | 'head-end' | 'body-start' | 'body-end' | 'before-selector' | 'after-selector' | 'replace-selector';
|
|
42
|
+
/**
|
|
43
|
+
* 选择器匹配模式
|
|
44
|
+
*
|
|
45
|
+
* @description 定义 HTML 选择器的匹配方式:
|
|
46
|
+
* - `string`:使用字符串精确匹配(默认)
|
|
47
|
+
* - `regex`:使用正则表达式匹配
|
|
48
|
+
*/
|
|
49
|
+
type SelectorMatch = 'string' | 'regex';
|
|
50
|
+
/**
|
|
51
|
+
* 条件判断类型
|
|
52
|
+
*
|
|
53
|
+
* @description 定义注入条件的类型:
|
|
54
|
+
* - `env`:基于环境变量是否存在且为真值
|
|
55
|
+
* - `file-contains`:基于 HTML 内容是否包含指定字符串
|
|
56
|
+
* - `custom`:基于自定义函数的返回值
|
|
57
|
+
*/
|
|
58
|
+
type ConditionType = 'env' | 'file-contains' | 'custom';
|
|
59
|
+
/**
|
|
60
|
+
* 注入条件配置
|
|
61
|
+
*
|
|
62
|
+
* @description 定义 HTML 内容注入的条件判断规则,
|
|
63
|
+
* 支持环境变量检测、内容包含检测和自定义函数判断,
|
|
64
|
+
* 可通过 `negate` 字段取反结果。
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // 当环境变量 ENABLE_ANALYTICS 存在时注入
|
|
69
|
+
* { type: 'env', value: 'ENABLE_ANALYTICS' }
|
|
70
|
+
*
|
|
71
|
+
* // 当 HTML 不包含特定元素时注入(取反)
|
|
72
|
+
* { type: 'file-contains', value: '<div id="app">', negate: true }
|
|
73
|
+
*
|
|
74
|
+
* // 使用自定义函数判断
|
|
75
|
+
* { type: 'custom', value: () => process.env.NODE_ENV === 'production' }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
interface InjectCondition {
|
|
79
|
+
/** 条件类型 */
|
|
80
|
+
type: ConditionType;
|
|
81
|
+
/**
|
|
82
|
+
* 条件值:
|
|
83
|
+
* - `env` 类型:环境变量名
|
|
84
|
+
* - `file-contains` 类型:要搜索的字符串
|
|
85
|
+
* - `custom` 类型:返回布尔值的自定义函数
|
|
86
|
+
*/
|
|
87
|
+
value: string | ((...args: any[]) => boolean);
|
|
88
|
+
/** 是否取反条件结果,默认为 `false` */
|
|
89
|
+
negate?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* HTML 安全配置
|
|
93
|
+
*
|
|
94
|
+
* @description 控制 HTML 内容注入时的安全过滤策略,
|
|
95
|
+
* 可配置是否阻止危险标签和属性,以及自定义允许/阻止列表。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // 完全禁用安全过滤(不推荐)
|
|
100
|
+
* const config: SecurityConfig = { blockDangerousTags: false, blockDangerousAttributes: false }
|
|
101
|
+
*
|
|
102
|
+
* // 允许特定标签
|
|
103
|
+
* const config: SecurityConfig = { allowedTags: ['iframe'] }
|
|
104
|
+
*
|
|
105
|
+
* // 自定义阻止属性列表
|
|
106
|
+
* const config: SecurityConfig = { blockedAttributes: ['onclick', 'onerror'] }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
interface SecurityConfig {
|
|
110
|
+
/** 是否阻止危险 HTML 标签(如 script、iframe),默认为 `true` */
|
|
111
|
+
blockDangerousTags?: boolean;
|
|
112
|
+
/** 是否阻止危险 HTML 属性(如 onclick、onerror),默认为 `true` */
|
|
113
|
+
blockDangerousAttributes?: boolean;
|
|
114
|
+
/** 允许的标签列表,设置后将从默认阻止列表中排除这些标签 */
|
|
115
|
+
allowedTags?: string[];
|
|
116
|
+
/** 自定义阻止的标签列表,覆盖默认阻止列表 */
|
|
117
|
+
blockedTags?: string[];
|
|
118
|
+
/** 自定义阻止的属性列表,覆盖默认阻止属性列表 */
|
|
119
|
+
blockedAttributes?: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type { ConditionType as C, DualInjectResult as D, HtmlInjectResult as H, InjectCondition as I, SecurityConfig as S, InjectPosition as a, SelectorMatch as b };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function C(i){return/<script\b/i.test(i)}const p=["script","iframe","object","embed","applet","form","input","textarea","select","button"],d=["onclick","ondblclick","onmouseover","onmouseout","onmousemove","onmousedown","onmouseup","onkeydown","onkeyup","onkeypress","onload","onerror","onfocus","onblur","onsubmit","onchange","oninput","oncontextmenu","ondrag","ondrop","onanimationend","ontransitionend"];function w(i,o,e,r){const l=e?.blockDangerousTags!==!1,a=e?.blockDangerousAttributes!==!1,B=e?.blockedTags||p,c=e?.allowedTags,E=e?.blockedAttributes||d;let n=i;if(l){const t=c?B.filter(u=>!c.includes(u)):B;if(C(i))if(o.allowScriptInjection)r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5DF2\u542F\u7528\u811A\u672C\u6CE8\u5165(allowScriptInjection=true)\uFF0C\u8BF7\u786E\u4FDD\u6CE8\u5165\u5185\u5BB9\u6765\u6E90\u53EF\u4FE1\u3002\u6CE8\u5165\u811A\u672C\u53EF\u80FD\u5E26\u6765 XSS \u653B\u51FB\u98CE\u9669\u3002`);else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B <script> \u6807\u7B7E\uFF0C\u9ED8\u8BA4\u88AB\u963B\u6B62\u3002\u5982\u9700\u6CE8\u5165\u811A\u672C\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true`);for(const u of t){if(u==="script")continue;const F=new RegExp(`<${u}\\b[^>]*>[\\s\\S]*?<\\/${u}>`,"gi"),s=new RegExp(`<${u}\\b[^>]*/?>`,"gi");if(F.test(n)||s.test(n))if(o.allowScriptInjection){r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5305\u542B\u88AB\u963B\u6B62\u7684\u6807\u7B7E <${u}>\uFF0C\u5DF2\u901A\u8FC7 allowScriptInjection \u8DF3\u8FC7\u5B89\u5168\u68C0\u67E5\uFF0C\u8BF7\u786E\u4FDD\u5185\u5BB9\u53EF\u4FE1\u3002`);continue}else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B\u88AB\u963B\u6B62\u7684\u6807\u7B7E <${u}>\u3002\u5982\u9700\u6CE8\u5165\u6B64\u6807\u7B7E\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true \u6216\u5728 security.allowedTags \u4E2D\u6DFB\u52A0 "${u}"`);n=n.replace(F,""),n=n.replace(s,"")}}if(a)for(const t of E){const u=new RegExp(`\\s${t}\\s*=\\s*["'][^"']*["']`,"gi");if(u.test(n))if(o.allowScriptInjection){r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5305\u542B\u5371\u9669\u5C5E\u6027 ${t}\uFF0C\u5DF2\u901A\u8FC7 allowScriptInjection \u8DF3\u8FC7\u5B89\u5168\u68C0\u67E5\uFF0C\u8BF7\u786E\u4FDD\u5185\u5BB9\u53EF\u4FE1\u3002`);continue}else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B\u5371\u9669\u5C5E\u6027 ${t}\u3002\u5982\u9700\u6CE8\u5165\u6B64\u5C5E\u6027\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true`);n=n.replace(u,"")}return n}export{w as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function w(i){return/<script\b/i.test(i)}const f=["script","iframe","object","embed","applet","form","input","textarea","select","button"],b=["onclick","ondblclick","onmouseover","onmouseout","onmousemove","onmousedown","onmouseup","onkeydown","onkeyup","onkeypress","onload","onerror","onfocus","onblur","onsubmit","onchange","oninput","oncontextmenu","ondrag","ondrop","onanimationend","ontransitionend"];function sanitizeContent(i,o,e,r){const l=e?.blockDangerousTags!==!1,a=e?.blockDangerousAttributes!==!1,B=e?.blockedTags||f,c=e?.allowedTags,E=e?.blockedAttributes||b;let n=i;if(l){const t=c?B.filter(u=>!c.includes(u)):B;if(w(i))if(o.allowScriptInjection)r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5DF2\u542F\u7528\u811A\u672C\u6CE8\u5165(allowScriptInjection=true)\uFF0C\u8BF7\u786E\u4FDD\u6CE8\u5165\u5185\u5BB9\u6765\u6E90\u53EF\u4FE1\u3002\u6CE8\u5165\u811A\u672C\u53EF\u80FD\u5E26\u6765 XSS \u653B\u51FB\u98CE\u9669\u3002`);else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B <script> \u6807\u7B7E\uFF0C\u9ED8\u8BA4\u88AB\u963B\u6B62\u3002\u5982\u9700\u6CE8\u5165\u811A\u672C\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true`);for(const u of t){if(u==="script")continue;const F=new RegExp(`<${u}\\b[^>]*>[\\s\\S]*?<\\/${u}>`,"gi"),s=new RegExp(`<${u}\\b[^>]*/?>`,"gi");if(F.test(n)||s.test(n))if(o.allowScriptInjection){r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5305\u542B\u88AB\u963B\u6B62\u7684\u6807\u7B7E <${u}>\uFF0C\u5DF2\u901A\u8FC7 allowScriptInjection \u8DF3\u8FC7\u5B89\u5168\u68C0\u67E5\uFF0C\u8BF7\u786E\u4FDD\u5185\u5BB9\u53EF\u4FE1\u3002`);continue}else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B\u88AB\u963B\u6B62\u7684\u6807\u7B7E <${u}>\u3002\u5982\u9700\u6CE8\u5165\u6B64\u6807\u7B7E\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true \u6216\u5728 security.allowedTags \u4E2D\u6DFB\u52A0 "${u}"`);n=n.replace(F,""),n=n.replace(s,"")}}if(a)for(const t of E){const u=new RegExp(`\\s${t}\\s*=\\s*["'][^"']*["']`,"gi");if(u.test(n))if(o.allowScriptInjection){r?.warn(`[\u5B89\u5168\u8B66\u544A] \u89C4\u5219 "${o.id||"unnamed"}" \u5305\u542B\u5371\u9669\u5C5E\u6027 ${t}\uFF0C\u5DF2\u901A\u8FC7 allowScriptInjection \u8DF3\u8FC7\u5B89\u5168\u68C0\u67E5\uFF0C\u8BF7\u786E\u4FDD\u5185\u5BB9\u53EF\u4FE1\u3002`);continue}else throw new Error(`\u89C4\u5219 "${o.id||"unnamed"}" \u7684\u5185\u5BB9\u5305\u542B\u5371\u9669\u5C5E\u6027 ${t}\u3002\u5982\u9700\u6CE8\u5165\u6B64\u5C5E\u6027\uFF0C\u8BF7\u8BBE\u7F6E allowScriptInjection: true`);n=n.replace(u,"")}return n}exports.sanitizeContent=sanitizeContent;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meng-xi/vite-plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "一个为 Vite 提供实用插件的工具包,同时也是一个完整的插件开发框架",
|
|
7
7
|
"keywords": [
|
|
@@ -25,11 +25,6 @@
|
|
|
25
25
|
"import": "./dist/common/index.mjs",
|
|
26
26
|
"types": "./dist/common/index.d.ts"
|
|
27
27
|
},
|
|
28
|
-
"./common/compress": {
|
|
29
|
-
"require": "./dist/common/compress/index.cjs",
|
|
30
|
-
"import": "./dist/common/compress/index.mjs",
|
|
31
|
-
"types": "./dist/common/compress/index.d.ts"
|
|
32
|
-
},
|
|
33
28
|
"./common/format": {
|
|
34
29
|
"require": "./dist/common/format/index.cjs",
|
|
35
30
|
"import": "./dist/common/format/index.mjs",
|
|
@@ -45,21 +40,16 @@
|
|
|
45
40
|
"import": "./dist/common/html/index.mjs",
|
|
46
41
|
"types": "./dist/common/html/index.d.ts"
|
|
47
42
|
},
|
|
48
|
-
"./common/object": {
|
|
49
|
-
"require": "./dist/common/object/index.cjs",
|
|
50
|
-
"import": "./dist/common/object/index.mjs",
|
|
51
|
-
"types": "./dist/common/object/index.d.ts"
|
|
52
|
-
},
|
|
53
|
-
"./common/path": {
|
|
54
|
-
"require": "./dist/common/path/index.cjs",
|
|
55
|
-
"import": "./dist/common/path/index.mjs",
|
|
56
|
-
"types": "./dist/common/path/index.d.ts"
|
|
57
|
-
},
|
|
58
43
|
"./common/script": {
|
|
59
44
|
"require": "./dist/common/script/index.cjs",
|
|
60
45
|
"import": "./dist/common/script/index.mjs",
|
|
61
46
|
"types": "./dist/common/script/index.d.ts"
|
|
62
47
|
},
|
|
48
|
+
"./common/ui": {
|
|
49
|
+
"require": "./dist/common/ui/index.cjs",
|
|
50
|
+
"import": "./dist/common/ui/index.mjs",
|
|
51
|
+
"types": "./dist/common/ui/index.d.ts"
|
|
52
|
+
},
|
|
63
53
|
"./common/validation": {
|
|
64
54
|
"require": "./dist/common/validation/index.cjs",
|
|
65
55
|
"import": "./dist/common/validation/index.mjs",
|
|
@@ -80,6 +70,11 @@
|
|
|
80
70
|
"import": "./dist/plugins/index.mjs",
|
|
81
71
|
"types": "./dist/plugins/index.d.ts"
|
|
82
72
|
},
|
|
73
|
+
"./plugins/auto-import": {
|
|
74
|
+
"require": "./dist/plugins/autoImport/index.cjs",
|
|
75
|
+
"import": "./dist/plugins/autoImport/index.mjs",
|
|
76
|
+
"types": "./dist/plugins/autoImport/index.d.ts"
|
|
77
|
+
},
|
|
83
78
|
"./plugins/build-progress": {
|
|
84
79
|
"require": "./dist/plugins/buildProgress/index.cjs",
|
|
85
80
|
"import": "./dist/plugins/buildProgress/index.mjs",
|
|
@@ -100,6 +95,11 @@
|
|
|
100
95
|
"import": "./dist/plugins/copyFile/index.mjs",
|
|
101
96
|
"types": "./dist/plugins/copyFile/index.d.ts"
|
|
102
97
|
},
|
|
98
|
+
"./plugins/env-guard": {
|
|
99
|
+
"require": "./dist/plugins/envGuard/index.cjs",
|
|
100
|
+
"import": "./dist/plugins/envGuard/index.mjs",
|
|
101
|
+
"types": "./dist/plugins/envGuard/index.d.ts"
|
|
102
|
+
},
|
|
103
103
|
"./plugins/favicon-manager": {
|
|
104
104
|
"require": "./dist/plugins/faviconManager/index.cjs",
|
|
105
105
|
"import": "./dist/plugins/faviconManager/index.mjs",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const node_zlib=require("node:zlib"),promises=require("node:stream/promises"),node_stream=require("node:stream");async function calculateGzipSize(e){const t=typeof e=="string"?Buffer.from(e,"utf-8"):e,r=[],n=node_zlib.createGzip({level:9}),o=new node_stream.Transform({transform(s,a,i){r.push(s),i()}});return await promises.pipeline(node_stream.Readable.from(t),n,o),Buffer.concat(r).length}exports.calculateGzipSize=calculateGzipSize;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计算给定数据的 gzip 压缩后大小
|
|
3
|
-
*
|
|
4
|
-
* @async
|
|
5
|
-
* @param {Buffer | string} data - 待计算的数据
|
|
6
|
-
* @returns {Promise<number>} gzip 压缩后的字节大小
|
|
7
|
-
*
|
|
8
|
-
* @description 将数据通过 gzip 流压缩后计算压缩体积,
|
|
9
|
-
* 用于估算网络传输时的实际体积。
|
|
10
|
-
* 使用最高压缩级别(level: 9)以获得最小的压缩体积。
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const gzipSize = await calculateGzipSize(Buffer.from('hello world'))
|
|
15
|
-
* console.log(`gzip 大小: ${gzipSize} 字节`)
|
|
16
|
-
*
|
|
17
|
-
* const stringData = 'some long string content...'
|
|
18
|
-
* const size = await calculateGzipSize(stringData)
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function calculateGzipSize(data: Buffer | string): Promise<number>;
|
|
22
|
-
|
|
23
|
-
export { calculateGzipSize };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计算给定数据的 gzip 压缩后大小
|
|
3
|
-
*
|
|
4
|
-
* @async
|
|
5
|
-
* @param {Buffer | string} data - 待计算的数据
|
|
6
|
-
* @returns {Promise<number>} gzip 压缩后的字节大小
|
|
7
|
-
*
|
|
8
|
-
* @description 将数据通过 gzip 流压缩后计算压缩体积,
|
|
9
|
-
* 用于估算网络传输时的实际体积。
|
|
10
|
-
* 使用最高压缩级别(level: 9)以获得最小的压缩体积。
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const gzipSize = await calculateGzipSize(Buffer.from('hello world'))
|
|
15
|
-
* console.log(`gzip 大小: ${gzipSize} 字节`)
|
|
16
|
-
*
|
|
17
|
-
* const stringData = 'some long string content...'
|
|
18
|
-
* const size = await calculateGzipSize(stringData)
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function calculateGzipSize(data: Buffer | string): Promise<number>;
|
|
22
|
-
|
|
23
|
-
export { calculateGzipSize };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计算给定数据的 gzip 压缩后大小
|
|
3
|
-
*
|
|
4
|
-
* @async
|
|
5
|
-
* @param {Buffer | string} data - 待计算的数据
|
|
6
|
-
* @returns {Promise<number>} gzip 压缩后的字节大小
|
|
7
|
-
*
|
|
8
|
-
* @description 将数据通过 gzip 流压缩后计算压缩体积,
|
|
9
|
-
* 用于估算网络传输时的实际体积。
|
|
10
|
-
* 使用最高压缩级别(level: 9)以获得最小的压缩体积。
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const gzipSize = await calculateGzipSize(Buffer.from('hello world'))
|
|
15
|
-
* console.log(`gzip 大小: ${gzipSize} 字节`)
|
|
16
|
-
*
|
|
17
|
-
* const stringData = 'some long string content...'
|
|
18
|
-
* const size = await calculateGzipSize(stringData)
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function calculateGzipSize(data: Buffer | string): Promise<number>;
|
|
22
|
-
|
|
23
|
-
export { calculateGzipSize };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createGzip as i}from"node:zlib";import{pipeline as p}from"node:stream/promises";import{Transform as m,Readable as c}from"node:stream";async function l(e){const o=typeof e=="string"?Buffer.from(e,"utf-8"):e,r=[],t=i({level:9}),f=new m({transform(n,u,a){r.push(n),a()}});return await p(c.from(o),t,f),Buffer.concat(r).length}export{l as calculateGzipSize};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.prototype.toString.call(e)==="[object Object]"}function deepMerge(...e){const t={};for(const r of e)if(r)for(const o in r){if(!Object.prototype.hasOwnProperty.call(r,o))continue;const n=r[o],c=t[o];n!==void 0&&(i(n)&&i(c)?t[o]=deepMerge(c,n):t[o]=n)}return t}exports.deepMerge=deepMerge;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 深度合并对象
|
|
3
|
-
*
|
|
4
|
-
* @description 将多个源对象深度合并到一个新对象中。
|
|
5
|
-
* - undefined 值会被跳过,不会覆盖已有值
|
|
6
|
-
* - 嵌套对象会递归合并
|
|
7
|
-
* - 数组会直接覆盖,不会合并
|
|
8
|
-
* - null 值会覆盖已有值
|
|
9
|
-
*
|
|
10
|
-
* @param sources 源对象列表
|
|
11
|
-
* @returns 合并后的对象
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // 基本合并
|
|
16
|
-
* deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
|
|
17
|
-
*
|
|
18
|
-
* // undefined 不覆盖
|
|
19
|
-
* deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
|
|
20
|
-
*
|
|
21
|
-
* // 嵌套对象合并
|
|
22
|
-
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
|
|
23
|
-
*
|
|
24
|
-
* // 数组覆盖
|
|
25
|
-
* deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
29
|
-
|
|
30
|
-
export { deepMerge };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 深度合并对象
|
|
3
|
-
*
|
|
4
|
-
* @description 将多个源对象深度合并到一个新对象中。
|
|
5
|
-
* - undefined 值会被跳过,不会覆盖已有值
|
|
6
|
-
* - 嵌套对象会递归合并
|
|
7
|
-
* - 数组会直接覆盖,不会合并
|
|
8
|
-
* - null 值会覆盖已有值
|
|
9
|
-
*
|
|
10
|
-
* @param sources 源对象列表
|
|
11
|
-
* @returns 合并后的对象
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // 基本合并
|
|
16
|
-
* deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
|
|
17
|
-
*
|
|
18
|
-
* // undefined 不覆盖
|
|
19
|
-
* deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
|
|
20
|
-
*
|
|
21
|
-
* // 嵌套对象合并
|
|
22
|
-
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
|
|
23
|
-
*
|
|
24
|
-
* // 数组覆盖
|
|
25
|
-
* deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
29
|
-
|
|
30
|
-
export { deepMerge };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 深度合并对象
|
|
3
|
-
*
|
|
4
|
-
* @description 将多个源对象深度合并到一个新对象中。
|
|
5
|
-
* - undefined 值会被跳过,不会覆盖已有值
|
|
6
|
-
* - 嵌套对象会递归合并
|
|
7
|
-
* - 数组会直接覆盖,不会合并
|
|
8
|
-
* - null 值会覆盖已有值
|
|
9
|
-
*
|
|
10
|
-
* @param sources 源对象列表
|
|
11
|
-
* @returns 合并后的对象
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // 基本合并
|
|
16
|
-
* deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
|
|
17
|
-
*
|
|
18
|
-
* // undefined 不覆盖
|
|
19
|
-
* deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
|
|
20
|
-
*
|
|
21
|
-
* // 嵌套对象合并
|
|
22
|
-
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
|
|
23
|
-
*
|
|
24
|
-
* // 数组覆盖
|
|
25
|
-
* deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
29
|
-
|
|
30
|
-
export { deepMerge };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function i(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)&&Object.prototype.toString.call(o)==="[object Object]"}function f(...o){const e={};for(const r of o)if(r)for(const t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;const n=r[t],c=e[t];n!==void 0&&(i(n)&&i(c)?e[t]=f(c,n):e[t]=n)}return e}export{f as deepMerge};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function isNodeModule(s){return s.includes("node_modules")||s.startsWith("\0")||s.startsWith("virtual:")}exports.isNodeModule=isNodeModule;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断模块 ID 是否来自 node_modules
|
|
3
|
-
*
|
|
4
|
-
* @param {string} moduleId - 模块标识符
|
|
5
|
-
* @returns {boolean} 是否来自 node_modules
|
|
6
|
-
*
|
|
7
|
-
* @description 检测规则:
|
|
8
|
-
* - 路径中包含 `node_modules` 的模块
|
|
9
|
-
* - 以 `\0` 开头的虚拟模块(Rollup 内部模块)
|
|
10
|
-
* - 以 `virtual:` 开头的虚拟模块
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* isNodeModule('node_modules/lodash/index.js') // true
|
|
15
|
-
* isNodeModule('src/utils/helper.ts') // false
|
|
16
|
-
* isNodeModule('\0some-virtual-module') // true
|
|
17
|
-
* isNodeModule('virtual:import-meta-env') // true
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function isNodeModule(moduleId: string): boolean;
|
|
21
|
-
|
|
22
|
-
export { isNodeModule };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断模块 ID 是否来自 node_modules
|
|
3
|
-
*
|
|
4
|
-
* @param {string} moduleId - 模块标识符
|
|
5
|
-
* @returns {boolean} 是否来自 node_modules
|
|
6
|
-
*
|
|
7
|
-
* @description 检测规则:
|
|
8
|
-
* - 路径中包含 `node_modules` 的模块
|
|
9
|
-
* - 以 `\0` 开头的虚拟模块(Rollup 内部模块)
|
|
10
|
-
* - 以 `virtual:` 开头的虚拟模块
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* isNodeModule('node_modules/lodash/index.js') // true
|
|
15
|
-
* isNodeModule('src/utils/helper.ts') // false
|
|
16
|
-
* isNodeModule('\0some-virtual-module') // true
|
|
17
|
-
* isNodeModule('virtual:import-meta-env') // true
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function isNodeModule(moduleId: string): boolean;
|
|
21
|
-
|
|
22
|
-
export { isNodeModule };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断模块 ID 是否来自 node_modules
|
|
3
|
-
*
|
|
4
|
-
* @param {string} moduleId - 模块标识符
|
|
5
|
-
* @returns {boolean} 是否来自 node_modules
|
|
6
|
-
*
|
|
7
|
-
* @description 检测规则:
|
|
8
|
-
* - 路径中包含 `node_modules` 的模块
|
|
9
|
-
* - 以 `\0` 开头的虚拟模块(Rollup 内部模块)
|
|
10
|
-
* - 以 `virtual:` 开头的虚拟模块
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* isNodeModule('node_modules/lodash/index.js') // true
|
|
15
|
-
* isNodeModule('src/utils/helper.ts') // false
|
|
16
|
-
* isNodeModule('\0some-virtual-module') // true
|
|
17
|
-
* isNodeModule('virtual:import-meta-env') // true
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
declare function isNodeModule(moduleId: string): boolean;
|
|
21
|
-
|
|
22
|
-
export { isNodeModule };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(t){return t.includes("node_modules")||t.startsWith("\0")||t.startsWith("virtual:")}export{e as isNodeModule};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 构造函数参数接口
|
|
3
|
-
*/
|
|
4
|
-
interface LoggerOptions {
|
|
5
|
-
/**
|
|
6
|
-
* 插件名称
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* 是否启用日志
|
|
11
|
-
*/
|
|
12
|
-
enabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 日志工具类(单例模式)
|
|
17
|
-
* @description 全局单例日志管理器,统一管理所有插件的日志输出
|
|
18
|
-
*/
|
|
19
|
-
declare class Logger {
|
|
20
|
-
/**
|
|
21
|
-
* 单例实例
|
|
22
|
-
*/
|
|
23
|
-
private static instance;
|
|
24
|
-
/**
|
|
25
|
-
* 库名称
|
|
26
|
-
*/
|
|
27
|
-
private readonly libName;
|
|
28
|
-
/**
|
|
29
|
-
* 插件日志配置映射表
|
|
30
|
-
* @description 存储每个插件的日志开关状态
|
|
31
|
-
*/
|
|
32
|
-
private pluginConfigs;
|
|
33
|
-
/**
|
|
34
|
-
* 日志类型映射
|
|
35
|
-
*/
|
|
36
|
-
private readonly logTypes;
|
|
37
|
-
/**
|
|
38
|
-
* 私有构造函数,防止外部实例化
|
|
39
|
-
*/
|
|
40
|
-
private constructor();
|
|
41
|
-
/**
|
|
42
|
-
* 获取单例实例
|
|
43
|
-
* @returns Logger 单例实例
|
|
44
|
-
*/
|
|
45
|
-
private static getInstance;
|
|
46
|
-
/**
|
|
47
|
-
* 创建日志记录器(工厂方法)
|
|
48
|
-
* @param options 配置选项
|
|
49
|
-
* @returns Logger 单例实例
|
|
50
|
-
* @description 为插件创建日志记录器,实际返回单例实例并注册插件配置
|
|
51
|
-
*/
|
|
52
|
-
static create(options: LoggerOptions): Logger;
|
|
53
|
-
/**
|
|
54
|
-
* 注册插件日志配置
|
|
55
|
-
* @param pluginName 插件名称
|
|
56
|
-
* @param enabled 是否启用日志
|
|
57
|
-
*/
|
|
58
|
-
private registerPlugin;
|
|
59
|
-
/**
|
|
60
|
-
* 注销插件日志配置
|
|
61
|
-
* @param pluginName 插件名称
|
|
62
|
-
*/
|
|
63
|
-
private unregisterPlugin;
|
|
64
|
-
/**
|
|
65
|
-
* 注销指定插件的日志配置
|
|
66
|
-
* @param pluginName 插件名称
|
|
67
|
-
* @description 从单例中移除指定插件的日志配置,通常在插件销毁时调用
|
|
68
|
-
*/
|
|
69
|
-
static unregister(pluginName: string): void;
|
|
70
|
-
/**
|
|
71
|
-
* 销毁单例实例,释放所有资源
|
|
72
|
-
* @description 清除所有已注册的插件配置,重置单例实例。主要用于测试场景
|
|
73
|
-
*/
|
|
74
|
-
static destroy(): void;
|
|
75
|
-
/**
|
|
76
|
-
* 生成日志前缀
|
|
77
|
-
* @param pluginName 插件名称
|
|
78
|
-
* @returns 格式化的日志前缀
|
|
79
|
-
*/
|
|
80
|
-
private formatPrefix;
|
|
81
|
-
/**
|
|
82
|
-
* 检查插件日志是否启用
|
|
83
|
-
* @param pluginName 插件名称
|
|
84
|
-
* @returns 是否启用
|
|
85
|
-
*/
|
|
86
|
-
private isPluginEnabled;
|
|
87
|
-
/**
|
|
88
|
-
* 统一日志输出方法
|
|
89
|
-
* @param pluginName 插件名称
|
|
90
|
-
* @param type 日志类型
|
|
91
|
-
* @param message 日志消息
|
|
92
|
-
* @param data 附加数据
|
|
93
|
-
*/
|
|
94
|
-
private log;
|
|
95
|
-
/**
|
|
96
|
-
* 创建插件日志代理对象
|
|
97
|
-
* @param pluginName 插件名称
|
|
98
|
-
* @returns 插件日志代理对象
|
|
99
|
-
* @internal 供 BasePlugin 内部使用
|
|
100
|
-
*/
|
|
101
|
-
createPluginLogger(pluginName: string): PluginLogger;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 插件日志代理接口
|
|
105
|
-
* @description 为每个插件提供独立的日志接口
|
|
106
|
-
*/
|
|
107
|
-
interface PluginLogger {
|
|
108
|
-
/**
|
|
109
|
-
* 输出成功日志
|
|
110
|
-
* @param message 日志消息
|
|
111
|
-
* @param data 附加数据
|
|
112
|
-
*/
|
|
113
|
-
success(message: string, data?: any): void;
|
|
114
|
-
/**
|
|
115
|
-
* 输出信息日志
|
|
116
|
-
* @param message 日志消息
|
|
117
|
-
* @param data 附加数据
|
|
118
|
-
*/
|
|
119
|
-
info(message: string, data?: any): void;
|
|
120
|
-
/**
|
|
121
|
-
* 输出警告日志
|
|
122
|
-
* @param message 日志消息
|
|
123
|
-
* @param data 附加数据
|
|
124
|
-
*/
|
|
125
|
-
warn(message: string, data?: any): void;
|
|
126
|
-
/**
|
|
127
|
-
* 输出错误日志
|
|
128
|
-
* @param message 日志消息
|
|
129
|
-
* @param data 附加数据
|
|
130
|
-
*/
|
|
131
|
-
error(message: string, data?: any): void;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export { Logger as L };
|
|
135
|
-
export type { PluginLogger as P, LoggerOptions as a };
|