import { LOADER_VERSION } from './version.js'; import { AdapterRegistry } from './registry.js'; import { createHostAPI } from './api.js'; import type { CordisContext, AdapterFactory } from './types.js'; export declare const name = "@dsh-plugin/dsh-loader"; export declare const inject: string[]; interface LoaderConfig { exposeAllNamespaces: boolean; hostPackageAliases?: Record; } /** * Locate the profile directory this loader instance is mounted into. * * Strategy, in order: * 1. Self-location: under pnpm the entry's realpath resolves inside * `/node_modules/...`, so walk up for an ancestor * `node_modules` whose parent manifest declares `dsh.profile`. * 2. Dependency scan (covers `link:` installs whose realpath escapes the * profile): the profile manifests under `$DSH_HOME/profiles` that depend * on this package. Unambiguous only when exactly one matches — with * several, per-profile manifest config stays unread rather than reading * the wrong profile (env and cordis entry config still apply). * * @returns the absolute profile directory, or undefined when undetectable. */ export declare function detectProfileDir(opts?: { moduleUrl?: string; dshHome?: string; }): string | undefined; /** * Read the profile-level dshloader config (exposeAllNamespaces etc.). * Sources, in priority order (first true wins): * 1. process.env.DSHLOADER_EXPOSE_ALL_SETTINGS=1 * 2. cordis entry config (`- id: dsh-loader` row's `config:`) — per-profile * by construction, the officially sanctioned channel * 3. the ACTIVE profile's package.json `dsh.dshloader.exposeAllNamespaces` * (or legacy `dshLoader.settings.exposeAllNamespaces`), located via * {@link detectProfileDir} — never a hardcoded profile name */ export declare function readLoaderConfig(opts?: { profileDir?: string; config?: Partial; }): LoaderConfig; interface AdapterSelectionResult { registry: AdapterRegistry; factory: AdapterFactory; mode: 'exact' | 'range' | 'fallback'; dshVersion: string; } /** * Build the registry + select an adapter for the current dsh version, without * touching the cordis context. Exported for tests and the `info` CLI command. */ export declare function selectAdapter(opts?: { dshVersion?: string; registry?: AdapterRegistry; }): AdapterSelectionResult; /** * Apply the selected adapter onto a cordis context and expose the stable API. * @param ctx cordis context * @returns */ export declare function applyAdapter(ctx: CordisContext, opts?: { dshVersion?: string; config?: LoaderConfig; registry?: AdapterRegistry; }): Promise<{ api: ReturnType; factory: AdapterFactory; mode: string; dshVersion: string; }>; /** cordis function-plugin entry point. */ export declare function apply(ctx: CordisContext, entryConfig?: Partial): Promise; export { LOADER_VERSION };