/** * Walk a conditional `exports` target (string, array of fallbacks, or a * condition object) and return the first relative path that matches a runtime * condition in declaration order. Returns `null` when nothing applies (e.g. * an `import`-only entry). */ export declare function selectConditionalTarget(target: unknown): string | null; /** * Split a bare specifier into its package name and optional subpath, handling * scoped packages (`@scope/name/sub` → `@scope/name` + `sub`). */ export declare function splitBareSpecifier(specifier: string): { packageName: string; subpath: string | undefined; }; /** * Resolve a bare specifier against an installed `node_modules` directory, * honoring `exports` (CommonJS conditions), then `main`, then `index.js`. * Returns an absolute file path, or `null` when the package/entry is absent. */ export declare function resolveRuntimeModule(runtimeNodeModules: string, specifier: string): string | null; export interface RuntimeResolverOptions { /** Absolute path to the runtime cache's `node_modules`. */ runtimeNodeModules: string; /** Bare specifier → absolute file path overrides (e.g. `sharp` → no-op stub). */ stubs?: Record; } /** * Patch `node:module`'s resolver (idempotently) so bare specifiers that the * stock compiled-binary resolver cannot find fall back to the registered * runtime caches. Stock resolution is tried first and kept for anything * outside the registered roots (bundled imports, node builtins, host or * extension trees). Multiple runtime roots may register; they are consulted * in registration order. * * One stock "success" is distrusted: the compiled-binary resolver ignores * `main`/`exports` for real-FS packages (Bun #1763), so a package shipping * its TS source next to `dist/` (e.g. `@huggingface/hub`'s root `index.ts`) * resolves to the wrong file. When the stock hit lands inside a registered * runtime root, the manifest-aware resolution wins. */ export declare function installRuntimeModuleResolver({ runtimeNodeModules, stubs }: RuntimeResolverOptions): void; /** Pinned dependency set materialized into a runtime cache directory. */ export interface RuntimeInstallSpec { dependencies: Record; /** Version pins forced across the whole runtime tree (bun `overrides`), e.g. dislodging a transitive dep. */ overrides?: Record; /** Packages whose lifecycle scripts bun may run during the install. */ trustedDependencies?: string[]; } export type RuntimeInstallPhase = "initiate" | "download" | "done"; export interface EnsureRuntimeInstalledOptions { /** Directory owning the runtime `package.json` + `node_modules`. */ runtimeDir: string; install: RuntimeInstallSpec; /** Package whose installed manifest marks the runtime complete; defaults to the first dependency. */ probePackage?: string; /** Phase notifications (progress UI); not emitted when already installed. */ onPhase?: (phase: RuntimeInstallPhase) => void; lockAttempts?: number; lockSleepMs?: number; } export declare function writeRuntimeManifest(runtimeDir: string, install: RuntimeInstallSpec): Promise; /** * Materialize a pinned dependency set into `runtimeDir` (idempotent, * cross-process safe via a lock directory). Returns `runtimeDir`. */ export declare function ensureRuntimeInstalled(options: EnsureRuntimeInstalledOptions): Promise;