@nasti-toolchain/nasti 2.5.0 → 2.5.2

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 (60) hide show
  1. package/README.md +34 -2
  2. package/dist/build-CENae4VM.js +748 -0
  3. package/dist/build-CENae4VM.js.map +1 -0
  4. package/dist/build-vjh6h7PB.cjs +786 -0
  5. package/dist/build-vjh6h7PB.cjs.map +1 -0
  6. package/dist/cli.cjs +166 -7608
  7. package/dist/cli.cjs.map +1 -1
  8. package/dist/cli.d.cts +1 -2
  9. package/dist/cli.d.ts +1 -2
  10. package/dist/cli.js +166 -7606
  11. package/dist/cli.js.map +1 -1
  12. package/dist/client/hmr.cjs +0 -19
  13. package/dist/client/hmr.d.cts +14 -12
  14. package/dist/client/hmr.d.cts.map +1 -0
  15. package/dist/client/hmr.d.ts +14 -12
  16. package/dist/client/hmr.d.ts.map +1 -0
  17. package/dist/client/hmr.js +1 -1
  18. package/dist/dev-engine-DJL9sfv5.cjs +473 -0
  19. package/dist/dev-engine-DJL9sfv5.cjs.map +1 -0
  20. package/dist/dev-engine-DapuTPIz.js +469 -0
  21. package/dist/dev-engine-DapuTPIz.js.map +1 -0
  22. package/dist/electron-Bj8H-BJ6.js +278 -0
  23. package/dist/electron-Bj8H-BJ6.js.map +1 -0
  24. package/dist/electron-D0PSXz-a.cjs +316 -0
  25. package/dist/electron-D0PSXz-a.cjs.map +1 -0
  26. package/dist/electron-dev-BzI2IFnR.cjs +272 -0
  27. package/dist/electron-dev-BzI2IFnR.cjs.map +1 -0
  28. package/dist/electron-dev-CM15gsFp.js +251 -0
  29. package/dist/electron-dev-CM15gsFp.js.map +1 -0
  30. package/dist/env-GY7K1zPK.js +833 -0
  31. package/dist/env-GY7K1zPK.js.map +1 -0
  32. package/dist/env-lOj3yw8v.cjs +924 -0
  33. package/dist/env-lOj3yw8v.cjs.map +1 -0
  34. package/dist/environment-B2jCrhY2.js +1361 -0
  35. package/dist/environment-B2jCrhY2.js.map +1 -0
  36. package/dist/environment-CjmvoHIG.cjs +1443 -0
  37. package/dist/environment-CjmvoHIG.cjs.map +1 -0
  38. package/dist/index.cjs +453 -7976
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +872 -817
  41. package/dist/index.d.cts.map +1 -0
  42. package/dist/index.d.ts +872 -817
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +418 -7939
  45. package/dist/index.js.map +1 -1
  46. package/dist/logger-BVZwdqqT.js +116 -0
  47. package/dist/logger-BVZwdqqT.js.map +1 -0
  48. package/dist/logger-M7AuVVTV.cjs +171 -0
  49. package/dist/logger-M7AuVVTV.cjs.map +1 -0
  50. package/dist/runnable-environment-BjoOvdDa.js +1345 -0
  51. package/dist/runnable-environment-BjoOvdDa.js.map +1 -0
  52. package/dist/runnable-environment-ByA3DHQ6.cjs +1351 -0
  53. package/dist/runnable-environment-ByA3DHQ6.cjs.map +1 -0
  54. package/dist/server-Bqgl25z0.js +1871 -0
  55. package/dist/server-Bqgl25z0.js.map +1 -0
  56. package/dist/server-BynlMdFc.cjs +1895 -0
  57. package/dist/server-BynlMdFc.cjs.map +1 -0
  58. package/package.json +20 -10
  59. package/dist/client/hmr.cjs.map +0 -1
  60. package/dist/client/hmr.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,84 +1,85 @@
1
- import { RenderedChunk, InputOptions, OutputOptions } from 'rolldown';
2
- import { IncomingMessage, ServerResponse } from 'node:http';
3
- import { SFCParseOptions, SFCScriptCompileOptions, SFCTemplateCompileOptions, SFCAsyncStyleCompileOptions } from '@vue/compiler-sfc';
4
-
1
+ import { InputOptions, MinifyOptions, OutputOptions, RenderedChunk } from "rolldown";
2
+ import { IncomingMessage, ServerResponse } from "node:http";
3
+ import { SFCAsyncStyleCompileOptions, SFCParseOptions, SFCScriptCompileOptions, SFCTemplateCompileOptions } from "@vue/compiler-sfc";
4
+ //#region src/core/logger.d.ts
5
5
  type LogType = 'error' | 'warn' | 'info';
6
6
  type LogLevel = LogType | 'silent';
7
7
  interface LogOptions {
8
- /** 是否清屏(仅 allowClearScreen 且 TTY 下生效) */
9
- clear?: boolean;
10
- /** 是否带 HH:mm:ss 时间戳前缀 */
11
- timestamp?: boolean;
12
- /** 关联的 Error(用于 hasErrorLogged 去重) */
13
- error?: Error | null;
8
+ /** 是否清屏(仅 allowClearScreen 且 TTY 下生效) */
9
+ clear?: boolean;
10
+ /** 是否带 HH:mm:ss 时间戳前缀 */
11
+ timestamp?: boolean;
12
+ /** 关联的 Error(用于 hasErrorLogged 去重) */
13
+ error?: Error | null;
14
14
  }
15
15
  interface Logger {
16
- info(msg: string, options?: LogOptions): void;
17
- warn(msg: string, options?: LogOptions): void;
18
- /** 同一条 warn 整个进程只输出一次 */
19
- warnOnce(msg: string, options?: LogOptions): void;
20
- error(msg: string, options?: LogOptions): void;
21
- clearScreen(type: LogType): void;
22
- /** 该 Error 是否已经走 logger.error 输出过(避免 CLI 兜底重复打印) */
23
- hasErrorLogged(error: Error): boolean;
24
- hasWarned: boolean;
16
+ info(msg: string, options?: LogOptions): void;
17
+ warn(msg: string, options?: LogOptions): void;
18
+ /** 同一条 warn 整个进程只输出一次 */
19
+ warnOnce(msg: string, options?: LogOptions): void;
20
+ error(msg: string, options?: LogOptions): void;
21
+ clearScreen(type: LogType): void;
22
+ /** 该 Error 是否已经走 logger.error 输出过(避免 CLI 兜底重复打印) */
23
+ hasErrorLogged(error: Error): boolean;
24
+ hasWarned: boolean;
25
25
  }
26
26
  interface LoggerOptions {
27
- prefix?: string;
28
- allowClearScreen?: boolean;
29
- customLogger?: Logger;
30
- console?: Console;
27
+ prefix?: string;
28
+ allowClearScreen?: boolean;
29
+ customLogger?: Logger;
30
+ console?: Console;
31
31
  }
32
32
  declare const LogLevels: Record<LogLevel, number>;
33
33
  declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
34
34
  interface ServerUrls {
35
- local: string[];
36
- network: string[];
35
+ local: string[];
36
+ network: string[];
37
37
  }
38
38
  /** 打印 dev server 地址:➜ Local / Network,端口加粗 */
39
39
  declare function printServerUrls(urls: ServerUrls, info: Logger['info']): void;
40
-
40
+ //#endregion
41
+ //#region src/types.d.ts
41
42
  interface NastiConfig {
42
- /** 项目根目录 */
43
- root?: string;
44
- /** 公共基础路径 */
45
- base?: string;
46
- /** 运行模式 */
47
- mode?: 'development' | 'production';
48
- /** 打包目标平台:web(默认)或 electron */
49
- target?: 'web' | 'electron';
50
- /** 框架自动检测或手动指定 */
51
- framework?: 'react' | 'vue' | 'auto';
52
- /** React JSX / Fast Refresh / Compiler 管线。仅在 framework 解析为 react 时生效。 */
53
- react?: ReactOptions;
54
- /** 路径解析配置 */
55
- resolve?: ResolveConfig;
56
- /** 插件列表 */
57
- plugins?: NastiPlugin[];
58
- /** 开发服务器配置 */
59
- server?: ServerConfig;
60
- /** 构建配置 */
61
- build?: BuildConfig;
62
- /** Electron 配置(当 target === 'electron' 时生效) */
63
- electron?: ElectronConfig;
64
- /** 环境变量前缀 */
65
- envPrefix?: string | string[];
66
- /** 日志级别 */
67
- logLevel?: 'info' | 'warn' | 'error' | 'silent';
68
- /** 启动/重启时是否允许清屏(CI/非 TTY 下自动禁用),默认 true */
69
- clearScreen?: boolean;
70
- /** 自定义 Logger(替换内置实现,logLevel 等选项由自定义实现自行处理) */
71
- customLogger?: Logger;
72
- /**
73
- * 环境配置 map(Environment API,2.0)。默认注入 `{ client, ssr }`。
74
- *
75
- * `client` 环境与 top-level `resolve`/`build` **精确镜像**:对
76
- * `environments.client` 的覆盖会写回 top-level(反之亦然),保证读 flat
77
- * config 的既有插件与新 API 看到同一份配置。
78
- */
79
- environments?: Record<string, EnvironmentOptions>;
80
- /** 实验特性(无稳定性保证,随时可能变更/移除) */
81
- experimental?: ExperimentalOptions;
43
+ /** 项目根目录 */
44
+ root?: string;
45
+ /** 公共基础路径 */
46
+ base?: string;
47
+ /** 运行模式 */
48
+ mode?: 'development' | 'production';
49
+ /** 打包目标平台:web(默认)或 electron */
50
+ target?: 'web' | 'electron';
51
+ /** 框架自动检测或手动指定 */
52
+ framework?: 'react' | 'vue' | 'auto';
53
+ /** React JSX / Fast Refresh / Compiler 管线。仅在 framework 解析为 react 时生效。 */
54
+ react?: ReactOptions;
55
+ /** 路径解析配置 */
56
+ resolve?: ResolveConfig;
57
+ /** 插件列表 */
58
+ plugins?: NastiPlugin[];
59
+ /** 开发服务器配置 */
60
+ server?: ServerConfig;
61
+ /** 构建配置 */
62
+ build?: BuildConfig;
63
+ /** Electron 配置(当 target === 'electron' 时生效) */
64
+ electron?: ElectronConfig;
65
+ /** 环境变量前缀 */
66
+ envPrefix?: string | string[];
67
+ /** 日志级别 */
68
+ logLevel?: 'info' | 'warn' | 'error' | 'silent';
69
+ /** 启动/重启时是否允许清屏(CI/非 TTY 下自动禁用),默认 true */
70
+ clearScreen?: boolean;
71
+ /** 自定义 Logger(替换内置实现,logLevel 等选项由自定义实现自行处理) */
72
+ customLogger?: Logger;
73
+ /**
74
+ * 环境配置 map(Environment API,2.0)。默认注入 `{ client, ssr }`。
75
+ *
76
+ * `client` 环境与 top-level `resolve`/`build` **精确镜像**:对
77
+ * `environments.client` 的覆盖会写回 top-level(反之亦然),保证读 flat
78
+ * config 的既有插件与新 API 看到同一份配置。
79
+ */
80
+ environments?: Record<string, EnvironmentOptions>;
81
+ /** 实验特性(无稳定性保证,随时可能变更/移除) */
82
+ experimental?: ExperimentalOptions;
82
83
  }
83
84
  type ReactFileFilter = string | RegExp | Array<string | RegExp>;
84
85
  /**
@@ -86,502 +87,541 @@ type ReactFileFilter = string | RegExp | Array<string | RegExp>;
86
87
  * `oxc-transform-react`,无需让 Nasti 与编译器的快速迭代强耦合。
87
88
  */
88
89
  interface ReactCompilerOptions {
89
- compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all';
90
- panicThreshold?: 'none' | 'critical_errors' | 'all_errors';
91
- target?: '17' | '18' | '19' | {
92
- kind: 'donotuse_meta_internal';
93
- runtimeModule?: string;
94
- };
95
- gating?: {
96
- source: string;
97
- importSpecifierName: string;
98
- };
99
- dynamicGating?: {
100
- source: string;
101
- };
102
- noEmit?: boolean;
103
- outputMode?: 'client' | 'ssr' | 'lint';
104
- sources?: string[];
105
- [option: string]: unknown;
90
+ compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all';
91
+ panicThreshold?: 'none' | 'critical_errors' | 'all_errors';
92
+ target?: '17' | '18' | '19' | {
93
+ kind: 'donotuse_meta_internal';
94
+ runtimeModule?: string;
95
+ };
96
+ gating?: {
97
+ source: string;
98
+ importSpecifierName: string;
99
+ };
100
+ dynamicGating?: {
101
+ source: string;
102
+ };
103
+ noEmit?: boolean;
104
+ outputMode?: 'client' | 'ssr' | 'lint';
105
+ sources?: string[];
106
+ [option: string]: unknown;
106
107
  }
107
108
  /** React 管线选项;命名与 @vitejs/plugin-react 保持一致。 */
