@nasti-toolchain/nasti 2.4.3 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -49,6 +49,8 @@ interface NastiConfig {
49
49
  target?: 'web' | 'electron';
50
50
  /** 框架自动检测或手动指定 */
51
51
  framework?: 'react' | 'vue' | 'auto';
52
+ /** React JSX / Fast Refresh / Compiler 管线。仅在 framework 解析为 react 时生效。 */
53
+ react?: ReactOptions;
52
54
  /** 路径解析配置 */
53
55
  resolve?: ResolveConfig;
54
56
  /** 插件列表 */
@@ -78,6 +80,50 @@ interface NastiConfig {
78
80
  /** 实验特性(无稳定性保证,随时可能变更/移除) */
79
81
  experimental?: ExperimentalOptions;
80
82
  }
83
+ type ReactFileFilter = string | RegExp | Array<string | RegExp>;
84
+ /**
85
+ * 原生 React Compiler 的公共配置子集。其余实验字段会原样传给
86
+ * `oxc-transform-react`,无需让 Nasti 与编译器的快速迭代强耦合。
87
+ */
88
+ 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;
106
+ }
107
+ /** React 管线选项;命名与 @vitejs/plugin-react 保持一致。 */
108
+ 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;
119
+ }
120
+ interface ResolvedReactOptions {
121
+ include: ReactFileFilter;
122
+ exclude: ReactFileFilter;
123
+ jsxImportSource: string;
124
+ jsxRuntime: 'automatic' | 'classic';
125
+ compiler: false | ReactCompilerOptions;
126
+ }
81
127
  interface ExperimentalOptions {
82
128
  /**
83
129
  * dev 用 Rolldown `dev()` 引擎整体打包 client 环境后从内存服务
@@ -607,6 +653,8 @@ interface ResolvedConfig {
607
653
  target: 'web' | 'electron';
608
654
  /** `auto` 在配置解析阶段已收敛为具体框架 */
609
655
  framework: 'react' | 'vue';
656
+ /** 解析后的 React 管线配置;Vue 项目仍保留该字段以简化插件读取。 */
657
+ react: ResolvedReactOptions;
610
658
  command: 'build' | 'serve';
611
659
  resolve: Required<ResolveConfig>;
612
660
  plugins: NastiPlugin[];
@@ -811,6 +859,13 @@ declare class ModuleGraph {
811
859
  getModuleByUrl(url: string): ModuleNode | undefined;
812
860
  getModuleById(id: string): ModuleNode | undefined;
813
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>;
814
869
  ensureEntryFromUrl(url: string): Promise<ModuleNode>;
815
870
  createModule(url: string, id?: string): ModuleNode;
816
871
  /** 注册文件路径到模块的映射 */
@@ -978,6 +1033,42 @@ interface MonacoEditorPluginOptions {
978
1033
  }
979
1034
  declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
980
1035
 
1036
+ 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;
1047
+ }
1048
+ interface RscManifestReference {
1049
+ id: string;
1050
+ name: string;
1051
+ chunks: string[];
1052
+ }
1053
+ 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>;
1062
+ }
1063
+ /**
1064
+ * React Server Components 的低层生成器。
1065
+ *
1066
+ * 它只在显式安装时启用:RSC 环境中的 `"use client"` 模块会变成 client
1067
+ * reference proxy,文件级 `"use server"` 导出会在 RSC 图注册、在 client/SSR
1068
+ * 图生成 server reference proxy,并在 buildApp 收尾阶段写出稳定清单。
1069
+ */
1070
+ declare function rsc(options?: RscPluginOptions): NastiPlugin;
1071
+
981
1072
  /** 非 client 环境的占位通道(SSR/edge 可由 runner/driver 接上真实 transport) */
982
1073
  declare function createNoopHotChannel(): HotChannel;
983
1074
  /**
@@ -1014,4 +1105,4 @@ declare function buildEnvDefine(env: EnvRecord, mode: string, overrides?: Record
1014
1105
  /** 按环境 consumer 派生 import.meta.env.SSR 的 define 覆盖 */
1015
1106
  declare function ssrDefineOverrides(consumer: 'client' | 'server'): Record<string, string>;
1016
1107
 
