interface BaseWorkspaceOptions { /** * Optional target directory. If provided, creates workspace in this directory * instead of a hash-based temp directory. Caller is responsible for directory lifecycle. */ targetDir?: string; } interface DependenciesWorkspaceOptions extends BaseWorkspaceOptions { /** * NPM dependencies (package name to version mapping). */ dependencies: Record; packageJsonContent?: never; packageLockContent?: never; } interface PackageJsonWorkspaceOptions extends BaseWorkspaceOptions { /** * package.json content as a string. Dependencies are extracted from it * and the content is written to the workspace. */ packageJsonContent: string; dependencies?: never; /** * Optional package-lock.json content. If provided: * - The lock file content is used as the cache key (more precise than dependency hash) * - `npm ci` is used instead of `npm install` (faster, deterministic) */ packageLockContent?: string; /** * Optional workspace member package.json files. * Keys are relative paths (e.g., "packages/foo/package.json"), values are content. */ workspacePackages?: Record; } /** * Options for creating a dependency workspace. * Provide either `dependencies` or `packageJsonContent`, but not both. */ export type WorkspaceOptions = DependenciesWorkspaceOptions | PackageJsonWorkspaceOptions; /** * Manages workspace directories for TypeScript compilation with dependencies. * Creates temporary workspaces with package.json and installed node_modules * to enable proper type attribution for templates. */ export declare class DependencyWorkspace { private static readonly WORKSPACE_BASE; private static readonly cache; /** * Gets or creates a workspace directory for the given dependencies. * Workspaces are cached by dependency hash (or lock file hash if provided) to avoid repeated npm installs. * * @param options Workspace options including dependencies or package.json content * @returns Path to the workspace directory */ static getOrCreateWorkspace(options: WorkspaceOptions): Promise; /** * Internal method that handles workspace creation. */ private static createWorkspace; /** * Generates a hash from dependencies for caching. */ private static hashDependencies; /** * Generates a hash from arbitrary content for caching. */ private static hashContent; /** * Checks if a workspace is valid (has node_modules and matching package.json). * Handles both real node_modules directories and symlinks to cached workspaces. * * @param workspaceDir Directory to check * @param expectedDependencies Optional dependencies to check against package.json */ private static isWorkspaceValid; /** * Cleans up old workspace directories. * Removes workspaces older than the specified age. * Also removes all temporary directories (*.tmp-*) regardless of age, * as these indicate incomplete/crashed operations. * * @param maxAgeMs Maximum age in milliseconds (default: 24 hours) */ static cleanupOldWorkspaces(maxAgeMs?: number): void; /** * Clears all cached workspaces. */ static clearCache(): void; } export {}; //# sourceMappingURL=dependency-workspace.d.ts.map