@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.
@@ -2,26 +2,26 @@ import type fs from 'node:fs';
2
2
  import type { ImportMap, SpecifierMap } from '@esmx/import';
3
3
  import type { ParsedModuleConfig } from '../module-config';
4
4
  /**
5
- * JS 代码中获取静态 import 的模块名列表。也许不能并发多个调用,没实验过。
6
- * @param code js 代码
7
- * @returns `Promise<string[]>` 静态 import 的模块名列表
5
+ * Get the list of statically imported module names from JS code. Maybe cannot handle multiple concurrent calls, not tested.
6
+ * @param code JS code
7
+ * @returns `Promise<string[]>` List of statically imported module names
8
8
  */
9
9
  export declare function getImportsFromJsCode(code: string): Promise<string[]>;
10
10
  /**
11
- * JS 文件中获取静态 import 的模块名列表。
12
- * @param filepath js 文件路径
13
- * @returns `Promise<string[]>` 静态 import 的模块名列表
11
+ * Get the list of statically imported module names from a JS file.
12
+ * @param filepath JS file path
13
+ * @returns `Promise<string[]>` List of statically imported module names
14
14
  */
15
15
  export declare function getImportsFromJsFile(filepath: fs.PathLike | fs.promises.FileHandle): Promise<string[]>;
16
16
  export type ImportPreloadInfo = SpecifierMap;
17
17
  /**
18
- * 获取导入的预加载信息。
19
- * @param specifier 模块名
20
- * @param importMap 导入映射对象
21
- * @param moduleConfig 模块配置
18
+ * Get import preload information.
19
+ * @param specifier Module name
20
+ * @param importMap Import map object
21
+ * @param moduleConfig Module configuration
22
22
  * @returns
23
- * - `Promise<{ [specifier: string]: ImportPreloadPathString }>` 模块名和文件路径的映射对象
24
- * - `null` specifier 不存在
23
+ * - `Promise<{ [specifier: string]: ImportPreloadPathString }>` Mapping object of module names to file paths
24
+ * - `null` specifier does not exist
25
25
  */
26
26
  export declare function getImportPreloadInfo(specifier: string, importMap: ImportMap, moduleConfig: ParsedModuleConfig): Promise<{
27
27
  [k: string]: string;
@@ -16,7 +16,7 @@ export async function getImportPreloadInfo(specifier, importMap, moduleConfig) {
16
16
  return null;
17
17
  }
18
18
  const ans = {
19
- // 入口文件也放入预加载列表
19
+ // Entry file is also added to the preload list
20
20
  [specifier]: importInfo[specifier]
21
21
  };
22
22
  const needHandles = [specifier];
package/package.json CHANGED
@@ -59,7 +59,7 @@
59
59
  "build": "unbuild"
60
60
  },
61
61
  "dependencies": {
62
- "@esmx/import": "3.0.0-rc.60",
62
+ "@esmx/import": "3.0.0-rc.63",
63
63
  "@types/serialize-javascript": "^5.0.4",
64
64
  "es-module-lexer": "^1.7.0",
65
65
  "find": "^0.3.0",
@@ -77,7 +77,7 @@
77
77
  "unbuild": "3.6.0",
78
78
  "vitest": "3.2.4"
79
79
  },
80
- "version": "3.0.0-rc.60",
80
+ "version": "3.0.0-rc.63",
81
81
  "type": "module",
82
82
  "private": false,
83
83
  "exports": {
@@ -100,5 +100,5 @@
100
100
  "template",
101
101
  "public"
102
102
  ],
103
- "gitHead": "615e91c617e0a58796c591643c6a2e1d2a1f0a76"
103
+ "gitHead": "18a524ff1b7f9c6ea60d8bb57ad314329febc58c"
104
104
  }
