@chuckcchen/vite-plugin 0.0.3 → 1.0.0

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/dist/types.d.ts CHANGED
@@ -1,265 +1,265 @@
1
1
  /**
2
- * EdgeOne Vite Plugin Adapter - 类型定义文件
2
+ * EdgeOne Vite Plugin Adapter - Type Definitions
3
3
  *
4
- * 本文件定义了适配器插件系统的所有核心类型
5
- * 包括路由信息、元数据配置、构建上下文、钩子函数等
4
+ * This file defines all core types for the adapter plugin system,
5
+ * including route info, meta config, build context, hook functions, etc.
6
6
  */
7
7
  import type { Plugin, ResolvedConfig } from "vite";
8
8
  /**
9
- * 路由信息接口
10
- * 用于描述部署时的路由配置
9
+ * Route information interface
10
+ * Describes route configuration for deployment
11
11
  */
12
12
  export interface RouteInfo {
13
- /** 路由路径模式,如 "/" "/about" "/*" */
13
+ /** Route path pattern, e.g. "/" or "/about" or "/*" */
14
14
  path: string;
15
- /** 是否为静态内容路由(true 表示静态,false 表示需要 SSR */
15
+ /** Whether this is a static content route (true = static, false = requires SSR) */
16
16
  isStatic: boolean;
17
- /** 源路由模式,用于动态路由的映射 */
17
+ /** Source route pattern for dynamic route mapping */
18
18
  srcRoute?: string;
19
19
  }
20
20
  /**
21
- * EdgeOne 部署的元数据配置接口
22
- * 生成的 meta.json 文件结构
21
+ * EdgeOne deployment metadata configuration interface
22
+ * Structure of the generated meta.json file
23
23
  */
24
24
  export interface MetaConfig {
25
- /** 配置对象 */
25
+ /** Configuration object */
26
26
  conf: {
27
- /** HTTP 响应头规则列表 */
27
+ /** HTTP response header rules list */
28
28
  headers: HeaderRule[];
29
- /** 重定向规则列表 */
29
+ /** Redirect rules list */
30
30
  redirects: RedirectRule[];
31
- /** URL 重写规则列表 */
31
+ /** URL rewrite rules list */
32
32
  rewrites: RewriteRule[];
33
- /** 缓存规则列表 */
33
+ /** Cache rules list */
34
34
  caches: CacheRule[];
35
- /** 是否存在自定义 404 页面 */
35
+ /** Whether a custom 404 page exists */
36
36
  has404: boolean;
37
- /** 404 页面是否使用 SSR 渲染 */
37
+ /** Whether 404 page uses SSR rendering */
38
38
  ssr404: boolean;
39
39
  };
40
- /** 是否存在自定义 404 页面(顶层字段) */
40
+ /** Whether a custom 404 page exists (top-level field) */
41
41
  has404: boolean;
42
- /** 框架路由列表 */
42
+ /** Framework routes list */
43
43
  frameworkRoutes: RouteInfo[];
44
44
  }
45
45
  /**
46
- * HTTP 响应头规则配置
47
- * 用于为特定路径添加自定义 HTTP 响应头
46
+ * HTTP response header rule configuration
47
+ * Used to add custom HTTP response headers for specific paths
48
48
  */
49
49
  export interface HeaderRule {
50
- /** 匹配的源路径模式 */
50
+ /** Source path pattern to match */
51
51
  source: string;
52
- /** 要添加的响应头键值对 */
52
+ /** Response header key-value pairs to add */
53
53
  headers: Record<string, string>;
54
54
  }
55
55
  /**
56
- * 重定向规则配置
57
- * 用于配置 URL 重定向
56
+ * Redirect rule configuration
57
+ * Used to configure URL redirects
58
58
  */
