@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.
Files changed (142) hide show
  1. package/README-en.md +49 -775
  2. package/README.md +46 -770
  3. package/dist/common/format/index.cjs +1 -1
  4. package/dist/common/format/index.d.cts +1 -130
  5. package/dist/common/format/index.d.mts +1 -130
  6. package/dist/common/format/index.d.ts +1 -130
  7. package/dist/common/format/index.mjs +1 -1
  8. package/dist/common/fs/index.cjs +1 -1
  9. package/dist/common/fs/index.d.cts +1 -89
  10. package/dist/common/fs/index.d.mts +1 -89
  11. package/dist/common/fs/index.d.ts +1 -89
  12. package/dist/common/fs/index.mjs +1 -1
  13. package/dist/common/html/index.cjs +2 -2
  14. package/dist/common/html/index.d.cts +19 -81
  15. package/dist/common/html/index.d.mts +19 -81
  16. package/dist/common/html/index.d.ts +19 -81
  17. package/dist/common/html/index.mjs +2 -2
  18. package/dist/common/index.cjs +1 -1
  19. package/dist/common/index.d.cts +7 -8
  20. package/dist/common/index.d.mts +7 -8
  21. package/dist/common/index.d.ts +7 -8
  22. package/dist/common/index.mjs +1 -1
  23. package/dist/common/script/index.cjs +1 -1
  24. package/dist/common/script/index.d.cts +1 -44
  25. package/dist/common/script/index.d.mts +1 -44
  26. package/dist/common/script/index.d.ts +1 -44
  27. package/dist/common/script/index.mjs +1 -1
  28. package/dist/common/ui/index.cjs +1 -0
  29. package/dist/common/ui/index.d.cts +22 -0
  30. package/dist/common/ui/index.d.mts +22 -0
  31. package/dist/common/ui/index.d.ts +22 -0
  32. package/dist/common/ui/index.mjs +1 -0
  33. package/dist/common/validation/index.cjs +1 -1
  34. package/dist/common/validation/index.d.cts +2 -79
  35. package/dist/common/validation/index.d.mts +2 -79
  36. package/dist/common/validation/index.d.ts +2 -79
  37. package/dist/common/validation/index.mjs +1 -1
  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 +12 -10
  45. package/dist/index.d.mts +12 -10
  46. package/dist/index.d.ts +12 -10
  47. package/dist/index.mjs +1 -1
  48. package/dist/logger/index.d.cts +92 -1
  49. package/dist/logger/index.d.mts +92 -1
  50. package/dist/logger/index.d.ts +92 -1
  51. package/dist/plugins/autoImport/index.cjs +17 -0
  52. package/dist/plugins/autoImport/index.d.cts +291 -0
  53. package/dist/plugins/autoImport/index.d.mts +291 -0
  54. package/dist/plugins/autoImport/index.d.ts +291 -0
  55. package/dist/plugins/autoImport/index.mjs +17 -0
  56. package/dist/plugins/buildProgress/index.cjs +2 -2
  57. package/dist/plugins/buildProgress/index.d.cts +1 -1
  58. package/dist/plugins/buildProgress/index.d.mts +1 -1
  59. package/dist/plugins/buildProgress/index.d.ts +1 -1
  60. package/dist/plugins/buildProgress/index.mjs +2 -2
  61. package/dist/plugins/bundleAnalyzer/index.cjs +11 -11
  62. package/dist/plugins/bundleAnalyzer/index.d.cts +1 -1
  63. package/dist/plugins/bundleAnalyzer/index.d.mts +1 -1
  64. package/dist/plugins/bundleAnalyzer/index.d.ts +1 -1
  65. package/dist/plugins/bundleAnalyzer/index.mjs +18 -18
  66. package/dist/plugins/compressAssets/index.cjs +1 -1
  67. package/dist/plugins/compressAssets/index.d.cts +1 -1
  68. package/dist/plugins/compressAssets/index.d.mts +1 -1
  69. package/dist/plugins/compressAssets/index.d.ts +1 -1
  70. package/dist/plugins/compressAssets/index.mjs +1 -1
  71. package/dist/plugins/copyFile/index.cjs +1 -1
  72. package/dist/plugins/copyFile/index.d.cts +21 -3
  73. package/dist/plugins/copyFile/index.d.mts +21 -3
  74. package/dist/plugins/copyFile/index.d.ts +21 -3
  75. package/dist/plugins/copyFile/index.mjs +1 -1
  76. package/dist/plugins/envGuard/index.cjs +67 -0
  77. package/dist/plugins/envGuard/index.d.cts +255 -0
  78. package/dist/plugins/envGuard/index.d.mts +255 -0
  79. package/dist/plugins/envGuard/index.d.ts +255 -0
  80. package/dist/plugins/envGuard/index.mjs +67 -0
  81. package/dist/plugins/faviconManager/index.cjs +1 -1
  82. package/dist/plugins/faviconManager/index.d.cts +44 -6
  83. package/dist/plugins/faviconManager/index.d.mts +44 -6
  84. package/dist/plugins/faviconManager/index.d.ts +44 -6
  85. package/dist/plugins/faviconManager/index.mjs +1 -1
  86. package/dist/plugins/generateRouter/index.cjs +4 -4
  87. package/dist/plugins/generateRouter/index.d.cts +62 -15
  88. package/dist/plugins/generateRouter/index.d.mts +62 -15
  89. package/dist/plugins/generateRouter/index.d.ts +62 -15
  90. package/dist/plugins/generateRouter/index.mjs +4 -4
  91. package/dist/plugins/generateVersion/index.cjs +1 -1
  92. package/dist/plugins/generateVersion/index.d.cts +13 -1
  93. package/dist/plugins/generateVersion/index.d.mts +13 -1
  94. package/dist/plugins/generateVersion/index.d.ts +13 -1
  95. package/dist/plugins/generateVersion/index.mjs +1 -1
  96. package/dist/plugins/htmlInject/index.cjs +7 -7
  97. package/dist/plugins/htmlInject/index.d.cts +50 -195
  98. package/dist/plugins/htmlInject/index.d.mts +50 -195
  99. package/dist/plugins/htmlInject/index.d.ts +50 -195
  100. package/dist/plugins/htmlInject/index.mjs +7 -7
  101. package/dist/plugins/index.cjs +1 -1
  102. package/dist/plugins/index.d.cts +5 -2
  103. package/dist/plugins/index.d.mts +5 -2
  104. package/dist/plugins/index.d.ts +5 -2
  105. package/dist/plugins/index.mjs +1 -1
  106. package/dist/plugins/loadingManager/index.cjs +26 -26
  107. package/dist/plugins/loadingManager/index.d.cts +1 -1
  108. package/dist/plugins/loadingManager/index.d.mts +1 -1
  109. package/dist/plugins/loadingManager/index.d.ts +1 -1
  110. package/dist/plugins/loadingManager/index.mjs +11 -11
  111. package/dist/plugins/versionUpdateChecker/index.cjs +1 -1
  112. package/dist/plugins/versionUpdateChecker/index.d.cts +1 -1
  113. package/dist/plugins/versionUpdateChecker/index.d.mts +1 -1
  114. package/dist/plugins/versionUpdateChecker/index.d.ts +1 -1
  115. package/dist/plugins/versionUpdateChecker/index.mjs +1 -1
  116. package/dist/shared/vite-plugin.B8FuZce1.d.cts +45 -0
  117. package/dist/shared/vite-plugin.B8FuZce1.d.mts +45 -0
  118. package/dist/shared/vite-plugin.B8FuZce1.d.ts +45 -0
  119. package/dist/shared/vite-plugin.BI9taN75.d.cts +122 -0
  120. package/dist/shared/vite-plugin.BI9taN75.d.mts +122 -0
  121. package/dist/shared/vite-plugin.BI9taN75.d.ts +122 -0
  122. package/dist/shared/vite-plugin.BPFqtmWa.mjs +1 -0
  123. package/dist/shared/vite-plugin.CnOy46d3.cjs +1 -0
  124. package/package.json +16 -16
  125. package/dist/common/compress/index.cjs +0 -1
  126. package/dist/common/compress/index.d.cts +0 -23
  127. package/dist/common/compress/index.d.mts +0 -23
  128. package/dist/common/compress/index.d.ts +0 -23
  129. package/dist/common/compress/index.mjs +0 -1
  130. package/dist/common/object/index.cjs +0 -1
  131. package/dist/common/object/index.d.cts +0 -30
  132. package/dist/common/object/index.d.mts +0 -30
  133. package/dist/common/object/index.d.ts +0 -30
  134. package/dist/common/object/index.mjs +0 -1
  135. package/dist/common/path/index.cjs +0 -1
  136. package/dist/common/path/index.d.cts +0 -22
  137. package/dist/common/path/index.d.mts +0 -22
  138. package/dist/common/path/index.d.ts +0 -22
  139. package/dist/common/path/index.mjs +0 -1
  140. package/dist/shared/vite-plugin.CLr0ttuO.d.cts +0 -135
  141. package/dist/shared/vite-plugin.CLr0ttuO.d.mts +0 -135
  142. package/dist/shared/vite-plugin.CLr0ttuO.d.ts +0 -135
