import type { BunPlugin } from 'bun'; import type { DtsGenerationOption, GenerationStats } from '@stacksjs/dtsx'; export type { DtsGenerationOption, GenerationStats }; /** * Creates a Bun plugin for generating TypeScript declaration files * @param options - Configuration options for DTS generation * @returns BunPlugin instance */ export declare function dts(options?: PluginConfig): BunPlugin; /** * Create a watch mode plugin that regenerates on file changes */ export declare function dtsWatch(options?: PluginConfig): BunPlugin; /** * Create a plugin that only validates types without generating */ export declare function dtsCheck(options: Omit): BunPlugin; /** * Clear the incremental cache */ export declare function clearCache(cacheDir?: string): void; /** * Error codes for categorizing plugin errors */ export declare const PluginErrorCodes: { CONFIG_ERROR: 'CONFIG_ERROR'; GENERATION_ERROR: 'GENERATION_ERROR'; FILE_ERROR: 'FILE_ERROR'; CACHE_ERROR: 'CACHE_ERROR'; TIMEOUT_ERROR: 'TIMEOUT_ERROR' }; /** * Build event payload */ export declare interface BuildEvent { type: BuildEventType timestamp: number data: BuildEventData } /** * Incremental cache entry */ declare interface CacheEntry { hash: string outputFile: string timestamp: number } /** * Configuration interface extending DtsGenerationOption with build-specific properties */ export declare interface PluginConfig extends DtsGenerationOption { build?: { config: { root?: string outdir?: string } } onSuccess?: (stats: GenerationStats) => void | Promise onError?: (error: DtsxPluginError) => void | Promise failOnError?: boolean incremental?: boolean cacheDir?: string on?: Partial> timeout?: number continueOnError?: boolean verbose?: boolean } export type PluginErrorCode = typeof PluginErrorCodes[keyof typeof PluginErrorCodes]; /** * Build event types */ export type BuildEventType = 'start' | 'progress' | 'file' | 'complete' | 'error'; export type BuildEventData = | { type: 'start', files: string[], config: DtsGenerationOption } | { type: 'progress', processed: number, total: number, currentFile: string } | { type: 'file', file: string, outputFile: string, duration: number, cached: boolean } | { type: 'complete', stats: GenerationStats, duration: number, fromCache: number } | { type: 'error', error: DtsxPluginError, file?: string } /** * Event listener function */ export type BuildEventListener = (_event: BuildEvent) => void | Promise; /** * Custom error class for bun-plugin-dtsx */ export declare class DtsxPluginError extends Error { readonly code: PluginErrorCode; readonly context?: Record; readonly cause?: Error; constructor(message: string, code: PluginErrorCode, context?: Record, cause?: Error); toJSON(): Record; } /** * Event emitter for build events */ declare class BuildEventEmitter { on(type: BuildEventType, listener: BuildEventListener): void; emit(type: BuildEventType, data: BuildEventData): Promise; } /** * Incremental cache manager */ declare class IncrementalCache { constructor(cacheDir: string, configHash: string); save(): void; getEntry(filePath: string): CacheEntry | undefined; setEntry(filePath: string, entry: CacheEntry): void; isValid(filePath: string, currentHash: string): boolean; clear(): void; } export default dts;