refactor(loader): resolve config after injected services

This commit is contained in:
Turtle
2026-08-07 17:27:38 +08:00
parent b692f38506
commit 7e3a82eacc
38 changed files with 404 additions and 306 deletions

View File

@@ -1,4 +1,4 @@
import { EntryTree, isJsExpr, type EntryOptions } from '@deepseek-ai/cordis-plugin-loader'
import { EntryConfigResolver, EntryTree, interpolate, isJsExpr, type EntryOptions } from '@deepseek-ai/cordis-plugin-loader'
import { Context, Service } from '@deepseek-ai/cordis'
import { extname } from 'node:path'
import { access, constants, readFile, rename, writeFile } from 'node:fs/promises'
@@ -174,6 +174,21 @@ export namespace Include {
export class Include extends EntryTree {
static inject = ['loader']
/**
* Resolve Include's own options while preserving nested entry expressions.
* @param ctx - the Include plugin context.
* @param config - the raw Include config.
* @returns resolved Include options with `initial` and `patches` untouched.
*/
static [EntryConfigResolver](ctx: Context, config: Include.Config): Include.Config {
const { initial, patches, ...own } = config
return {
...interpolate(ctx, own),
...(initial === undefined ? {} : { initial }),
...(patches === undefined ? {} : { patches }),
}
}
public filename: string
private type?: string
private readonly: boolean