@nasti-toolchain/nasti 2.3.1 → 2.4.1
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/README.md +97 -1
- package/bin/nasti.js +0 -0
- package/client/hmr.ts +4 -3
- package/dist/cli.cjs +1896 -583
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1891 -575
- package/dist/cli.js.map +1 -1
- package/dist/client/hmr.cjs.map +1 -1
- package/dist/client/hmr.d.cts +4 -3
- package/dist/client/hmr.d.ts +4 -3
- package/dist/index.cjs +1810 -497
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -18
- package/dist/index.d.ts +233 -18
- package/dist/index.js +1810 -494
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { InputOptions, OutputOptions
|
|
1
|
+
import { RenderedChunk, InputOptions, OutputOptions } from 'rolldown';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import { SFCParseOptions, SFCScriptCompileOptions, SFCTemplateCompileOptions, SFCAsyncStyleCompileOptions } from '@vue/compiler-sfc';
|
|
3
4
|
|
|
4
5
|
type LogType = 'error' | 'warn' | 'info';
|
|
5
6
|
type LogLevel = LogType | 'silent';
|
|
@@ -82,7 +83,7 @@ interface ExperimentalOptions {
|
|
|
82
83
|
* dev 用 Rolldown `dev()` 引擎整体打包 client 环境后从内存服务
|
|
83
84
|
* (完整打包模式 / Full Bundle Mode)。HMR 由引擎的 patch 机制驱动,
|
|
84
85
|
* 动态 import 走懒编译端点。依赖 rolldown 实验 API(无 semver 保护,
|
|
85
|
-
*
|
|
86
|
+
* Nasti 会精确锁定经过验证的 Rolldown 版本)。unbundled 管线保持默认。
|
|
86
87
|
* @experimental
|
|
87
88
|
* @default false
|
|
88
89
|
*/
|
|
@@ -105,6 +106,11 @@ interface EnvironmentOptions {
|
|
|
105
106
|
* Electron renderer 会把 `electron.renderer` 映射到这里。
|
|
106
107
|
*/
|
|
107
108
|
html?: string;
|
|
109
|
+
/**
|
|
110
|
+
* 是否参与生产构建。默认 true;设为 false 可跳过默认 client,构建纯多环境应用。
|
|
111
|
+
* 仅影响 `nasti build`,不影响 dev server 中环境实例的可见性。
|
|
112
|
+
*/
|
|
113
|
+
buildEnabled?: boolean;
|
|
108
114
|
/**
|
|
109
115
|
* 外部环境编译驱动标识。声明后由插件的 `createEnvironmentDriver` 提供实际实现,
|
|
110
116
|
* 可用于接入 Rspeedy 等不基于 Rolldown 的构建系统。
|
|
@@ -114,10 +120,45 @@ interface EnvironmentOptions {
|
|
|
114
120
|
resolve?: ResolveConfig;
|
|
115
121
|
/** per-env 构建覆盖(未设置的字段回退 top-level build) */
|
|
116
122
|
build?: BuildConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Vue SFC 编译扩展点。每个环境可独立设置 compiler-sfc 选项与源码变换,
|
|
125
|
+
* 同一个 SFC 的虚拟模块 id / scope id 不包含环境名,因而在多图之间保持稳定。
|
|
126
|
+
*/
|
|
127
|
+
vue?: VueEnvironmentOptions;
|
|
128
|
+
}
|
|
129
|
+
interface VueSfcTransformContext {
|
|
130
|
+
filename: string;
|
|
131
|
+
environmentName: string;
|
|
132
|
+
type: 'sfc' | 'template' | 'style';
|
|
133
|
+
index?: number;
|
|
134
|
+
}
|
|
135
|
+
type VueSfcSourceTransform = (source: string, context: VueSfcTransformContext) => string
|
|
136
|
+
/**
|
|
137
|
+
* Object results may provide a source map from `code` back to `source`.
|
|
138
|
+
* Nasti composes it with compiler-sfc maps where that stage supports chaining.
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
code: string;
|
|
142
|
+
map?: unknown;
|
|
143
|
+
} | Promise<string | {
|
|
144
|
+
code: string;
|
|
145
|
+
map?: unknown;
|
|
146
|
+
}>;
|
|
147
|
+
/** 直接透传给 `@vue/compiler-sfc` 对应阶段的 per-environment 选项。 */
|
|
148
|
+
interface VueEnvironmentOptions {
|
|
149
|
+
parse?: SFCParseOptions;
|
|
150
|
+
script?: Partial<SFCScriptCompileOptions>;
|
|
151
|
+
template?: Partial<SFCTemplateCompileOptions>;
|
|
152
|
+
style?: Partial<SFCAsyncStyleCompileOptions>;
|
|
153
|
+
transformSfc?: VueSfcSourceTransform;
|
|
154
|
+
transformTemplate?: VueSfcSourceTransform;
|
|
155
|
+
transformStyle?: VueSfcSourceTransform;
|
|
117
156
|
}
|
|
118
157
|
/** 解析后的环境配置 */
|
|
119
158
|
interface ResolvedEnvironmentOptions {
|
|
120
159
|
consumer: 'client' | 'server';
|
|
160
|
+
/** 是否参与生产构建 */
|
|
161
|
+
buildEnabled: boolean;
|
|
121
162
|
/** 环境构建入口(绝对路径);client 未显式配置时为空并从 HTML 提取 */
|
|
122
163
|
entry: string[];
|
|
123
164
|
/** HTML 入口绝对路径(仅 client consumer 有值) */
|
|
@@ -126,6 +167,7 @@ interface ResolvedEnvironmentOptions {
|
|
|
126
167
|
driver?: string;
|
|
127
168
|
resolve: Required<ResolveConfig>;
|
|
128
169
|
build: Required<BuildConfig>;
|
|
170
|
+
vue: VueEnvironmentOptions;
|
|
129
171
|
}
|
|
130
172
|
/** Electron 目标专用配置,支持 Electron 41+ */
|
|
131
173
|
interface ElectronConfig {
|
|
@@ -224,10 +266,21 @@ interface CssConfig {
|
|
|
224
266
|
/** CSP nonce to add to inline <style> tags (dev only since 2.0 — build emits real .css files) */
|
|
225
267
|
nonce?: string;
|
|
226
268
|
/**
|
|
227
|
-
* @deprecated
|
|
228
|
-
*
|
|
269
|
+
* @deprecated 请改用 `css.emit` 控制是否写出 CSS 文件。控制拆分用
|
|
270
|
+
* `build.cssCodeSplit`,控制压缩用 `build.cssMinify`。
|
|
229
271
|
*/
|
|
230
272
|
emitCssFile?: boolean;
|
|
273
|
+
/**
|
|
274
|
+
* 是否在浏览器运行时 / HTML 中注入 CSS。原生 client 环境可关闭注入,
|
|
275
|
+
* 同时继续保留 CSS 模块图与结构化元数据。
|
|
276
|
+
* @default true
|
|
277
|
+
*/
|
|
278
|
+
inject?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* 是否写出 `.css` 文件。关闭后仍收集每个 chunk 的 CSS 所有权。
|
|
281
|
+
* @default true
|
|
282
|
+
*/
|
|
283
|
+
emit?: boolean;
|
|
231
284
|
}
|
|
232
285
|
interface NastiPlugin {
|
|
233
286
|
name: string;
|
|
@@ -302,7 +355,7 @@ interface NastiPlugin {
|
|
|
302
355
|
* 所有环境构建完成后的 app 级收尾钩子,用于跨环境聚合产物。
|
|
303
356
|
* Vue Lynx 原生后端可在这里组合 background/main-thread bundle。
|
|
304
357
|
*/
|
|
305
|
-
afterBuildApp?: (results: Record<string, EnvironmentBuildResult>, api: PluginApi) => void | Promise<void>;
|
|
358
|
+
afterBuildApp?: (results: Record<string, EnvironmentBuildResult>, api: PluginApi, context: BuildAppContext) => void | Promise<void>;
|
|
306
359
|
configureServer?: (server: DevServer) => void | (() => void) | Promise<void | (() => void)>;
|
|
307
360
|
transformIndexHtml?: (html: string) => string | HtmlTagDescriptor[] | {
|
|
308
361
|
html: string;
|
|
@@ -312,6 +365,11 @@ interface NastiPlugin {
|
|
|
312
365
|
tags: HtmlTagDescriptor[];
|
|
313
366
|
}>;
|
|
314
367
|
handleHotUpdate?: (ctx: HmrContext) => void | ModuleNode[] | Promise<void | ModuleNode[]>;
|
|
368
|
+
/**
|
|
369
|
+
* 一个文件在所有 dev client 环境完成失效、插件 HMR 钩子与重新转换后调用一次。
|
|
370
|
+
* 多运行时工具链可据此只重编码受影响的 native section。
|
|
371
|
+
*/
|
|
372
|
+
handleHotUpdateApp?: (ctx: AppHmrContext) => void | Promise<void>;
|
|
315
373
|
}
|
|
316
374
|
interface PluginContext {
|
|
317
375
|
resolve: (source: string, importer?: string) => Promise<ResolveIdResult>;
|
|
@@ -336,14 +394,83 @@ interface EnvironmentBuildOutput {
|
|
|
336
394
|
type: string;
|
|
337
395
|
code?: string;
|
|
338
396
|
source?: Uint8Array | string;
|
|
397
|
+
map?: unknown;
|
|
398
|
+
name?: string;
|
|
399
|
+
names?: string[];
|
|
400
|
+
isEntry?: boolean;
|
|
401
|
+
isDynamicEntry?: boolean;
|
|
402
|
+
imports?: string[];
|
|
403
|
+
dynamicImports?: string[];
|
|
404
|
+
moduleIds?: string[];
|
|
339
405
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
406
|
+
interface EnvironmentCssModule {
|
|
407
|
+
id: string;
|
|
408
|
+
source: string;
|
|
409
|
+
code: string;
|
|
410
|
+
}
|
|
411
|
+
interface EnvironmentCssChunk {
|
|
412
|
+
fileName: string;
|
|
413
|
+
moduleIds: string[];
|
|
414
|
+
cssFileNames: string[];
|
|
415
|
+
}
|
|
416
|
+
interface EnvironmentCssMetadata {
|
|
417
|
+
modules: Record<string, EnvironmentCssModule>;
|
|
418
|
+
chunks: Record<string, EnvironmentCssChunk>;
|
|
419
|
+
}
|
|
420
|
+
interface EnvironmentChunkMetadata {
|
|
421
|
+
fileName: string;
|
|
422
|
+
name: string;
|
|
423
|
+
isEntry: boolean;
|
|
424
|
+
isDynamicEntry: boolean;
|
|
425
|
+
imports: string[];
|
|
426
|
+
dynamicImports: string[];
|
|
427
|
+
moduleIds: string[];
|
|
428
|
+
css: string[];
|
|
429
|
+
assets: string[];
|
|
430
|
+
}
|
|
431
|
+
interface EnvironmentAssetMetadata {
|
|
432
|
+
fileName: string;
|
|
433
|
+
names: string[];
|
|
434
|
+
publicPath: string;
|
|
435
|
+
}
|
|
436
|
+
/** 单个环境附加到标准构建结果上的结构化元数据。 */
|
|
437
|
+
interface EnvironmentBuildMetadata {
|
|
343
438
|
entries?: Record<string, string>;
|
|
344
439
|
publicPath?: string;
|
|
345
440
|
manifest?: unknown;
|
|
346
441
|
stats?: unknown;
|
|
442
|
+
chunks?: Record<string, EnvironmentChunkMetadata>;
|
|
443
|
+
assets?: Record<string, EnvironmentAssetMetadata>;
|
|
444
|
+
css?: EnvironmentCssMetadata;
|
|
445
|
+
sourceMaps?: Record<string, unknown>;
|
|
446
|
+
}
|
|
447
|
+
/** 外部环境驱动或原生 Rolldown 环境返回的标准构建结果。 */
|
|
448
|
+
interface EnvironmentBuildResult extends EnvironmentBuildMetadata {
|
|
449
|
+
output: EnvironmentBuildOutput[];
|
|
450
|
+
}
|
|
451
|
+
/** app 级 finalizer 写出的聚合产物。 */
|
|
452
|
+
interface AppBuildOutput extends EnvironmentBuildOutput {
|
|
453
|
+
type: 'asset';
|
|
454
|
+
source: Uint8Array | string;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* 所有环境完成后提供给 `afterBuildApp` 的只读查询与产物写出接口。
|
|
458
|
+
* Lynx 等多运行时工具链可用它聚合 background/main-thread 结果,而无需读取磁盘目录。
|
|
459
|
+
*/
|
|
460
|
+
interface BuildAppContext {
|
|
461
|
+
readonly config: ResolvedConfig;
|
|
462
|
+
readonly results: Readonly<Record<string, EnvironmentBuildResult>>;
|
|
463
|
+
readonly output: readonly AppBuildOutput[];
|
|
464
|
+
getResult: (environmentName: string) => EnvironmentBuildResult | undefined;
|
|
465
|
+
getArtifact: (environmentName: string, fileName: string) => EnvironmentBuildOutput | undefined;
|
|
466
|
+
getEntry: (environmentName: string, entryName: string) => EnvironmentBuildOutput | undefined;
|
|
467
|
+
getManifest: <T = unknown>(environmentName: string) => T | undefined;
|
|
468
|
+
getChunk: (environmentName: string, fileName: string) => EnvironmentChunkMetadata | undefined;
|
|
469
|
+
getCss: (environmentName: string) => EnvironmentCssMetadata | undefined;
|
|
470
|
+
getSourceMap: (environmentName: string, fileName: string) => unknown;
|
|
471
|
+
resolvePublicPath: (environmentName: string, fileName: string) => string | undefined;
|
|
472
|
+
/** 将聚合产物安全地写入 top-level `build.outDir`,并纳入 BuildResult.appOutput。 */
|
|
473
|
+
emitFile: (file: AppBuildOutput) => string;
|
|
347
474
|
}
|
|
348
475
|
/** 外部环境驱动返回的开发服务信息。 */
|
|
349
476
|
interface EnvironmentServeResult {
|
|
@@ -380,6 +507,24 @@ interface EnvironmentInstance {
|
|
|
380
507
|
hot: HotChannel;
|
|
381
508
|
/** 声明 driver 后,由插件提供的外部环境编译驱动 */
|
|
382
509
|
driver?: EnvironmentDriver;
|
|
510
|
+
/** per-environment dev 模块图与插件列表。 */
|
|
511
|
+
moduleGraph: ModuleGraph$1;
|
|
512
|
+
plugins: NastiPlugin[];
|
|
513
|
+
/**
|
|
514
|
+
* 在该环境的独立 transform 管线中请求模块。仅 dev 环境在初始化后可用。
|
|
515
|
+
*/
|
|
516
|
+
transformRequest: (url: string) => Promise<{
|
|
517
|
+
code: string;
|
|
518
|
+
map?: unknown;
|
|
519
|
+
} | null>;
|
|
520
|
+
/** 内置 CSS 管线登记模块;工具链通常读取 getCssModule(s)。 */
|
|
521
|
+
setCssModule: (module: EnvironmentCssModule) => void;
|
|
522
|
+
getCssModule: (id: string) => EnvironmentCssModule | undefined;
|
|
523
|
+
getCssModules: () => Readonly<Record<string, EnvironmentCssModule>>;
|
|
524
|
+
setAssetModule: (id: string, fileName: string) => void;
|
|
525
|
+
getAssetModules: () => Readonly<Record<string, string>>;
|
|
526
|
+
/** 由生产插件登记 entries / manifest / stats,构建完成后合并进环境结果。 */
|
|
527
|
+
setBuildMetadata: (metadata: EnvironmentBuildMetadata) => void;
|
|
383
528
|
}
|
|
384
529
|
/**
|
|
385
530
|
* renderChunk / augmentChunkHash 的 `this`:Rolldown 真实插件上下文的最小可用面。
|
|
@@ -389,6 +534,8 @@ interface EnvironmentInstance {
|
|
|
389
534
|
interface RenderChunkContext {
|
|
390
535
|
emitFile: (file: EmittedFile) => string;
|
|
391
536
|
getFileName: (referenceId: string) => string;
|
|
537
|
+
/** 当前生产钩子所属环境;BG/MT 同为 client consumer 时也可准确区分。 */
|
|
538
|
+
environment: EnvironmentInstance;
|
|
392
539
|
}
|
|
393
540
|
interface ResolveIdOptions {
|
|
394
541
|
isEntry?: boolean;
|
|
@@ -436,6 +583,8 @@ interface ModuleNode {
|
|
|
436
583
|
acceptedHmrDeps: Set<ModuleNode>;
|
|
437
584
|
transformResult: TransformResult | null;
|
|
438
585
|
lastHMRTimestamp: number;
|
|
586
|
+
/** 每次失效递增,防止较慢的旧转换覆盖较新的缓存。 */
|
|
587
|
+
invalidationVersion: number;
|
|
439
588
|
isSelfAccepting: boolean;
|
|
440
589
|
/** Environment API:节点所属环境名(per-env 模块图,默认 'client') */
|
|
441
590
|
environment?: string;
|
|
@@ -476,13 +625,14 @@ interface DevServer {
|
|
|
476
625
|
moduleGraph: ModuleGraph$1;
|
|
477
626
|
watcher: any;
|
|
478
627
|
ws: WebSocketServer;
|
|
479
|
-
/** Environment API
|
|
628
|
+
/** Environment API:每个 client-consumer 环境都有独立的 transform/HMR 管线。 */
|
|
480
629
|
environments: Record<string, EnvironmentInstance>;
|
|
481
630
|
/** 外部环境驱动启动后返回的服务 URL / middleware 信息 */
|
|
482
631
|
environmentServices: Record<string, EnvironmentServeResult>;
|
|
483
632
|
listen: (port?: number) => Promise<DevServer>;
|
|
484
633
|
close: () => Promise<void>;
|
|
485
634
|
transformRequest: (url: string) => Promise<TransformResult>;
|
|
635
|
+
transformEnvironmentRequest: (environmentName: string, url: string) => Promise<TransformResult>;
|
|
486
636
|
/**
|
|
487
637
|
* SSR:在 server consumer 环境(默认 `ssr`)中加载并执行模块,返回其导出。
|
|
488
638
|
* Vite `server.ssrLoadModule` 的 back-compat shim(底层是 module runner +
|
|
@@ -496,7 +646,12 @@ interface ModuleGraph$1 {
|
|
|
496
646
|
getModuleById: (id: string) => ModuleNode | undefined;
|
|
497
647
|
getModulesByFile: (file: string) => Set<ModuleNode> | undefined;
|
|
498
648
|
ensureEntryFromUrl: (url: string) => Promise<ModuleNode>;
|
|
499
|
-
invalidateModule: (mod: ModuleNode) => void;
|
|
649
|
+
invalidateModule: (mod: ModuleNode, timestamp?: number) => void;
|
|
650
|
+
invalidateModuleAndImporters: (mod: ModuleNode, timestamp?: number) => void;
|
|
651
|
+
getHmrBoundaries: (mod: ModuleNode) => Array<{
|
|
652
|
+
boundary: ModuleNode;
|
|
653
|
+
acceptedVia: ModuleNode;
|
|
654
|
+
}>;
|
|
500
655
|
invalidateAll: () => void;
|
|
501
656
|
}
|
|
502
657
|
interface WebSocketServer {
|
|
@@ -535,8 +690,29 @@ interface HmrContext {
|
|
|
535
690
|
modules: ModuleNode[];
|
|
536
691
|
read: () => string | Promise<string>;
|
|
537
692
|
server: DevServer;
|
|
693
|
+
environment: EnvironmentInstance;
|
|
694
|
+
}
|
|
695
|
+
interface EnvironmentTransformedModule {
|
|
696
|
+
module: ModuleNode;
|
|
697
|
+
result: {
|
|
698
|
+
code: string;
|
|
699
|
+
map?: unknown;
|
|
700
|
+
} | null;
|
|
701
|
+
}
|
|
702
|
+
interface EnvironmentHotUpdateResult {
|
|
703
|
+
environment: EnvironmentInstance;
|
|
704
|
+
modules: ModuleNode[];
|
|
705
|
+
updates: HmrUpdate[];
|
|
706
|
+
transformed: EnvironmentTransformedModule[];
|
|
707
|
+
fullReload: boolean;
|
|
708
|
+
}
|
|
709
|
+
interface AppHmrContext {
|
|
710
|
+
file: string;
|
|
711
|
+
timestamp: number;
|
|
712
|
+
environments: Readonly<Record<string, EnvironmentHotUpdateResult>>;
|
|
713
|
+
server: DevServer;
|
|
538
714
|
}
|
|
539
|
-
type HmrPayload = {
|
|
715
|
+
type HmrPayload = ({
|
|
540
716
|
type: 'connected';
|
|
541
717
|
} | {
|
|
542
718
|
type: 'update';
|
|
@@ -553,6 +729,12 @@ type HmrPayload = {
|
|
|
553
729
|
message: string;
|
|
554
730
|
stack?: string;
|
|
555
731
|
};
|
|
732
|
+
} | {
|
|
733
|
+
type: 'custom';
|
|
734
|
+
event: string;
|
|
735
|
+
data?: unknown;
|
|
736
|
+
}) & {
|
|
737
|
+
environment?: string;
|
|
556
738
|
};
|
|
557
739
|
interface HmrUpdate {
|
|
558
740
|
type: 'js-update' | 'css-update';
|
|
@@ -610,9 +792,11 @@ declare class PluginContainer {
|
|
|
610
792
|
}
|
|
611
793
|
|
|
612
794
|
declare class ModuleGraph {
|
|
795
|
+
readonly environmentName: string;
|
|
613
796
|
private urlToModuleMap;
|
|
614
797
|
private idToModuleMap;
|
|
615
798
|
private fileToModulesMap;
|
|
799
|
+
constructor(environmentName?: string);
|
|
616
800
|
getModuleByUrl(url: string): ModuleNode | undefined;
|
|
617
801
|
getModuleById(id: string): ModuleNode | undefined;
|
|
618
802
|
getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
|
@@ -630,8 +814,18 @@ declare class ModuleGraph {
|
|
|
630
814
|
setModuleId(mod: ModuleNode, id: string): void;
|
|
631
815
|
/** 更新模块依赖关系 */
|
|
632
816
|
updateModuleImports(mod: ModuleNode, importedIds: Set<string>): void;
|
|
817
|
+
/**
|
|
818
|
+
* 用一次转换得到的信息原子更新 import 与 HMR accept 关系。
|
|
819
|
+
* 依赖节点会在真正被浏览器请求前预先创建,这样入口模块先转换时也能建立完整图。
|
|
820
|
+
*/
|
|
821
|
+
updateModuleInfo(mod: ModuleNode, importedUrls: Set<string>, acceptedUrls: Set<string>, isSelfAccepting: boolean, expectedInvalidationVersion?: number): Promise<Set<ModuleNode> | null>;
|
|
633
822
|
/** 使模块的转换缓存失效 */
|
|
634
|
-
invalidateModule(mod: ModuleNode): void;
|
|
823
|
+
invalidateModule(mod: ModuleNode, timestamp?: number): void;
|
|
824
|
+
/**
|
|
825
|
+
* 仅失效到 HMR 边界:显式接受依赖的模块本身不会重执行;自接受模块需要失效,
|
|
826
|
+
* 但不再继续影响其 importer。这样既能传播依赖时间戳,也不会隐式重复副作用。
|
|
827
|
+
*/
|
|
828
|
+
invalidateModuleAndImporters(mod: ModuleNode, timestamp?: number, seen?: Set<ModuleNode>): void;
|
|
635
829
|
/** 使所有模块缓存失效 */
|
|
636
830
|
invalidateAll(): void;
|
|
637
831
|
/** 获取 HMR 传播边界 - 从变更模块向上遍历找到接受更新的边界 */
|
|
@@ -665,11 +859,30 @@ declare class NastiEnvironment implements EnvironmentInstance {
|
|
|
665
859
|
moduleGraph: ModuleGraph;
|
|
666
860
|
private candidatePlugins;
|
|
667
861
|
private pluginApi;
|
|
862
|
+
private buildMetadata;
|
|
863
|
+
private cssModules;
|
|
864
|
+
private assetModules;
|
|
865
|
+
private transformRequestHandler?;
|
|
668
866
|
private initialized;
|
|
669
867
|
constructor(name: string, config: ResolvedConfig, init?: NastiEnvironmentInit);
|
|
670
868
|
/** 过滤插件并建 per-env PluginContainer */
|
|
671
869
|
init(): Promise<void>;
|
|
672
870
|
getDriverContext(): EnvironmentDriverContext;
|
|
871
|
+
configureDevPipeline(transformRequest: (url: string) => Promise<{
|
|
872
|
+
code: string;
|
|
873
|
+
map?: unknown;
|
|
874
|
+
} | null>): void;
|
|
875
|
+
transformRequest(url: string): Promise<{
|
|
876
|
+
code: string;
|
|
877
|
+
map?: unknown;
|
|
878
|
+
} | null>;
|
|
879
|
+
setCssModule(module: EnvironmentCssModule): void;
|
|
880
|
+
getCssModule(id: string): EnvironmentCssModule | undefined;
|
|
881
|
+
getCssModules(): Readonly<Record<string, EnvironmentCssModule>>;
|
|
882
|
+
setAssetModule(id: string, fileName: string): void;
|
|
883
|
+
getAssetModules(): Readonly<Record<string, string>>;
|
|
884
|
+
setBuildMetadata(metadata: EnvironmentBuildMetadata): void;
|
|
885
|
+
getBuildMetadata(): EnvironmentBuildMetadata;
|
|
673
886
|
close(): Promise<void>;
|
|
674
887
|
}
|
|
675
888
|
/** 按 applyToEnvironment 过滤环境插件(未声明 = 应用于所有环境) */
|
|
@@ -680,8 +893,10 @@ interface BuildResult {
|
|
|
680
893
|
output: EnvironmentBuildOutput[];
|
|
681
894
|
/** 全部已构建环境的产物(2.0 多环境 builder) */
|
|
682
895
|
environments?: Record<string, BuildResult['output']>;
|
|
683
|
-
/**
|
|
896
|
+
/** 全部环境的完整结果(entries / manifest / stats 等) */
|
|
684
897
|
environmentResults?: Record<string, EnvironmentBuildResult>;
|
|
898
|
+
/** app 级 finalizer 聚合写出的产物(如 `.lynx.bundle`) */
|
|
899
|
+
appOutput?: AppBuildOutput[];
|
|
685
900
|
}
|
|
686
901
|
declare function build(inlineConfig?: NastiConfig): Promise<BuildResult>;
|
|
687
902
|
|
|
@@ -752,13 +967,13 @@ interface MonacoEditorPluginOptions {
|
|
|
752
967
|
}
|
|
753
968
|
declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
|
|
754
969
|
|
|
755
|
-
/** 非 client 环境的占位通道(SSR/edge
|
|
970
|
+
/** 非 client 环境的占位通道(SSR/edge 可由 runner/driver 接上真实 transport) */
|
|
756
971
|
declare function createNoopHotChannel(): HotChannel;
|
|
757
972
|
/**
|
|
758
|
-
* client 环境的 ws 通道:包装 server/ws.ts 的 WebSocketServer。
|
|
759
|
-
* 事件监听与 invoke 在现有 ws
|
|
973
|
+
* client-consumer 环境的 ws 通道:包装 server/ws.ts 的 WebSocketServer。
|
|
974
|
+
* 事件监听与 invoke 在现有 ws 协议上预留,payload 以 environment 字段分流。
|
|
760
975
|
*/
|
|
761
|
-
declare function createWsHotChannel(ws: WebSocketServer): HotChannel;
|
|
976
|
+
declare function createWsHotChannel(ws: WebSocketServer, environmentName?: string): HotChannel;
|
|
762
977
|
|
|
763
978
|
type NastiDebugScope = `nasti:${string}`;
|
|
764
979
|
interface DebuggerOptions {
|
|
@@ -788,4 +1003,4 @@ declare function buildEnvDefine(env: EnvRecord, mode: string, overrides?: Record
|
|
|
788
1003
|
/** 按环境 consumer 派生 import.meta.env.SSR 的 define 覆盖 */
|
|
789
1004
|
declare function ssrDefineOverrides(consumer: 'client' | 'server'): Record<string, string>;
|
|
790
1005
|
|
|
791
|
-
export { type BuildConfig, type DevServer, type ElectronConfig, type EnvironmentBuildOutput, type EnvironmentBuildResult, type EnvironmentDriver, type EnvironmentDriverContext, type EnvironmentDriverServeContext, type EnvironmentInstance, type EnvironmentOptions, type EnvironmentServeResult, type HmrPayload, 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 RenderChunkContext, type ResolvedConfig, type ResolvedEnvironmentOptions, type TransformResult, build, buildElectron, buildEnvDefine, createDebugger, createElectronRendererConfig, createLogger, createNoopHotChannel, createServer, createWsHotChannel, defineConfig, detectFramework, electronPlugin, electronRendererDevPath, loadEnv, monacoEditorPlugin, printServerUrls, resolveConfig, resolveEnvironmentPlugins, ssrDefineOverrides, startElectronDev };
|
|
1006
|
+
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 RenderChunkContext, type ResolvedConfig, type ResolvedEnvironmentOptions, 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, ssrDefineOverrides, startElectronDev };
|