108
109
  interface ReactOptions {
109
- /** @default /\.[tj]sx?$/ */
110
- include?: ReactFileFilter;
111
- /** @default /node_modules/ */
112
- exclude?: ReactFileFilter;
113
- /** @default 'react' */
114
- jsxImportSource?: string;
115
- /** @default 'automatic' */
116
- jsxRuntime?: 'automatic' | 'classic';
117
- /** 可选的原生 React Compiler;只编译 client consumer。 */
118
- compiler?: boolean | ReactCompilerOptions;
110
+ /** @default /\.[tj]sx?$/ */
111
+ include?: ReactFileFilter;
112
+ /** @default /node_modules/ */
113
+ exclude?: ReactFileFilter;
114
+ /** @default 'react' */
115
+ jsxImportSource?: string;
116
+ /** @default 'automatic' */
117
+ jsxRuntime?: 'automatic' | 'classic';
118
+ /** 可选的原生 React Compiler;只编译 client consumer。 */
119
+ compiler?: boolean | ReactCompilerOptions;
119
120
  }
120
121
  interface ResolvedReactOptions {
121
- include: ReactFileFilter;
122
- exclude: ReactFileFilter;
123
- jsxImportSource: string;
124
- jsxRuntime: 'automatic' | 'classic';
125
- compiler: false | ReactCompilerOptions;
122
+ include: ReactFileFilter;
123
+ exclude: ReactFileFilter;
124
+ jsxImportSource: string;
125
+ jsxRuntime: 'automatic' | 'classic';
126
+ compiler: false | ReactCompilerOptions;
126
127
  }
127
128
  interface ExperimentalOptions {
128
- /**
129
- * dev 用 Rolldown `dev()` 引擎整体打包 client 环境后从内存服务
130
- * (完整打包模式 / Full Bundle Mode)。HMR 由引擎的 patch 机制驱动,
131
- * 动态 import 走懒编译端点。依赖 rolldown 实验 API(无 semver 保护,
132
- * Nasti 会精确锁定经过验证的 Rolldown 版本)。unbundled 管线保持默认。
133
- * @experimental
134
- * @default false
135
- */
136
- bundledDev?: boolean;
129
+ /**
130
+ * dev 用 Rolldown `dev()` 引擎整体打包 client 环境后从内存服务
131
+ * (完整打包模式 / Full Bundle Mode)。HMR 由引擎的 patch 机制驱动,
132
+ * 动态 import 走懒编译端点。依赖 rolldown 实验 API(无 semver 保护,
133
+ * Nasti 会精确锁定经过验证的 Rolldown 版本)。unbundled 管线保持默认。
134
+ * @experimental
135
+ * @default false
136
+ */
137
+ bundledDev?: boolean;
137
138
  }
138
139
  /** 单个环境的可配置面(Environment API) */
139
140
  interface EnvironmentOptions {
140
- /**
141
- * 产物消费者:决定 per-env 的 resolve 行为与 `import.meta.env.SSR` 取值。
142
- * 默认:环境名为 'client' → 'client',其余 → 'server'。
143
- */
144
- consumer?: 'client' | 'server';
145
- /**
146
- * 该环境的构建入口(相对 root)。client 默认从 HTML 提取;显式配置后可覆盖。
147
- * 非 client 环境只有声明 entry 或 driver 才会被 `nasti build` 构建。
148
- */
149
- entry?: string | string[];
150
- /**
151
- * HTML 入口(相对 root),仅 client consumer 使用。默认 `index.html`。
152
- * Electron renderer 会把 `electron.renderer` 映射到这里。
153
- */
154
- html?: string;
155
- /**
156
- * 是否参与生产构建。默认 true;设为 false 可跳过默认 client,构建纯多环境应用。
157
- * 仅影响 `nasti build`,不影响 dev server 中环境实例的可见性。
158
- */
159
- buildEnabled?: boolean;
160
- /**
161
- * 外部环境编译驱动标识。声明后由插件的 `createEnvironmentDriver` 提供实际实现,
162
- * 可用于接入 Rspeedy 等不基于 Rolldown 的构建系统。
163
- */
164
- driver?: string;
165
- /** per-env 路径解析(client 默认含 'browser' condition;server 走 node conditions) */
166
- resolve?: ResolveConfig;
167
- /** per-env 构建覆盖(未设置的字段回退 top-level build) */
168
- build?: BuildConfig;
169
- /**
170
- * Vue SFC 编译扩展点。每个环境可独立设置 compiler-sfc 选项与源码变换,
171
- * 同一个 SFC 的虚拟模块 id / scope id 不包含环境名,因而在多图之间保持稳定。
172
- */
173
- vue?: VueEnvironmentOptions;
141
+ /**
142
+ * 产物消费者:决定 per-env 的 resolve 行为与 `import.meta.env.SSR` 取值。
143
+ * 默认:环境名为 'client' → 'client',其余 → 'server'。
144
+ */
145
+ consumer?: 'client' | 'server';
146
+ /**
147
+ * 该环境的构建入口(相对 root)。client 默认从 HTML 提取;显式配置后可覆盖。
148
+ * 非 client 环境只有声明 entry 或 driver 才会被 `nasti build` 构建。
149
+ */
150
+ entry?: string | string[];
151
+ /**
152
+ * HTML 入口(相对 root),仅 client consumer 使用。默认 `index.html`。
153
+ * Electron renderer 会把 `electron.renderer` 映射到这里。
154
+ */
155
+ html?: string;
156
+ /**
157
+ * 是否参与生产构建。默认 true;设为 false 可跳过默认 client,构建纯多环境应用。
158
+ * 仅影响 `nasti build`,不影响 dev server 中环境实例的可见性。
159
+ */
160
+ buildEnabled?: boolean;
161
+ /**
162
+ * 外部环境编译驱动标识。声明后由插件的 `createEnvironmentDriver` 提供实际实现,
163
+ * 可用于接入 Rspeedy 等不基于 Rolldown 的构建系统。
164
+ */
165
+ driver?: string;
166
+ /** per-env 路径解析(client 默认含 'browser' condition;server 走 node conditions) */
167
+ resolve?: ResolveConfig;
168
+ /** per-env 构建覆盖(未设置的字段回退 top-level build) */
169
+ build?: BuildConfig;
170
+ /**
171
+ * Vue SFC 编译扩展点。每个环境可独立设置 compiler-sfc 选项与源码变换,
172
+ * 同一个 SFC 的虚拟模块 id / scope id 不包含环境名,因而在多图之间保持稳定。
173
+ */
174
+ vue?: VueEnvironmentOptions;
174
175
  }
175
176
  interface VueSfcTransformContext {
176
- filename: string;
177
- environmentName: string;
178
- type: 'sfc' | 'template' | 'style';
179
- index?: number;
177
+ filename: string;
178
+ environmentName: string;
179
+ type: 'sfc' | 'template' | 'style';
180
+ index?: number;
180
181
  }
181
- type VueSfcSourceTransform = (source: string, context: VueSfcTransformContext) => string
182
+ type VueSfcSourceTransform = (source: string, context: VueSfcTransformContext) => string |
182
183
  /**
183
184
  * Object results may provide a source map from `code` back to `source`.
184
185
  * Nasti composes it with compiler-sfc maps where that stage supports chaining.
185
186
  */