59
59
  export interface RedirectRule {
60
- /** 匹配的源路径模式 */
60
+ /** Source path pattern to match */
61
61
  source: string;
62
- /** 重定向的目标 URL */
62
+ /** Destination URL for redirect */
63
63
  destination: string;
64
- /** 是否为永久重定向(301),否则为临时重定向(302 */
64
+ /** Whether this is a permanent redirect (301), otherwise temporary (302) */
65
65
  permanent?: boolean;
66
- /** 自定义 HTTP 状态码 */
66
+ /** Custom HTTP status code */
67
67
  statusCode?: number;
68
68
  }
69
69
  /**
70
- * URL 重写规则配置
71
- * 用于在不改变浏览器 URL 的情况下重写请求路径
70
+ * URL rewrite rule configuration
71
+ * Used to rewrite request paths without changing browser URL
72
72
  */
73
73
  export interface RewriteRule {
74
- /** 匹配的源路径模式 */
74
+ /** Source path pattern to match */
75
75
  source: string;
76
- /** 重写的目标路径 */
76
+ /** Destination path to rewrite to */
77
77
  destination: string;
78
78
  }
79
79
  /**
80
- * 缓存规则配置
81
- * 用于配置特定路径的缓存策略
80
+ * Cache rule configuration
81
+ * Used to configure caching strategy for specific paths
82
82
  */
83
83
  export interface CacheRule {
84
- /** 匹配的源路径模式 */
84
+ /** Source path pattern to match */
85
85
  source: string;
86
- /** 最大缓存时间(秒) */
86
+ /** Maximum cache time in seconds */
87
87
  maxAge?: number;
88
- /** 过期后重新验证的宽限时间(秒) */
88
+ /** Grace period for revalidation after expiry in seconds */
89
89
  staleWhileRevalidate?: number;
90
90
  }
91
91
  /**
92
- * 构建上下文接口
93
- * 传递给各个钩子函数的上下文信息
92
+ * Build context interface
93
+ * Context information passed to hook functions
94
94
  */
95
95
  export interface BuildContext {
96
- /** 项目根目录的绝对路径 */
96
+ /** Absolute path to project root directory */
97
97
  projectRoot: string;
98
- /** 输出目录名称(默认: .edgeone */
98
+ /** Output directory name (default: .edgeone) */
99
99
  outputDir: string;
100
- /** 是否启用 SSR 模式 */
100
+ /** Whether SSR mode is enabled */
101
101
  isSSR: boolean;
102
- /** Vite 解析后的完整配置对象 */
102
+ /** Vite resolved configuration object */
103
103
  viteConfig: ResolvedConfig;
104
- /** 日志工具实例 */
104
+ /** Logger utility instance */
105
105
  logger: Logger;
106
106
  }
107
107
  /**
108
- * 日志接口
109
- * 提供统一的日志输出方法
108
+ * Logger interface
109
+ * Provides unified logging methods
110
110
  */
111
111
  export interface Logger {
112
- /** 普通日志输出 */
112
+ /** Normal log output */
113
113
  log: (message: string, ...args: unknown[]) => void;
114
- /** 详细日志输出(仅在 verbose 模式下显示) */
114
+ /** Verbose log output (only shown in verbose mode) */
115
115
  verbose: (message: string, ...args: unknown[]) => void;
116
- /** 警告日志输出 */
116
+ /** Warning log output */
117
117
  warn: (message: string, ...args: unknown[]) => void;
118
- /** 错误日志输出 */
118
+ /** Error log output */
119
119
  error: (message: string, ...args: unknown[]) => void;
120
120
  }
121
121
  /**
122
- * 构建产物信息接口
123
- * 描述构建后生成的各类文件路径
122
+ * Build artifacts information interface
123
+ * Describes paths of generated files after build
124
124
  */