package/src/app.ts CHANGED
@@ -9,21 +9,21 @@ import {
9
9
  import { type Middleware, createMiddleware } from './utils/middleware';
10
10
 
11
11
  /**
12
- * 应用程序实例接口。
12
+ * Application instance interface.
13
13
  *
14
- * App Esmx 框架的应用抽象,提供了统一的接口来管理应用的生命周期、
15
- * 静态资源和服务端渲染。
14
+ * App is the application abstraction of the Esmx framework, providing a unified interface
15
+ * to manage application lifecycle, static assets, and server-side rendering.
16
16
  *
17
17
  * @example
18
18
  * ```ts
19
19
  * // entry.node.ts
20
20
  * export default {
21
- * // 开发环境配置
21
+ * // Development environment configuration
22
22
  * async devApp(esmx) {
23
23
  * return import('@esmx/rspack').then((m) =>
24
24
  * m.createRspackHtmlApp(esmx, {
25
25
  * config(rc) {
26
- * // 自定义 Rspack 配置
26
+ * // Custom Rspack configuration
27
27
  * }
28
28
  * })
29
29
  * );
@@ -33,17 +33,17 @@ import { type Middleware, createMiddleware } from './utils/middleware';
33
33
  */
34
34
  export interface App {
35
35
  /**
36
- * 静态资源处理中间件。
36
+ * Static asset processing middleware.
37
37
  *
38
- * 开发环境:
39
- * - 处理源码的静态资源请求
40
- * - 支持实时编译和热更新
41
- * - 使用 no-cache 缓存策略
38
+ * Development environment:
39
+ * - Handles static asset requests from source code
40
+ * - Supports real-time compilation and hot reloading
41
+ * - Uses no-cache strategy
42
42
  *
43
- * 生产环境:
44
- * - 处理构建后的静态资源
45
- * - 支持不可变文件的长期缓存(.final.xxx
46
- * - 优化的资源加载策略
43
+ * Production environment:
44
+ * - Handles built static assets
45
+ * - Supports long-term caching for immutable files (.final.xxx)
46
+ * - Optimized asset loading strategy
47
47
  *
48
48
  * @example
49
49
  * ```ts
@@ -53,14 +53,14 @@ export interface App {
53
53
  middleware: Middleware;
54
54
 
55
55
  /**
56
- * 服务端渲染函数。
56
+ * Server-side rendering function.
57
57
  *
58
- * 根据运行环境提供不同实现:
59
- * - 生产环境(start):加载构建后的服务端入口文件(entry.server)执行渲染
60
- * - 开发环境(dev):加载源码中的服务端入口文件执行渲染
58
+ * Provides different implementations based on the runtime environment:
59
+ * - Production environment (start): Loads the built server entry file (entry.server) to execute rendering
60
+ * - Development environment (dev): Loads the server entry file from source code to execute rendering
61
61
  *
62
- * @param options - 渲染选项
63
- * @returns 返回渲染上下文,包含渲染结果
62
+ * @param options - Rendering options
63
+ * @returns Returns the rendering context containing the rendering result
64
64
  *
65
65
  * @example
66
66
  * ```ts
@@ -73,30 +73,30 @@ export interface App {
73
73
  render: (options?: RenderContextOptions) => Promise<RenderContext>;
74
74
 
75
75
  /**
76
- * 生产环境构建函数。
77
- * 用于资源打包和优化。
76
+ * Production environment build function.
77
+ * Used for asset packaging and optimization.
78
78
  *
79
- * @returns 构建成功返回 true,失败返回 false
79
+ * @returns Returns true for successful build, false for failed build
80
80
  */
81
81
  build?: () => Promise<boolean>;
82
82
 
83
83
  /**
84
- * 资源清理函数。
85
- * 用于关闭服务器、断开连接等。
84
+ * Resource cleanup function.
85
+ * Used for shutting down servers, disconnecting connections, etc.
86
86
  *
87
- * @returns 清理成功返回 true,失败返回 false
87
+ * @returns Returns true for successful cleanup, false for failed cleanup
88
88
  */
89
89
  destroy?: () => Promise<boolean>;
90
90
  }
91
91
 
92
92
  /**
93
- * 创建生产环境的应用程序实例,开发环境不可用。
93
+ * Create an application instance for production environment, not available in development environment.
94
94
  */
95
95
  export async function createApp(esmx: Esmx, command: COMMAND): Promise<App> {
96
96
  const render =
97
97
  command === esmx.COMMAND.start
98
- ? await createStartRender(esmx) // 提供实际的渲染函数
99
- : createErrorRender(esmx); // 提供错误提示渲染函数
98
+ ? await createStartRender(esmx) // Provides actual rendering function
99
+ : createErrorRender(esmx); // Provides error prompt rendering function
100
100
  return {
101
101
  middleware: createMiddleware(esmx),
102
102
  render
@@ -104,16 +104,16 @@ export async function createApp(esmx: Esmx, command: COMMAND): Promise<App> {
104
104
  }
105
105
 
106
106
  /**
107
- * 创建生产环境渲染函数。
108
- * 加载构建后的服务端入口文件(entry.server)执行渲染。
107
+ * Create production environment rendering function.
108
+ * Loads the built server entry file (entry.server) to execute rendering.
109
109
  *
110
- * @param esmx - Esmx 实例
111
- * @returns 返回渲染函数
110
+ * @param esmx - Esmx instance
111
+ * @returns Returns the rendering function
112
112
  * @internal
113
113
  *
114
114
  * @example
115
115
  * ```ts
116
- * // 服务端入口文件 (entry.server)
116
+ * // Server entry file (entry.server)
117
117
  * export default async function render(rc: RenderContext) {
118
118
  * rc.html = '<html>...</html>';
119
119
  * }