@stacksjs/dtsx
Version:
A modern, fast .d.ts generation tool, powered by Bun.
85 lines (84 loc) • 2.23 kB
TypeScript
import type { Declaration, DtsGenerationConfig } from './types';
/**
* Create an incremental build wrapper
*/
export declare function createIncrementalBuilder(cache: IncrementalCache, configHash: string): void;
/**
* Prune old cache entries
*/
export declare function pruneCache(cache: IncrementalCache, _maxAge?: number): Promise<number>;
/**
* Format incremental build result
*/
export declare function formatIncrementalResult(result: IncrementalBuildResult): string;
/**
* Extract dependencies from source content
*/
export declare function extractDependencies(content: string, basePath: string): string[];
/**
* Incremental build configuration
*/
export declare interface IncrementalConfig {
enabled?: boolean
cacheDir?: string
format?: 'json' | 'binary'
maxAge?: number
force?: boolean
validateCache?: boolean
}
/**
* Cached file entry for incremental builds
*/
export declare interface IncrementalCacheEntry {
filePath: string
hash: string
mtime: number
declarations: Declaration[]
dtsContent: string
dependencies: string[]
cachedAt: number
configHash: string
}
/**
* Cache manifest for incremental builds
*/
export declare interface IncrementalCacheManifest {
version: string
entries: Record<string, IncrementalCacheEntry>
createdAt: number
updatedAt: number
}
/**
* Incremental build result
*/
export declare interface IncrementalBuildResult {
rebuilt: string[]
cached: string[]
skipped: string[]
stats: CacheStats
}
/**
* Cache statistics
*/
export declare interface CacheStats {
totalEntries: number
hits: number
misses: number
hitRatio: number
sizeBytes: number
timeSavedMs: number
}
/**
* Incremental build cache manager
*/
export declare class IncrementalCache {
constructor(config?: IncrementalConfig);
init(): Promise<void>;
save(): Promise<void>;
get(filePath: string, configHash: string): Promise<IncrementalCacheEntry | null>;
set(filePath: string, content: string, declarations: Declaration[], dtsContent: string, dependencies: string[], configHash: string): Promise<void>;
invalidate(filePath: string): void;
clear(): Promise<void>;
getStats(): CacheStats;
static hashConfig(config: DtsGenerationConfig): string;
}