1017
- 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -49,6 +49,8 @@ interface NastiConfig {
49
49
  target?: 'web' | 'electron';
50
50
  /** 框架自动检测或手动指定 */
51
51
  framework?: 'react' | 'vue' | 'auto';
52
+ /** React JSX / Fast Refresh / Compiler 管线。仅在 framework 解析为 react 时生效。 */
53
+ react?: ReactOptions;
52
54
  /** 路径解析配置 */
53
55
  resolve?: ResolveConfig;
54
56
  /** 插件列表 */
@@ -78,6 +80,50 @@ interface NastiConfig {
78
80
  /** 实验特性(无稳定性保证,随时可能变更/移除) */
79
81
  experimental?: ExperimentalOptions;
80
82
  }
83
+ type ReactFileFilter = string | RegExp | Array<string | RegExp>;
84
+ /**
85
+ * 原生 React Compiler 的公共配置子集。其余实验字段会原样传给
86
+ * `oxc-transform-react`,无需让 Nasti 与编译器的快速迭代强耦合。
87
+ */
88
+ 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;
106
+ }
107
+ /** React 管线选项;命名与 @vitejs/plugin-react 保持一致。 */
108
+ 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;
119
+ }
120
+ interface ResolvedReactOptions {
121
+ include: ReactFileFilter;
122
+ exclude: ReactFileFilter;
123
+ jsxImportSource: string;
124
+ jsxRuntime: 'automatic' | 'classic';
125
+ compiler: false | ReactCompilerOptions;
126
+ }
81
127
  interface ExperimentalOptions {
82
128
  /**
83
129
  * dev 用 Rolldown `dev()` 引擎整体打包 client 环境后从内存服务
@@ -607,6 +653,8 @@ interface ResolvedConfig {
607
653
  target: 'web' | 'electron';
608
654
  /** `auto` 在配置解析阶段已收敛为具体框架 */
609
655
  framework: 'react' | 'vue';
656
+ /** 解析后的 React 管线配置;Vue 项目仍保留该字段以简化插件读取。 */
657
+ react: ResolvedReactOptions;
610
658
  command: 'build' | 'serve';
611
659
  resolve: Required<ResolveConfig>;
612
660
  plugins: NastiPlugin[];
@@ -811,6 +859,13 @@ declare class ModuleGraph {
811
859
  getModuleByUrl(url: string): ModuleNode | undefined;
812
860
  getModuleById(id: string): ModuleNode | undefined;
813
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>;
814
869
  ensureEntryFromUrl(url: string): Promise<ModuleNode>;
815
870
  createModule(url: string, id?: string): ModuleNode;
816
871
  /** 注册文件路径到模块的映射 */
@@ -978,6 +1033,42 @@ interface MonacoEditorPluginOptions {
978
1033
  }
979
1034
  declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
980
1035
 
1036
+ 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;
1047
+ }
1048
+ interface RscManifestReference {
1049
+ id: string;
1050
+ name: string;
1051
+ chunks: string[];
1052
+ }
1053
+ 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>;
1062
+ }
1063
+ /**
1064
+ * React Server Components 的低层生成器。
1065
+ *
1066
+ * 它只在显式安装时启用:RSC 环境中的 `"use client"` 模块会变成 client
1067
+ * reference proxy,文件级 `"use server"` 导出会在 RSC 图注册、在 client/SSR
1068
+ * 图生成 server reference proxy,并在 buildApp 收尾阶段写出稳定清单。
1069
+ */
1070
+ declare function rsc(options?: RscPluginOptions): NastiPlugin;
1071
+
981
1072
  /** 非 client 环境的占位通道(SSR/edge 可由 runner/driver 接上真实 transport) */
982
1073
  declare function createNoopHotChannel(): HotChannel;
983
1074
  /**
@@ -1014,4 +1105,4 @@ declare function buildEnvDefine(env: EnvRecord, mode: string, overrides?: Record
1014
1105
  /** 按环境 consumer 派生 import.meta.env.SSR 的 define 覆盖 */
1015
1106
  declare function ssrDefineOverrides(consumer: 'client' | 'server'): Record<string, string>;
1016
1107
 
1017
- 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 };
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 };