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<PluginConfig, 'outdir'>): 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
      entrypoints?: string[]
    }
  }
  onSuccess?: (stats: GenerationStats) => void | Promise<void>
  onError?: (error: DtsxPluginError) => void | Promise<void>
  failOnError?: boolean
  incremental?: boolean
  cacheDir?: string
  on?: Partial<Record<BuildEventType, BuildEventListener>>
  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<void>;
/**
 * Custom error class for bun-plugin-dtsx
 */
export declare class DtsxPluginError extends Error {
  readonly code: PluginErrorCode;
  readonly context?: Record<string, unknown>;
  readonly cause?: Error;
  constructor(message: string, code: PluginErrorCode, context?: Record<string, unknown>, cause?: Error);
  toJSON(): Record<string, unknown>;
}
/**
 * Event emitter for build events
 */
declare class BuildEventEmitter {
  on(type: BuildEventType, listener: BuildEventListener): void;
  emit(type: BuildEventType, data: BuildEventData): Promise<void>;
}
/**
 * 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;
