@meng-xi/vite-plugin 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README-en.md +170 -49
  2. package/README.md +149 -29
  3. package/dist/common/format/index.cjs +1 -0
  4. package/dist/common/format/index.d.cts +156 -0
  5. package/dist/common/format/index.d.mts +156 -0
  6. package/dist/common/format/index.d.ts +156 -0
  7. package/dist/common/format/index.mjs +1 -0
  8. package/dist/common/fs/index.cjs +1 -0
  9. package/dist/common/fs/index.d.cts +150 -0
  10. package/dist/common/fs/index.d.mts +150 -0
  11. package/dist/common/fs/index.d.ts +150 -0
  12. package/dist/common/fs/index.mjs +1 -0
  13. package/dist/common/html/index.cjs +2 -0
  14. package/dist/common/html/index.d.cts +109 -0
  15. package/dist/common/html/index.d.mts +109 -0
  16. package/dist/common/html/index.d.ts +109 -0
  17. package/dist/common/html/index.mjs +2 -0
  18. package/dist/common/index.cjs +1 -1
  19. package/dist/common/index.d.cts +7 -417
  20. package/dist/common/index.d.mts +7 -417
  21. package/dist/common/index.d.ts +7 -417
  22. package/dist/common/index.mjs +1 -1
  23. package/dist/common/object/index.cjs +1 -0
  24. package/dist/common/object/index.d.cts +30 -0
  25. package/dist/common/object/index.d.mts +30 -0
  26. package/dist/common/object/index.d.ts +30 -0
  27. package/dist/common/object/index.mjs +1 -0
  28. package/dist/common/script/index.cjs +1 -0
  29. package/dist/common/script/index.d.cts +54 -0
  30. package/dist/common/script/index.d.mts +54 -0
  31. package/dist/common/script/index.d.ts +54 -0
  32. package/dist/common/script/index.mjs +1 -0
  33. package/dist/common/validation/index.cjs +1 -0
  34. package/dist/common/validation/index.d.cts +93 -0
  35. package/dist/common/validation/index.d.mts +93 -0
  36. package/dist/common/validation/index.d.ts +93 -0
  37. package/dist/common/validation/index.mjs +1 -0
  38. package/dist/factory/index.cjs +1 -1
  39. package/dist/factory/index.d.cts +1 -1
  40. package/dist/factory/index.d.mts +1 -1
  41. package/dist/factory/index.d.ts +1 -1
  42. package/dist/factory/index.mjs +1 -1
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.cts +15 -3
  45. package/dist/index.d.mts +15 -3
  46. package/dist/index.d.ts +15 -3
  47. package/dist/index.mjs +1 -1
  48. package/dist/plugins/buildProgress/index.cjs +2 -0
  49. package/dist/plugins/buildProgress/index.d.cts +187 -0
  50. package/dist/plugins/buildProgress/index.d.mts +187 -0
  51. package/dist/plugins/buildProgress/index.d.ts +187 -0
  52. package/dist/plugins/buildProgress/index.mjs +2 -0
  53. package/dist/plugins/copyFile/index.cjs +1 -0
  54. package/dist/plugins/copyFile/index.d.cts +78 -0
  55. package/dist/plugins/copyFile/index.d.mts +78 -0
  56. package/dist/plugins/copyFile/index.d.ts +78 -0
  57. package/dist/plugins/copyFile/index.mjs +1 -0
  58. package/dist/plugins/faviconManager/index.cjs +1 -0
  59. package/dist/plugins/faviconManager/index.d.cts +143 -0
  60. package/dist/plugins/faviconManager/index.d.mts +143 -0
  61. package/dist/plugins/faviconManager/index.d.ts +143 -0
  62. package/dist/plugins/faviconManager/index.mjs +1 -0
  63. package/dist/plugins/generateRouter/index.cjs +35 -0
  64. package/dist/plugins/generateRouter/index.d.cts +215 -0
  65. package/dist/plugins/generateRouter/index.d.mts +215 -0
  66. package/dist/plugins/generateRouter/index.d.ts +215 -0
  67. package/dist/plugins/generateRouter/index.mjs +35 -0
  68. package/dist/plugins/generateVersion/index.cjs +1 -0
  69. package/dist/plugins/generateVersion/index.d.cts +184 -0
  70. package/dist/plugins/generateVersion/index.d.mts +184 -0
  71. package/dist/plugins/generateVersion/index.d.ts +184 -0
  72. package/dist/plugins/generateVersion/index.mjs +1 -0
  73. package/dist/plugins/htmlInject/index.cjs +7 -0
  74. package/dist/plugins/htmlInject/index.d.cts +278 -0
  75. package/dist/plugins/htmlInject/index.d.mts +278 -0
  76. package/dist/plugins/htmlInject/index.d.ts +278 -0
  77. package/dist/plugins/htmlInject/index.mjs +7 -0
  78. package/dist/plugins/index.cjs +1 -1
  79. package/dist/plugins/index.d.cts +10 -1714
  80. package/dist/plugins/index.d.mts +10 -1714
  81. package/dist/plugins/index.d.ts +10 -1714
  82. package/dist/plugins/index.mjs +1 -1
  83. package/dist/plugins/loadingManager/index.cjs +487 -0
  84. package/dist/plugins/loadingManager/index.d.cts +769 -0
  85. package/dist/plugins/loadingManager/index.d.mts +769 -0
  86. package/dist/plugins/loadingManager/index.d.ts +769 -0
  87. package/dist/plugins/loadingManager/index.mjs +487 -0
  88. package/dist/plugins/versionUpdateChecker/index.cjs +185 -0
  89. package/dist/plugins/versionUpdateChecker/index.d.cts +200 -0
  90. package/dist/plugins/versionUpdateChecker/index.d.mts +200 -0
  91. package/dist/plugins/versionUpdateChecker/index.d.ts +200 -0
  92. package/dist/plugins/versionUpdateChecker/index.mjs +185 -0
  93. package/dist/shared/vite-plugin.Bcg6RW2N.cjs +3 -0
  94. package/dist/shared/{vite-plugin.CiHfwMiN.d.ts → vite-plugin.DRRlWY8P.d.cts} +50 -0
  95. package/dist/shared/{vite-plugin.CiHfwMiN.d.cts → vite-plugin.DRRlWY8P.d.mts} +50 -0
  96. package/dist/shared/{vite-plugin.CiHfwMiN.d.mts → vite-plugin.DRRlWY8P.d.ts} +50 -0
  97. package/dist/shared/{vite-plugin.B88RyRN8.mjs → vite-plugin.DcExl6jd.mjs} +2 -2
  98. package/package.json +72 -2
  99. package/dist/shared/vite-plugin.CawoITTT.cjs +0 -1
  100. package/dist/shared/vite-plugin.D6Law9Ke.mjs +0 -706
  101. package/dist/shared/vite-plugin.D8L9KzuW.cjs +0 -706
  102. package/dist/shared/vite-plugin.DFjf9wFM.mjs +0 -2
  103. package/dist/shared/vite-plugin.DSb6XzBn.mjs +0 -1
  104. package/dist/shared/vite-plugin.IGZeStMa.cjs +0 -3
  105. package/dist/shared/vite-plugin.Tab4qcIM.cjs +0 -2
