@esmx/core 3.0.0-rc.60 → 3.0.0-rc.63

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/core.d.ts CHANGED
@@ -8,93 +8,93 @@ import type { RenderContext, RenderContextOptions } from './render-context';
8
8
  import type { Middleware } from './utils/middleware';
9
9
  import { type ProjectPath } from './utils/resolve-path';
10
10
  /**
11
- * Esmx 框架的核心配置选项接口
11
+ * Core configuration options interface for the Esmx framework
12
12
  */
13
13
  export interface EsmxOptions {
14
14
  /**
15
- * 项目根目录路径
16
- * - 可以是绝对路径或相对路径
17
- * - 默认为当前工作目录 (process.cwd())
15
+ * Project root directory path
16
+ * - Can be absolute or relative path
17
+ * - Defaults to current working directory (process.cwd())
18
18
  */
19
19
  root?: string;
20
20
  /**
21
- * 是否为生产环境
22
- * - true: 生产环境
23
- * - false: 开发环境
24
- * - 默认根据 process.env.NODE_ENV === 'production' 判断
21
+ * Whether it is production environment
22
+ * - true: Production environment
23
+ * - false: Development environment
24
+ * - Defaults to process.env.NODE_ENV === 'production'
25
25
  */
26
26
  isProd?: boolean;
27
27
  /**
28
- * 基础路径占位符配置
29
- * - string: 自定义占位符
30
- * - false: 禁用占位符
31
- * - 默认值为 '[[[___GEZ_DYNAMIC_BASE___]]]'
32
- * - 用于运行时动态替换资源的基础路径
28
+ * Base path placeholder configuration
29
+ * - string: Custom placeholder
30
+ * - false: Disable placeholder
31
+ * - Default value is '[[[___ESMX_DYNAMIC_BASE___]]]'
32
+ * - Used for dynamically replacing the base path of assets at runtime
33
33
  */
34
34
  basePathPlaceholder?: string | false;
35
35
  /**
36
- * 模块配置选项
37
- * - 用于配置项目的模块解析规则
38
- * - 包括模块别名、外部依赖等配置
36
+ * Module configuration options
37
+ * - Used to configure module resolution rules for the project
38
+ * - Includes module aliases, external dependencies, etc.
39
39
  */
40
40
  modules?: ModuleConfig;
41
41
  /**
42
- * 打包配置选项
43
- * - 用于将构建产物打包成标准的 npm .tgz 格式软件包
44
- * - 包括输出路径、package.json 处理、打包钩子等配置
42
+ * Package configuration options
43
+ * - Used to package build artifacts into standard npm .tgz format packages
44
+ * - Includes output path, package.json handling, packaging hooks, etc.
45
45
  */
46
46
  packs?: PackConfig;
47
47
  /**
48
- * 开发环境应用创建函数
49
- * - 仅在开发环境中使用
50
- * - 用于创建开发服务器的应用实例
51
- * @param esmx Esmx实例
48
+ * Development environment application creation function
49
+ * - Only used in development environment
50
+ * - Used to create application instance for development server
51
+ * @param esmx Esmx instance
52
52
  */
53
53
  devApp?: (esmx: Esmx) => Promise<App>;
54
54
  /**
55
- * 服务器启动配置函数
56
- * - 用于配置和启动 HTTP 服务器
57
- * - 在开发环境和生产环境中都可使用
58
- * @param esmx Esmx实例
55
+ * Server startup configuration function
56
+ * - Used to configure and start HTTP server
57
+ * - Can be used in both development and production environments
58
+ * @param esmx Esmx instance
59
59
  */
60
60
  server?: (esmx: Esmx) => Promise<void>;
61
61
  /**
62
- * 构建后置处理函数
63
- * - 在项目构建完成后执行
64
- * - 可用于执行额外的资源处理、部署等操作
65
- * @param esmx Esmx实例
62
+ * Post-build processing function
63
+ * - Executed after project build is completed
64
+ * - Can be used to perform additional resource processing, deployment, etc.
65
+ * @param esmx Esmx instance
66
66
  */
67
67
  postBuild?: (esmx: Esmx) => Promise<void>;
68
68
  }
69
69
  /**
70
- * 应用程序构建目标类型。
71
- * - client: 客户端构建目标,用于生成浏览器端运行的代码
72
- * - server: 服务端构建目标,用于生成 Node.js 环境运行的代码
70
+ * Application build target types.
71
+ * - client: Client build target, used to generate code that runs in the browser
72
+ * - server: Server build target, used to generate code that runs in Node.js environment
73
73
  */
74
74
  export type BuildEnvironment = 'client' | 'server';
75
75
  /**
76
- * Esmx 框架的命令枚举。
77
- * 用于控制框架的运行模式和生命周期。
76
+ * Command enumeration for the Esmx framework.
77
+ * Used to control the runtime mode and lifecycle of the framework.
78
78
  */