125
125
  export interface BuildArtifacts {
126
- /** 客户端构建目录路径(如 dist/client */
126
+ /** Client build directory path (e.g. dist/client) */
127
127
  clientDir: string | null;
128
- /** 服务端构建目录路径(如 dist/server */
128
+ /** Server build directory path (e.g. dist/server) */
129
129
  serverDir: string | null;
130
- /** 服务端入口文件路径(如 dist/server/index.js */
130
+ /** Server entry file path (e.g. dist/server/index.js) */
131
131
  serverEntry: string | null;
132
- /** 静态资源目录路径 */
132
+ /** Static assets directory path */
133
133
  assetsDir: string | null;
134
134
  }
135
135
  /**
136
- * 服务端包装器配置接口
137
- * 用于生成服务端代码的包装器
136
+ * Server wrapper configuration interface
137
+ * Used for generating server code wrapper
138
138
  */
139
139
  export interface ServerWrapperConfig {
140
- /** 服务端构建入口文件的路径 */
140
+ /** Path to server build entry file */
141
141
  serverEntryPath: string;
142
- /** 自定义包装器代码模板(可选) */
142
+ /** Custom wrapper code template (optional) */
143
143
  wrapperTemplate?: string;
144
- /** 需要从服务端构建中导出的变量列表 */
144
+ /** List of variables to export from server build */
145
145
  exports?: string[];
146
- /** 在包装器代码开头添加的额外代码 */
146
+ /** Extra code to add at the beginning of wrapper */
147
147
  banner?: string;
148
148
  }
149
149
  /**
150
- * esbuild 打包配置接口
151
- * 用于配置服务端代码的打包选项
150
+ * esbuild bundle configuration interface
151
+ * Used to configure server code bundling options
152
152
  */
153
153
  export interface ServerBundleConfig {
154
- /** 打包入口点文件列表 */
154
+ /** Bundle entry point file list */
155
155
  entryPoints: string[];
156
- /** 输出文件路径 */
156
+ /** Output file path */
157
157
  outfile: string;
158
- /** 需要排除的外部模块列表(不打包进 bundle) */
158
+ /** External modules list (not bundled) */
159
159
  external?: string[];
160
- /** 额外的 esbuild 配置选项 */
160
+ /** Additional esbuild configuration options */
161
161
  esbuildOptions?: Record<string, unknown>;
162
162
  }
163
163
  /**
164
- * 钩子函数类型定义
165
- * 这些类型定义了各个生命周期钩子的函数签名
164
+ * Hook function type definitions
165
+ * These types define function signatures for lifecycle hooks
166
166
  */
167
- /** 构建开始前的钩子 */
167
+ /** Hook called before build starts */
168
168
  export type BeforeBuildHook = (context: BuildContext) => Promise<void> | void;
169
- /** 构建产物检测后的钩子 */
169
+ /** Hook called after build artifacts are detected */
170
170
  export type AfterBuildHook = (context: BuildContext, artifacts: BuildArtifacts) => Promise<void> | void;
171
- /** 服务端代码打包前的钩子,可修改打包配置 */
171
+ /** Hook called before server code bundling, can modify bundle config */
172
172
  export type BeforeBundleHook = (context: BuildContext, config: ServerBundleConfig) => Promise<ServerBundleConfig> | ServerBundleConfig;
173
- /** 服务端代码打包后的钩子 */
173
+ /** Hook called after server code bundling */
174
174
  export type AfterBundleHook = (context: BuildContext, outputPath: string) => Promise<void> | void;
175
- /** 生成路由信息的钩子 */
175
+ /** Hook for generating route information */
176
176
  export type GenerateRoutesHook = (context: BuildContext) => Promise<RouteInfo[]> | RouteInfo[];
177
- /** 生成元数据配置的钩子 */
177
+ /** Hook for generating metadata configuration */
178
178
  export type GenerateMetaHook = (context: BuildContext, routes: RouteInfo[]) => Promise<MetaConfig> | MetaConfig;
179
- /** 生成服务端包装器代码的钩子 */
179
+ /** Hook for generating server wrapper code */
180
180
  export type GenerateServerWrapperHook = (context: BuildContext, config: ServerWrapperConfig) => Promise<string> | string;