@@ -1,417 +1,7 @@
1
- export { V as Validator } from '../shared/vite-plugin.CiHfwMiN.js';
2
-
3
- /**
4
- * 复制操作的选项接口
5
- */
6
- interface CopyOptions {
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.js';
2
+ export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.js';
3
+ export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.js';
4
+ export { deepMerge } from './object/index.js';
5
+ export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.js';
6
+ export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.js';
7
+ export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.js';
@@ -1 +1 @@
1
- export{c as checkSourceExists,a as containsScriptTag,b as copySourceToTarget,e as ensureTargetDir,f as fileExists,d as formatDate,g as generateRandomHash,h as getDateFormatParams,i as injectBeforeTag,j as injectHtmlByPriority,m as makeCallback,p as padNumber,k as parseTemplate,r as readDirRecursive,l as readFileContent,n as readFileSync,o as runWithConcurrency,s as shouldUpdateFile,q as stripJsonComments,t as toCamelCase,u as toPascalCase,v as validateIdentifierName,w as writeFileContent}from"../shared/vite-plugin.DFjf9wFM.mjs";export{V as Validator,d as deepMerge}from"../shared/vite-plugin.B88RyRN8.mjs";import"fs";import"path";import"crypto";
1
+ export{checkSourceExists,copySourceToTarget,ensureTargetDir,fileExists,readDirRecursive,readFileContent,readFileSync,runWithConcurrency,shouldUpdateFile,writeFileContent}from"./fs/index.mjs";export{escapeHtmlAttr,formatDate,generateRandomHash,getDateFormatParams,padNumber,parseTemplate,stripJsonComments,toCamelCase,toPascalCase}from"./format/index.mjs";export{injectBeforeTag,injectBeforeTagWithFallback,injectHeadAndBody,injectHtmlByPriority}from"./html/index.mjs";export{deepMerge}from"./object/index.mjs";export{containsScriptTag,makeCallback,validateIdentifierName}from"./script/index.mjs";export{V as Validator}from"../shared/vite-plugin.DcExl6jd.mjs";export{validateCallbackFields,validateEnumValue,validateGlobalName,validateNestedDuration,validateNoScriptInTemplate,validateNonNegativeNumber}from"./validation/index.mjs";import"fs";import"path";import"crypto";
@@ -0,0 +1 @@
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;
@@ -0,0 +1,30 @@
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 };
@@ -0,0 +1,30 @@
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 };
@@ -0,0 +1,30 @@
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 };
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
1
+ "use strict";function makeCallback(u,r="callback",t=""){return u?`function(${t}) { try { ${u} } catch(e) { console.error('[${r}] error:', e); } }`:`function(${t}) {}`}function containsScriptTag(u){return/<script\b/i.test(u)}function validateIdentifierName(u){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(u))throw new Error(`"${u}" \u4E0D\u662F\u5408\u6CD5\u7684 JavaScript \u6807\u8BC6\u7B26\uFF0C\u5FC5\u987B\u4EE5\u5B57\u6BCD\u3001\u4E0B\u5212\u7EBF\u6216\u7F8E\u5143\u7B26\u5F00\u5934\uFF0C\u4EC5\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u548C\u7F8E\u5143\u7B26`);if(["__proto__","constructor","prototype"].includes(u))throw new Error(`"${u}" \u662F JavaScript \u5185\u7F6E\u5C5E\u6027\uFF0C\u53EF\u80FD\u5BFC\u81F4\u539F\u578B\u6C61\u67D3\uFF0C\u8BF7\u4F7F\u7528\u5176\u4ED6\u540D\u79F0`)}exports.containsScriptTag=containsScriptTag,exports.makeCallback=makeCallback,exports.validateIdentifierName=validateIdentifierName;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 将回调函数体字符串包装为安全的函数表达式
3
+ *
4
+ * @param body - 函数体代码字符串
5
+ * @param context - 回调上下文标识,用于错误日志
6
+ * @param params - 函数参数列表字符串,默认为空
7
+ * @returns 安全的函数表达式字符串(包含 try-catch 保护)
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * makeCallback('console.log("done")')
12
+ * // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
13
+ *
14
+ * makeCallback('console.log(a, b)', 'callback', 'a, b')
15
+ * // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
16
+ *
17
+ * makeCallback('')
18
+ * // 'function() {}'
19
+ * ```
20
+ */
21
+ declare function makeCallback(body?: string, context?: string, params?: string): string;
22
+ /**
23
+ * 检测字符串是否包含 `<script>` 标签
24
+ *
25
+ * @param str - 待检测的字符串
26
+ * @returns 是否包含 script 标签
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * containsScriptTag('<div onclick="alert(1)">') // false
31
+ * containsScriptTag('<script>alert(1)</script>') // true
32
+ * ```
33
+ */
34
+ declare function containsScriptTag(str: string): boolean;
35
+ /**
36
+ * 验证字符串是否为合法的 JavaScript 标识符
37
+ *
38
+ * @description 检查名称是否以字母、下划线或美元符开头,
39
+ * 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
40
+ *
41
+ * @param name - 待验证的标识符名称
42
+ * @throws 当名称不是合法标识符时抛出错误
43
+ * @throws 当名称为 JavaScript 内置属性时抛出错误
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * validateIdentifierName('__LOADING_MANAGER__') // 通过
48
+ * validateIdentifierName('123abc') // 抛出错误
49
+ * validateIdentifierName('__proto__') // 抛出错误(内置属性)
50
+ * ```
51
+ */
52
+ declare function validateIdentifierName(name: string): void;
53
+
54
+ export { containsScriptTag, makeCallback, validateIdentifierName };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 将回调函数体字符串包装为安全的函数表达式
3
+ *
4
+ * @param body - 函数体代码字符串
5
+ * @param context - 回调上下文标识,用于错误日志
6
+ * @param params - 函数参数列表字符串,默认为空
7
+ * @returns 安全的函数表达式字符串(包含 try-catch 保护)
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * makeCallback('console.log("done")')
12
+ * // 'function() { try { console.log("done") } catch(e) { console.error('[callback] error:', e); } }'
13
+ *
14
+ * makeCallback('console.log(a, b)', 'callback', 'a, b')
15
+ * // 'function(a, b) { try { console.log(a, b) } catch(e) { console.error('[callback] error:', e); } }'
16
+ *
17
+ * makeCallback('')
18
+ * // 'function() {}'
19
+ * ```
20
+ */
21
+ declare function makeCallback(body?: string, context?: string, params?: string): string;
22
+ /**
23
+ * 检测字符串是否包含 `<script>` 标签
24
+ *
25
+ * @param str - 待检测的字符串
26
+ * @returns 是否包含 script 标签
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * containsScriptTag('<div onclick="alert(1)">') // false
31
+ * containsScriptTag('<script>alert(1)</script>') // true
32
+ * ```
33
+ */
34
+ declare function containsScriptTag(str: string): boolean;
35
+ /**
36
+ * 验证字符串是否为合法的 JavaScript 标识符
37
+ *
38
+ * @description 检查名称是否以字母、下划线或美元符开头,
39
+ * 仅包含字母、数字、下划线和美元符,并排除可能导致原型污染的内置属性
40
+ *
41
+ * @param name - 待验证的标识符名称
42
+ * @throws 当名称不是合法标识符时抛出错误
43
+ * @throws 当名称为 JavaScript 内置属性时抛出错误
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * validateIdentifierName('__LOADING_MANAGER__') // 通过
48
+ * validateIdentifierName('123abc') // 抛出错误
49
+ * validateIdentifierName('__proto__') // 抛出错误(内置属性)
50
+ * ```
51
+ */
52
+ declare function validateIdentifierName(name: string): void;
53
+
54
+ export { containsScriptTag, makeCallback, validateIdentifierName };