import type { Bud } from '@roots/bud-framework'; import { Service } from '@roots/bud-framework/service'; /** * Import method options */ interface ImportOptions { bustCache?: boolean; raw?: boolean; reject?: boolean; } /** * Map of module signifiers to absolute paths */ type Resolutions = Record; /** * Module cache data */ interface ModuleCache { resolutions: Resolutions; sha1: string; version: string; } /** * Module resolver */ export declare class Module extends Service { /** * Bootstrapped args */ args: { cache?: boolean; force?: boolean; }; /** * Cached resolutions data */ cache: ModuleCache; /** * Bootstrapped paths */ paths: { storage: string; }; /** * Resolved module paths */ resolutions: Resolutions; /** * Cache enabled */ get cacheEnabled(): boolean; /** * Cache location */ get cachePath(): string; /** * Constructor */ constructor(options: { app: () => Bud; args: Record; paths: { storage: string; }; }); /** * {@link Service.bootstrap} */ bootstrap(bud: Bud): Promise; /** * At end of process write resolutions to cache */ after(bud: Bud): Promise; /** * Handle error * * @param messages - error messages for logging * @returns */ handleError(...messages: string[]): Promise; /** * Get `package.json` absolute path from a module signifier */ getDirectory(signifier: string, context?: string): Promise; /** * Get `package.json` absolute path from a module signifier */ getManifestPath(signifier: string): Promise; /** * Import a module from its signifier */ import(signifier: string, context?: string, options?: ImportOptions): Promise; /** * Make context URL */ makeContextURL(context?: string | URL): URL; /** * Read `package.json` manifest from a module signifier */ readManifest(signifier: string): Promise; /** * Reset cached resolutions */ removeCachedResolutions(error?: string): Promise; /** * Resolve a module path from its signifier */ resolve(signifier: string, context?: string): Promise; /** * Write resolutions to cache */ writeResolutions(path?: string, data?: any): Promise; /** * Get a module resolution path */ getResolution(signifier: string): string; /** * Check if a module has been resolved */ hasResolution(signifier: string): signifier is keyof Resolutions; /** * Remove a module resolution path * * @param signifier * @returns */ removeResolution(signifier: string): boolean; /** * Set a module resolution path */ setResolution(signifier: string, url: string): void; } export {};