@@ -1 +1 @@
1
- "use strict";const crypto=require("crypto"),a=require("node:path");function _interopDefaultCompat(e){return e&&typeof e=="object"&&"default"in e?e.default:e}const a__default=_interopDefaultCompat(a);function padNumber(e,t=2){return e.toString().padStart(t,"0")}function generateRandomHash(e=8){const t=Math.max(1,Math.min(64,e));return crypto.randomBytes(Math.ceil(t/2)).toString("hex").slice(0,t)}function getDateFormatParams(e=new Date){return{YYYY:e.getFullYear().toString(),YY:e.getFullYear().toString().slice(-2),MM:padNumber(e.getMonth()+1),DD:padNumber(e.getDate()),HH:padNumber(e.getHours()),mm:padNumber(e.getMinutes()),ss:padNumber(e.getSeconds()),SSS:padNumber(e.getMilliseconds(),3),timestamp:e.getTime().toString()}}function formatDate(e,t){const r=getDateFormatParams(e);let o=t;for(const[n,s]of Object.entries(r))o=o.replace(new RegExp(`\\{${n}\\}`,"g"),s);return o}function parseTemplate(e,t){let r=e;for(const[o,n]of Object.entries(t))r=r.replace(new RegExp(`\\{${o}\\}`,"g"),n);return r}function toCamelCase(e,t=/[/-]/){return e.replace(/^\/+/,"").split(t).filter(Boolean).map((r,o)=>o===0?r.toLowerCase():r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function toPascalCase(e,t=/[/-]/){return e.replace(/^\/+/,"").split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function stripJsonComments(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function escapeHtmlAttr(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function formatFileSize(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}function getExtension(e){return a__default.extname(e).toLowerCase()}exports.escapeHtmlAttr=escapeHtmlAttr,exports.formatDate=formatDate,exports.formatFileSize=formatFileSize,exports.generateRandomHash=generateRandomHash,exports.getDateFormatParams=getDateFormatParams,exports.getExtension=getExtension,exports.padNumber=padNumber,exports.parseTemplate=parseTemplate,exports.stripJsonComments=stripJsonComments,exports.toCamelCase=toCamelCase,exports.toPascalCase=toPascalCase;
1
+ "use strict";function r(e,t=2){return e.toString().padStart(t,"0")}function getDateFormatParams(e=new Date){return{YYYY:e.getFullYear().toString(),YY:e.getFullYear().toString().slice(-2),MM:r(e.getMonth()+1),DD:r(e.getDate()),HH:r(e.getHours()),mm:r(e.getMinutes()),ss:r(e.getSeconds()),SSS:r(e.getMilliseconds(),3),timestamp:e.getTime().toString()}}function formatFileSize(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}exports.formatFileSize=formatFileSize,exports.getDateFormatParams=getDateFormatParams;
@@ -22,34 +22,6 @@ interface DateFormatOptions {
22
22
  timestamp: string;
23
23
  }
24
24
 
25
- /**
26
- * 数字补零格式化
27
- *
28
- * @param num 要格式化的数字
29
- * @param length 目标长度
30
- * @returns 补零后的字符串
31
- *
32
- * @example
33
- * ```typescript
34
- * padNumber(5, 2) // '05'
35
- * padNumber(12, 3) // '012'
36
- * padNumber(123, 2) // '123'
37
- * ```
38
- */
39
- declare function padNumber(num: number, length?: number): string;
40
- /**
41
- * 生成随机哈希字符串
42
- *
43
- * @param length 哈希长度,范围 1-64
44
- * @returns 随机哈希字符串
45
- *
46
- * @example
47
- * ```typescript
48
- * generateRandomHash(8) // 'a1b2c3d4'
49
- * generateRandomHash(16) // 'a1b2c3d4e5f6g7h8'
50
- * ```
51
- */
52
- declare function generateRandomHash(length?: number): string;
53
25
  /**
54
26
  * 获取日期格式化参数
55
27
  *
@@ -63,94 +35,6 @@ declare function generateRandomHash(length?: number): string;
63
35
  * ```
64
36
  */
65
37
  declare function getDateFormatParams(date?: Date): DateFormatOptions;
66
- /**
67
- * 格式化日期
68
- *
69
- * @param date 日期对象
70
- * @param format 格式模板
71
- * @returns 格式化后的日期字符串
72
- *
73
- * @example
74
- * ```typescript
75
- * formatDate(new Date(), '{YYYY}-{MM}-{DD}') // '2026-02-03'
76
- * formatDate(new Date(), '{YYYY}{MM}{DD}{HH}{mm}{ss}') // '20260203153000'
77
- * formatDate(new Date(), '{YYYY}.{MM}.{DD}') // '2026.02.03'
78
- * ```
79
- */
80
- declare function formatDate(date: Date, format: string): string;
81
- /**
82
- * 解析模板字符串,替换占位符
83
- *
84
- * @param template 模板字符串
85
- * @param values 占位符值映射
86
- * @returns 替换后的字符串
87
- *
88
- * @example
89
- * ```typescript
90
- * parseTemplate('{name}-{version}', { name: 'app', version: '1.0.0' })
91
- * // 'app-1.0.0'
92
- * ```
93
- */
94
- declare function parseTemplate(template: string, values: Record<string, string>): string;
95
- /**
96
- * 将字符串转换为驼峰命名(camelCase)
97
- *
98
- * @param str 输入字符串
99
- * @param separators 分隔符正则,默认为斜杠和横线
100
- * @returns 驼峰命名字符串
101
- *
102
- * @example
103
- * ```typescript
104
- * toCamelCase('pages/user/profile') // 'pagesUserProfile'
105
- * toCamelCase('user-profile-page') // 'userProfilePage'
106
- * toCamelCase('/pages/index') // 'pagesIndex'
107
- * ```
108
- */
109
- declare function toCamelCase(str: string, separators?: RegExp): string;
110
- /**
111
- * 将字符串转换为帕斯卡命名(PascalCase)
112
- *
113
- * @param str 输入字符串
114
- * @param separators 分隔符正则,默认为斜杠和横线
115
- * @returns 帕斯卡命名字符串
116
- *
117
- * @example
118
- * ```typescript
119
- * toPascalCase('pages/user/profile') // 'PagesUserProfile'
120
- * toPascalCase('user-profile-page') // 'UserProfilePage'
121
- * toPascalCase('/pages/index') // 'PagesIndex'
122
- * ```
123
- */
124
- declare function toPascalCase(str: string, separators?: RegExp): string;
125
- /**
126
- * 移除 JSON 字符串中的注释
127
- *
128
- * @param jsonString 包含注释的 JSON 字符串
129
- * @returns 移除注释后的 JSON 字符串
130
- *
131
- * @example
132
- * ```typescript
133
- * stripJsonComments('{\n // comment\n "name": "test"\n}')
134
- * // '{\n "name": "test"\n}'
135
- * ```
136
- */
137
- declare function stripJsonComments(jsonString: string): string;
138
- /**
139
- * 转义 HTML 属性值中的特殊字符,防止 XSS 注入
140
- *
141
- * @param str - 需要转义的字符串
142
- * @returns 转义后的安全字符串
143
- *
144
- * @example
145
- * ```typescript
146
- * escapeHtmlAttr('hello "world"')
147
- * // 'hello &quot;world&quot;'
148
- *
149
- * escapeHtmlAttr('<script>alert(1)</script>')
150
- * // '&lt;script&gt;alert(1)&lt;/script&gt;'
151
- * ```
152
- */
153
- declare function escapeHtmlAttr(str: string): string;
154
38
  /**
155
39
  * 将字节数格式化为人类可读的文件大小字符串
156
40
  *
@@ -170,19 +54,6 @@ declare function escapeHtmlAttr(str: string): string;
170
54
  * ```
171
55
  */
172
56
  declare function formatFileSize(bytes: number): string;
173
- /**
174
- * 获取文件扩展名
175
- *
176
- * @param {string} filePath - 文件路径
177
- * @returns {string} 小写的文件扩展名(如 '.js')
178
- *
179
- * @example
180
- * ```typescript
181
- * getExtension('dist/app.js') // '.js'
182
- * getExtension('dist/style.CSS') // '.css'
183
- * ```
184
- */
185
- declare function getExtension(filePath: string): string;
186
57
 
187
- export { escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase };
58
+ export { formatFileSize, getDateFormatParams };
188
59
  export type { DateFormatOptions };
@@ -22,34 +22,6 @@ interface DateFormatOptions {
22
22
  timestamp: string;
23
23
  }
24
24
 
25
- /**
26
- * 数字补零格式化
27
- *
28
- * @param num 要格式化的数字
29
- * @param length 目标长度
30
- * @returns 补零后的字符串
31
- *
32
- * @example
33
- * ```typescript
34
- * padNumber(5, 2) // '05'
35
- * padNumber(12, 3) // '012'
36
- * padNumber(123, 2) // '123'
37
- * ```
38
- */
39
- declare function padNumber(num: number, length?: number): string;
40
- /**
41
- * 生成随机哈希字符串
42
- *
43
- * @param length 哈希长度,范围 1-64
44
- * @returns 随机哈希字符串
45
- *
46
- * @example
47
- * ```typescript
48
- * generateRandomHash(8) // 'a1b2c3d4'
49
- * generateRandomHash(16) // 'a1b2c3d4e5f6g7h8'
50
- * ```
51
- */
52
- declare function generateRandomHash(length?: number): string;
53
25
  /**
54
26
  * 获取日期格式化参数
55
27
  *
@@ -63,94 +35,6 @@ declare function generateRandomHash(length?: number): string;
63
35
  * ```
64
36
  */
65
37
  declare function getDateFormatParams(date?: Date): DateFormatOptions;
66
- /**
67
- * 格式化日期
68
- *
69
- * @param date 日期对象
70
- * @param format 格式模板
71
- * @returns 格式化后的日期字符串
72
- *
73
- * @example
74
- * ```typescript
75
- * formatDate(new Date(), '{YYYY}-{MM}-{DD}') // '2026-02-03'
76
- * formatDate(new Date(), '{YYYY}{MM}{DD}{HH}{mm}{ss}') // '20260203153000'
77
- * formatDate(new Date(), '{YYYY}.{MM}.{DD}') // '2026.02.03'
78
- * ```
79
- */
80
- declare function formatDate(date: Date, format: string): string;
81
- /**
82
- * 解析模板字符串,替换占位符
83
- *
84
- * @param template 模板字符串
85
- * @param values 占位符值映射
86
- * @returns 替换后的字符串
87
- *
88
- * @example
89
- * ```typescript
90
- * parseTemplate('{name}-{version}', { name: 'app', version: '1.0.0' })
91
- * // 'app-1.0.0'
92
- * ```
93
- */
94
- declare function parseTemplate(template: string, values: Record<string, string>): string;
95
- /**
96
- * 将字符串转换为驼峰命名(camelCase)
97
- *
98
- * @param str 输入字符串
99
- * @param separators 分隔符正则,默认为斜杠和横线
100
- * @returns 驼峰命名字符串
101
- *
102
- * @example
103
- * ```typescript
104
- * toCamelCase('pages/user/profile') // 'pagesUserProfile'
105
- * toCamelCase('user-profile-page') // 'userProfilePage'
106
- * toCamelCase('/pages/index') // 'pagesIndex'
107
- * ```
108
- */
109
- declare function toCamelCase(str: string, separators?: RegExp): string;
110
- /**
111
- * 将字符串转换为帕斯卡命名(PascalCase)
112
- *
113
- * @param str 输入字符串
114
- * @param separators 分隔符正则,默认为斜杠和横线
115
- * @returns 帕斯卡命名字符串
116
- *
117
- * @example
118
- * ```typescript
119
- * toPascalCase('pages/user/profile') // 'PagesUserProfile'
120
- * toPascalCase('user-profile-page') // 'UserProfilePage'
121
- * toPascalCase('/pages/index') // 'PagesIndex'
122
- * ```
123
- */
124
- declare function toPascalCase(str: string, separators?: RegExp): string;
125
- /**
126
- * 移除 JSON 字符串中的注释
127
- *
128
- * @param jsonString 包含注释的 JSON 字符串
129
- * @returns 移除注释后的 JSON 字符串
130
- *
131
- * @example
132
- * ```typescript
133
- * stripJsonComments('{\n // comment\n "name": "test"\n}')
134
- * // '{\n "name": "test"\n}'
135
- * ```
136
- */
137
- declare function stripJsonComments(jsonString: string): string;
138
- /**
139
- * 转义 HTML 属性值中的特殊字符,防止 XSS 注入
140
- *
141
- * @param str - 需要转义的字符串
142
- * @returns 转义后的安全字符串
143
- *
144
- * @example
145
- * ```typescript
146
- * escapeHtmlAttr('hello "world"')
147
- * // 'hello &quot;world&quot;'
148
- *
149
- * escapeHtmlAttr('<script>alert(1)</script>')
150
- * // '&lt;script&gt;alert(1)&lt;/script&gt;'
151
- * ```
152
- */
153
- declare function escapeHtmlAttr(str: string): string;
154
38
  /**
155
39
  * 将字节数格式化为人类可读的文件大小字符串
156
40
  *
@@ -170,19 +54,6 @@ declare function escapeHtmlAttr(str: string): string;
170
54
  * ```
171
55
  */
172
56
  declare function formatFileSize(bytes: number): string;
173
- /**
174
- * 获取文件扩展名
175
- *
176
- * @param {string} filePath - 文件路径
177
- * @returns {string} 小写的文件扩展名(如 '.js')
178
- *
179
- * @example
180
- * ```typescript
181
- * getExtension('dist/app.js') // '.js'
182
- * getExtension('dist/style.CSS') // '.css'
183
- * ```
184
- */
185
- declare function getExtension(filePath: string): string;
186
57
 
187
- export { escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase };
58
+ export { formatFileSize, getDateFormatParams };
188
59
  export type { DateFormatOptions };
@@ -22,34 +22,6 @@ interface DateFormatOptions {
22
22
  timestamp: string;
23
23
  }
24
24
 
25
- /**
26
- * 数字补零格式化
27
- *
28
- * @param num 要格式化的数字
29
- * @param length 目标长度
30
- * @returns 补零后的字符串
31
- *
32
- * @example
33
- * ```typescript
34
- * padNumber(5, 2) // '05'
35
- * padNumber(12, 3) // '012'
36
- * padNumber(123, 2) // '123'
37
- * ```
38
- */
39
- declare function padNumber(num: number, length?: number): string;
40
- /**
41
- * 生成随机哈希字符串
42
- *
43
- * @param length 哈希长度,范围 1-64
44
- * @returns 随机哈希字符串
45
- *
46
- * @example
47
- * ```typescript
48
- * generateRandomHash(8) // 'a1b2c3d4'
49
- * generateRandomHash(16) // 'a1b2c3d4e5f6g7h8'
50
- * ```
51
- */
52
- declare function generateRandomHash(length?: number): string;
53
25
  /**
54
26
  * 获取日期格式化参数
55
27
  *
@@ -63,94 +35,6 @@ declare function generateRandomHash(length?: number): string;
63
35
  * ```
64
36
  */
65
37
  declare function getDateFormatParams(date?: Date): DateFormatOptions;
66
- /**
67
- * 格式化日期
68
- *
69
- * @param date 日期对象
70
- * @param format 格式模板
71
- * @returns 格式化后的日期字符串
72
- *
73
- * @example
74
- * ```typescript
75
- * formatDate(new Date(), '{YYYY}-{MM}-{DD}') // '2026-02-03'
76
- * formatDate(new Date(), '{YYYY}{MM}{DD}{HH}{mm}{ss}') // '20260203153000'
77
- * formatDate(new Date(), '{YYYY}.{MM}.{DD}') // '2026.02.03'
78
- * ```
79
- */
80
- declare function formatDate(date: Date, format: string): string;
81
- /**
82
- * 解析模板字符串,替换占位符
83
- *
84
- * @param template 模板字符串
85
- * @param values 占位符值映射
86
- * @returns 替换后的字符串
87
- *
88
- * @example
89
- * ```typescript
90
- * parseTemplate('{name}-{version}', { name: 'app', version: '1.0.0' })
91
- * // 'app-1.0.0'
92
- * ```
93
- */
94
- declare function parseTemplate(template: string, values: Record<string, string>): string;
95
- /**
96
- * 将字符串转换为驼峰命名(camelCase)
97
- *
98
- * @param str 输入字符串
99
- * @param separators 分隔符正则,默认为斜杠和横线
100
- * @returns 驼峰命名字符串
101
- *
102
- * @example
103
- * ```typescript
104
- * toCamelCase('pages/user/profile') // 'pagesUserProfile'
105
- * toCamelCase('user-profile-page') // 'userProfilePage'
106
- * toCamelCase('/pages/index') // 'pagesIndex'
107
- * ```
108
- */
109
- declare function toCamelCase(str: string, separators?: RegExp): string;
110
- /**
111
- * 将字符串转换为帕斯卡命名(PascalCase)
112
- *
113
- * @param str 输入字符串
114
- * @param separators 分隔符正则,默认为斜杠和横线
115
- * @returns 帕斯卡命名字符串
116
- *
117
- * @example
118
- * ```typescript
119
- * toPascalCase('pages/user/profile') // 'PagesUserProfile'
120
- * toPascalCase('user-profile-page') // 'UserProfilePage'
121
- * toPascalCase('/pages/index') // 'PagesIndex'
122
- * ```
123
- */
124
- declare function toPascalCase(str: string, separators?: RegExp): string;
125
- /**
126
- * 移除 JSON 字符串中的注释
127
- *
128
- * @param jsonString 包含注释的 JSON 字符串
129
- * @returns 移除注释后的 JSON 字符串
130
- *
131
- * @example
132
- * ```typescript
133
- * stripJsonComments('{\n // comment\n "name": "test"\n}')
134
- * // '{\n "name": "test"\n}'
135
- * ```
136
- */
137
- declare function stripJsonComments(jsonString: string): string;
138
- /**
139
- * 转义 HTML 属性值中的特殊字符,防止 XSS 注入
140
- *
141
- * @param str - 需要转义的字符串
142
- * @returns 转义后的安全字符串
143
- *
144
- * @example
145
- * ```typescript
146
- * escapeHtmlAttr('hello "world"')
147
- * // 'hello &quot;world&quot;'
148
- *
149
- * escapeHtmlAttr('<script>alert(1)</script>')
150
- * // '&lt;script&gt;alert(1)&lt;/script&gt;'
151
- * ```
152
- */
153
- declare function escapeHtmlAttr(str: string): string;
154
38
  /**
155
39
  * 将字节数格式化为人类可读的文件大小字符串
156
40
  *
@@ -170,19 +54,6 @@ declare function escapeHtmlAttr(str: string): string;
170
54
  * ```
171
55
  */
172
56
  declare function formatFileSize(bytes: number): string;
173
- /**
174
- * 获取文件扩展名
175
- *
176
- * @param {string} filePath - 文件路径
177
- * @returns {string} 小写的文件扩展名(如 '.js')
178
- *
179
- * @example
180
- * ```typescript
181
- * getExtension('dist/app.js') // '.js'
182
- * getExtension('dist/style.CSS') // '.css'
183
- * ```
184
- */
185
- declare function getExtension(filePath: string): string;
186
57
 
187
- export { escapeHtmlAttr, formatDate, formatFileSize, generateRandomHash, getDateFormatParams, getExtension, padNumber, parseTemplate, stripJsonComments, toCamelCase, toPascalCase };
58
+ export { formatFileSize, getDateFormatParams };
188
59
  export type { DateFormatOptions };
@@ -1 +1 @@
1
- import{randomBytes as c}from"crypto";import l from"node:path";function o(e,t=2){return e.toString().padStart(t,"0")}function p(e=8){const t=Math.max(1,Math.min(64,e));return c(Math.ceil(t/2)).toString("hex").slice(0,t)}function i(e=new Date){return{YYYY:e.getFullYear().toString(),YY:e.getFullYear().toString().slice(-2),MM:o(e.getMonth()+1),DD:o(e.getDate()),HH:o(e.getHours()),mm:o(e.getMinutes()),ss:o(e.getSeconds()),SSS:o(e.getMilliseconds(),3),timestamp:e.getTime().toString()}}function g(e,t){const r=i(e);let n=t;for(const[a,s]of Object.entries(r))n=n.replace(new RegExp(`\\{${a}\\}`,"g"),s);return n}function m(e,t){let r=e;for(const[n,a]of Object.entries(t))r=r.replace(new RegExp(`\\{${n}\\}`,"g"),a);return r}function u(e,t=/[/-]/){return e.replace(/^\/+/,"").split(t).filter(Boolean).map((r,n)=>n===0?r.toLowerCase():r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function f(e,t=/[/-]/){return e.replace(/^\/+/,"").split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join("")}function S(e){return e.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function C(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function x(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}function M(e){return l.extname(e).toLowerCase()}export{C as escapeHtmlAttr,g as formatDate,x as formatFileSize,p as generateRandomHash,i as getDateFormatParams,M as getExtension,o as padNumber,m as parseTemplate,S as stripJsonComments,u as toCamelCase,f as toPascalCase};
1
+ function t(e,r=2){return e.toString().padStart(r,"0")}function n(e=new Date){return{YYYY:e.getFullYear().toString(),YY:e.getFullYear().toString().slice(-2),MM:t(e.getMonth()+1),DD:t(e.getDate()),HH:t(e.getHours()),mm:t(e.getMinutes()),ss:t(e.getSeconds()),SSS:t(e.getMilliseconds(),3),timestamp:e.getTime().toString()}}function i(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(2)}MB`}export{i as formatFileSize,n as getDateFormatParams};
@@ -1 +1 @@
1
- "use strict";const s=require("fs"),f=require("path");function _interopDefaultCompat(u){return u&&typeof u=="object"&&"default"in u?u.default:u}const s__default=_interopDefaultCompat(s),f__default=_interopDefaultCompat(f),S=10;async function checkSourceExists(u){try{await s__default.promises.access(u,s__default.constants.F_OK)}catch(t){const e=t;throw e.code==="ENOENT"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 - ${u}`):e.code==="EACCES"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u8BBF\u95EE\u6E90\u6587\u4EF6 - ${u}`):new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u68C0\u67E5\u6E90\u6587\u4EF6\u65F6\u51FA\u9519 - ${u}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}async function ensureTargetDir(u){try{await s__default.promises.mkdir(u,{recursive:!0})}catch(t){const e=t;throw e.code==="EACCES"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u521B\u5EFA\u76EE\u6807\u76EE\u5F55 - ${u}`):new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u65F6\u51FA\u9519 - ${u}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}async function readDirRecursive(u,t){const e=await s__default.promises.readdir(u,{withFileTypes:!0}),r=[];for(const n of e){const a=f__default.join(u,n.name),F=n.isFile(),c=n.isDirectory();if(r.push({path:a,isFile:F,isDirectory:c}),c&&t){const l=await readDirRecursive(a,t);r.push(...l)}}return r}async function shouldUpdateFile(u,t){try{const[e,r]=await Promise.all([s__default.promises.stat(u),s__default.promises.stat(t)]);return e.mtimeMs>r.mtimeMs||e.size!==r.size}catch{return!0}}async function fileExists(u){try{return await s__default.promises.access(u,s__default.constants.F_OK),!0}catch{return!1}}async function runWithConcurrency(u,t,e){const r=[];let n=0;async function a(){for(;n<u.length;){const c=n++,l=await t(u[c]);r[c]=l}}const F=Array(Math.min(e,u.length)).fill(null).map(()=>a());return await Promise.all(F),r}async function copySourceToTarget(u,t,e){const r=Date.now(),{recursive:n,overwrite:a,incremental:F=!1,parallelLimit:c=S}=e;let l=0,p=0,E=0;if((await s__default.promises.stat(u)).isDirectory()){await ensureTargetDir(t);const o=await readDirRecursive(u,n),w=o.filter(i=>i.isFile);E=o.filter(i=>i.isDirectory).length;const h=new Set;for(const i of w){const D=f__default.relative(u,i.path),y=f__default.dirname(f__default.join(t,D));h.add(y)}await Promise.all([...h].map(i=>ensureTargetDir(i)));const A=await runWithConcurrency(w,async i=>{const D=f__default.relative(u,i.path),y=f__default.join(t,D);let m=a;return m||(m=!await fileExists(y)),F&&m&&(m=await shouldUpdateFile(i.path,y)),m?(await s__default.promises.copyFile(i.path,y),{copied:!0,skipped:!1}):{copied:!1,skipped:!0}},c);for(const i of A)i.copied&&l++,i.skipped&&p++}else{await ensureTargetDir(f__default.dirname(t));let o=a;o||(o=!await fileExists(t)),F&&o&&(o=await shouldUpdateFile(u,t)),o?(await s__default.promises.copyFile(u,t),l++):p++}const d=Date.now()-r;return{copiedFiles:l,skippedFiles:p,copiedDirs:E,executionTime:d}}async function writeFileContent(u,t){try{await s__default.promises.writeFile(u,t,"utf-8")}catch(e){const r=e;throw r.code==="EACCES"?new Error(`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u5199\u5165\u6587\u4EF6 - ${u}`):new Error(`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A\u5199\u5165\u6587\u4EF6\u65F6\u51FA\u9519 - ${u}\uFF0C\u9519\u8BEF\uFF1A${r.message}`)}}async function readFileContent(u){try{return await s__default.promises.readFile(u,"utf-8")}catch(t){const e=t;throw e.code==="EACCES"?new Error(`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u8BFB\u53D6\u6587\u4EF6 - ${u}`):new Error(`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A\u8BFB\u53D6\u6587\u4EF6\u65F6\u51FA\u9519 - ${u}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}function readFileSync(u){try{return s__default.readFileSync(u,"utf-8")}catch(t){const e=t;throw e.code==="EACCES"?new Error(`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u8BFB\u53D6\u6587\u4EF6 - ${u}`):new Error(`\u8BFB\u53D6\u6587\u4EF6\u5931\u8D25\uFF1A\u8BFB\u53D6\u6587\u4EF6\u65F6\u51FA\u9519 - ${u}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}async function scanDirectory(u,t={}){const{includeExtensions:e=[],excludePatterns:r=[],filter:n}=t,a=[];async function F(c){const l=await s__default.promises.readdir(c,{withFileTypes:!0});for(const p of l){const E=f__default.join(c,p.name);if(p.isDirectory()){await F(E);continue}if(!p.isFile()||r.some(w=>w.startsWith("*")?E.endsWith(w.slice(1)):E.includes(w)))continue;const d=f__default.extname(p.name).toLowerCase();if(e.length>0&&!e.includes(d))continue;const o=await s__default.promises.stat(E);n&&!n(E,d,o.size)||a.push({filePath:E,size:o.size,extension:d})}}return await F(u),a}async function writeJsonReport(u,t,e=2){await writeFileContent(u,JSON.stringify(t,null,e))}exports.checkSourceExists=checkSourceExists,exports.copySourceToTarget=copySourceToTarget,exports.ensureTargetDir=ensureTargetDir,exports.fileExists=fileExists,exports.readDirRecursive=readDirRecursive,exports.readFileContent=readFileContent,exports.readFileSync=readFileSync,exports.runWithConcurrency=runWithConcurrency,exports.scanDirectory=scanDirectory,exports.shouldUpdateFile=shouldUpdateFile,exports.writeFileContent=writeFileContent,exports.writeJsonReport=writeJsonReport;
1
+ "use strict";const n=require("fs"),m=require("path");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const n__default=_interopDefaultCompat(n),m__default=_interopDefaultCompat(m),R=10;async function checkSourceExists(t){try{await n__default.promises.access(t,n__default.constants.F_OK)}catch(u){const e=u;throw e.code==="ENOENT"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 - ${t}`):e.code==="EACCES"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u8BBF\u95EE\u6E90\u6587\u4EF6 - ${t}`):new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u68C0\u67E5\u6E90\u6587\u4EF6\u65F6\u51FA\u9519 - ${t}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}async function h(t){try{await n__default.promises.mkdir(t,{recursive:!0})}catch(u){const e=u;throw e.code==="EACCES"?new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u521B\u5EFA\u76EE\u6807\u76EE\u5F55 - ${t}`):new Error(`\u590D\u5236\u6587\u4EF6\u5931\u8D25\uFF1A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u65F6\u51FA\u9519 - ${t}\uFF0C\u9519\u8BEF\uFF1A${e.message}`)}}async function C(t,u){const e=await n__default.promises.readdir(t,{withFileTypes:!0}),s=[];for(const o of e){const a=m__default.join(t,o.name),F=o.isFile(),c=o.isDirectory();if(s.push({path:a,isFile:F,isDirectory:c}),c&&u){const l=await C(a,u);s.push(...l)}}return s}async function S(t,u){try{const[e,s]=await Promise.all([n__default.promises.stat(t),n__default.promises.stat(u)]);return e.mtimeMs>s.mtimeMs||e.size!==s.size}catch{return!0}}async function D(t){try{return await n__default.promises.access(t,n__default.constants.F_OK),!0}catch{return!1}}async function T(t,u,e){const s=[];let o=0;async function a(){for(;o<t.length;){const c=o++,l=await u(t[c]);s[c]=l}}const F=Array(Math.min(e,t.length)).fill(null).map(()=>a());return await Promise.all(F),s}async function copySourceToTarget(t,u,e){const s=Date.now(),{recursive:o,overwrite:a,incremental:F=!1,parallelLimit:c=R}=e;let l=0,E=0,p=0;if((await n__default.promises.stat(t)).isDirectory()){await h(u);const r=await C(t,o),w=r.filter(i=>i.isFile);p=r.filter(i=>i.isDirectory).length;const x=new Set;for(const i of w){const A=m__default.relative(t,i.path),d=m__default.dirname(m__default.join(u,A));x.add(d)}await Promise.all([...x].map(i=>h(i)));const g=await T(w,async i=>{const A=m__default.relative(t,i.path),d=m__default.join(u,A);let y=a;return y||(y=!await D(d)),F&&y&&(y=await S(i.path,d)),y?(await n__default.promises.copyFile(i.path,d),{copied:!0,skipped:!1}):{copied:!1,skipped:!0}},c);for(const i of g)i.copied&&l++,i.skipped&&E++}else{await h(m__default.dirname(u));let r=a;r||(r=!await D(u)),F&&r&&(r=await S(t,u)),r?(await n__default.promises.copyFile(t,u),l++):E++}const f=Date.now()-s;return{copiedFiles:l,skippedFiles:E,copiedDirs:p,executionTime:f}}async function writeFileContent(t,u){try{await n__default.promises.writeFile(t,u,"utf-8")}catch(e){const s=e;throw s.code==="EACCES"?new Error(`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A\u6CA1\u6709\u6743\u9650\u5199\u5165\u6587\u4EF6 - ${t}`):new Error(`\u5199\u5165\u6587\u4EF6\u5931\u8D25\uFF1A\u5199\u5165\u6587\u4EF6\u65F6\u51FA\u9519 - ${t}\uFF0C\u9519\u8BEF\uFF1A${s.message}`)}}async function scanDirectory(t,u={}){const{includeExtensions:e=[],excludePatterns:s=[],filter:o}=u,a=[];async function F(c){const l=await n__default.promises.readdir(c,{withFileTypes:!0});for(const E of l){const p=m__default.join(c,E.name);if(E.isDirectory()){await F(p);continue}if(!E.isFile()||s.some(w=>w.startsWith("*")?p.endsWith(w.slice(1)):p.includes(w)))continue;const f=m__default.extname(E.name).toLowerCase();if(e.length>0&&!e.includes(f))continue;const r=await n__default.promises.stat(p);o&&!o(p,f,r.size)||a.push({filePath:p,size:r.size,extension:f})}}return await F(t),a}async function writeJsonReport(t,u,e=2){await writeFileContent(t,JSON.stringify(u,null,e))}exports.checkSourceExists=checkSourceExists,exports.copySourceToTarget=copySourceToTarget,exports.scanDirectory=scanDirectory,exports.writeFileContent=writeFileContent,exports.writeJsonReport=writeJsonReport;
@@ -45,75 +45,12 @@ interface CopyResult {
45
45
  executionTime: number;
46
46
  }
47
47
 
48
- /**
49
- * 文件/目录条目信息
50
- */
51
- interface FileEntry {
52
- /** 完整路径 */
53
- path: string;
54
- /** 是否为文件 */
55
- isFile: boolean;
56
- /** 是否为目录 */
57
- isDirectory: boolean;
58
- }
59
48
  /**
60
49
  * 检查源文件是否存在
61
50
  * @param sourcePath 源文件路径
62
51
  * @throws 当源文件不存在或无法访问时抛出异常
63
52
  */
64
53
  declare function checkSourceExists(sourcePath: string): Promise<void>;
65
- /**
66
- * 创建目标目录
67
- * @param targetPath 目标目录路径
68
- * @throws 当无法创建目标目录时抛出异常
69
- */
70
- declare function ensureTargetDir(targetPath: string): Promise<void>;
71
- /**
72
- * 读取目录内容(优化版:一次性获取文件类型信息)
73
- * @param dirPath 目录路径
74
- * @param recursive 是否递归读取
75
- * @returns 文件和目录条目列表
76
- */
77
- declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<FileEntry[]>;
78
- /**
79
- * 检查文件是否需要更新
80
- * @param sourceFile 源文件路径
81
- * @param targetFile 目标文件路径
82
- * @returns 是否需要更新
83
- */
84
- declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
85
- /**
86
- * 检查文件是否存在
87
- * @param filePath 文件路径
88
- * @returns 是否存在
89
- *
90
- * @example
91
- * ```typescript
92
- * if (await fileExists('/path/to/file')) {
93
- * console.log('文件存在')
94
- * }
95
- * ```
96
- */
97
- declare function fileExists(filePath: string): Promise<boolean>;
98
- /**
99
- * 带并发限制的批量执行
100
- *
101
- * @param items 待处理项
102
- * @param handler 处理函数
103
- * @param concurrency 并发数
104
- * @returns 处理结果数组,顺序与输入项对应
105
- *
106
- * @example
107
- * ```typescript
108
- * const urls = ['url1', 'url2', 'url3', 'url4', 'url5']
109
- * const results = await runWithConcurrency(
110
- * urls,
111
- * async (url) => fetch(url),
112
- * 3 // 最多同时处理3个请求
113
- * )
114
- * ```
115
- */
116
- declare function runWithConcurrency<T, R>(items: T[], handler: (item: T) => Promise<R>, concurrency: number): Promise<R[]>;
117
54
  /**
118
55
  * 执行文件复制操作(优化版:并行IO)
119
56
  * @param sourcePath 源文件或目录路径
@@ -130,21 +67,6 @@ declare function copySourceToTarget(sourcePath: string, targetPath: string, opti
130
67
  * @throws 当写入过程中出现错误时抛出异常
131
68
  */
132
69
  declare function writeFileContent(filePath: string, content: string): Promise<void>;
133
- /**
134
- * 读取文件内容
135
- * @param filePath 文件路径
136
- * @returns 文件内容字符串
137
- * @throws 当读取过程中出现错误时抛出异常
138
- */
139
- declare function readFileContent(filePath: string): Promise<string>;
140
- /**
141
- * 同步读取文件内容
142
- * @param filePath 文件路径
143
- * @returns 文件内容字符串
144
- * @throws 当读取过程中出现错误时抛出异常
145
- * @deprecated 请使用异步版本 readFileContent
146
- */
147
- declare function readFileSync(filePath: string): string;
148
70
  /**
149
71
  * 扫描目录中的文件信息
150
72
  */
@@ -177,20 +99,11 @@ interface ScanDirectoryOptions {
177
99
  *
178
100
  * @description 递归遍历指定目录下的所有文件,收集每个文件的大小和扩展名信息,
179
101
  * 支持按扩展名、路径模式和自定义过滤函数进行过滤。
180
- * 这是通用的目录扫描函数,可被不同插件复用。
181
102
  *
182
103
  * @example
183
104
  * ```typescript
184
- * // 扫描所有 .js 文件
185
105
  * const jsFiles = await scanDirectory('dist', { includeExtensions: ['.js'] })
186
- *
187
- * // 排除 node_modules
188
106
  * const files = await scanDirectory('dist', { excludePatterns: ['node_modules'] })
189
- *
190
- * // 使用自定义过滤
191
- * const largeFiles = await scanDirectory('dist', {
192
- * filter: (filePath, ext, size) => size > 1024
193
- * })
194
107
  * ```
195
108
  */
196
109
  declare function scanDirectory(dirPath: string, options?: ScanDirectoryOptions): Promise<ScannedFile[]>;
@@ -209,10 +122,9 @@ declare function scanDirectory(dirPath: string, options?: ScanDirectoryOptions):
209
122
  * @example
210
123
  * ```typescript
211
124
  * await writeJsonReport('dist/report.json', { timestamp: Date.now(), stats: [] })
212
- * await writeJsonReport('dist/report.json', data, 4)
213
125
  * ```
214
126
  */
215
127
  declare function writeJsonReport(filePath: string, data: object, indent?: number): Promise<void>;
216
128
 
217
- export { checkSourceExists, copySourceToTarget, ensureTargetDir, fileExists, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, scanDirectory, shouldUpdateFile, writeFileContent, writeJsonReport };
129
+ export { checkSourceExists, copySourceToTarget, scanDirectory, writeFileContent, writeJsonReport };
218
130
  export type { CopyOptions, CopyResult, ScanDirectoryOptions, ScannedFile };