181
181
  /**
182
- * 适配器钩子配置接口
183
- * 定义了适配器可以使用的所有钩子函数
182
+ * Adapter hooks configuration interface
183
+ * Defines all hook functions available to adapters
184
184
  */
185
185
  export interface AdapterHooks {
186
- /** 构建处理开始前调用 */
186
+ /** Called before build processing starts */
187
187
  beforeBuild?: BeforeBuildHook;
188
- /** 构建产物检测完成后调用 */
188
+ /** Called after build artifacts detection completes */
189
189
  afterBuild?: AfterBuildHook;
190
- /** 服务端代码打包前调用,可修改打包配置 */
190
+ /** Called before server code bundling, can modify bundle config */
191
191
  beforeBundle?: BeforeBundleHook;
192
- /** 服务端代码打包完成后调用 */
192
+ /** Called after server code bundling completes */
193
193
  afterBundle?: AfterBundleHook;
194
- /** 生成路由信息时调用 */
194
+ /** Called when generating route information */
195
195
  generateRoutes?: GenerateRoutesHook;
196
- /** 生成 meta.json 配置时调用 */
196
+ /** Called when generating meta.json configuration */
197
197
  generateMeta?: GenerateMetaHook;
198
- /** 生成服务端包装器代码时调用 */
198
+ /** Called when generating server wrapper code */
199
199
  generateServerWrapper?: GenerateServerWrapperHook;
200
200
  }
201
201
  /**
202
- * 框架适配器接口
203
- * 框架特定的适配器(如 React RouterTanStack Start)需要实现此接口
202
+ * Framework adapter interface
203
+ * Framework-specific adapters (e.g. React Router, TanStack Start) must implement this interface
204
204
  */
205
205
  export interface FrameworkAdapter {
206
- /** 适配器名称,用于日志和调试 */
206
+ /** Adapter name for logging and debugging */
207
207
  name: string;
208
- /** 检测当前项目是否应该使用此适配器 */
208
+ /** Detect whether current project should use this adapter */
209
209
  detect: (context: BuildContext) => Promise<boolean> | boolean;
210
- /** 获取构建产物的路径信息 */
210
+ /** Get build artifacts path information */
211
211
  getBuildArtifacts: (context: BuildContext) => Promise<BuildArtifacts> | BuildArtifacts;
212
- /** 适配器特定的钩子函数 */
212
+ /** Adapter-specific hook functions */
213
213
  hooks?: AdapterHooks;
214
214
  }
215
215
  /**
216
- * 核心适配器插件选项接口
217
- * 所有适配器的基础配置选项
216
+ * Core adapter plugin options interface
217
+ * Base configuration options for all adapters
218
218
  */
219
219
  export interface CoreAdapterOptions {
220
- /** 是否启用详细日志输出(默认: false */
220
+ /** Enable verbose logging output (default: false) */
221
221
  verbose?: boolean;
222
- /** 输出目录名称(默认: .edgeone */
222
+ /** Output directory name (default: .edgeone) */
223
223
  outputDir?: string;
224
- /** 构建前是否清理输出目录(默认: true */
224
+ /** Clean output directory before build (default: true) */
225
225
  cleanOutput?: boolean;
226
- /** 要使用的框架适配器实例 */
226
+ /** Framework adapter instance to use */
227
227
  adapter?: FrameworkAdapter;
228
- /** 自定义钩子函数 */
228
+ /** Custom hook functions */
229
229
  hooks?: AdapterHooks;
230
- /** 是否启用 SSR(如未指定则自动检测) */
230
+ /** Enable SSR (auto-detected if not specified) */
231
231
  ssr?: boolean;
232
232
  }
233
233
  /**
234
- * Vite 适配器插件选项接口
235
- * 用于通用 Vite 项目(SPA 和自定义 SSR
234
+ * Vite adapter plugin options interface
235
+ * For generic Vite projects (SPA and custom SSR)
236
236
  */
