@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.
Files changed (105) hide show
  1. package/README-en.md +467 -269
  2. package/README.md +451 -254
  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 -318
  20. package/dist/common/index.d.mts +7 -318
  21. package/dist/common/index.d.ts +7 -318
  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 -1520
  80. package/dist/plugins/index.d.mts +10 -1520
  81. package/dist/plugins/index.d.ts +10 -1520
  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.cts → vite-plugin.DRRlWY8P.d.cts} +50 -0
  95. package/dist/shared/{vite-plugin.CiHfwMiN.d.mts → vite-plugin.DRRlWY8P.d.mts} +50 -0
  96. package/dist/shared/{vite-plugin.CiHfwMiN.d.ts → 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.BI4kA-bR.mjs +0 -526
  100. package/dist/shared/vite-plugin.Ba9646wL.cjs +0 -1
  101. package/dist/shared/vite-plugin.C3ejdBNf.mjs +0 -1
  102. package/dist/shared/vite-plugin.CawoITTT.cjs +0 -1
  103. package/dist/shared/vite-plugin.CsdNNQ-4.cjs +0 -526
  104. package/dist/shared/vite-plugin.DSb6XzBn.mjs +0 -1
  105. package/dist/shared/vite-plugin.IGZeStMa.cjs +0 -3
@@ -1,318 +1,7 @@
1
- export { V as Validator } from '../shared/vite-plugin.CiHfwMiN.cjs';
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
- * 深度合并对象
290
- *
291
- * @description 将多个源对象深度合并到一个新对象中。
292
- * - undefined 值会被跳过,不会覆盖已有值
293
- * - 嵌套对象会递归合并
294
- * - 数组会直接覆盖,不会合并
295
- * - null 值会覆盖已有值
296
- *
297
- * @param sources 源对象列表
298
- * @returns 合并后的对象
299
- *
300
- * @example
301
- * ```typescript
302
- * // 基本合并
303
- * deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
304
- *
305
- * // undefined 不覆盖
306
- * deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
307
- *
308
- * // 嵌套对象合并
309
- * deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
310
- *
311
- * // 数组覆盖
312
- * deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
313
- * ```
314
- */
315
- declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
316
-
317
- export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent };
318
- export type { DateFormatOptions };
1
+ export { CopyOptions, CopyResult, checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, writeFileContent } from './fs/index.cjs';
2
+ export { DateFormatOptions, escapeHtmlAttr, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase } from './format/index.cjs';
3
+ export { DualInjectResult, HtmlInjectResult, injectBeforeTag, injectBeforeTagWithFallback, injectHeadAndBody, injectHtmlByPriority } from './html/index.cjs';
4
+ export { deepMerge } from './object/index.cjs';
5
+ export { containsScriptTag, makeCallback, validateIdentifierName } from './script/index.cjs';
6
+ export { V as Validator } from '../shared/vite-plugin.DRRlWY8P.cjs';
7
+ export { validateCallbackFields, validateEnumValue, validateGlobalName, validateNestedDuration, validateNoScriptInTemplate, validateNonNegativeNumber } from './validation/index.cjs';
@@ -1,318 +1,7 @@
1
- export { V as Validator } from '../shared/vite-plugin.CiHfwMiN.mjs';
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
- * 深度合并对象
290
- *
291
- * @description 将多个源对象深度合并到一个新对象中。
292
- * - undefined 值会被跳过,不会覆盖已有值
293
- * - 嵌套对象会递归合并
294
- * - 数组会直接覆盖,不会合并
295
- * - null 值会覆盖已有值
296
- *
297
- * @param sources 源对象列表
298
- * @returns 合并后的对象
299
- *
300
- * @example
301
- * ```typescript
302
- * // 基本合并
303
- * deepMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }
304
- *
305
- * // undefined 不覆盖
306
- * deepMerge({ a: 1 }, { a: undefined }) // { a: 1 }
307
- *
308
- * // 嵌套对象合并
309
- * deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // { a: { b: 1, c: 2 } }
310
- *
311
- * // 数组覆盖
312
- * deepMerge({ a: [1, 2] }, { a: [3, 4] }) // { a: [3, 4] }
313
- * ```
314
- */
315
- declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
316
-
317
- export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent };
318
- export type { DateFormatOptions };
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';