79
79
  export declare enum COMMAND {
80
80
  /**
81
- * 开发模式
82
- * 启动开发服务器并支持热更新
81
+ * Development mode
82
+ * Starts development server with hot reload support
83
83
  */
84
84
  dev = "dev",
85
85
  /**
86
- * 构建模式
87
- * 生成生产环境构建产物
86
+ * Build mode
87
+ * Generates production build artifacts
88
88
  */
89
89
  build = "build",
90
90
  /**
91
- * 预览模式
92
- * 预览构建产物
91
+ * Preview mode
92
+ * Preview build artifacts
93
93
  */
94
94
  preview = "preview",
95
95
  /**
96
- * 启动模式
97
- * 启动生产环境服务器
96
+ * Start mode
97
+ * Starts production environment server
98
98
  */
99
99
  start = "start"
100
100
  }
@@ -105,76 +105,77 @@ export declare class Esmx {
105
105
  private _importmapHash;
106
106
  private get readied();
107
107
  /**
108
- * 获取模块名称
109
- * @returns {string} 当前模块的名称,来源于模块配置
110
- * @throws {NotReadyError} 在框架实例未初始化时抛出错误
108
+ * Get module name
109
+ * @returns {string} The name of the current module, sourced from module configuration
110
+ * @throws {NotReadyError} Throws error when framework instance is not initialized
111
111
  */
112
112
  get name(): string;
113
113
  /**
114
- * 获取模块变量名
115
- * @returns {string} 基于模块名称生成的合法 JavaScript 变量名
116
- * @throws {NotReadyError} 在框架实例未初始化时抛出错误
114
+ * Get module variable name
115
+ * @returns {string} A valid JavaScript variable name generated based on the module name
116
+ * @throws {NotReadyError} Throws error when framework instance is not initialized
117
117
  */
118
118
  get varName(): string;
119
119
  /**
120
- * 获取项目根目录的绝对路径
121
- * @returns {string} 项目根目录的绝对路径
122
- * 如果配置的 root 为相对路径,则基于当前工作目录解析为绝对路径
120
+ * Get the absolute path of the project root directory
121
+ * @returns {string} The absolute path of the project root directory
122
+ * If the configured root is a relative path, it is resolved to an absolute path based on the current working directory
123
123
  */
124
124
  get root(): string;
125
125
  /**
126
- * 判断当前是否为生产环境
127
- * @returns {boolean} 环境标识
128
- * 优先使用配置项中的 isProd,若未配置则根据 process.env.NODE_ENV 判断
126
+ * Determine if currently in production environment
127
+ * @returns {boolean} Environment flag
128
+ * Prioritizes the isProd in configuration, if not configured, judges based on process.env.NODE_ENV
129
129
  */
130
130
  get isProd(): boolean;
131
131
  /**
132
- * 获取模块的基础路径
133
- * @returns {string} 以斜杠开头和结尾的模块基础路径
134
- * 用于构建模块资源的访问路径
132
+ * Get the base path of the module
133
+ * @returns {string} The base path of the module starting and ending with a slash
134
+ * Used to construct the access path for module assets
135
135
  */
136
136
  get basePath(): string;
137
137
  /**
138
- * 获取基础路径占位符
139
- * @returns {string} 基础路径占位符或空字符串
140
- * 用于运行时动态替换模块的基础路径,可通过配置禁用
138
+ * Get the base path placeholder
139
+ * @returns {string} Base path placeholder or empty string
140
+ * Used for dynamically replacing the base path of the module at runtime, can be disabled through configuration
141
141
  */
142
142
  get basePathPlaceholder(): string;
143
143
  /**
144
- * 获取当前执行的命令
145
- * @returns {COMMAND} 当前正在执行的命令枚举值
146
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
144
+ * Get the currently executing command
145
+ * @returns {COMMAND} The command enumeration value currently being executed
146
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
147
147
  */
148
148
  get command(): COMMAND;
149
149
  /**
150
- * 获取命令枚举类型
151
- * @returns {typeof COMMAND} 命令枚举类型定义
150
+ * Get the command enumeration type
151
+ * @returns {typeof COMMAND} Command enumeration type definition
152
152
  */
153
153
  get COMMAND(): typeof COMMAND;
154
154
  /**
155
- * 获取模块配置信息
156
- * @returns {ParsedModuleConfig} 当前模块的完整配置信息
155
+ * Get module configuration information
156
+ * @returns {ParsedModuleConfig} Complete configuration information of the current module
157
157
  */
158
158
  get moduleConfig(): ParsedModuleConfig;
159
159
  /**
160
- * 获取打包配置信息
161
- * @returns {ParsedPackConfig} 当前模块的打包相关配置
160
+ * Get package configuration information
161
+ * @returns {ParsedPackConfig} Package-related configuration of the current module
162
162
  */
163
163
  get packConfig(): ParsedPackConfig;
164
164
  /**
165
- * 获取应用程序的静态资源处理中间件。
165
+ * Get the static asset processing middleware for the application.
166
166
  *
167
- * 该中间件负责处理应用程序的静态资源请求,根据运行环境提供不同的实现:
168
- * - 开发环境:支持源码的实时编译、热更新,使用 no-cache 缓存策略
169
- * - 生产环境:处理构建后的静态资源,支持不可变文件的长期缓存
167
+ * This middleware is responsible for handling static asset requests for the application,
168
+ * providing different implementations based on the runtime environment:
169
+ * - Development environment: Supports real-time compilation and hot reloading of source code, uses no-cache strategy
170
+ * - Production environment: Handles built static assets, supports long-term caching for immutable files
170
171
  *
171
- * @returns {Middleware} 返回静态资源处理中间件函数
172
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
172
+ * @returns {Middleware} Returns the static asset processing middleware function
173
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
173
174
  *
174
175
  * @example
175
176
  * ```ts
176
177
  * const server = http.createServer((req, res) => {
177
- * // 使用中间件处理静态资源请求
178
+ * // Use middleware to handle static asset requests
178
179
  * esmx.middleware(req, res, async () => {
179
180
  * const rc = await esmx.render({ url: req.url });
180
181
  * res.end(rc.html);
@@ -184,28 +185,29 @@ export declare class Esmx {
184
185
  */
185
186
  get middleware(): Middleware;
186
187
  /**
187
- * 获取应用程序的服务端渲染函数。
188
+ * Get the server-side rendering function for the application.
188
189
  *
189
- * 该函数负责执行服务端渲染,根据运行环境提供不同的实现:
190
- * - 开发环境:加载源码中的服务端入口文件,支持热更新和实时预览
191
- * - 生产环境:加载构建后的服务端入口文件,提供优化的渲染性能
190
+ * This function is responsible for executing server-side rendering,
191
+ * providing different implementations based on the runtime environment:
192
+ * - Development environment: Loads server entry file from source code, supports hot reloading and real-time preview
193
+ * - Production environment: Loads built server entry file, provides optimized rendering performance
192
194
  *
193
- * @returns {(options?: RenderContextOptions) => Promise<RenderContext>} 返回服务端渲染函数
194
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
195
+ * @returns {(options?: RenderContextOptions) => Promise<RenderContext>} Returns the server-side rendering function
196
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
195
197
  *
196
198
  * @example
197
199
  * ```ts
198
- * // 基本用法
200
+ * // Basic usage
199
201
  * const rc = await esmx.render({
200
202
  * params: { url: req.url }
201
203
  * });
202
204
  * res.end(rc.html);
203
205
  *
204
- * // 高级配置
206
+ * // Advanced configuration
205
207
  * const rc = await esmx.render({
206
- * base: '', // 设置基础路径
207
- * importmapMode: 'inline', // 设置导入映射模式
208
- * entryName: 'default', // 指定渲染入口
208
+ * base: '', // Set base path
209
+ * importmapMode: 'inline', // Set import map mode
210
+ * entryName: 'default', // Specify render entry
209
211
  * params: {
210
212
  * url: req.url,
211
213
  * state: { user: 'admin' }
@@ -216,21 +218,21 @@ export declare class Esmx {
216
218
  get render(): (options?: RenderContextOptions) => Promise<RenderContext>;
217
219
  constructor(options?: EsmxOptions);
218
220
  /**
219
- * 初始化 Esmx 框架实例。
221
+ * Initialize the Esmx framework instance.
220
222
  *
221
- * 该方法执行以下核心初始化流程:
222
- * 1. 解析项目配置(package.json、模块配置、打包配置等)
223
- * 2. 创建应用实例(开发环境或生产环境)
224
- * 3. 根据命令执行相应的生命周期方法
223
+ * This method executes the following core initialization process:
224
+ * 1. Parse project configuration (package.json, module configuration, package configuration, etc.)
225
+ * 2. Create application instance (development or production environment)
226
+ * 3. Execute corresponding lifecycle methods based on the command
225
227
  *
226
- * @param command - 框架运行命令
227
- * - dev: 启动开发服务器,支持热更新
228
- * - build: 构建生产环境产物
229
- * - preview: 预览构建产物
230
- * - start: 启动生产环境服务器
228
+ * @param command - Framework running command
229
+ * - dev: Start development server with hot reload support
230
+ * - build: Build production artifacts
231
+ * - preview: Preview build artifacts
232
+ * - start: Start production environment server
231
233
  *
232
- * @returns 初始化成功返回 true
233
- * @throws {Error} 重复初始化时抛出错误
234
+ * @returns Returns true for successful initialization
235
+ * @throws {Error} Throws error when initializing repeatedly
234
236
  *
235
237
  * @example
236
238
  * ```ts
@@ -238,32 +240,32 @@ export declare class Esmx {
238
240
  * import type { EsmxOptions } from '@esmx/core';
239
241
  *
240
242
  * export default {
241
- * // 开发环境配置
243
+ * // Development environment configuration
242
244
  * async devApp(esmx) {
243
245
  * return import('@esmx/rspack').then((m) =>
244
246
  * m.createRspackHtmlApp(esmx, {
245
247
  * config(context) {
246
- * // 自定义 Rspack 配置
248
+ * // Custom Rspack configuration
247
249
  * }
248
250
  * })
249
251
  * );
250
252
  * },
251
253
  *
252
- * // HTTP 服务器配置
254
+ * // HTTP server configuration
253
255
  * async server(esmx) {
254
256
  * const server = http.createServer((req, res) => {
255
- * // 静态文件处理
257
+ * // Static file handling
256
258
  * esmx.middleware(req, res, async () => {
257
- * // 传入渲染的参数
259
+ * // Pass rendering parameters
258
260
  * const render = await esmx.render({
259
261
  * params: { url: req.url }
260
262
  * });
261
- * // 响应 HTML 内容
263
+ * // Respond with HTML content
262
264
  * res.end(render.html);
263
265
  * });
264
266
  * });
265
267
  *
266
- * // 监听端口
268
+ * // Listen to port
267
269
  * server.listen(3000, () => {
268
270
  * console.log('http://localhost:3000');
269
271
  * });
@@ -273,46 +275,46 @@ export declare class Esmx {
273
275
  */
274
276
  init(command: COMMAND): Promise<boolean>;
275
277
  /**
276
- * 销毁 Esmx 框架实例,执行资源清理和连接关闭等操作。
278
+ * Destroy the Esmx framework instance, performing resource cleanup and connection closing operations.
277
279
  *
278
- * 该方法主要用于开发环境下的资源清理,包括:
279
- * - 关闭开发服务器(如 Rspack Dev Server
280
- * - 清理临时文件和缓存
281
- * - 释放系统资源
280
+ * This method is mainly used for resource cleanup in development environment, including:
281
+ * - Closing development servers (such as Rspack Dev Server)
282
+ * - Cleaning up temporary files and cache
283
+ * - Releasing system resources
282
284
  *
283
- * 注意:一般情况下,框架会自动处理资源的释放,用户无需手动调用此方法。
284
- * 仅在需要自定义资源清理逻辑时才需要使用。
285
+ * Note: In general, the framework automatically handles resource release, users do not need to manually call this method.
286
+ * Only use it when custom resource cleanup logic is needed.
285
287
  *
286
- * @returns 返回一个 Promise,resolve boolean
287
- * - true: 清理成功或无需清理
288
- * - false: 清理失败
288
+ * @returns Returns a Promise that resolves to a boolean value
289
+ * - true: Cleanup successful or no cleanup needed
290
+ * - false: Cleanup failed
289
291
  *
290
292
  * @example
291
293
  * ```ts
292
- * // 在需要自定义清理逻辑时使用
294
+ * // Use when custom cleanup logic is needed
293
295
  * process.once('SIGTERM', async () => {
294
- * await esmx.destroy(); // 清理资源
296
+ * await esmx.destroy(); // Clean up resources
295
297
  * process.exit(0);
296
298
  * });
297
299
  * ```
298
300
  */
299
301
  destroy(): Promise<boolean>;
300
302
  /**
301
- * 执行应用程序的构建流程。
303
+ * Execute the application's build process.
302
304
  *
303
- * 该方法负责执行整个应用的构建过程,包括:
304
- * - 编译源代码
305
- * - 生成生产环境的构建产物
306
- * - 优化和压缩代码
307
- * - 生成资源清单
305
+ * This method is responsible for executing the entire application build process, including:
306
+ * - Compiling source code
307
+ * - Generating production build artifacts
308
+ * - Optimizing and compressing code
309
+ * - Generating asset manifests
308
310
  *
309
- * 构建过程会打印开始和结束时间,以及总耗时等信息。
311
+ * The build process prints start and end times, as well as total duration and other information.
310
312
  *
311
- * @returns 返回一个 Promise,resolve boolean
312
- * - true: 构建成功或构建方法未实现
313
- * - false: 构建失败
313
+ * @returns Returns a Promise that resolves to a boolean value
314
+ * - true: Build successful or build method not implemented
315
+ * - false: Build failed
314
316
  *
315
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
317
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
316
318
  *
317
319
  * @example
318
320
  * ```ts
@@ -320,20 +322,20 @@ export declare class Esmx {
320
322
  * import type { EsmxOptions } from '@esmx/core';
321
323
  *
322
324
  * export default {
323
- * // 开发环境配置
325
+ * // Development environment configuration
324
326
  * async devApp(esmx) {
325
327
  * return import('@esmx/rspack').then((m) =>
326
328
  * m.createRspackHtmlApp(esmx, {
327
329
  * config(context) {
328
- * // 自定义 Rspack 配置
330
+ * // Custom Rspack configuration
329
331
  * }
330
332
  * })
331
333
  * );
332
334
  * },
333
335
  *
334
- * // 构建后处理
336
+ * // Post-build processing
335
337
  * async postBuild(esmx) {
336
- * // 构建完成后生成静态 HTML
338
+ * // Generate static HTML after build completion
337
339
  * const render = await esmx.render({
338
340
  * params: { url: '/' }
339
341
  * });
@@ -347,21 +349,21 @@ export declare class Esmx {
347
349
  */
348
350
  build(): Promise<boolean>;
349
351
  /**
350
- * 启动 HTTP 服务器并配置服务器实例。
352
+ * Start HTTP server and configure server instance.
351
353
  *
352
- * 该方法在框架的以下生命周期中被调用:
353
- * - 开发环境(dev):启动开发服务器,提供热更新等功能
354
- * - 生产环境(start):启动生产服务器,提供生产级性能
354
+ * This method is called in the following lifecycle of the framework:
355
+ * - Development environment (dev): Start development server, providing features like hot reload
356
+ * - Production environment (start): Start production server, providing production-grade performance
355
357
  *
356
- * 服务器的具体实现由用户通过 EsmxOptions server 配置函数提供。
357
- * 该函数负责:
358
- * - 创建 HTTP 服务器实例
359
- * - 配置中间件和路由
360
- * - 处理请求和响应
361
- * - 启动服务器监听
358
+ * The specific implementation of the server is provided by the user through the server configuration function in EsmxOptions.
359
+ * This function is responsible for:
360
+ * - Creating HTTP server instance
361
+ * - Configuring middleware and routes
362
+ * - Handling requests and responses
363
+ * - Starting server listening
362
364
  *
363
- * @returns 返回一个 Promise,在服务器启动完成后 resolve
364
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
365
+ * @returns Returns a Promise that resolves when the server startup is complete
366
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
365
367
  *
366
368
  * @example
367
369
  * ```ts
@@ -370,12 +372,12 @@ export declare class Esmx {
370
372
  * import type { EsmxOptions } from '@esmx/core';
371
373
  *
372
374
  * export default {
373
- * // 服务器配置
375
+ * // Server configuration
374
376
  * async server(esmx) {
375
377
  * const server = http.createServer((req, res) => {
376
- * // 处理静态资源
378
+ * // Handle static assets
377
379
  * esmx.middleware(req, res, async () => {
378
- * // 服务端渲染
380
+ * // Server-side rendering
379
381
  * const render = await esmx.render({
380
382
  * params: { url: req.url }
381
383
  * });
@@ -383,7 +385,7 @@ export declare class Esmx {
383
385
  * });
384
386
  * });
385
387
  *
386
- * // 启动服务器
388
+ * // Start server
387
389
  * server.listen(3000, () => {
388
390
  * console.log('Server running at http://localhost:3000');
389
391
  * });
@@ -393,19 +395,19 @@ export declare class Esmx {
393
395
  */
394
396
  server(): Promise<void>;
395
397
  /**
396
- * 执行构建后的处理逻辑。
398
+ * Execute post-build processing logic.
397
399
  *
398
- * 该方法在应用构建完成后被调用,用于执行额外的资源处理,如:
399
- * - 生成静态 HTML 文件
400
- * - 处理构建产物
401
- * - 执行部署任务
402
- * - 发送构建通知
400
+ * This method is called after the application build is completed, used to perform additional resource processing, such as:
401
+ * - Generating static HTML files
402
+ * - Processing build artifacts
403
+ * - Executing deployment tasks
404
+ * - Sending build notifications
403
405
  *
404
- * 方法会自动捕获并处理执行过程中的异常,确保不会影响主构建流程。
406
+ * The method automatically captures and handles exceptions during execution, ensuring it does not affect the main build process.
405
407
  *
406
- * @returns 返回一个 Promise,resolve boolean
407
- * - true: 后处理成功或无需处理
408
- * - false: 后处理失败
408
+ * @returns Returns a Promise that resolves to a boolean value
409
+ * - true: Post-processing successful or no processing needed
410
+ * - false: Post-processing failed
409
411
  *
410
412
  * @example
411
413
  * ```ts
@@ -413,9 +415,9 @@ export declare class Esmx {
413
415
  * import type { EsmxOptions } from '@esmx/core';
414
416
  *
415
417
  * export default {
416
- * // 构建后处理
418
+ * // Post-build processing
417
419
  * async postBuild(esmx) {
418
- * // 生成多个页面的静态 HTML
420
+ * // Generate static HTML for multiple pages
419
421
  * const pages = ['/', '/about', '/404'];
420
422
  *
421
423
  * for (const url of pages) {
@@ -423,7 +425,7 @@ export declare class Esmx {
423
425
  * params: { url }
424
426
  * });
425
427
  *
426
- * // 写入静态 HTML 文件
428
+ * // Write static HTML file
427
429
  * esmx.writeSync(
428
430
  * esmx.resolvePath('dist/client', url.substring(1), 'index.html'),
429
431
  * render.html
@@ -435,32 +437,32 @@ export declare class Esmx {
435
437
  */
436
438
  postBuild(): Promise<boolean>;
437
439
  /**
438
- * 解析项目相对路径为绝对路径
440
+ * Resolve project relative path to absolute path
439
441
  *
440
- * @param projectPath - 项目路径类型,如 'dist/client''dist/server'
441
- * @param args - 需要拼接的路径片段
442
- * @returns 解析后的绝对路径
442
+ * @param projectPath - Project path type, such as 'dist/client', 'dist/server', etc.
443
+ * @param args - Path segments to be concatenated
444
+ * @returns Resolved absolute path
443
445
  *
444
446
  * @example
445
447
  * ```ts
446
- * // entry.node.ts 中使用
448
+ * // Used in entry.node.ts
447
449
  * async postBuild(esmx) {
448
450
  * const outputPath = esmx.resolvePath('dist/client', 'index.html');
449
- * // 输出: /project/root/dist/client/index.html
451
+ * // Output: /project/root/dist/client/index.html
450
452
  * }
451
453
  * ```
452
454
  */
453
455
  resolvePath(projectPath: ProjectPath, ...args: string[]): string;
454
456
  /**
455
- * 同步写入文件内容
457
+ * Write file content synchronously
456
458
  *
457
- * @param filepath - 文件的绝对路径
458
- * @param data - 要写入的数据,可以是字符串、Buffer 或对象
459
- * @returns 写入是否成功
459
+ * @param filepath - Absolute path of the file
460
+ * @param data - Data to be written, can be string, Buffer or object
461
+ * @returns Whether the write was successful
460
462
  *
461
463
  * @example
462
464
  * ```ts
463
- * // entry.node.ts 中使用
465
+ * // Used in entry.node.ts
464
466
  * async postBuild(esmx) {
465
467
  * const htmlPath = esmx.resolvePath('dist/client', 'index.html');
466
468
  * const success = esmx.writeSync(htmlPath, '<html>...</html>');
@@ -469,15 +471,15 @@ export declare class Esmx {
469
471
  */
470
472
  writeSync(filepath: string, data: any): boolean;
471
473
  /**
472
- * 异步写入文件内容
474
+ * Write file content asynchronously
473
475
  *
474
- * @param filepath - 文件的绝对路径
475
- * @param data - 要写入的数据,可以是字符串、Buffer 或对象
476
- * @returns Promise<boolean> 写入是否成功
476
+ * @param filepath - Absolute path of the file
477
+ * @param data - Data to be written, can be string, Buffer or object
478
+ * @returns Promise<boolean> Whether the write was successful
477
479
  *
478
480
  * @example
479
481
  * ```ts
480
- * // entry.node.ts 中使用
482
+ * // Used in entry.node.ts
481
483
  * async postBuild(esmx) {
482
484
  * const htmlPath = esmx.resolvePath('dist/client', 'index.html');
483
485
  * const success = await esmx.write(htmlPath, '<html>...</html>');
@@ -486,72 +488,72 @@ export declare class Esmx {
486
488
  */
487
489
  write(filepath: string, data: any): Promise<boolean>;
488
490
  /**
489
- * 同步读取并解析 JSON 文件
491
+ * Read and parse JSON file synchronously
490
492
  *
491
- * @template T - 期望返回的JSON对象类型
492
- * @param filename - JSON 文件的绝对路径
493
- * @returns {T} 解析后的 JSON 对象
494
- * @throws 当文件不存在或 JSON 格式错误时抛出异常
493
+ * @template T - Expected JSON object type to return
494
+ * @param filename - Absolute path of the JSON file
495
+ * @returns {T} Parsed JSON object
496
+ * @throws Throws exception when file does not exist or JSON format is incorrect
495
497
  *
496
498
  * @example
497
499
  * ```ts
498
- * // entry.node.ts 中使用
500
+ * // Used in entry.node.ts
499
501
  * async server(esmx) {
500
502
  * const manifest = esmx.readJsonSync<Manifest>(esmx.resolvePath('dist/client', 'manifest.json'));
501
- * // 使用 manifest 对象
503
+ * // Use manifest object
502
504
  * }
503
505
  * ```
504
506
  */
505
507
  readJsonSync<T = any>(filename: string): T;
506
508
  /**
507
- * 异步读取并解析 JSON 文件
509
+ * Read and parse JSON file asynchronously
508
510
  *
509
- * @template T - 期望返回的JSON对象类型
510
- * @param filename - JSON 文件的绝对路径
511
- * @returns {Promise<T>} 解析后的 JSON 对象
512
- * @throws 当文件不存在或 JSON 格式错误时抛出异常
511
+ * @template T - Expected JSON object type to return
512
+ * @param filename - Absolute path of the JSON file
513
+ * @returns {Promise<T>} Parsed JSON object
514
+ * @throws Throws exception when file does not exist or JSON format is incorrect
513
515
  *
514
516
  * @example
515
517
  * ```ts
516
- * // entry.node.ts 中使用
518
+ * // Used in entry.node.ts
517
519
  * async server(esmx) {
518
520
  * const manifest = await esmx.readJson<Manifest>(esmx.resolvePath('dist/client', 'manifest.json'));
519
- * // 使用 manifest 对象
521
+ * // Use manifest object
520
522
  * }
521
523
  * ```
522
524
  */
523
525
  readJson<T = any>(filename: string): Promise<T>;
524
526
  /**
525
- * 获取构建清单列表
527
+ * Get build manifest list
526
528
  *
527
529
  * @description
528
- * 该方法用于获取指定目标环境的构建清单列表,包含以下功能:
529
- * 1. **缓存管理**
530
- * - 使用内部缓存机制避免重复加载
531
- * - 返回不可变的清单列表
530
+ * This method is used to get the build manifest list for the specified target environment, including the following features:
531
+ * 1. **Cache Management**
532
+ * - Uses internal caching mechanism to avoid repeated loading
533
+ * - Returns immutable manifest list
532
534
  *
533
- * 2. **环境适配**
534
- * - 支持客户端和服务端两种环境
535
- * - 根据目标环境返回对应的清单信息
535
+ * 2. **Environment Adaptation**
536
+ * - Supports both client and server environments
537
+ * - Returns corresponding manifest information based on the target environment
536
538
  *
537
- * 3. **模块映射**
538
- * - 包含模块导出信息
539
- * - 记录资源依赖关系
539
+ * 3. **Module Mapping**
540
+ * - Contains module export information
541
+ * - Records resource dependency relationships
540
542
  *
541
- * @param env - 目标环境类型
542
- * - 'client': 客户端环境
543
- * - 'server': 服务端环境
544
- * @returns 返回只读的构建清单列表
545
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
543
+ * @param env - Target environment type
544
+ * - 'client': Client environment
545
+ * - 'server': Server environment
546
+ * @returns Returns read-only build manifest list
547
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
546
548
  *
547
549
  * @example
548
550
  * ```ts
549
- * // entry.node.ts 中使用
551
+ * // Used in entry.node.ts
550
552
  * async server(esmx) {
551
- * // 获取客户端构建清单
553
+ * // Get client build manifest
552
554
  * const manifests = await esmx.getManifestList('client');
553
555
  *
554
- * // 查找特定模块的构建信息
556
+ * // Find build information for a specific module
555
557
  * const appModule = manifests.find(m => m.name === 'my-app');
556
558
  * if (appModule) {
557
559
  * console.log('App exports:', appModule.exports);
@@ -562,37 +564,37 @@ export declare class Esmx {
562
564
  */
563
565
  getManifestList(env: BuildEnvironment): Promise<readonly ManifestJson[]>;
564
566
  /**
565
- * 获取导入映射对象
567
+ * Get import map object
566
568
  *
567
569
  * @description
568
- * 该方法用于生成 ES 模块导入映射(Import Map),具有以下特点:
569
- * 1. **模块解析**
570
- * - 基于构建清单生成模块映射
571
- * - 支持客户端和服务端两种环境
572
- * - 自动处理模块路径解析
573
- *
574
- * 2. **缓存优化**
575
- * - 使用内部缓存机制
576
- * - 返回不可变的映射对象
577
- *
578
- * 3. **路径处理**
579
- * - 自动处理模块路径
580
- * - 支持动态基础路径
581
- *
582
- * @param env - 目标环境类型
583
- * - 'client': 生成浏览器环境的导入映射
584
- * - 'server': 生成服务端环境的导入映射
585
- * @returns 返回只读的导入映射对象
586
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
570
+ * This method is used to generate ES module import maps with the following features:
571
+ * 1. **Module Resolution**
572
+ * - Generate module mappings based on build manifests
573
+ * - Support both client and server environments
574
+ * - Automatically handle module path resolution
575
+ *
576
+ * 2. **Cache Optimization**
577
+ * - Use internal caching mechanism
578
+ * - Return immutable mapping objects
579
+ *
580
+ * 3. **Path Handling**
581
+ * - Automatically handle module paths
582
+ * - Support dynamic base paths
583
+ *
584
+ * @param env - Target environment type
585
+ * - 'client': Generate import map for browser environment
586
+ * - 'server': Generate import map for server environment
587
+ * @returns Returns read-only import map object
588
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
587
589
  *
588
590
  * @example
589
591
  * ```ts
590
- * // entry.node.ts 中使用
592
+ * // Used in entry.node.ts
591
593
  * async server(esmx) {
592
- * // 获取客户端导入映射
594
+ * // Get client import map
593
595
  * const importmap = await esmx.getImportMap('client');
594
596
  *
595
- * // 自定义 HTML 模板
597
+ * // Custom HTML template
596
598
  * const html = `
597
599
  * <!DOCTYPE html>
598
600
  * <html>
@@ -602,7 +604,7 @@ export declare class Esmx {
602
604
  * </script>
603
605
  * </head>
604
606
  * <body>
605
- * <!-- 页面内容 -->
607
+ * <!-- Page content -->
606
608
  * </body>
607
609
  * </html>
608
610
  * `;
@@ -611,44 +613,44 @@ export declare class Esmx {
611
613
  */
612
614
  getImportMap(env: BuildEnvironment): Promise<Readonly<ImportMap>>;
613
615
  /**
614
- * 获取客户端导入映射信息
616
+ * Get client import map information
615
617
  *
616
618
  * @description
617
- * 该方法用于生成客户端环境的导入映射代码,支持两种模式:
618
- * 1. **内联模式 (inline)**
619
- * - 将导入映射直接内联到 HTML
620
- * - 减少额外的网络请求
621
- * - 适合导入映射较小的场景
622
- *
623
- * 2. **JS 文件模式 (js)**
624
- * - 生成独立的 JS 文件
625
- * - 支持浏览器缓存
626
- * - 适合导入映射较大的场景
627
- *
628
- * 核心功能:
629
- * - 自动处理动态基础路径
630
- * - 支持模块路径运行时替换
631
- * - 优化缓存策略
632
- * - 确保模块加载顺序
633
- *
634
- * @param mode - 导入映射模式
635
- * - 'inline': 内联模式,返回 HTML script 标签
636
- * - 'js': JS 文件模式,返回带有文件路径的信息
637
- * @returns 返回导入映射的相关信息
638
- * - src: JS 文件的 URL(仅在 js 模式下)
639
- * - filepath: JS 文件的本地路径(仅在 js 模式下)
640
- * - code: HTML script 标签内容
641
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
619
+ * This method is used to generate import map code for client environment, supporting two modes:
620
+ * 1. **Inline Mode (inline)**
621
+ * - Inline import map directly into HTML
622
+ * - Reduce additional network requests
623
+ * - Suitable for scenarios with smaller import maps
624
+ *
625
+ * 2. **JS File Mode (js)**
626
+ * - Generate standalone JS file
627
+ * - Support browser caching
628
+ * - Suitable for scenarios with larger import maps
629
+ *
630
+ * Core Features:
631
+ * - Automatically handle dynamic base paths
632
+ * - Support module path runtime replacement
633
+ * - Optimize caching strategy
634
+ * - Ensure module loading order
635
+ *
636
+ * @param mode - Import map mode
637
+ * - 'inline': Inline mode, returns HTML script tag
638
+ * - 'js': JS file mode, returns information with file path
639
+ * @returns Returns import map related information
640
+ * - src: URL of the JS file (only in js mode)
641
+ * - filepath: Local path of the JS file (only in js mode)
642
+ * - code: HTML script tag content
643
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
642
644
  *
643
645
  * @example
644
646
  * ```ts
645
- * // entry.node.ts 中使用
647
+ * // Used in entry.node.ts
646
648
  * async server(esmx) {
647
649
  * const server = express();
648
650
  * server.use(esmx.middleware);
649
651
  *
650
652
  * server.get('*', async (req, res) => {
651
- * // 使用 JS 文件模式
653
+ * // Use JS file mode
652
654
  * const result = await esmx.render({
653
655
  * importmapMode: 'js',
654
656
  * params: { url: req.url }
@@ -656,7 +658,7 @@ export declare class Esmx {
656
658
  * res.send(result.html);
657
659
  * });
658
660
  *
659
- * // 或者使用内联模式
661
+ * // Or use inline mode
660
662
  * server.get('/inline', async (req, res) => {
661
663
  * const result = await esmx.render({
662
664
  * importmapMode: 'inline',
@@ -677,16 +679,16 @@ export declare class Esmx {
677
679
  code: string;
678
680
  }>;
679
681
  /**
680
- * 获取模块的静态导入路径列表。
682
+ * Get the list of static import paths for a module.
681
683
  *
682
- * @param env - 构建目标('client' | 'server'
683
- * @param specifier - 模块标识符
684
- * @returns 返回静态导入路径列表,如果未找到则返回 null
685
- * @throws {NotReadyError} 在框架实例未初始化时调用此方法会抛出错误
684
+ * @param env - Build target ('client' | 'server')
685
+ * @param specifier - Module specifier
686
+ * @returns Returns the list of static import paths, returns null if not found
687
+ * @throws {NotReadyError} Throws error when calling this method if the framework instance is not initialized
686
688
  *
687
689
  * @example
688
690
  * ```ts
689
- * // 获取客户端入口模块的静态导入路径
691
+ * // Get static import paths for client entry module
690
692
  * const paths = await esmx.getStaticImportPaths(
691
693
  * 'client',
692
694
  * `your-app-name/src/entry.client`