237
237
  export interface ViteAdapterOptions extends CoreAdapterOptions {
238
- /** 客户端构建目录(默认: dist */
238
+ /** Client build directory (default: dist) */
239
239
  clientBuildDir?: string;
240
- /** 服务端构建目录(默认: dist/server */
240
+ /** Server build directory (default: dist/server) */
241
241
  serverBuildDir?: string;
242
- /** 服务端入口文件路径(默认: server/index.js */
242
+ /** Server entry file path (default: server/index.js) */
243
243
  serverEntry?: string;
244
244
  }
245
245
  /**
246
- * React Router 适配器选项接口
247
- * 用于 React Router v7 框架项目
246
+ * React Router adapter options interface
247
+ * For React Router v7 framework projects
248
248
  *
249
- * 注意:SSR 和预渲染配置以框架的 react-router.config.ts 为准
249
+ * Note: SSR and prerender config follows framework's react-router.config.ts
250
250
  */
251
251
  export interface ReactRouterAdapterOptions extends CoreAdapterOptions {
252
252
  }
253
253
  /**
254
- * TanStack Start 适配器选项接口
255
- * 用于 TanStack Start 框架项目
254
+ * TanStack Start adapter options interface
255
+ * For TanStack Start framework projects
256
256
  */
257
257
  export interface TanStackStartAdapterOptions extends CoreAdapterOptions {
258
- /** 服务端预设(默认: node-server */
258
+ /** Server preset (default: node-server) */
259
259
  preset?: string;
260
260
  }
261
261
  /**
262
- * 创建适配器插件的工厂函数类型
262
+ * Factory function type for creating adapter plugins
263
263
  */
264
264
  export type CreateAdapterPlugin = (options?: CoreAdapterOptions) => Plugin;
265
265
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAA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C,OAAO,CAAC,EAAE,kBAAkB,KAAK,MAAM,CAAC"}
package/dist/types.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * EdgeOne Vite Plugin Adapter - 类型定义文件
2
+ * EdgeOne Vite Plugin Adapter - Type Definitions
3
3
  *
4
- * 本文件定义了适配器插件系统的所有核心类型
5
- * 包括路由信息、元数据配置、构建上下文、钩子函数等
4
+ * This file defines all core types for the adapter plugin system,
5
+ * including route info, meta config, build context, hook functions, etc.
6
6
  */
7
7
  export {};
8
8
  //# sourceMappingURL=types.js.map
package/dist/utils.d.ts CHANGED
@@ -1,43 +1,43 @@
1
1
  /**
2
- * EdgeOne Vite Plugin Adapter - 工具函数模块
3
- *
4
- * 本模块提供了一系列通用的工具函数,包括:
5
- * - 日志记录
6
- * - 文件系统操作(读写、复制、删除等)
7
- * - 路径检测
8
- * - 文件大小格式化
9
- * - 条件等待等
2
+ * EdgeOne Vite Plugin Adapter - Utility Functions Module
3
+ *
4
+ * This module provides a set of general utility functions, including:
5
+ * - Logging
6
+ * - File system operations (read, write, copy, delete, etc.)
7
+ * - Path detection
8
+ * - File size formatting
9
+ * - Conditional waiting, etc.
10
10
  */
11
11
  import type { Logger } from "./types.js";
12
12
  /**
13
- * 创建日志记录器实例
13
+ * Create logger instance
14
14
  *
15
- * @param verbose - 是否启用详细日志模式,默认为 false
16
- * @returns 返回一个包含 logverbosewarnerror 方法的日志对象
15
+ * @param verbose - Enable verbose logging mode, default is false
16
+ * @returns Logger object with log, verbose, warn, error methods
17
17
  *
18
18
  * @example
19
19
  * const logger = createLogger(true);
20
- * logger.verbose("这条消息只在 verbose 模式下显示");
21
- * logger.warn("这是一条警告消息");
20
+ * logger.verbose("This message only shows in verbose mode");
21
+ * logger.warn("This is a warning message");
22
22
  */
