@nasti-toolchain/nasti 2.3.1 → 2.4.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/README.md CHANGED
@@ -303,7 +303,70 @@ export default defineConfig({
303
303
 
304
304
  bridge 插件通过 `createEnvironmentDriver()` 提供 `build`、`serve`、`watchChange`
305
305
  和 `close`,并可使用 `setup(api)`、`api.expose/useExposed` 与
306
- `afterBuildApp()` 协调多个插件或环境。
306
+ `afterBuildApp(results, api, context)` 协调多个插件或环境。
307
+
308
+ ## 原生多环境聚合(Lynx BG / MT)
309
+
310
+ 纯 Lynx 应用可以禁用默认 Web client,把同一入口交给两套独立的 client-consumer
311
+ Rolldown 环境。每套环境都有独立 module graph、resolve conditions、插件上下文和输出目录:
312
+
313
+ ```ts
314
+ export default defineConfig({
315
+ environments: {
316
+ client: { buildEnabled: false },
317
+ 'lynx-background': {
318
+ consumer: 'client',
319
+ entry: 'src/index.ts',
320
+ resolve: { conditions: ['lynx-background', 'browser', 'import'] },
321
+ },
322
+ 'lynx-main-thread': {
323
+ consumer: 'client',
324
+ entry: 'src/index.ts',
325
+ resolve: { conditions: ['lynx-main-thread', 'browser', 'import'] },
326
+ },
327
+ },
328
+ plugins: [pluginVueLynxNative()],
329
+ })
330
+ ```
331
+
332
+ Environment API 是 `conditionNames` 和 `mainFields` 的唯一高层配置入口:
333
+ 请使用 `environments.<name>.resolve.conditions` / `mainFields`(client 也可使用
334
+ top-level `resolve`)。这些值会无条件覆盖
335
+ `build.rolldownOptions.resolve.conditionNames` / `mainFields` 中的对应底层选项。
336
+
337
+ 在生产构建的 bundle/finalizer 相关钩子(如 `generateBundle`、`buildEnd`、
338
+ `closeBundle`)中,`this.environment` 会准确指向当前 BG/MT 环境。unbundled
339
+ dev 调用路径可能不提供该对象,开发期插件不得依赖 `this.environment`;应使用
340
+ Environment API 的显式环境参数。插件可登记结构化 manifest,并在 app 级
341
+ finalizer 中直接查询 entry/artifact,最后写出聚合 bundle:
342
+
343
+ ```ts
344
+ const pluginVueLynxNative = () => ({
345
+ name: 'vue-lynx:native',
346
+
347
+ generateBundle() {
348
+ this.environment.setBuildMetadata({
349
+ manifest: { thread: this.environment.name },
350
+ })
351
+ },
352
+
353
+ afterBuildApp(_results, _api, app) {
354
+ const background = app.getEntry('lynx-background', 'index')
355
+ const mainThread = app.getEntry('lynx-main-thread', 'index')
356
+ if (!background || !mainThread) throw new Error('Missing Lynx thread entry')
357
+
358
+ app.emitFile({
359
+ type: 'asset',
360
+ fileName: 'main.native.lynx.bundle',
361
+ source: encodeLynxBundle({ background, mainThread }),
362
+ })
363
+ },
364
+ })
365
+ ```
366
+
367
+ `build()` 的 `environmentResults` 会包含原生环境自动推导的 `entries`、插件登记的
368
+ `manifest/stats` 及完整 `output`;app 级产物同时出现在 `BuildResult.appOutput`。
369
+ 这些 API 只负责双线程编排与聚合,Vue SFC/worklet、Lynx CSS 和 encoder 由后续工具链插件实现。
307
370
 
308
371
  ## Monaco Editor 支持
309
372
 
package/bin/nasti.js CHANGED
File without changes
package/client/hmr.ts CHANGED
@@ -3,10 +3,11 @@
3
3
 
4
4
  export interface HotModule {
5
5
  accept(cb?: (mod: any) => void): void
6
+ accept(dep: string, cb: (mod: any) => void): void
6
7
  accept(deps: string[], cb: (mods: any[]) => void): void
7
- dispose(cb: (data: any) => void): void
8
- prune(cb: () => void): void
9
- invalidate(): void
8
+ dispose(cb: (data: Record<string, any>) => void | Promise<void>): void
9
+ prune(cb: (data: Record<string, any>) => void | Promise<void>): void
10
+ invalidate(message?: string): void
10
11
  data: Record<string, any>
11
12
  }
12
13