@meng-xi/vite-plugin 0.1.0 → 0.1.2
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 +264 -533
- package/README.md +253 -522
- 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 -417
- package/dist/common/index.d.mts +7 -417
- package/dist/common/index.d.ts +7 -417
- 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 +16 -3
- package/dist/index.d.mts +16 -3
- package/dist/index.d.ts +16 -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/compressAssets/index.cjs +1 -0
- package/dist/plugins/compressAssets/index.d.cts +132 -0
- package/dist/plugins/compressAssets/index.d.mts +132 -0
- package/dist/plugins/compressAssets/index.d.ts +132 -0
- package/dist/plugins/compressAssets/index.mjs +1 -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 +11 -1714
- package/dist/plugins/index.d.mts +11 -1714
- package/dist/plugins/index.d.ts +11 -1714
- 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.ts → vite-plugin.DRRlWY8P.d.cts} +50 -0
- package/dist/shared/{vite-plugin.CiHfwMiN.d.cts → vite-plugin.DRRlWY8P.d.mts} +50 -0
- package/dist/shared/{vite-plugin.CiHfwMiN.d.mts → vite-plugin.DRRlWY8P.d.ts} +50 -0
- package/dist/shared/{vite-plugin.B88RyRN8.mjs → vite-plugin.DcExl6jd.mjs} +2 -2
- package/package.json +80 -3
- package/dist/shared/vite-plugin.CawoITTT.cjs +0 -1
- package/dist/shared/vite-plugin.D6Law9Ke.mjs +0 -706
- package/dist/shared/vite-plugin.D8L9KzuW.cjs +0 -706
- package/dist/shared/vite-plugin.DFjf9wFM.mjs +0 -2
- package/dist/shared/vite-plugin.DSb6XzBn.mjs +0 -1
- package/dist/shared/vite-plugin.IGZeStMa.cjs +0 -3
- package/dist/shared/vite-plugin.Tab4qcIM.cjs +0 -2
package/dist/common/index.d.mts
CHANGED
|
@@ -1,417 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* 是否支持递归复制
|
|
9
|
-
*/
|
|
10
|
-
recursive: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* 是否覆盖同名文件
|
|
13
|
-
*/
|
|
14
|
-
overwrite: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* 是否启用增量复制
|
|
17
|
-
*/
|
|
18
|
-
incremental?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* 并行处理的最大文件数
|
|
21
|
-
*/
|
|
22
|
-
parallelLimit?: number;
|
|
23
|
-
/**
|
|
24
|
-
* 是否跳过空目录
|
|
25
|
-
*/
|
|
26
|
-
skipEmptyDirs?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 复制结果接口
|
|
30
|
-
*/
|
|
31
|
-
interface CopyResult {
|
|
32
|
-
/**
|
|
33
|
-
* 复制的文件数量
|
|
34
|
-
*/
|
|
35
|
-
copiedFiles: number;
|
|
36
|
-
/**
|
|
37
|
-
* 跳过的文件数量
|
|
38
|
-
*/
|
|
39
|
-
skippedFiles: number;
|
|
40
|
-
/**
|
|
41
|
-
* 复制的目录数量
|
|
42
|
-
*/
|
|
43
|
-
copiedDirs: number;
|
|
44
|
-
/**
|
|
45
|
-
* 总执行时间(毫秒)
|
|
46
|
-
*/
|
|
47
|
-
executionTime: number;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 文件/目录条目信息
|
|
52
|
-
*/
|
|
53
|
-
interface FileEntry {
|
|
54
|
-
/** 完整路径 */
|
|
55
|
-
path: string;
|
|
56
|
-
/** 是否为文件 */
|
|
57
|
-
isFile: boolean;
|
|
58
|
-
/** 是否为目录 */
|
|
59
|
-
isDirectory: boolean;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* 检查源文件是否存在
|
|
63
|
-
* @param sourcePath 源文件路径
|
|
64
|
-
* @throws 当源文件不存在或无法访问时抛出异常
|
|
65
|
-
*/
|
|
66
|
-
declare function checkSourceExists(sourcePath: string): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* 创建目标目录
|
|
69
|
-
* @param targetPath 目标目录路径
|
|
70
|
-
* @throws 当无法创建目标目录时抛出异常
|
|
71
|
-
*/
|
|
72
|
-
declare function ensureTargetDir(targetPath: string): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* 读取目录内容(优化版:一次性获取文件类型信息)
|
|
75
|
-
* @param dirPath 目录路径
|
|
76
|
-
* @param recursive 是否递归读取
|
|
77
|
-
* @returns 文件和目录条目列表
|
|
78
|
-
*/
|
|
79
|
-
declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<FileEntry[]>;
|
|
80
|
-
/**
|
|
81
|
-
* 检查文件是否需要更新
|
|
82
|
-
* @param sourceFile 源文件路径
|
|
83
|
-
* @param targetFile 目标文件路径
|
|
84
|
-
* @returns 是否需要更新
|
|
85
|
-
*/
|
|
86
|
-
declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
|
|
87
|
-
/**
|
|
88
|
-
* 检查文件是否存在
|
|
89
|
-
* @param filePath 文件路径
|
|
90
|
-
* @returns 是否存在
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* if (await fileExists('/path/to/file')) {
|
|
95
|
-
* console.log('文件存在')
|
|
96
|
-
* }
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
declare function fileExists(filePath: string): Promise<boolean>;
|
|
100
|
-
/**
|
|
101
|
-
* 带并发限制的批量执行
|
|
102
|
-
*
|
|
103
|
-
* @param items 待处理项
|
|
104
|
-
* @param handler 处理函数
|
|
105
|
-
* @param concurrency 并发数
|
|
106
|
-
* @returns 处理结果数组,顺序与输入项对应
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5']
|
|
111
|
-
* const results = await runWithConcurrency(
|
|
112
|
-
* urls,
|
|
113
|
-
* async (url) => fetch(url),
|
|
114
|
-
* 3 // 最多同时处理3个请求
|
|
115
|
-
* )
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare function runWithConcurrency<T, R>(items: T[], handler: (item: T) => Promise<R>, concurrency: number): Promise<R[]>;
|
|
119
|
-
/**
|
|
120
|
-
* 执行文件复制操作(优化版:并行IO)
|
|
121
|
-
* @param sourcePath 源文件或目录路径
|
|
122
|
-
* @param targetPath 目标文件或目录路径
|
|
123
|
-
* @param options 复制选项
|
|
124
|
-
* @returns 复制结果
|
|
125
|
-
* @throws 当复制过程中出现错误时抛出异常
|
|
126
|
-
*/
|
|
127
|
-
declare function copySourceToTarget(sourcePath: string, targetPath: string, options: CopyOptions): Promise<CopyResult>;
|
|
128
|
-
/**
|
|
129
|
-
* 写入文件内容
|
|
130
|
-
* @param filePath 文件路径
|
|
131
|
-
* @param content 文件内容
|
|
132
|
-
* @throws 当写入过程中出现错误时抛出异常
|
|
133
|
-
*/
|
|
134
|
-
declare function writeFileContent(filePath: string, content: string): Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
* 读取文件内容
|
|
137
|
-
* @param filePath 文件路径
|
|
138
|
-
* @returns 文件内容字符串
|
|
139
|
-
* @throws 当读取过程中出现错误时抛出异常
|
|
140
|
-
*/
|
|
141
|
-
declare function readFileContent(filePath: string): Promise<string>;
|
|
142
|
-
/**
|
|
143
|
-
* 同步读取文件内容
|
|
144
|
-
* @param filePath 文件路径
|
|
145
|
-
* @returns 文件内容字符串
|
|
146
|
-
* @throws 当读取过程中出现错误时抛出异常
|
|
147
|
-
* @deprecated 请使用异步版本 readFileContent
|
|
148
|
-
*/
|
|
149
|
-
declare function readFileSync(filePath: string): string;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 数字补零格式化
|
|
153
|
-
*
|
|
154
|
-
* @param num 要格式化的数字
|
|
155
|
-
* @param length 目标长度
|
|
156
|
-
* @returns 补零后的字符串
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
|
-
* ```typescript
|
|
160
|
-
* padNumber(5, 2) // '05'
|
|
161
|
-
* padNumber(12, 3) // '012'
|
|
162
|
-
* padNumber(123, 2) // '123'
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
declare function padNumber(num: number, length?: number): string;
|
|
166
|
-
/**
|
|
167
|
-
* 生成随机哈希字符串
|
|
168
|
-
*
|
|
169
|
-
* @param length 哈希长度,范围 1-64
|
|
170
|
-
* @returns 随机哈希字符串
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```typescript
|
|
174
|
-
* generateRandomHash(8) // 'a1b2c3d4'
|
|
175
|
-
* generateRandomHash(16) // 'a1b2c3d4e5f6g7h8'
|
|
176
|
-
* ```
|
|
177
|
-
*/
|
|
178
|
-
declare function generateRandomHash(length?: number): string;
|
|
179
|
-
/**
|
|
180
|
-
* 日期格式化选项
|
|
181
|
-
*/
|
|
182
|
-
interface DateFormatOptions {
|
|
183
|
-
/** 四位年份 */
|
|
184
|
-
YYYY: string;
|
|
185
|
-
/** 两位年份 */
|
|
186
|
-
YY: string;
|
|
187
|
-
/** 两位月份 */
|
|
188
|
-
MM: string;
|
|
189
|
-
/** 两位日期 */
|
|
190
|
-
DD: string;
|
|
191
|
-
/** 两位小时(24小时制) */
|
|
192
|
-
HH: string;
|
|
193
|
-
/** 两位分钟 */
|
|
194
|
-
mm: string;
|
|
195
|
-
/** 两位秒数 */
|
|
196
|
-
ss: string;
|
|
197
|
-
/** 三位毫秒 */
|
|
198
|
-
SSS: string;
|
|
199
|
-
/** 时间戳(毫秒) */
|
|
200
|
-
timestamp: string;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 获取日期格式化参数
|
|
204
|
-
*
|
|
205
|
-
* @param date 日期对象
|
|
206
|
-
* @returns 日期格式化参数对象
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* ```typescript
|
|
210
|
-
* const params = getDateFormatParams(new Date())
|
|
211
|
-
* // { YYYY: '2026', MM: '02', DD: '03', HH: '15', mm: '30', ss: '00', ... }
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
declare function getDateFormatParams(date?: Date): DateFormatOptions;
|
|
215
|
-
/**
|
|
216
|
-
* 格式化日期
|
|
217
|
-
*
|
|
218
|
-
* @param date 日期对象
|
|
219
|
-
* @param format 格式模板
|
|
220
|
-
* @returns 格式化后的日期字符串
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```typescript
|
|
224
|
-
* formatDate(new Date(), '{YYYY}-{MM}-{DD}') // '2026-02-03'
|
|
225
|
-
* formatDate(new Date(), '{YYYY}{MM}{DD}{HH}{mm}{ss}') // '20260203153000'
|
|
226
|
-
* formatDate(new Date(), '{YYYY}.{MM}.{DD}') // '2026.02.03'
|
|
227
|
-
* ```
|
|
228
|
-
*/
|
|
229
|
-
declare function formatDate(date: Date, format: string): string;
|
|
230
|
-
/**
|
|
231
|
-
* 解析模板字符串,替换占位符
|
|
232
|
-
*
|
|
233
|
-
* @param template 模板字符串
|
|
234
|
-
* @param values 占位符值映射
|
|
235
|
-
* @returns 替换后的字符串
|
|
236
|
-
*
|
|
237
|
-
* @example
|
|
238
|
-
* ```typescript
|
|
239
|
-
* parseTemplate('{name}-{version}', { name: 'app', version: '1.0.0' })
|
|
240
|
-
* // 'app-1.0.0'
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
declare function parseTemplate(template: string, values: Record<string, string>): string;
|
|
244
|
-
/**
|
|
245
|
-
* 将字符串转换为驼峰命名(camelCase)
|
|
246
|
-
*
|
|
247
|
-
* @param str 输入字符串
|
|
248
|
-
* @param separators 分隔符正则,默认为斜杠和横线
|
|
249
|
-
* @returns 驼峰命名字符串
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
* ```typescript
|
|
253
|
-
* toCamelCase('pages/user/profile') // 'pagesUserProfile'
|
|
254
|
-
* toCamelCase('user-profile-page') // 'userProfilePage'
|
|
255
|
-
* toCamelCase('/pages/index') // 'pagesIndex'
|
|
256
|
-
* ```
|
|
257
|
-
*/
|
|
258
|
-
declare function toCamelCase(str: string, separators?: RegExp): string;
|
|
259
|
-
/**
|
|
260
|
-
* 将字符串转换为帕斯卡命名(PascalCase)
|
|
261
|
-
*
|
|
262
|
-
* @param str 输入字符串
|
|
263
|
-
* @param separators 分隔符正则,默认为斜杠和横线
|
|
264
|
-
* @returns 帕斯卡命名字符串
|
|
265
|
-
*
|
|
266
|
-
* @example
|
|
267
|
-
* ```typescript
|
|
268
|
-
* toPascalCase('pages/user/profile') // 'PagesUserProfile'
|
|
269
|
-
* toPascalCase('user-profile-page') // 'UserProfilePage'
|
|
270
|
-
* toPascalCase('/pages/index') // 'PagesIndex'
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
declare function toPascalCase(str: string, separators?: RegExp): string;
|
|
274
|
-
/**
|
|
275
|
-
* 移除 JSON 字符串中的注释
|
|
276
|
-
*
|
|
277
|
-
* @param jsonString 包含注释的 JSON 字符串
|
|
278
|
-
* @returns 移除注释后的 JSON 字符串
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* ```typescript
|
|
282
|
-
* stripJsonComments('{\n // comment\n "name": "test"\n}')
|
|
283
|
-
* // '{\n "name": "test"\n}'
|
|
284
|
-
* ```
|
|
285
|
-
*/
|
|
286
|
-
declare function stripJsonComments(jsonString: string): string;
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* HTML 注入结果
|
|
290
|
-
*/
|
|
291
|
-
interface HtmlInjectResult {
|
|
292
|
-
/** 注入后的 HTML 内容 */
|
|
293
|
-
html: string;
|
|
294
|
-
/** 是否成功注入 */
|
|
295
|
-
injected: boolean;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* 在 HTML 中指定闭合标签前注入代码
|
|
299
|
-
*
|
|
300
|
-
* @param html - 原始 HTML 内容
|
|
301
|
-
* @param tag - 目标闭合标签(如 `</head>`、`</body>`、`</html>`)
|
|
302
|
-
* @param code - 要注入的代码
|
|
303
|
-
* @returns 注入结果对象
|
|
304
|
-
*
|
|
305
|
-
* @example
|
|
306
|
-
* ```typescript
|
|
307
|
-
* // 在 </head> 前注入 CSS
|
|
308
|
-
* const result = injectBeforeTag(html, '</head>', '<style>...</style>')
|
|
309
|
-
*
|
|
310
|
-
* // 在 </body> 前注入 JS
|
|
311
|
-
* const result = injectBeforeTag(html, '</body>', '<script>...</script>')
|
|
312
|
-
* ```
|
|
313
|
-
*/
|
|
314
|
-
declare function injectBeforeTag(html: string, tag: string, code: string): HtmlInjectResult;
|
|
315
|
-
/**
|
|
316
|
-
* 按优先级向 HTML 中注入代码
|
|
317
|
-
*
|
|
318
|
-
* @description 依次尝试在 `</head>`、`</body>`、`</html>` 前注入代码,
|
|
319
|
-
* 优先注入到靠前的标签位置。适用于需要注入到页面中但无特定位置要求的场景
|
|
320
|
-
*
|
|
321
|
-
* @param html - 原始 HTML 内容
|
|
322
|
-
* @param code - 要注入的代码
|
|
323
|
-
* @param targets - 目标标签优先级列表,默认为 `['</head>', '</body>', '</html>']`
|
|
324
|
-
* @returns 注入结果对象
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* ```typescript
|
|
328
|
-
* // 优先注入到 </body> 前
|
|
329
|
-
* const result = injectHtmlByPriority(html, scriptCode, ['</body>', '</html>'])
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
declare function injectHtmlByPriority(html: string, code: string, targets?: string[]): HtmlInjectResult;
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* 深度合并对象
|
|
336
|
-
*
|
|
337
|
-
* @description 将多个源对象深度合并到一个新对象中。
|
|
338
|
-
* - undefined 值会被跳过,不会覆盖已有值
|
|
339
|
-
* - 嵌套对象会递归合并
|
|
340
|
-
* - 数组会直接覆盖,不会合并
|
|
341
|
-
* - null 值会覆盖已有值
|
|
342
|
-
*
|
|
343
|
-
* @param sources 源对象列表
|
|
344
|
-
* @returns 合并后的对象
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```typescript
|
|
348
|
-
* // 基本合并
|
|
349
|
-
* deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
|
|
350
|
-
*
|
|
351
|
-
* // undefined 不覆盖
|
|
352
|
-
* deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
|
|
353
|
-
*
|
|
354
|
-
* // 嵌套对象合并
|
|
355
|
-
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
|
|
356
|
-
*
|
|
357
|
-
* // 数组覆盖
|
|
358
|
-
* deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* 将回调函数体字符串包装为安全的函数表达式
|
|
365
|
-
*
|
|
366
|
-
* @param body - 函数体代码字符串
|
|
367
|
-
* @param context - 回调上下文标识,用于错误日志
|
|
368
|
-
* @param params - 函数参数列表字符串,默认为空
|
|
369
|
-
* @returns 安全的函数表达式字符串(包含 try-catch 保护)
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```typescript
|
|
373
|
-
* makeCallback('console.log("done")')
|
|
374
|
-
* // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
|
|
375
|
-
*
|
|
376
|
-
* makeCallback('console.log(a, b)', 'callback', 'a, b')
|
|
377
|
-
* // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
|
|
378
|
-
*
|
|
379
|
-
* makeCallback('')
|
|
380
|
-
* // 'function() {}'
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
declare function makeCallback(body?: string, context?: string, params?: string): string;
|
|
384
|
-
/**
|
|
385
|
-
* 检测字符串是否包含 `<script>` 标签
|
|
386
|
-
*
|
|
387
|
-
* @param str - 待检测的字符串
|
|
388
|
-
* @returns 是否包含 script 标签
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* ```typescript
|
|
392
|
-
* containsScriptTag('<div onclick="alert(1)">') // false
|
|
393
|
-
* containsScriptTag('<script>alert(1)</script>') // true
|
|
394
|
-
* ```
|
|
395
|
-
*/
|
|
396
|
-
declare function containsScriptTag(str: string): boolean;
|
|
397
|
-
/**
|
|
398
|
-
* 验证字符串是否为合法的 JavaScript 标识符
|
|
399
|
-
*
|
|
400
|
-
* @description 检查名称是否以字母、下划线或美元符开头,
|
|
401
|
-
* 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
|
|
402
|
-
*
|
|
403
|
-
* @param name - 待验证的标识符名称
|
|
404
|
-
* @throws 当名称不是合法标识符时抛出错误
|
|
405
|
-
* @throws 当名称为 JavaScript 内置属性时抛出错误
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```typescript
|
|
409
|
-
* validateIdentifierName('__LOADING_MANAGER__') // 通过
|
|
410
|
-
* validateIdentifierName('123abc') // 抛出错误
|
|
411
|
-
* validateIdentifierName('__proto__') // 抛出错误(内置属性)
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
declare function validateIdentifierName(name: string): void;
|
|
415
|
-
|
|
416
|
-
export { checkSourceExists, containsScriptTag, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, injectBeforeTag, injectHtmlByPriority, makeCallback, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, validateIdentifierName, writeFileContent };
|
|
417
|
-
export type { DateFormatOptions, HtmlInjectResult };
|
|
1
|
+
export { CopyOptions, CopyResult, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, writeFileContent } from './fs/index.mjs';
|
|
2
|
+
export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.mjs';
|
|
3
|
+
export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.mjs';
|
|
4
|
+
export { deepMerge } from './object/index.mjs';
|
|
5
|
+
export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.mjs';
|
|
6
|
+
export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.mjs';
|
|
7
|
+
export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.mjs';
|