23
23
  export declare function createLogger(verbose?: boolean): Logger;
24
24
  /**
25
- * 检查指定路径是否存在
25
+ * Check if specified path exists
26
26
  *
27
- * @param filePath - 要检查的文件或目录路径
28
- * @returns 如果路径存在返回 true,否则返回 false
27
+ * @param filePath - File or directory path to check
28
+ * @returns True if path exists, false otherwise
29
29
  *
30
30
  * @example
31
31
  * if (await pathExists('/path/to/file')) {
32
- * console.log('文件存在');
32
+ * console.log('File exists');
33
33
  * }
34
34
  */
35
35
  export declare function pathExists(filePath: string): Promise<boolean>;
36
36
  /**
37
- * 从候选路径列表中找到第一个存在的路径
37
+ * Find first existing path from candidate list
38
38
  *
39
- * @param candidates - 候选路径数组,按优先级排序
40
- * @returns 返回第一个存在的路径,如果都不存在则返回 null
39
+ * @param candidates - Candidate paths array, sorted by priority
40
+ * @returns First existing path, or null if none exist
41
41
  *
42
42
  * @example
43
43
  * const buildDir = await findExistingPath([
@@ -48,71 +48,71 @@ export declare function pathExists(filePath: string): Promise<boolean>;
48
48
  */
49
49
  export declare function findExistingPath(candidates: string[]): Promise<string | null>;
50
50
  /**
51
- * 递归复制目录
52
- * 将源目录的所有内容复制到目标目录
51
+ * Recursively copy directory
52
+ * Copy all contents from source directory to destination directory
53
53
  *
54
- * @param src - 源目录路径
55
- * @param dest - 目标目录路径
54
+ * @param src - Source directory path
55
+ * @param dest - Destination directory path
56
56
  *
57
57
  * @example
58
58
  * await copyDirectory('dist/client', '.edgeone/assets');
59
59
  */
60
60
  export declare function copyDirectory(src: string, dest: string): Promise<void>;
61
61
  /**
62
- * 清理目录(删除后重新创建)
63
- * 用于确保目录为空的干净状态
62
+ * Clean directory (delete and recreate)
63
+ * Used to ensure directory is in a clean empty state
64
64
  *
65
- * @param dir - 要清理的目录路径
65
+ * @param dir - Directory path to clean
66
66
  *
67
67
  * @example
68
68
  * await cleanDirectory('.edgeone');
69
69
  */
70
70
  export declare function cleanDirectory(dir: string): Promise<void>;
71
71
  /**
72
- * 确保目录存在
73
- * 如果目录不存在则递归创建
72
+ * Ensure directory exists
73
+ * Recursively create if directory doesn't exist
74
74
  *
75
- * @param dir - 目录路径
75
+ * @param dir - Directory path
76
76
  *
77
77
  * @example
78
78
  * await ensureDirectory('.edgeone/server-handler');
79
79
  */
80
80
  export declare function ensureDirectory(dir: string): Promise<void>;
81
81
  /**
82
- * 读取文件内容为字符串
82
+ * Read file content as string
83
83
  *
84
- * @param filePath - 文件路径
85
- * @returns 文件内容字符串(UTF-8 编码)
84
+ * @param filePath - File path
85
+ * @returns File content string (UTF-8 encoded)
86
86
  *
87
87
  * @example
88
88
  * const content = await readFile('dist/server/index.js');
89
89
  */
90
90
  export declare function readFile(filePath: string): Promise<string>;