186
- | {
187
- code: string;
188
- map?: unknown;
187
+ {
188
+ code: string;
189
+ map?: unknown;
189
190
  } | Promise<string | {
190
- code: string;
191
- map?: unknown;
191
+ code: string;
192
+ map?: unknown;
192
193
  }>;
193
194
  /** 直接透传给 `@vue/compiler-sfc` 对应阶段的 per-environment 选项。 */
194
195
  interface VueEnvironmentOptions {
195
- parse?: SFCParseOptions;
196
- script?: Partial<SFCScriptCompileOptions>;
197
- template?: Partial<SFCTemplateCompileOptions>;
198
- style?: Partial<SFCAsyncStyleCompileOptions>;
199
- /**
200
- * Vue 编译特性开关。
201
- *
202
- * `vapor`:将可强制进入 Vapor Mode 的 SFC(`<script setup>` / 纯 template)
203
- * 统一按 Vapor 编译。单文件仍可通过 `<script setup vapor>` / `<template vapor>`
204
- * 按需 opt-in。需要 `@vue/compiler-sfc` ≥ 3.6。
205
- * @experimental
206
- */
207
- features?: {
208
- vapor?: boolean;
209
- };
210
- transformSfc?: VueSfcSourceTransform;
211
- transformTemplate?: VueSfcSourceTransform;
212
- transformStyle?: VueSfcSourceTransform;
196
+ parse?: SFCParseOptions;
197
+ script?: Partial<SFCScriptCompileOptions>;
198
+ template?: Partial<SFCTemplateCompileOptions>;
199
+ style?: Partial<SFCAsyncStyleCompileOptions>;
200
+ /**
201
+ * Vue 编译特性开关。
202
+ *
203
+ * `vapor`:将可强制进入 Vapor Mode 的 SFC(`<script setup>` / 纯 template)
204
+ * 统一按 Vapor 编译。单文件仍可通过 `<script setup vapor>` / `<template vapor>`
205
+ * 按需 opt-in。需要 `@vue/compiler-sfc` ≥ 3.6。
206
+ * @experimental
207
+ */
208
+ features?: {
209
+ vapor?: boolean;
210
+ };
211
+ transformSfc?: VueSfcSourceTransform;
212
+ transformTemplate?: VueSfcSourceTransform;
213
+ transformStyle?: VueSfcSourceTransform;
213
214
  }
214
215
  /** 解析后的环境配置 */
215
216
  interface ResolvedEnvironmentOptions {
216
- consumer: 'client' | 'server';
217
- /** 是否参与生产构建 */
218
- buildEnabled: boolean;
219
- /** 环境构建入口(绝对路径);client 未显式配置时为空并从 HTML 提取 */
220
- entry: string[];
221
- /** HTML 入口绝对路径(仅 client consumer 有值) */
222
- html?: string;
223
- /** 外部环境编译驱动标识 */
224
- driver?: string;
225
- resolve: Required<ResolveConfig>;
226
- build: Required<BuildConfig>;
227
- vue: VueEnvironmentOptions;
217
+ consumer: 'client' | 'server';
218
+ /** 是否参与生产构建 */
219
+ buildEnabled: boolean;
220
+ /** 环境构建入口(绝对路径);client 未显式配置时为空并从 HTML 提取 */
221
+ entry: string[];
222
+ /** HTML 入口绝对路径(仅 client consumer 有值) */
223
+ html?: string;
224
+ /** 外部环境编译驱动标识 */
225
+ driver?: string;
226
+ resolve: Required<ResolveConfig>;
227
+ build: Required<BuildConfig>;
228
+ vue: VueEnvironmentOptions;
228
229
  }
229
230
  /** Electron 目标专用配置,支持 Electron 41+ */
230
231
  interface ElectronConfig {
231
- /** 主进程入口文件,相对项目根目录 */
232
- main?: string;
233
- /** Preload 脚本入口,相对项目根目录。可传入多个 */
234
- preload?: string | string[];
235
- /** 渲染进程(Web)入口 HTML,默认沿用根目录 index.html */
236
- renderer?: string;
237
- /**
238
- * 主进程与 preload 打包目标 Node 版本。
239
- * Electron 41 捆绑 Node 22.x,默认为 'node22'
240
- */
241
- nodeTarget?: string;
242
- /**
243
- * 主进程输出格式:cjs(默认,兼容 Electron 加载器)或 esm
244
- * (Electron 41+ 完整支持 ESM 主进程)
245
- */
246
- mainFormat?: 'cjs' | 'esm';
247
- /** Preload 输出格式,默认 cjs(Electron contextIsolation 推荐) */
248
- preloadFormat?: 'cjs' | 'esm';
249
- /** Electron 可执行文件路径,默认从 node_modules/electron 查找 */
250
- electronPath?: string;
251
- /** 传递给 Electron 的命令行参数(dev 模式) */
252
- electronArgs?: string[];
253
- /** 开发时主/preload 文件变化后自动重启 Electron,默认 true */
254
- autoRestart?: boolean;
255
- /** 声明最低 Electron 版本,默认 41(低于此版本将警告) */
256
- minVersion?: number;
257
- /** 主进程/preload 的外部依赖(不参与打包,运行时 require) */
258
- external?: string[];
232
+ /** 主进程入口文件,相对项目根目录 */
233
+ main?: string;
234
+ /** Preload 脚本入口,相对项目根目录。可传入多个 */
235
+ preload?: string | string[];
236
+ /** 渲染进程(Web)入口 HTML,默认沿用根目录 index.html */
237
+ renderer?: string;
238
+ /**
239
+ * 主进程与 preload 打包目标 Node 版本。
240
+ * Electron 41 捆绑 Node 22.x,默认为 'node22'
241
+ */
242
+ nodeTarget?: string;
243
+ /**
244
+ * 主进程输出格式:cjs(默认,兼容 Electron 加载器)或 esm
245
+ * (Electron 41+ 完整支持 ESM 主进程)
246
+ */
247
+ mainFormat?: 'cjs' | 'esm';
248
+ /** Preload 输出格式,默认 cjs(Electron contextIsolation 推荐) */
249
+ preloadFormat?: 'cjs' | 'esm';
250
+ /** Electron 可执行文件路径,默认从 node_modules/electron 查找 */
251
+ electronPath?: string;
252
+ /** 传递给 Electron 的命令行参数(dev 模式) */
253
+ electronArgs?: string[];
254
+ /** 开发时主/preload 文件变化后自动重启 Electron,默认 true */
255
+ autoRestart?: boolean;
256
+ /** 声明最低 Electron 版本,默认 41(低于此版本将警告) */
257
+ minVersion?: number;
258
+ /** 主进程/preload 的外部依赖(不参与打包,运行时 require) */
259
+ external?: string[];
259
260
  }
260
261
  interface ResolveConfig {
261
- alias?: Record<string, string>;
262
- extensions?: string[];
263
- conditions?: string[];
264
- mainFields?: string[];
262
+ alias?: Record<string, string>;
263
+ extensions?: string[];
264
+ conditions?: string[];
265
+ mainFields?: string[];
265
266
  }
266
267
  interface ServerConfig {
267
- port?: number;
268
- host?: string | boolean;
269
- https?: boolean;
270
- open?: boolean | string;
271
- proxy?: Record<string, string | ProxyConfig>;
272
- cors?: boolean;
273
- hmr?: boolean | HmrConfig;
268
+ port?: number;
269
+ host?: string | boolean;
270
+ https?: boolean;
271
+ open?: boolean | string;
272
+ proxy?: Record<string, string | ProxyConfig>;
273
+ cors?: boolean;
274
+ hmr?: boolean | HmrConfig;
274
275
  }
275
276
  interface HmrConfig {
276
- port?: number;
277
- host?: string;
278
- protocol?: 'ws' | 'wss';
279
- overlay?: boolean;
277
+ port?: number;
278
+ host?: string;
279
+ protocol?: 'ws' | 'wss';
280
+ overlay?: boolean;
280
281
  }
281
282
  interface ProxyConfig {
282
- target: string;
283
- changeOrigin?: boolean;
284
- rewrite?: (path: string) => string;
283
+ target: string;
284
+ changeOrigin?: boolean;
285
+ rewrite?: (path: string) => string;
285
286
  }
286
287
  interface BuildConfig {
287
- outDir?: string;
288
- assetsDir?: string;
289
- minify?: boolean | 'oxc';
290
- sourcemap?: boolean | 'inline' | 'hidden';
291
- target?: string | string[];
292
- /**
293
- * 透传给 Rolldown 的底层选项,供生产应用手动控制代码拆分与 Tree-shaking。
294
- *
295
- * - input 侧(`treeshake`、`resolve`、`external`、`platform` 等)会合并进 `rolldown()`;
296
- * - `output` 会合并进 `bundle.write()`,用于控制代码拆分
297
- * (`output.advancedChunks` / `output.codeSplitting`)、chunk 命名等。
298
- *
299
- * 注:`input` `plugins` Nasti 管理,故不在此暴露;`output.dir` 始终由
300
- * `build.outDir` 决定(HTML 改写依赖产物路径),传入会被忽略。
301
- */
302
- rolldownOptions?: NastiRolldownOptions;
303
- emptyOutDir?: boolean;
304
- css?: CssConfig;
305
- /** 体积表是否计算 gzip 压缩后大小(大产物可关闭以加速构建),默认 true */
306
- reportCompressedSize?: boolean;
307
- /** 触发大 chunk 警告的体积阈值(单位 kB,按压缩前 chunk 体积),默认 500 */
308
- chunkSizeWarningLimit?: number;
309
- /** 按 chunk 抽取 CSS 为独立 .css 文件(关闭则全部合并为单个 CSS 文件),默认 true */
310
- cssCodeSplit?: boolean;
311
- /** 是否压缩抽取出的 CSS(Lightning CSS,不可用时回退正则压缩),默认同 minify */
312
- cssMinify?: boolean;
288
+ outDir?: string;
289
+ assetsDir?: string;
290
+ /**
291
+ * 产物压缩(Rolldown 内置 OXC Minifier)。
292
+ *
293
+ * - `true` / `false`:整体开关,默认 `true`;
294
+ * - `'oxc'`:历史写法,等同 `true`(Rolldown 只有 OXC 一个 minifier);
295
+ * - `'dce-only'`:只做死代码消除,不重命名、不压缩语法;
296
+ * - {@link NastiMinifyOptions}:细粒度控制 `compress` / `mangle` / `codegen`。
297
+ *
298
+ * @example 保留类名(依赖 `Class.prototype.name` 做注册/绑定的框架需要)
299
+ * ```ts
300
+ * build: { minify: { mangle: { keepNames: { class: true, function: false } } } }
301
+ * ```
302
+ *
303
+ * @example 最小化类成员 / 属性名(Rolldown 1.2.6 · OXC 0.147 新增)
304
+ * ```ts
305
+ * build: { minify: { mangleProps: { include: /^_/ } } }
306
+ * ```
307
+ * `mangleProps` 与 `mangle` 平级,独立于标识符重命名之外单独处理属性名。
308
+ * 仅支持最终生成一个 JavaScript chunk;分包产生多个 JS chunk Rolldown 会报错。
309
+ * 单入口可设置 `rolldownOptions.output.codeSplitting: false` 内联动态导入。
310
+ * 它只按名字匹配、不做类型分析,因此必须排除掉由未压缩代码、模块命名空间、
311
+ * 全局对象或宿主 API 持有的属性,否则会改坏访问路径。
312
+ */
313
+ minify?: MinifyOption;
314
+ sourcemap?: boolean | 'inline' | 'hidden';
315
+ target?: string | string[];
316
+ /**
317
+ * 透传给 Rolldown 的底层选项,供生产应用手动控制代码拆分与 Tree-shaking。
318
+ *
319
+ * - input 侧(`treeshake`、`resolve`、`external`、`platform` 等)会合并进 `rolldown()`;
320
+ * - `output` 会合并进 `bundle.write()`,用于控制代码拆分
321
+ * (`output.advancedChunks` / `output.codeSplitting`)、chunk 命名等。
322
+ *
323
+ * 注:`input` 与 `plugins` 由 Nasti 管理,故不在此暴露;`output.dir` 始终由
324
+ * `build.outDir` 决定(HTML 改写依赖产物路径),传入会被忽略。
325
+ */
326
+ rolldownOptions?: NastiRolldownOptions;
327
+ emptyOutDir?: boolean;
328
+ css?: CssConfig;
329
+ /** 体积表是否计算 gzip 压缩后大小(大产物可关闭以加速构建),默认 true */
330
+ reportCompressedSize?: boolean;
331
+ /** 触发大 chunk 警告的体积阈值(单位 kB,按压缩前 chunk 体积),默认 500 */
332
+ chunkSizeWarningLimit?: number;
333
+ /** 按 chunk 抽取 CSS 为独立 .css 文件(关闭则全部合并为单个 CSS 文件),默认 true */
334
+ cssCodeSplit?: boolean;
335
+ /** 是否压缩抽取出的 CSS(Lightning CSS,不可用时回退正则压缩),默认同 minify */
336
+ cssMinify?: boolean;
313
337
  }
338
+ /**
339
+ * Nasti 暴露的 OXC Minifier 选项,直接复用 Rolldown 的 `MinifyOptions`
340
+ * (`compress` / `mangle` / `codegen`)。
341
+ *
342
+ * 与类名最小化直接相关的两项:
343
+ * - `mangle.keepNames.class` / `.function` —— 是否保留类 / 函数的标识符名。
344
+ * 默认 `false`,即类名参与最小化;置 `true` 可让 `Class.prototype.name`
345
+ * 在压缩后仍然可用。
346
+ * - `mangleProps` —— 按 `include` / `exclude` 正则最小化属性名(含类成员),
347
+ * 与 `mangle` 平级,Rolldown 1.2.6 · OXC 0.147 起可用。
348
+ */
349
+ type NastiMinifyOptions = MinifyOptions;
350
+ /** {@link BuildConfig.minify} 的取值域。 */
351
+ type MinifyOption = boolean | 'oxc' | 'dce-only' | NastiMinifyOptions;
352
+ /** 归一化后交给 Rolldown `OutputOptions.minify` 的取值域(不含 `'oxc'` 别名)。 */
353
+ type ResolvedMinifyOption = boolean | 'dce-only' | NastiMinifyOptions;
314
354
  /**
315
355
  * Nasti 暴露的 Rolldown 选项:在 Rolldown {@link InputOptions} 基础上去掉由 Nasti
316
356
  * 接管的 `input` / `plugins`,并补充一个 `output` 出口用于 `bundle.write()`。
317
357
  */
318
358
  type NastiRolldownOptions = Omit<InputOptions, 'input' | 'plugins'> & {
319
- /** 传给 `bundle.write()` 的输出选项:代码拆分(`advancedChunks` / `codeSplitting`)、chunk 命名等 */
320
- output?: OutputOptions;
359
+ /** 传给 `bundle.write()` 的输出选项:代码拆分(`advancedChunks` / `codeSplitting`)、chunk 命名等 */
360
+ output?: OutputOptions;
321
361
  };
322
362
  interface CssConfig {
323
- /** CSP nonce to add to inline <style> tags (dev only since 2.0 — build emits real .css files) */
324
- nonce?: string;
325
- /**
326
- * @deprecated 请改用 `css.emit` 控制是否写出 CSS 文件。控制拆分用
327
- * `build.cssCodeSplit`,控制压缩用 `build.cssMinify`。
328
- */
329
- emitCssFile?: boolean;
330
- /**
331
- * 是否在浏览器运行时 / HTML 中注入 CSS。原生 client 环境可关闭注入,
332
- * 同时继续保留 CSS 模块图与结构化元数据。
333
- * @default true
334
- */
335
- inject?: boolean;
336
- /**
337
- * 是否写出 `.css` 文件。关闭后仍收集每个 chunk 的 CSS 所有权。
338
- * @default true
339
- */
340
- emit?: boolean;
363
+ /** CSP nonce to add to inline <style> tags (dev only since 2.0 — build emits real .css files) */
364
+ nonce?: string;
365
+ /**
366
+ * @deprecated 请改用 `css.emit` 控制是否写出 CSS 文件。控制拆分用
367
+ * `build.cssCodeSplit`,控制压缩用 `build.cssMinify`。
368
+ */
369
+ emitCssFile?: boolean;
370
+ /**
371
+ * 是否在浏览器运行时 / HTML 中注入 CSS。原生 client 环境可关闭注入,
372
+ * 同时继续保留 CSS 模块图与结构化元数据。
373
+ * @default true
374
+ */
375
+ inject?: boolean;
376
+ /**
377
+ * 是否写出 `.css` 文件。关闭后仍收集每个 chunk 的 CSS 所有权。
378
+ * @default true
379
+ */
380
+ emit?: boolean;
341
381
  }
342
382
  interface NastiPlugin {
343
- name: string;
344
- enforce?: 'pre' | 'post';
345
- /** 必须在当前插件 setup 前完成 setup 的插件名 */
346
- pre?: string[];
347
- /** 必须在当前插件 setup 后完成 setup 的插件名 */
348
- post?: string[];
349
- apply?: 'build' | 'serve' | ((config: ResolvedConfig, env: {
350
- mode: string;
351
- command: string;
352
- }) => boolean);
353
- /** 插件初始化与跨插件 API 注册;每次 resolveConfig 只执行一次 */
354
- setup?: (api: PluginApi) => void | Promise<void>;
355
- buildStart?: (this: PluginContext) => void | Promise<void>;
356
- buildEnd?: (this: PluginContext, error?: Error) => void | Promise<void>;
357
- /**
358
- * Called once after `bundle.close()` in production builds, mirroring Rollup/Vite semantics.
359
- * Plugins use this to emit final-stage artifacts that depend on the bundle being fully written
360
- * (PWA manifests, service workers, sitemaps, etc.). Not invoked in dev.
361
- */
362
- closeBundle?: (this: PluginContext, error?: Error) => void | Promise<void>;
363
- resolveId?: (this: PluginContext, source: string, importer: string | undefined, options: ResolveIdOptions) => ResolveIdResult | Promise<ResolveIdResult>;
364
- load?: (this: PluginContext, id: string) => LoadResult | Promise<LoadResult>;
365
- transform?: (this: PluginContext, code: string, id: string) => TransformResult | Promise<TransformResult>;
366
- /**
367
- * Rolldown output 阶段钩子:对每个 chunk 的最终代码做变换或按 chunk 收集产物。
368
- * 仅在生产构建生效(dev unbundled 管线没有 chunk 概念)。
369
- *
370
- * `this` 是 Rolldown 真实的(Rollup 兼容)插件上下文,不是 PluginContext stub:
371
- * `this.emitFile({type:'asset'})` 经 `output.assetFileNames` 产出带 hash 的文件,
372
- * `this.getFileName(ref)` 可立即解析最终文件名。CSS per-chunk 抽取依赖这两点。
373
- */
374
- renderChunk?: (this: RenderChunkContext, code: string, chunk: RenderedChunk) => string | {
375
- code: string;
376
- map?: unknown;
377
- } | null | undefined | Promise<string | {
378
- code: string;
379
- map?: unknown;
380
- } | null | undefined>;
381
- /** 向 chunk hash 折叠额外输入(如该 chunk 关联的 CSS 内容),保证缓存正确性 */
382
- augmentChunkHash?: (this: RenderChunkContext, chunk: RenderedChunk) => string | void | Promise<string | void>;
383
- /**
384
- * Rolldown output 收尾钩子(write 前最后时机)。`this` 同 renderChunk,
385
- * 可 emitFile 补充产物(如 cssCodeSplit:false 的合并 CSS、manifest 等)。
386
- */
387
- generateBundle?: (this: RenderChunkContext, options?: unknown, bundle?: Record<string, unknown>) => void | Promise<void>;
388
- config?: (config: NastiConfig, env: {
389
- mode: string;
390
- command: string;
391
- }) => NastiConfig | null | void | Promise<NastiConfig | null | void>;
392
- configResolved?: (config: ResolvedConfig) => void | Promise<void>;
393
- /**
394
- * Environment API:在环境配置最终解析前调整单个环境的选项。
395
- * 对每个环境名调用一次(含默认注入的 client/ssr)。
396
- */
397
- configEnvironment?: (name: string, options: EnvironmentOptions, env: {
398
- mode: string;
399
- command: string;
400
- }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>;
401
- /**
402
- * Environment API:按环境过滤插件。返回 false 则该插件不进入此环境的
403
- * 插件管线。未声明时插件应用于所有环境(与 Vite 默认一致)。
404
- */
405
- applyToEnvironment?: (environment: EnvironmentInstance) => boolean;
406
- /**
407
- * 为声明了 `environment.options.driver` 的环境提供外部编译驱动。
408
- * 一个环境只能被一个插件接管;返回多个驱动会报错。
409
- */
410
- createEnvironmentDriver?: (environment: EnvironmentInstance, api: PluginApi) => EnvironmentDriver | null | undefined | Promise<EnvironmentDriver | null | undefined>;
411
- /**
412
- * 所有环境构建完成后的 app 级收尾钩子,用于跨环境聚合产物。
413
- * Vue Lynx 原生后端可在这里组合 background/main-thread bundle。
414
- */
415
- afterBuildApp?: (results: Record<string, EnvironmentBuildResult>, api: PluginApi, context: BuildAppContext) => void | Promise<void>;
416
- configureServer?: (server: DevServer) => void | (() => void) | Promise<void | (() => void)>;
417
- transformIndexHtml?: (html: string) => string | HtmlTagDescriptor[] | {
418
- html: string;
419
- tags: HtmlTagDescriptor[];
420
- } | Promise<string | HtmlTagDescriptor[] | {
421
- html: string;
422
- tags: HtmlTagDescriptor[];
423
- }>;
424
- handleHotUpdate?: (ctx: HmrContext) => void | ModuleNode[] | Promise<void | ModuleNode[]>;
425
- /**
426
- * 一个文件在所有 dev client 环境完成失效、插件 HMR 钩子与重新转换后调用一次。
427
- * 多运行时工具链可据此只重编码受影响的 native section。
428
- */
429
- handleHotUpdateApp?: (ctx: AppHmrContext) => void | Promise<void>;
383
+ name: string;
384
+ enforce?: 'pre' | 'post';
385
+ /** 必须在当前插件 setup 前完成 setup 的插件名 */
386
+ pre?: string[];
387
+ /** 必须在当前插件 setup 后完成 setup 的插件名 */
388
+ post?: string[];
389
+ apply?: 'build' | 'serve' | ((config: ResolvedConfig, env: {
390
+ mode: string;
391
+ command: string;
392
+ }) => boolean);
393
+ /** 插件初始化与跨插件 API 注册;每次 resolveConfig 只执行一次 */
394
+ setup?: (api: PluginApi) => void | Promise<void>;
395
+ buildStart?: (this: PluginContext) => void | Promise<void>;
396
+ buildEnd?: (this: PluginContext, error?: Error) => void | Promise<void>;
397
+ /**
398
+ * Called once after `bundle.close()` in production builds, mirroring Rollup/Vite semantics.
399
+ * Plugins use this to emit final-stage artifacts that depend on the bundle being fully written
400
+ * (PWA manifests, service workers, sitemaps, etc.). Not invoked in dev.
401
+ */
402
+ closeBundle?: (this: PluginContext, error?: Error) => void | Promise<void>;
403
+ resolveId?: (this: PluginContext, source: string, importer: string | undefined, options: ResolveIdOptions) => ResolveIdResult | Promise<ResolveIdResult>;
404
+ load?: (this: PluginContext, id: string) => LoadResult | Promise<LoadResult>;
405
+ transform?: (this: PluginContext, code: string, id: string) => TransformResult | Promise<TransformResult>;
406
+ /**
407
+ * Rolldown output 阶段钩子:对每个 chunk 的最终代码做变换或按 chunk 收集产物。
408
+ * 仅在生产构建生效(dev unbundled 管线没有 chunk 概念)。
409
+ *
410
+ * `this` 是 Rolldown 真实的(Rollup 兼容)插件上下文,不是 PluginContext stub:
411
+ * `this.emitFile({type:'asset'})` 经 `output.assetFileNames` 产出带 hash 的文件,
412
+ * `this.getFileName(ref)` 可立即解析最终文件名。CSS per-chunk 抽取依赖这两点。
413
+ */
414
+ renderChunk?: (this: RenderChunkContext, code: string, chunk: RenderedChunk) => string | {
415
+ code: string;
416
+ map?: unknown;
417
+ } | null | undefined | Promise<string | {
418
+ code: string;
419
+ map?: unknown;
420
+ } | null | undefined>;
421
+ /** 向 chunk hash 折叠额外输入(如该 chunk 关联的 CSS 内容),保证缓存正确性 */
422
+ augmentChunkHash?: (this: RenderChunkContext, chunk: RenderedChunk) => string | void | Promise<string | void>;
423
+ /**
424
+ * Rolldown output 收尾钩子(write 前最后时机)。`this` 同 renderChunk,
425
+ * 可 emitFile 补充产物(如 cssCodeSplit:false 的合并 CSS、manifest 等)。
426
+ */
427
+ generateBundle?: (this: RenderChunkContext, options?: unknown, bundle?: Record<string, unknown>) => void | Promise<void>;
428
+ config?: (config: NastiConfig, env: {
429
+ mode: string;
430
+ command: string;
431
+ }) => NastiConfig | null | void | Promise<NastiConfig | null | void>;
432
+ configResolved?: (config: ResolvedConfig) => void | Promise<void>;
433
+ /**
434
+ * Environment API:在环境配置最终解析前调整单个环境的选项。
435
+ * 对每个环境名调用一次(含默认注入的 client/ssr)。
436
+ */
437
+ configEnvironment?: (name: string, options: EnvironmentOptions, env: {
438
+ mode: string;
439
+ command: string;
440
+ }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>;
441
+ /**
442
+ * Environment API:按环境过滤插件。返回 false 则该插件不进入此环境的
443
+ * 插件管线。未声明时插件应用于所有环境(与 Vite 默认一致)。
444
+ */
445
+ applyToEnvironment?: (environment: EnvironmentInstance) => boolean;
446
+ /**
447
+ * 为声明了 `environment.options.driver` 的环境提供外部编译驱动。
448
+ * 一个环境只能被一个插件接管;返回多个驱动会报错。
449
+ */
450
+ createEnvironmentDriver?: (environment: EnvironmentInstance, api: PluginApi) => EnvironmentDriver | null | undefined | Promise<EnvironmentDriver | null | undefined>;
451
+ /**
452
+ * 所有环境构建完成后的 app 级收尾钩子,用于跨环境聚合产物。
453
+ * Vue Lynx 原生后端可在这里组合 background/main-thread bundle。
454
+ */
455
+ afterBuildApp?: (results: Record<string, EnvironmentBuildResult>, api: PluginApi, context: BuildAppContext) => void | Promise<void>;
456
+ configureServer?: (server: DevServer) => void | (() => void) | Promise<void | (() => void)>;
457
+ transformIndexHtml?: (html: string) => string | HtmlTagDescriptor[] | {
458
+ html: string;
459
+ tags: HtmlTagDescriptor[];
460
+ } | Promise<string | HtmlTagDescriptor[] | {
461
+ html: string;
462
+ tags: HtmlTagDescriptor[];
463
+ }>;
464
+ handleHotUpdate?: (ctx: HmrContext) => void | ModuleNode[] | Promise<void | ModuleNode[]>;
465
+ /**
466
+ * 一个文件在所有 dev client 环境完成失效、插件 HMR 钩子与重新转换后调用一次。
467
+ * 多运行时工具链可据此只重编码受影响的 native section。
468
+ */
469
+ handleHotUpdateApp?: (ctx: AppHmrContext) => void | Promise<void>;
430
470
  }
431
471
  interface PluginContext {
432
- resolve: (source: string, importer?: string) => Promise<ResolveIdResult>;
433
- emitFile: (file: EmittedFile) => string;
434
- getModuleInfo: (id: string) => ModuleInfo | null;
435
- /**
436
- * Environment API:当前钩子运行所在的环境(dev 管线中可用;
437
- * 生产构建的 Rolldown 钩子注入在 Phase 2 接线)。
438
- */
439
- environment?: EnvironmentInstance;
472
+ resolve: (source: string, importer?: string) => Promise<ResolveIdResult>;
473
+ emitFile: (file: EmittedFile) => string;
474
+ getModuleInfo: (id: string) => ModuleInfo | null;
475
+ /**
476
+ * Environment API:当前钩子运行所在的环境(dev 管线中可用;
477
+ * 生产构建的 Rolldown 钩子注入在 Phase 2 接线)。
478
+ */
479
+ environment?: EnvironmentInstance;
440
480
  }
441
481
  type PluginApiKey = string | symbol;
442
482
  /** 插件 setup 与环境驱动共享的跨插件 API。 */
443
483
  interface PluginApi {
444
- readonly config: ResolvedConfig;
445
- readonly logger: Logger;
446
- expose: <T>(key: PluginApiKey, value: T) => void;
447
- useExposed: <T>(key: PluginApiKey) => T | undefined;
484
+ readonly config: ResolvedConfig;
485
+ readonly logger: Logger;
486
+ expose: <T>(key: PluginApiKey, value: T) => void;
487
+ useExposed: <T>(key: PluginApiKey) => T | undefined;
448
488
  }
449
489
  interface EnvironmentBuildOutput {
450
- fileName: string;
451
- type: string;
452
- code?: string;
453
- source?: Uint8Array | string;
454
- map?: unknown;
455
- name?: string;
456
- names?: string[];
457
- isEntry?: boolean;
458
- isDynamicEntry?: boolean;
459
- imports?: string[];
460
- dynamicImports?: string[];
461
- moduleIds?: string[];
490
+ fileName: string;
491
+ type: string;
492
+ code?: string;
493
+ source?: Uint8Array | string;
494
+ map?: unknown;
495
+ name?: string;
496
+ names?: string[];
497
+ isEntry?: boolean;
498
+ isDynamicEntry?: boolean;
499
+ imports?: string[];
500
+ dynamicImports?: string[];
501
+ moduleIds?: string[];
462
502
  }
463
503
  interface EnvironmentCssModule {
464
- id: string;
465
- source: string;
466
- code: string;
504
+ id: string;
505
+ source: string;
506
+ code: string;
467
507
  }
468
508
  interface EnvironmentCssChunk {
469
- fileName: string;
470
- moduleIds: string[];
471
- cssFileNames: string[];
509
+ fileName: string;
510
+ moduleIds: string[];
511
+ cssFileNames: string[];
472
512
  }
473
513
  interface EnvironmentCssMetadata {
474
- modules: Record<string, EnvironmentCssModule>;
475
- chunks: Record<string, EnvironmentCssChunk>;
514
+ modules: Record<string, EnvironmentCssModule>;
515
+ chunks: Record<string, EnvironmentCssChunk>;
476
516
  }
477
517
  interface EnvironmentChunkMetadata {
478
- fileName: string;
479
- name: string;
480
- isEntry: boolean;
481
- isDynamicEntry: boolean;
482
- imports: string[];
483
- dynamicImports: string[];
484
- moduleIds: string[];
485
- css: string[];
486
- assets: string[];
518
+ fileName: string;
519
+ name: string;
520
+ isEntry: boolean;
521
+ isDynamicEntry: boolean;
522
+ imports: string[];
523
+ dynamicImports: string[];
524
+ moduleIds: string[];
525
+ css: string[];
526
+ assets: string[];
487
527
  }
488
528
  interface EnvironmentAssetMetadata {
489
- fileName: string;
490
- names: string[];
491
- publicPath: string;
529
+ fileName: string;
530
+ names: string[];
531
+ publicPath: string;
492
532
  }
493
533
  /** 单个环境附加到标准构建结果上的结构化元数据。 */
494
534
  interface EnvironmentBuildMetadata {
495
- entries?: Record<string, string>;
496
- publicPath?: string;
497
- manifest?: unknown;
498
- stats?: unknown;
499
- chunks?: Record<string, EnvironmentChunkMetadata>;
500
- assets?: Record<string, EnvironmentAssetMetadata>;
501
- css?: EnvironmentCssMetadata;
502
- sourceMaps?: Record<string, unknown>;
535
+ entries?: Record<string, string>;
536
+ publicPath?: string;
537
+ manifest?: unknown;
538
+ stats?: unknown;
539
+ chunks?: Record<string, EnvironmentChunkMetadata>;
540
+ assets?: Record<string, EnvironmentAssetMetadata>;
541
+ css?: EnvironmentCssMetadata;
542
+ sourceMaps?: Record<string, unknown>;
503
543
  }
504
544
  /** 外部环境驱动或原生 Rolldown 环境返回的标准构建结果。 */
505
545
  interface EnvironmentBuildResult extends EnvironmentBuildMetadata {
506
- output: EnvironmentBuildOutput[];
546
+ output: EnvironmentBuildOutput[];
507
547
  }
508
548
  /** app 级 finalizer 写出的聚合产物。 */
509
549
  interface AppBuildOutput extends EnvironmentBuildOutput {
510
- type: 'asset';
511
- source: Uint8Array | string;
550
+ type: 'asset';
551
+ source: Uint8Array | string;
512
552
  }
513
553
  /**
514
554
  * 所有环境完成后提供给 `afterBuildApp` 的只读查询与产物写出接口。
515
555
  * Lynx 等多运行时工具链可用它聚合 background/main-thread 结果,而无需读取磁盘目录。
516
556
  */
517
557
  interface BuildAppContext {
518
- readonly config: ResolvedConfig;
519
- readonly results: Readonly<Record<string, EnvironmentBuildResult>>;
520
- readonly output: readonly AppBuildOutput[];
521
- getResult: (environmentName: string) => EnvironmentBuildResult | undefined;
522
- getArtifact: (environmentName: string, fileName: string) => EnvironmentBuildOutput | undefined;
523
- getEntry: (environmentName: string, entryName: string) => EnvironmentBuildOutput | undefined;
524
- getManifest: <T = unknown>(environmentName: string) => T | undefined;
525
- getChunk: (environmentName: string, fileName: string) => EnvironmentChunkMetadata | undefined;
526
- getCss: (environmentName: string) => EnvironmentCssMetadata | undefined;
527
- getSourceMap: (environmentName: string, fileName: string) => unknown;
528
- resolvePublicPath: (environmentName: string, fileName: string) => string | undefined;
529
- /** 将聚合产物安全地写入 top-level `build.outDir`,并纳入 BuildResult.appOutput。 */
530
- emitFile: (file: AppBuildOutput) => string;
558
+ readonly config: ResolvedConfig;
559
+ readonly results: Readonly<Record<string, EnvironmentBuildResult>>;
560
+ readonly output: readonly AppBuildOutput[];
561
+ getResult: (environmentName: string) => EnvironmentBuildResult | undefined;
562
+ getArtifact: (environmentName: string, fileName: string) => EnvironmentBuildOutput | undefined;
563
+ getEntry: (environmentName: string, entryName: string) => EnvironmentBuildOutput | undefined;
564
+ getManifest: <T = unknown>(environmentName: string) => T | undefined;
565
+ getChunk: (environmentName: string, fileName: string) => EnvironmentChunkMetadata | undefined;
566
+ getCss: (environmentName: string) => EnvironmentCssMetadata | undefined;
567
+ getSourceMap: (environmentName: string, fileName: string) => unknown;
568
+ resolvePublicPath: (environmentName: string, fileName: string) => string | undefined;
569
+ /** 将聚合产物安全地写入 top-level `build.outDir`,并纳入 BuildResult.appOutput。 */
570
+ emitFile: (file: AppBuildOutput) => string;
531
571
  }
532
572
  /** 外部环境驱动返回的开发服务信息。 */
533
573
  interface EnvironmentServeResult {
534
- localUrls?: string[];
535
- networkUrls?: string[];
536
- middleware?: (request: IncomingMessage, response: ServerResponse, next: (error?: unknown) => void) => void;
574
+ localUrls?: string[];
575
+ networkUrls?: string[];
576
+ middleware?: (request: IncomingMessage, response: ServerResponse, next: (error?: unknown) => void) => void;
537
577
  }
538
578
  interface EnvironmentDriverContext {
539
- environment: EnvironmentInstance;
540
- config: ResolvedConfig;
541
- api: PluginApi;
542
- logger: Logger;
579
+ environment: EnvironmentInstance;
580
+ config: ResolvedConfig;
581
+ api: PluginApi;
582
+ logger: Logger;
543
583
  }
544
584
  interface EnvironmentDriverServeContext extends EnvironmentDriverContext {
545
- server: DevServer;
585
+ server: DevServer;
546
586
  }
547
587
  interface EnvironmentDriver {
548
- name: string;
549
- build?: (context: EnvironmentDriverContext) => EnvironmentBuildResult | Promise<EnvironmentBuildResult>;
550
- serve?: (context: EnvironmentDriverServeContext) => EnvironmentServeResult | void | Promise<EnvironmentServeResult | void>;
551
- watchChange?: (file: string, event: 'add' | 'change' | 'unlink', context: EnvironmentDriverContext) => void | Promise<void>;
552
- close?: (context: EnvironmentDriverContext) => void | Promise<void>;
588
+ name: string;
589
+ build?: (context: EnvironmentDriverContext) => EnvironmentBuildResult | Promise<EnvironmentBuildResult>;
590
+ serve?: (context: EnvironmentDriverServeContext) => EnvironmentServeResult | void | Promise<EnvironmentServeResult | void>;
591
+ watchChange?: (file: string, event: 'add' | 'change' | 'unlink', context: EnvironmentDriverContext) => void | Promise<void>;
592
+ close?: (context: EnvironmentDriverContext) => void | Promise<void>;
553
593
  }
554
594
  /**
555
595
  * 环境实例的公共面(核心实现见 core/environment.ts 的 NastiEnvironment)。
556
596
  * 插件经 `this.environment` / `applyToEnvironment(env)` 感知环境。
557
597
  */
558
598
  interface EnvironmentInstance {
559
- name: string;
560
- consumer: 'client' | 'server';
561
- mode: 'dev' | 'build';
562
- config: ResolvedConfig;
563
- options: ResolvedEnvironmentOptions;
564
- hot: HotChannel;
565
- /** 声明 driver 后,由插件提供的外部环境编译驱动 */
566
- driver?: EnvironmentDriver;
567
- /** per-environment dev 模块图与插件列表。 */
568
- moduleGraph: ModuleGraph$1;
569
- plugins: NastiPlugin[];
570
- /**
571
- * 在该环境的独立 transform 管线中请求模块。仅 dev 环境在初始化后可用。
572
- */
573
- transformRequest: (url: string) => Promise<{
574
- code: string;
575
- map?: unknown;
576
- } | null>;
577
- /** 内置 CSS 管线登记模块;工具链通常读取 getCssModule(s)。 */
578
- setCssModule: (module: EnvironmentCssModule) => void;
579
- getCssModule: (id: string) => EnvironmentCssModule | undefined;
580
- getCssModules: () => Readonly<Record<string, EnvironmentCssModule>>;
581
- setAssetModule: (id: string, fileName: string) => void;
582
- getAssetModules: () => Readonly<Record<string, string>>;
583
- /** 由生产插件登记 entries / manifest / stats,构建完成后合并进环境结果。 */
584
- setBuildMetadata: (metadata: EnvironmentBuildMetadata) => void;
599
+ name: string;
600
+ consumer: 'client' | 'server';
601
+ mode: 'dev' | 'build';
602
+ config: ResolvedConfig;
603
+ options: ResolvedEnvironmentOptions;
604
+ hot: HotChannel;
605
+ /** 声明 driver 后,由插件提供的外部环境编译驱动 */
606
+ driver?: EnvironmentDriver;
607
+ /** per-environment dev 模块图与插件列表。 */
608
+ moduleGraph: ModuleGraph$1;
609
+ plugins: NastiPlugin[];
610
+ /**
611
+ * 在该环境的独立 transform 管线中请求模块。仅 dev 环境在初始化后可用。
612
+ */
613
+ transformRequest: (url: string) => Promise<{
614
+ code: string;
615
+ map?: unknown;
616
+ } | null>;
617
+ /** 内置 CSS 管线登记模块;工具链通常读取 getCssModule(s)。 */
618
+ setCssModule: (module: EnvironmentCssModule) => void;
619
+ getCssModule: (id: string) => EnvironmentCssModule | undefined;
620
+ getCssModules: () => Readonly<Record<string, EnvironmentCssModule>>;
621
+ setAssetModule: (id: string, fileName: string) => void;
622
+ getAssetModules: () => Readonly<Record<string, string>>;
623
+ /** 由生产插件登记 entries / manifest / stats,构建完成后合并进环境结果。 */
624
+ setBuildMetadata: (metadata: EnvironmentBuildMetadata) => void;
585
625
  }
586
626
  /**
587
627
  * renderChunk / augmentChunkHash 的 `this`:Rolldown 真实插件上下文的最小可用面。
@@ -589,219 +629,220 @@ interface EnvironmentInstance {
589
629
  * referenceId,getFileName 能解析出带 hash 的最终文件名。
590
630
  */
591
631
  interface RenderChunkContext {
592
- emitFile: (file: EmittedFile) => string;
593
- getFileName: (referenceId: string) => string;
594
- /** 当前生产钩子所属环境;BG/MT 同为 client consumer 时也可准确区分。 */
595
- environment: EnvironmentInstance;
632
+ emitFile: (file: EmittedFile) => string;
633
+ getFileName: (referenceId: string) => string;
634
+ /** 当前生产钩子所属环境;BG/MT 同为 client consumer 时也可准确区分。 */
635
+ environment: EnvironmentInstance;
596
636
  }
597
637
  interface ResolveIdOptions {
598
- isEntry?: boolean;
599
- ssr?: boolean;
638
+ isEntry?: boolean;
639
+ ssr?: boolean;
600
640
  }
601
641
  type ResolveIdResult = string | null | undefined | {
602
- id: string;
603
- external?: boolean;
642
+ id: string;
643
+ external?: boolean;
604
644
  };
605
645
  type LoadResult = string | null | undefined | {
606
- code: string;
607
- map?: unknown;
646
+ code: string;
647
+ map?: unknown;
608
648
  };
609
649
  type TransformResult = string | null | undefined | {
610
- code: string;
611
- map?: unknown;
612
- moduleType?: string;
613
- /** 透传 Rolldown:'no-treeshake' 可保证模块不被摇出 chunk.moduleIds */
614
- moduleSideEffects?: boolean | 'no-treeshake';
650
+ code: string;
651
+ map?: unknown;
652
+ moduleType?: string;
653
+ /** 透传 Rolldown:'no-treeshake' 可保证模块不被摇出 chunk.moduleIds */
654
+ moduleSideEffects?: boolean | 'no-treeshake';
615
655
  };
616
656
  interface EmittedFile {
617
- type: 'asset' | 'chunk';
618
- name?: string;
619
- fileName?: string;
620
- source?: string | Uint8Array;
657
+ type: 'asset' | 'chunk';
658
+ name?: string;
659
+ fileName?: string;
660
+ source?: string | Uint8Array;
621
661
  }
622
662
  interface ModuleInfo {
623
- id: string;
624
- importers: string[];
625
- importedIds: string[];
663
+ id: string;
664
+ importers: string[];
665
+ importedIds: string[];
626
666
  }
627
667
  interface HtmlTagDescriptor {
628
- tag: string;
629
- attrs?: Record<string, string | boolean>;
630
- children?: string | HtmlTagDescriptor[];
631
- injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
668
+ tag: string;
669
+ attrs?: Record<string, string | boolean>;
670
+ children?: string | HtmlTagDescriptor[];
671
+ injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
632
672
  }
633
673
  interface ModuleNode {
634
- id: string;
635
- file: string | null;
636
- url: string;
637
- type: 'js' | 'css';
638
- importers: Set<ModuleNode>;
639
- importedModules: Set<ModuleNode>;
640
- acceptedHmrDeps: Set<ModuleNode>;
641
- transformResult: TransformResult | null;
642
- lastHMRTimestamp: number;
643
- /** 每次失效递增,防止较慢的旧转换覆盖较新的缓存。 */
644
- invalidationVersion: number;
645
- isSelfAccepting: boolean;
646
- /** Environment API:节点所属环境名(per-env 模块图,默认 'client') */
647
- environment?: string;
674
+ id: string;
675
+ file: string | null;
676
+ url: string;
677
+ type: 'js' | 'css';
678
+ importers: Set<ModuleNode>;
679
+ importedModules: Set<ModuleNode>;
680
+ acceptedHmrDeps: Set<ModuleNode>;
681
+ transformResult: TransformResult | null;
682
+ lastHMRTimestamp: number;
683
+ /** 每次失效递增,防止较慢的旧转换覆盖较新的缓存。 */
684
+ invalidationVersion: number;
685
+ isSelfAccepting: boolean;
686
+ /** Environment API:节点所属环境名(per-env 模块图,默认 'client') */
687
+ environment?: string;
648
688
  }
649
689
  interface ResolvedConfig {
650
- root: string;
651
- base: string;
652
- mode: 'development' | 'production';
653
- target: 'web' | 'electron';
654
- /** `auto` 在配置解析阶段已收敛为具体框架 */
655
- framework: 'react' | 'vue';
656
- /** 解析后的 React 管线配置;Vue 项目仍保留该字段以简化插件读取。 */
657
- react: ResolvedReactOptions;
658
- command: 'build' | 'serve';
659
- resolve: Required<ResolveConfig>;
660
- plugins: NastiPlugin[];
661
- server: Required<ServerConfig>;
662
- build: Required<BuildConfig>;
663
- electron: Required<ElectronConfig>;
664
- envPrefix: string[];
665
- logLevel: 'info' | 'warn' | 'error' | 'silent';
666
- clearScreen: boolean;
667
- /** 已接线 logLevel 的 Logger 实例,所有 Nasti 输出统一经此通道 */
668
- logger: Logger;
669
- /**
670
- * 解析后的环境 map(默认 client + ssr)。`environments.client` 的
671
- * resolve/build 与 top-level **同引用**(精确镜像,运行时有断言校验)。
672
- */
673
- environments: Record<string, ResolvedEnvironmentOptions>;
674
- experimental: Required<ExperimentalOptions>;
690
+ root: string;
691
+ base: string;
692
+ mode: 'development' | 'production';
693
+ target: 'web' | 'electron';
694
+ /** `auto` 在配置解析阶段已收敛为具体框架 */
695
+ framework: 'react' | 'vue';
696
+ /** 解析后的 React 管线配置;Vue 项目仍保留该字段以简化插件读取。 */
697
+ react: ResolvedReactOptions;
698
+ command: 'build' | 'serve';
699
+ resolve: Required<ResolveConfig>;
700
+ plugins: NastiPlugin[];
701
+ server: Required<ServerConfig>;
702
+ build: Required<BuildConfig>;
703
+ electron: Required<ElectronConfig>;
704
+ envPrefix: string[];
705
+ logLevel: 'info' | 'warn' | 'error' | 'silent';
706
+ clearScreen: boolean;
707
+ /** 已接线 logLevel 的 Logger 实例,所有 Nasti 输出统一经此通道 */
708
+ logger: Logger;
709
+ /**
710
+ * 解析后的环境 map(默认 client + ssr)。`environments.client` 的
711
+ * resolve/build 与 top-level **同引用**(精确镜像,运行时有断言校验)。
712
+ */
713
+ environments: Record<string, ResolvedEnvironmentOptions>;
714
+ experimental: Required<ExperimentalOptions>;
675
715
  }
676
716
  interface DevServer {
677
- config: ResolvedConfig;
678
- middlewares: any;
679
- /**
680
- * client 环境模块图的别名(back-compat)。
681
- * @deprecated 跟随 Vite 退役 flat `server.*` 的方向,2.x 移除;
682
- * 新代码请用 `server.environments.client.moduleGraph`。
683
- */
684
- moduleGraph: ModuleGraph$1;
685
- watcher: any;
686
- ws: WebSocketServer;
687
- /** Environment API:每个 client-consumer 环境都有独立的 transform/HMR 管线。 */
688
- environments: Record<string, EnvironmentInstance>;
689
- /** 外部环境驱动启动后返回的服务 URL / middleware 信息 */
690
- environmentServices: Record<string, EnvironmentServeResult>;
691
- listen: (port?: number) => Promise<DevServer>;
692
- close: () => Promise<void>;
693
- transformRequest: (url: string) => Promise<TransformResult>;
694
- transformEnvironmentRequest: (environmentName: string, url: string) => Promise<TransformResult>;
695
- /**
696
- * SSR:在 server consumer 环境(默认 `ssr`)中加载并执行模块,返回其导出。
697
- * Vite `server.ssrLoadModule` 的 back-compat shim(底层是 module runner +
698
- * HotChannel invoke 桥)。模块经 moduleRunnerTransform 转换后在进程内求值,
699
- * `import.meta.env.SSR === true`,bare import 外部化交给 node 解析。
700
- */
701
- ssrLoadModule: (url: string) => Promise<Record<string, unknown>>;
717
+ config: ResolvedConfig;
718
+ middlewares: any;
719
+ /**
720
+ * client 环境模块图的别名(back-compat)。
721
+ * @deprecated 跟随 Vite 退役 flat `server.*` 的方向,2.x 移除;
722
+ * 新代码请用 `server.environments.client.moduleGraph`。
723
+ */
724
+ moduleGraph: ModuleGraph$1;
725
+ watcher: any;
726
+ ws: WebSocketServer;
727
+ /** Environment API:每个 client-consumer 环境都有独立的 transform/HMR 管线。 */
728
+ environments: Record<string, EnvironmentInstance>;
729
+ /** 外部环境驱动启动后返回的服务 URL / middleware 信息 */
730
+ environmentServices: Record<string, EnvironmentServeResult>;
731
+ listen: (port?: number) => Promise<DevServer>;
732
+ close: () => Promise<void>;
733
+ transformRequest: (url: string) => Promise<TransformResult>;
734
+ transformEnvironmentRequest: (environmentName: string, url: string) => Promise<TransformResult>;
735
+ /**
736
+ * SSR:在 server consumer 环境(默认 `ssr`)中加载并执行模块,返回其导出。
737
+ * Vite `server.ssrLoadModule` 的 back-compat shim(底层是 module runner +
738
+ * HotChannel invoke 桥)。模块经 moduleRunnerTransform 转换后在进程内求值,
739
+ * `import.meta.env.SSR === true`,bare import 外部化交给 node 解析。
740
+ */
741
+ ssrLoadModule: (url: string) => Promise<Record<string, unknown>>;
702
742
  }
703
743
  interface ModuleGraph$1 {
704
- getModuleByUrl: (url: string) => ModuleNode | undefined;
705
- getModuleById: (id: string) => ModuleNode | undefined;
706
- getModulesByFile: (file: string) => Set<ModuleNode> | undefined;
707
- ensureEntryFromUrl: (url: string) => Promise<ModuleNode>;
708
- invalidateModule: (mod: ModuleNode, timestamp?: number) => void;
709
- invalidateModuleAndImporters: (mod: ModuleNode, timestamp?: number) => void;
710
- getHmrBoundaries: (mod: ModuleNode) => Array<{
711
- boundary: ModuleNode;
712
- acceptedVia: ModuleNode;
713
- }>;
714
- invalidateAll: () => void;
744
+ getModuleByUrl: (url: string) => ModuleNode | undefined;
745
+ getModuleById: (id: string) => ModuleNode | undefined;
746
+ getModulesByFile: (file: string) => Set<ModuleNode> | undefined;
747
+ ensureEntryFromUrl: (url: string) => Promise<ModuleNode>;
748
+ invalidateModule: (mod: ModuleNode, timestamp?: number) => void;
749
+ invalidateModuleAndImporters: (mod: ModuleNode, timestamp?: number) => void;
750
+ getHmrBoundaries: (mod: ModuleNode) => Array<{
751
+ boundary: ModuleNode;
752
+ acceptedVia: ModuleNode;
753
+ }>;
754
+ invalidateAll: () => void;
715
755
  }
716
756
  interface WebSocketServer {
717
- send: (payload: HmrPayload) => void;
718
- close: () => void;
757
+ send: (payload: HmrPayload) => void;
758
+ close: () => void;
719
759
  }
720
760
  type HotChannelListener = (data: unknown, client: HotChannelClient) => void;
721
761
  interface HotChannelClient {
722
- send: (payload: HmrPayload) => void;
762
+ send: (payload: HmrPayload) => void;
723
763
  }
724
764
  /** module runner 经 invoke 调用的 RPC 方法集(Vite DevEnvironment.hot.setInvokeHandler 同构) */
725
765
  interface HotChannelInvokeHandlers {
726
- /** runner 回调 fetchModule → transformRequest → 求值 */
727
- fetchModule: (id: string, importer?: string, options?: {
728
- cached?: boolean;
729
- }) => Promise<unknown>;
730
- /** server 环境的内建模块清单(string/RegExp,序列化需对齐 runner 期望) */
731
- getBuiltins?: () => Promise<Array<string | RegExp>> | Array<string | RegExp>;
732
- /** 网络暴露的 transport 跳过文件系统存在性检查(安全相关,显式带上) */
733
- _skipFsCheck?: boolean;
766
+ /** runner 回调 fetchModule → transformRequest → 求值 */
767
+ fetchModule: (id: string, importer?: string, options?: {
768
+ cached?: boolean;
769
+ }) => Promise<unknown>;
770
+ /** server 环境的内建模块清单(string/RegExp,序列化需对齐 runner 期望) */
771
+ getBuiltins?: () => Promise<Array<string | RegExp>> | Array<string | RegExp>;
772
+ /** 网络暴露的 transport 跳过文件系统存在性检查(安全相关,显式带上) */
773
+ _skipFsCheck?: boolean;
734
774
  }
735
775
  interface HotChannel {
736
- /** 向该环境的所有客户端广播 */
737
- send: (payload: HmrPayload) => void;
738
- /** 监听客户端自定义事件(custom events / invoke transport) */
739
- on?: (event: string, listener: HotChannelListener) => void;
740
- off?: (event: string, listener: HotChannelListener) => void;
741
- listen?: () => void;
742
- close?: () => void | Promise<void>;
743
- /** 注册 invoke 处理器(SSR runner 的 RPC 桥;Phase 1 仅定义契约) */
744
- setInvokeHandler?: (handlers: HotChannelInvokeHandlers | undefined) => void;
776
+ /** 向该环境的所有客户端广播 */
777
+ send: (payload: HmrPayload) => void;
778
+ /** 监听客户端自定义事件(custom events / invoke transport) */
779
+ on?: (event: string, listener: HotChannelListener) => void;
780
+ off?: (event: string, listener: HotChannelListener) => void;
781
+ listen?: () => void;
782
+ close?: () => void | Promise<void>;
783
+ /** 注册 invoke 处理器(SSR runner 的 RPC 桥;Phase 1 仅定义契约) */
784
+ setInvokeHandler?: (handlers: HotChannelInvokeHandlers | undefined) => void;
745
785
  }
746
786
  interface HmrContext {
747
- file: string;
748
- timestamp: number;
749
- modules: ModuleNode[];
750
- read: () => string | Promise<string>;
751
- server: DevServer;
752
- environment: EnvironmentInstance;
787
+ file: string;
788
+ timestamp: number;
789
+ modules: ModuleNode[];
790
+ read: () => string | Promise<string>;
791
+ server: DevServer;
792
+ environment: EnvironmentInstance;
753
793
  }
754
794
  interface EnvironmentTransformedModule {
755
- module: ModuleNode;
756
- result: {
757
- code: string;
758
- map?: unknown;
759
- } | null;
795
+ module: ModuleNode;
796
+ result: {
797
+ code: string;
798
+ map?: unknown;
799
+ } | null;
760
800
  }
761
801
  interface EnvironmentHotUpdateResult {
762
- environment: EnvironmentInstance;
763
- modules: ModuleNode[];
764
- updates: HmrUpdate[];
765
- transformed: EnvironmentTransformedModule[];
766
- fullReload: boolean;
802
+ environment: EnvironmentInstance;
803
+ modules: ModuleNode[];
804
+ updates: HmrUpdate[];
805
+ transformed: EnvironmentTransformedModule[];
806
+ fullReload: boolean;
767
807
  }
768
808
  interface AppHmrContext {
769
- file: string;
770
- timestamp: number;
771
- environments: Readonly<Record<string, EnvironmentHotUpdateResult>>;
772
- server: DevServer;
809
+ file: string;
810
+ timestamp: number;
811
+ environments: Readonly<Record<string, EnvironmentHotUpdateResult>>;
812
+ server: DevServer;
773
813
  }
774
814
  type HmrPayload = ({
775
- type: 'connected';
815
+ type: 'connected';
776
816
  } | {
777
- type: 'update';
778
- updates: HmrUpdate[];
817
+ type: 'update';
818
+ updates: HmrUpdate[];
779
819
  } | {
780
- type: 'full-reload';
781
- path?: string;
820
+ type: 'full-reload';
821
+ path?: string;
782
822
  } | {
783
- type: 'prune';
784
- paths: string[];
823
+ type: 'prune';
824
+ paths: string[];
785
825
  } | {
786
- type: 'error';
787
- err: {
788
- message: string;
789
- stack?: string;
790
- };
826
+ type: 'error';
827
+ err: {
828
+ message: string;
829
+ stack?: string;
830
+ };
791
831
  } | {
792
- type: 'custom';
793
- event: string;
794
- data?: unknown;
832
+ type: 'custom';
833
+ event: string;
834
+ data?: unknown;
795
835
  }) & {
796
- environment?: string;
836
+ environment?: string;
797
837
  };
798
838
  interface HmrUpdate {
799
- type: 'js-update' | 'css-update';
800
- path: string;
801
- acceptedPath: string;
802
- timestamp: number;
839
+ type: 'js-update' | 'css-update';
840
+ path: string;
841
+ acceptedPath: string;
842
+ timestamp: number;
803
843
  }
804
-
844
+ //#endregion
845
+ //#region src/config/index.d.ts
805
846
  declare function defineConfig(config: NastiConfig): NastiConfig;
806
847
  /**
807
848
  * 将 framework:auto 收敛为具体框架。
@@ -820,156 +861,161 @@ declare function detectFramework(root: string): 'react' | 'vue';
820
861
  * @returns The fully resolved configuration with defaults applied, plugins filtered, and plugin hooks executed
821
862
  */
822
863
  declare function resolveConfig(inlineConfig: NastiConfig | undefined, command: 'build' | 'serve'): Promise<ResolvedConfig>;
823
-
864
+ //#endregion
865
+ //#region src/core/plugin-container.d.ts
824
866
  declare class PluginContainer {
825
- private plugins;
826
- private config;
827
- private ctx;
828
- private emittedFiles;
829
- /** Environment API:容器所属环境(未传时为 undefined,行为同 1.x client) */
830
- readonly environment?: EnvironmentInstance;
831
- constructor(config: ResolvedConfig, environment?: EnvironmentInstance);
832
- private createContext;
833
- /** 返回所有通过 emitFile() 输出的文件 */
834
- getEmittedFiles(): Array<{
835
- fileName: string;
836
- source: string | Uint8Array;
837
- }>;
838
- buildStart(): Promise<void>;
839
- buildEnd(error?: Error): Promise<void>;
840
- resolveId(source: string, importer?: string, options?: {
841
- isEntry?: boolean;
842
- }): Promise<ResolveIdResult>;
843
- load(id: string): Promise<LoadResult>;
844
- transform(code: string, id: string): Promise<TransformResult>;
845
- /** 完整的模块处理管道: resolveId → load → transform */
846
- processModule(source: string, importer?: string): Promise<{
847
- id: string;
848
- code: string;
849
- } | null>;
850
- getPlugins(): NastiPlugin[];
851
- }
852
-
867
+ private plugins;
868
+ private config;
869
+ private ctx;
870
+ private emittedFiles;
871
+ /** Environment API:容器所属环境(未传时为 undefined,行为同 1.x client) */
872
+ readonly environment?: EnvironmentInstance;
873
+ constructor(config: ResolvedConfig, environment?: EnvironmentInstance);
874
+ private createContext;
875
+ /** 返回所有通过 emitFile() 输出的文件 */
876
+ getEmittedFiles(): Array<{
877
+ fileName: string;
878
+ source: string | Uint8Array;
879
+ }>;
880
+ buildStart(): Promise<void>;
881
+ buildEnd(error?: Error): Promise<void>;
882
+ resolveId(source: string, importer?: string, options?: {
883
+ isEntry?: boolean;
884
+ }): Promise<ResolveIdResult>;
885
+ load(id: string): Promise<LoadResult>;
886
+ transform(code: string, id: string): Promise<TransformResult>;
887
+ /** 完整的模块处理管道: resolveId → load → transform */
888
+ processModule(source: string, importer?: string): Promise<{
889
+ id: string;
890
+ code: string;
891
+ } | null>;
892
+ getPlugins(): NastiPlugin[];
893
+ }
894
+ //#endregion
895
+ //#region src/core/module-graph.d.ts
853
896
  declare class ModuleGraph {
854
- readonly environmentName: string;
855
- private urlToModuleMap;
856
- private idToModuleMap;
857
- private fileToModulesMap;
858
- constructor(environmentName?: string);
859
- getModuleByUrl(url: string): ModuleNode | undefined;
860
- getModuleById(id: string): ModuleNode | undefined;
861
- getModulesByFile(file: string): Set<ModuleNode> | undefined;
862
- /**
863
- * Modules whose registered entry file lives under `dir` (inclusive).
864
- * Used when a non-entry source inside a prebundled workspace package changes:
865
- * only the package entry was registered, so getModulesByFile(changedFile)
866
- * misses — we invalidate every /@modules entry rooted in that package.
867
- */
868
- getModulesWithFileUnder(dir: string): Set<ModuleNode>;
869
- ensureEntryFromUrl(url: string): Promise<ModuleNode>;
870
- createModule(url: string, id?: string): ModuleNode;
871
- /** 注册文件路径到模块的映射 */
872
- registerModule(mod: ModuleNode, file: string): void;
873
- /**
874
- * Reindex a module under a plugin-provided canonical id (e.g. a `\0virtual:foo`
875
- * id returned from `resolveId`). Plugins look up their own virtual modules via
876
- * `getModuleById(RESOLVED_ID)` to invalidate them on watcher events; without
877
- * this remap they'd never find the node because `ensureEntryFromUrl` keys by
878
- * the public URL only.
879
- */
880
- setModuleId(mod: ModuleNode, id: string): void;
881
- /** 更新模块依赖关系 */
882
- updateModuleImports(mod: ModuleNode, importedIds: Set<string>): void;
883
- /**
884
- * 用一次转换得到的信息原子更新 import 与 HMR accept 关系。
885
- * 依赖节点会在真正被浏览器请求前预先创建,这样入口模块先转换时也能建立完整图。
886
- */
887
- updateModuleInfo(mod: ModuleNode, importedUrls: Set<string>, acceptedUrls: Set<string>, isSelfAccepting: boolean, expectedInvalidationVersion?: number): Promise<Set<ModuleNode> | null>;
888
- /** 使模块的转换缓存失效 */
889
- invalidateModule(mod: ModuleNode, timestamp?: number): void;
890
- /**
891
- * 仅失效到 HMR 边界:显式接受依赖的模块本身不会重执行;自接受模块需要失效,
892
- * 但不再继续影响其 importer。这样既能传播依赖时间戳,也不会隐式重复副作用。
893
- */
894
- invalidateModuleAndImporters(mod: ModuleNode, timestamp?: number, seen?: Set<ModuleNode>): void;
895
- /** 使所有模块缓存失效 */
896
- invalidateAll(): void;
897
- /** 获取 HMR 传播边界 - 从变更模块向上遍历找到接受更新的边界 */
898
- getHmrBoundaries(mod: ModuleNode): {
899
- boundary: ModuleNode;
900
- acceptedVia: ModuleNode;
901
- }[];
902
- }
903
-
897
+ readonly environmentName: string;
898
+ private urlToModuleMap;
899
+ private idToModuleMap;
900
+ private fileToModulesMap;
901
+ constructor(environmentName?: string);
902
+ getModuleByUrl(url: string): ModuleNode | undefined;
903
+ getModuleById(id: string): ModuleNode | undefined;
904
+ getModulesByFile(file: string): Set<ModuleNode> | undefined;
905
+ /**
906
+ * Modules whose registered entry file lives under `dir` (inclusive).
907
+ * Used when a non-entry source inside a prebundled workspace package changes:
908
+ * only the package entry was registered, so getModulesByFile(changedFile)
909
+ * misses — we invalidate every /@modules entry rooted in that package.
910
+ */
911
+ getModulesWithFileUnder(dir: string): Set<ModuleNode>;
912
+ ensureEntryFromUrl(url: string): Promise<ModuleNode>;
913
+ createModule(url: string, id?: string): ModuleNode;
914
+ /** 注册文件路径到模块的映射 */
915
+ registerModule(mod: ModuleNode, file: string): void;
916
+ /**
917
+ * Reindex a module under a plugin-provided canonical id (e.g. a `\0virtual:foo`
918
+ * id returned from `resolveId`). Plugins look up their own virtual modules via
919
+ * `getModuleById(RESOLVED_ID)` to invalidate them on watcher events; without
920
+ * this remap they'd never find the node because `ensureEntryFromUrl` keys by
921
+ * the public URL only.
922
+ */
923
+ setModuleId(mod: ModuleNode, id: string): void;
924
+ /** 更新模块依赖关系 */
925
+ updateModuleImports(mod: ModuleNode, importedIds: Set<string>): void;
926
+ /**
927
+ * 用一次转换得到的信息原子更新 import 与 HMR accept 关系。
928
+ * 依赖节点会在真正被浏览器请求前预先创建,这样入口模块先转换时也能建立完整图。
929
+ */
930
+ updateModuleInfo(mod: ModuleNode, importedUrls: Set<string>, acceptedUrls: Set<string>, isSelfAccepting: boolean, expectedInvalidationVersion?: number): Promise<Set<ModuleNode> | null>;
931
+ /** 使模块的转换缓存失效 */
932
+ invalidateModule(mod: ModuleNode, timestamp?: number): void;
933
+ /**
934
+ * 仅失效到 HMR 边界:显式接受依赖的模块本身不会重执行;自接受模块需要失效,
935
+ * 但不再继续影响其 importer。这样既能传播依赖时间戳,也不会隐式重复副作用。
936
+ */
937
+ invalidateModuleAndImporters(mod: ModuleNode, timestamp?: number, seen?: Set<ModuleNode>): void;
938
+ /** 使所有模块缓存失效 */
939
+ invalidateAll(): void;
940
+ /** 获取 HMR 传播边界 - 从变更模块向上遍历找到接受更新的边界 */
941
+ getHmrBoundaries(mod: ModuleNode): {
942
+ boundary: ModuleNode;
943
+ acceptedVia: ModuleNode;
944
+ }[];
945
+ }
946
+ //#endregion
947
+ //#region src/core/environment.d.ts
904
948
  interface NastiEnvironmentInit {
905
- hot?: HotChannel;
906
- mode?: 'dev' | 'build';
907
- /** 环境的候选插件(init 时经 applyToEnvironment 过滤) */
908
- plugins?: NastiPlugin[];
909
- /** 配置解析阶段创建的共享插件 API;通常自动从 ResolvedConfig 获取 */
910
- pluginApi?: PluginApi;
949
+ hot?: HotChannel;
950
+ mode?: 'dev' | 'build';
951
+ /** 环境的候选插件(init 时经 applyToEnvironment 过滤) */
952
+ plugins?: NastiPlugin[];
953
+ /** 配置解析阶段创建的共享插件 API;通常自动从 ResolvedConfig 获取 */
954
+ pluginApi?: PluginApi;
911
955
  }
912
956
  declare class NastiEnvironment implements EnvironmentInstance {
913
- readonly name: string;
914
- readonly consumer: 'client' | 'server';
915
- readonly mode: 'dev' | 'build';
916
- readonly config: ResolvedConfig;
917
- readonly options: ResolvedEnvironmentOptions;
918
- readonly hot: HotChannel;
919
- driver?: EnvironmentDriver;
920
- /** applyToEnvironment 过滤后的插件(init() 后可用) */
921
- plugins: NastiPlugin[];
922
- /** per-env 插件容器(init() 后可用;dev 管线使用) */
923
- pluginContainer: PluginContainer | null;
924
- /** per-env 模块图(dev 管线使用) */
925
- moduleGraph: ModuleGraph;
926
- private candidatePlugins;
927
- private pluginApi;
928
- private buildMetadata;
929
- private cssModules;
930
- private assetModules;
931
- private transformRequestHandler?;
932
- private initialized;
933
- constructor(name: string, config: ResolvedConfig, init?: NastiEnvironmentInit);
934
- /** 过滤插件并建 per-env PluginContainer */
935
- init(): Promise<void>;
936
- getDriverContext(): EnvironmentDriverContext;
937
- configureDevPipeline(transformRequest: (url: string) => Promise<{
938
- code: string;
939
- map?: unknown;
940
- } | null>): void;
941
- transformRequest(url: string): Promise<{
942
- code: string;
943
- map?: unknown;
944
- } | null>;
945
- setCssModule(module: EnvironmentCssModule): void;
946
- getCssModule(id: string): EnvironmentCssModule | undefined;
947
- getCssModules(): Readonly<Record<string, EnvironmentCssModule>>;
948
- setAssetModule(id: string, fileName: string): void;
949
- getAssetModules(): Readonly<Record<string, string>>;
950
- setBuildMetadata(metadata: EnvironmentBuildMetadata): void;
951
- getBuildMetadata(): EnvironmentBuildMetadata;
952
- close(): Promise<void>;
957
+ readonly name: string;
958
+ readonly consumer: 'client' | 'server';
959
+ readonly mode: 'dev' | 'build';
960
+ readonly config: ResolvedConfig;
961
+ readonly options: ResolvedEnvironmentOptions;
962
+ readonly hot: HotChannel;
963
+ driver?: EnvironmentDriver;
964
+ /** applyToEnvironment 过滤后的插件(init() 后可用) */
965
+ plugins: NastiPlugin[];
966
+ /** per-env 插件容器(init() 后可用;dev 管线使用) */
967
+ pluginContainer: PluginContainer | null;
968
+ /** per-env 模块图(dev 管线使用) */
969
+ moduleGraph: ModuleGraph;
970
+ private candidatePlugins;
971
+ private pluginApi;
972
+ private buildMetadata;
973
+ private cssModules;
974
+ private assetModules;
975
+ private transformRequestHandler?;
976
+ private initialized;
977
+ constructor(name: string, config: ResolvedConfig, init?: NastiEnvironmentInit);
978
+ /** 过滤插件并建 per-env PluginContainer */
979
+ init(): Promise<void>;
980
+ getDriverContext(): EnvironmentDriverContext;
981
+ configureDevPipeline(transformRequest: (url: string) => Promise<{
982
+ code: string;
983
+ map?: unknown;
984
+ } | null>): void;
985
+ transformRequest(url: string): Promise<{
986
+ code: string;
987
+ map?: unknown;
988
+ } | null>;
989
+ setCssModule(module: EnvironmentCssModule): void;
990
+ getCssModule(id: string): EnvironmentCssModule | undefined;
991
+ getCssModules(): Readonly<Record<string, EnvironmentCssModule>>;
992
+ setAssetModule(id: string, fileName: string): void;
993
+ getAssetModules(): Readonly<Record<string, string>>;
994
+ setBuildMetadata(metadata: EnvironmentBuildMetadata): void;
995
+ getBuildMetadata(): EnvironmentBuildMetadata;
996
+ close(): Promise<void>;
953
997
  }
954
998
  /** 按 applyToEnvironment 过滤环境插件(未声明 = 应用于所有环境) */
955
999
  declare function resolveEnvironmentPlugins(environment: EnvironmentInstance, plugins: NastiPlugin[]): NastiPlugin[];
956
-
1000
+ //#endregion
1001
+ //#region src/build/index.d.ts
957
1002
  interface BuildResult {
958
- /** client 环境的产物(back-compat:1.x 的 BuildResult 形态) */
959
- output: EnvironmentBuildOutput[];
960
- /** 全部已构建环境的产物(2.0 多环境 builder) */
961
- environments?: Record<string, BuildResult['output']>;
962
- /** 全部环境的完整结果(entries / manifest / stats 等) */
963
- environmentResults?: Record<string, EnvironmentBuildResult>;
964
- /** app 级 finalizer 聚合写出的产物(如 `.lynx.bundle`) */
965
- appOutput?: AppBuildOutput[];
1003
+ /** client 环境的产物(back-compat:1.x 的 BuildResult 形态) */
1004
+ output: EnvironmentBuildOutput[];
1005
+ /** 全部已构建环境的产物(2.0 多环境 builder) */
1006
+ environments?: Record<string, BuildResult['output']>;
1007
+ /** 全部环境的完整结果(entries / manifest / stats 等) */
1008
+ environmentResults?: Record<string, EnvironmentBuildResult>;
1009
+ /** app 级 finalizer 聚合写出的产物(如 `.lynx.bundle`) */
1010
+ appOutput?: AppBuildOutput[];
966
1011
  }
967
1012
  declare function build(inlineConfig?: NastiConfig): Promise<BuildResult>;
968
-
1013
+ //#endregion
1014
+ //#region src/build/electron.d.ts
969
1015
  interface ElectronBuildResult {
970
- rendererOutDir: string;
971
- mainFile: string;
972
- preloadFiles: string[];
1016
+ rendererOutDir: string;
1017
+ mainFile: string;
1018
+ preloadFiles: string[];
973
1019
  }
974
1020
  /**
975
1021
  * Performs a full Electron build pipeline producing renderer, main, and preload artifacts.
@@ -988,12 +1034,14 @@ declare function buildElectron(inlineConfig?: NastiConfig): Promise<ElectronBuil
988
1034
  * `./`,避免产物中的 `/assets/*` 被解析到文件系统根目录。
989
1035
  */
990
1036
  declare function createElectronRendererConfig(config: ResolvedConfig, inlineConfig?: NastiConfig, overrides?: Pick<NastiConfig, 'build'>): NastiConfig;
991
-
1037
+ //#endregion
1038
+ //#region src/server/index.d.ts
992
1039
  declare function createServer(inlineConfig?: NastiConfig): Promise<DevServer>;
993
-
1040
+ //#endregion
1041
+ //#region src/server/electron-dev.d.ts
994
1042
  interface ElectronDevOptions extends NastiConfig {
995
- /** 不启动 Electron 进程,只编译主/preload(CI 场景) */
996
- noSpawn?: boolean;
1043
+ /** 不启动 Electron 进程,只编译主/preload(CI 场景) */
1044
+ noSpawn?: boolean;
997
1045
  }
998
1046
  /**
999
1047
  * Start an Electron-focused development workflow: run the renderer dev server, build the main and preload bundles into .nasti/, and optionally spawn Electron with automatic restarts.
@@ -1003,7 +1051,8 @@ interface ElectronDevOptions extends NastiConfig {
1003
1051
  declare function startElectronDev(inlineConfig?: ElectronDevOptions): Promise<void>;
1004
1052
  /** 将 renderer HTML 路径转换为 Electron 开发服务器 URL path。 */
1005
1053
  declare function electronRendererDevPath(renderer: string): string;
1006
-
1054
+ //#endregion
1055
+ //#region src/plugins/electron.d.ts
1007
1056
  /**
1008
1057
  * Create a Vite/Rollup plugin that externalizes Electron and Node built-in imports according to the resolved config.
1009
1058
  *
@@ -1011,54 +1060,56 @@ declare function electronRendererDevPath(renderer: string): string;
1011
1060
  * @returns A plugin that marks `electron` and `electron/*` imports and Node built-in modules (including `node:`-prefixed names) as external.
1012
1061
  */
1013
1062
  declare function electronPlugin(config: ResolvedConfig): NastiPlugin;
1014
-
1063
+ //#endregion
1064
+ //#region src/plugins/monaco-editor.d.ts
1015
1065
  type MonacoEditorLanguageWorker = 'editorWorkerService' | 'css' | 'html' | 'json' | 'typescript';
1016
1066
  interface MonacoCustomWorker {
1017
- label: string;
1018
- entry: string;
1067
+ label: string;
1068
+ entry: string;
1019
1069
  }
1020
1070
  interface MonacoEditorPluginOptions {
1021
- /** 启用的 Monaco 语言 Worker,默认启用全部 */
1022
- languageWorkers?: MonacoEditorLanguageWorker[];
1023
- /** 额外自定义 Worker(如 monaco-graphql/esm/graphql.worker) */
1024
- customWorkers?: MonacoCustomWorker[];
1025
- /** Worker 在 URL 上的公共路径,默认 'monacoeditorwork'。可填 CDN 绝对 URL */
1026
- publicPath?: string;
1027
- /** 是否将 Monaco API 暴露到 window.monaco(兼容 0.22 之前的 globalAPI 模式) */
1028
- globalAPI?: boolean;
1029
- /** publicPath 是 CDN 时仍强制本地打包 Worker 产物 */
1030
- forceBuildCDN?: boolean;
1031
- /** 自定义生产构建下 Worker 产物目录(绝对路径) */
1032
- customDistPath?: (root: string, outDir: string, base: string) => string;
1071
+ /** 启用的 Monaco 语言 Worker,默认启用全部 */
1072
+ languageWorkers?: MonacoEditorLanguageWorker[];
1073
+ /** 额外自定义 Worker(如 monaco-graphql/esm/graphql.worker) */
1074
+ customWorkers?: MonacoCustomWorker[];
1075
+ /** Worker 在 URL 上的公共路径,默认 'monacoeditorwork'。可填 CDN 绝对 URL */
1076
+ publicPath?: string;
1077
+ /** 是否将 Monaco API 暴露到 window.monaco(兼容 0.22 之前的 globalAPI 模式) */
1078
+ globalAPI?: boolean;
1079
+ /** publicPath 是 CDN 时仍强制本地打包 Worker 产物 */
1080
+ forceBuildCDN?: boolean;
1081
+ /** 自定义生产构建下 Worker 产物目录(绝对路径) */
1082
+ customDistPath?: (root: string, outDir: string, base: string) => string;
1033
1083
  }
1034
1084
  declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
1035
-
1085
+ //#endregion
1086
+ //#region src/plugins/rsc.d.ts
1036
1087
  interface RscPluginOptions {
1037
- /** Vite RSC 风格的三环境入口简写。 */
1038
- entries?: Partial<Record<'client' | 'ssr' | 'rsc', string | string[]>>;
1039
- /** 自定义环境名;默认 client / ssr / rsc。 */
1040
- environment?: Partial<Record<'client' | 'ssr' | 'rsc', string>>;
1041
- /** 扫描 client/server directive 的源码目录;默认扫描 app 与 src。 */
1042
- scanDirectories?: string[];
1043
- include?: ReactFileFilter;
1044
- exclude?: ReactFileFilter;
1045
- /** 可检查的引用清单;false 可关闭写出。 @default 'rsc-manifest.json' */
1046
- manifestFile?: string | false;
1088
+ /** Vite RSC 风格的三环境入口简写。 */
1089
+ entries?: Partial<Record<'client' | 'ssr' | 'rsc', string | string[]>>;
1090
+ /** 自定义环境名;默认 client / ssr / rsc。 */
1091
+ environment?: Partial<Record<'client' | 'ssr' | 'rsc', string>>;
1092
+ /** 扫描 client/server directive 的源码目录;默认扫描 app 与 src。 */
1093
+ scanDirectories?: string[];
1094
+ include?: ReactFileFilter;
1095
+ exclude?: ReactFileFilter;
1096
+ /** 可检查的引用清单;false 可关闭写出。 @default 'rsc-manifest.json' */
1097
+ manifestFile?: string | false;
1047
1098
  }
1048
1099
  interface RscManifestReference {
1049
- id: string;
1050
- name: string;
1051
- chunks: string[];
1100
+ id: string;
1101
+ name: string;
1102
+ chunks: string[];
1052
1103
  }
1053
1104
  interface RscManifest {
1054
- version: 1;
1055
- environments: {
1056
- client: string;
1057
- ssr: string;
1058
- rsc: string;
1059
- };
1060
- clientReferences: Record<string, RscManifestReference>;
1061
- serverReferences: Record<string, RscManifestReference>;
1105
+ version: 1;
1106
+ environments: {
1107
+ client: string;
1108
+ ssr: string;
1109
+ rsc: string;
1110
+ };
1111
+ clientReferences: Record<string, RscManifestReference>;
1112
+ serverReferences: Record<string, RscManifestReference>;
1062
1113
  }
1063
1114
  /**
1064
1115
  * React Server Components 的低层生成器。
@@ -1068,7 +1119,8 @@ interface RscManifest {
1068
1119
  * 图生成 server reference proxy,并在 buildApp 收尾阶段写出稳定清单。
1069
1120
  */
1070
1121
  declare function rsc(options?: RscPluginOptions): NastiPlugin;
1071
-
1122
+ //#endregion
1123
+ //#region src/core/hot-channel.d.ts
1072
1124
  /** 非 client 环境的占位通道(SSR/edge 可由 runner/driver 接上真实 transport) */
1073
1125
  declare function createNoopHotChannel(): HotChannel;
1074
1126
  /**
@@ -1076,16 +1128,18 @@ declare function createNoopHotChannel(): HotChannel;
1076
1128
  * 事件监听与 invoke 在现有 ws 协议上预留,payload 以 environment 字段分流。
1077
1129
  */
1078
1130
  declare function createWsHotChannel(ws: WebSocketServer, environmentName?: string): HotChannel;
1079
-
1131
+ //#endregion
1132
+ //#region src/core/debug.d.ts
1080
1133
  type NastiDebugScope = `nasti:${string}`;
1081
1134
  interface DebuggerOptions {
1082
- /** 仅当 DEBUG 精确包含该命名空间(而非 nasti:* 通配)时才启用 */
1083
- onlyWhenFocused?: boolean | string;
1135
+ /** 仅当 DEBUG 精确包含该命名空间(而非 nasti:* 通配)时才启用 */
1136
+ onlyWhenFocused?: boolean | string;
1084
1137
  }
1085
1138
  declare function createDebugger(namespace: NastiDebugScope, options?: DebuggerOptions): ((...args: unknown[]) => void) | undefined;
1086
-
1139
+ //#endregion
1140
+ //#region src/core/env.d.ts
1087
1141
  interface EnvRecord {
1088
- [key: string]: string;
1142
+ [key: string]: string;
1089
1143
  }
1090
1144
  /**
1091
1145
  * 从 .env 文件加载环境变量,按优先级合并:
@@ -1104,5 +1158,6 @@ declare function loadEnv(mode: string, root: string, prefixes: string[]): EnvRec
1104
1158
  declare function buildEnvDefine(env: EnvRecord, mode: string, overrides?: Record<string, string>): Record<string, string>;
1105
1159
  /** 按环境 consumer 派生 import.meta.env.SSR 的 define 覆盖 */
1106
1160
  declare function ssrDefineOverrides(consumer: 'client' | 'server'): Record<string, string>;
1107
-
1108
- export { type AppBuildOutput, type AppHmrContext, type BuildAppContext, type BuildConfig, type BuildResult, type DevServer, type ElectronConfig, type EnvironmentAssetMetadata, type EnvironmentBuildMetadata, type EnvironmentBuildOutput, type EnvironmentBuildResult, type EnvironmentChunkMetadata, type EnvironmentCssChunk, type EnvironmentCssMetadata, type EnvironmentCssModule, type EnvironmentDriver, type EnvironmentDriverContext, type EnvironmentDriverServeContext, type EnvironmentHotUpdateResult, type EnvironmentInstance, type EnvironmentOptions, type EnvironmentServeResult, type EnvironmentTransformedModule, type HmrPayload, type HmrUpdate, type HotChannel, type HotChannelClient, type HotChannelInvokeHandlers, type LogLevel, LogLevels, type LogOptions, type Logger, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, NastiEnvironment, type NastiPlugin, type NastiRolldownOptions, type PluginApi, type PluginApiKey, type PluginContext, type ReactCompilerOptions, type ReactFileFilter, type ReactOptions, type RenderChunkContext, type ResolvedConfig, type ResolvedEnvironmentOptions, type ResolvedReactOptions, type RscManifest, type RscManifestReference, type RscPluginOptions, type TransformResult, type VueEnvironmentOptions, type VueSfcSourceTransform, type VueSfcTransformContext, build, buildElectron, buildEnvDefine, createDebugger, createElectronRendererConfig, createLogger, createNoopHotChannel, createServer, createWsHotChannel, defineConfig, detectFramework, electronPlugin, electronRendererDevPath, loadEnv, monacoEditorPlugin, printServerUrls, resolveConfig, resolveEnvironmentPlugins, rsc, ssrDefineOverrides, startElectronDev };
1161
+ //#endregion
1162
+ export { type AppBuildOutput, type AppHmrContext, type BuildAppContext, type BuildConfig, type BuildResult, type DevServer, type ElectronConfig, type EnvironmentAssetMetadata, type EnvironmentBuildMetadata, type EnvironmentBuildOutput, type EnvironmentBuildResult, type EnvironmentChunkMetadata, type EnvironmentCssChunk, type EnvironmentCssMetadata, type EnvironmentCssModule, type EnvironmentDriver, type EnvironmentDriverContext, type EnvironmentDriverServeContext, type EnvironmentHotUpdateResult, type EnvironmentInstance, type EnvironmentOptions, type EnvironmentServeResult, type EnvironmentTransformedModule, type HmrPayload, type HmrUpdate, type HotChannel, type HotChannelClient, type HotChannelInvokeHandlers, type LogLevel, LogLevels, type LogOptions, type Logger, type MinifyOption, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, NastiEnvironment, type NastiMinifyOptions, type NastiPlugin, type NastiRolldownOptions, type PluginApi, type PluginApiKey, type PluginContext, type ReactCompilerOptions, type ReactFileFilter, type ReactOptions, type RenderChunkContext, type ResolvedConfig, type ResolvedEnvironmentOptions, type ResolvedMinifyOption, type ResolvedReactOptions, type RscManifest, type RscManifestReference, type RscPluginOptions, type TransformResult, type VueEnvironmentOptions, type VueSfcSourceTransform, type VueSfcTransformContext, build, buildElectron, buildEnvDefine, createDebugger, createElectronRendererConfig, createLogger, createNoopHotChannel, createServer, createWsHotChannel, defineConfig, detectFramework, electronPlugin, electronRendererDevPath, loadEnv, monacoEditorPlugin, printServerUrls, resolveConfig, resolveEnvironmentPlugins, rsc, ssrDefineOverrides, startElectronDev };
1163
+ //# sourceMappingURL=index.d.cts.map