91
91
  /**
92
- * 将内容写入文件
93
- * 如果父目录不存在会自动创建
92
+ * Write content to file
93
+ * Automatically creates parent directory if it doesn't exist
94
94
  *
95
- * @param filePath - 文件路径
96
- * @param content - 要写入的内容
95
+ * @param filePath - File path
96
+ * @param content - Content to write
97
97
  *
98
98
  * @example
99
99
  * await writeFile('.edgeone/meta.json', JSON.stringify(config));
100
100
  */
101
101
  export declare function writeFile(filePath: string, content: string): Promise<void>;
102
102
  /**
103
- * 删除文件
103
+ * Delete file
104
104
  *
105
- * @param filePath - 要删除的文件路径
105
+ * @param filePath - File path to delete
106
106
  *
107
107
  * @example
108
108
  * await deleteFile('server-wrapper.temp.js');
109
109
  */
110
110
  export declare function deleteFile(filePath: string): Promise<void>;
111
111
  /**
112
- * 格式化文件大小为人类可读的字符串
112
+ * Format file size to human-readable string
113
113
  *
114
- * @param bytes - 字节数
115
- * @returns 格式化后的字符串,如 "1.5 KB""2.3 MB"
114
+ * @param bytes - Number of bytes
115
+ * @returns Formatted string, e.g. "1.5 KB", "2.3 MB"
116
116
  *
117
117
  * @example
118
118
  * formatSize(1536); // "1.5 KB"
@@ -120,14 +120,14 @@ export declare function deleteFile(filePath: string): Promise<void>;
120
120
  */
121
121
  export declare function formatSize(bytes: number): string;
122
122
  /**
123
- * 等待条件满足(带重试机制)
124
- * 用于等待异步操作完成,如文件写入完成
123
+ * Wait for condition to be met (with retry mechanism)
124
+ * Used to wait for async operations to complete, like file writes
125
125
  *
126
- * @param condition - 返回布尔值的异步条件函数
127
- * @param options - 配置选项
128
- * @param options.maxRetries - 最大重试次数,默认 15
129
- * @param options.delay - 每次重试的间隔时间(毫秒),默认 300ms
130
- * @returns 条件满足返回 true,超时返回 false
126
+ * @param condition - Async condition function returning boolean
127
+ * @param options - Configuration options
128
+ * @param options.maxRetries - Maximum retry count, default 15
129
+ * @param options.delay - Delay between retries in milliseconds, default 300ms
130
+ * @returns True if condition met, false if timeout
131
131
  *
132
132
  * @example
133
133
  * const ready = await waitFor(
@@ -140,10 +140,10 @@ export declare function waitFor(condition: () => Promise<boolean>, options?: {
140
140
  delay?: number;
141
141
  }): Promise<boolean>;
142
142
  /**
143
- * 列出目录中的文件和子目录名称
143
+ * List files and subdirectory names in directory
144
144
  *
145
- * @param dir - 目录路径
146
- * @returns 文件和目录名称数组,如果目录不存在则返回空数组
145
+ * @param dir - Directory path
146
+ * @returns Array of file and directory names, empty array if directory doesn't exist
147
147
  *
148
148
  * @example
149
149
  * const files = await listFiles('dist/client');
@@ -151,14 +151,14 @@ export declare function waitFor(condition: () => Promise<boolean>, options?: {
151
151
  */
152
152
  export declare function listFiles(dir: string): Promise<string[]>;
153
153
  /**
154
- * 递归统计目录中的文件数量
154
+ * Recursively count files in directory
155
155
  *
156
- * @param dir - 目录路径
157
- * @returns 文件总数(不包括目录)
156
+ * @param dir - Directory path
157
+ * @returns Total file count (excluding directories)
158
158
  *
159
159
  * @example
160
160
  * const count = await countFiles('dist');
161
- * console.log(`构建产物包含 ${count} 个文件`);
161
+ * console.log(`Build artifacts contain ${count} files`);
162
162
  */
163
163
  export declare function countFiles(dir: string): Promise<number>;
164
164
  //# sourceMappingURL=utils.d.ts.map