UNPKG

@stacksjs/dtsx

Version:

A modern, fast .d.ts generation tool, powered by Bun.

65 lines (64 loc) 1.8 kB
import type { DtsGenerationConfig } from './types'; /** * Create a file watcher for .d.ts generation */ export declare function createWatcher(config: WatchConfig, buildFn: (files?: string[]) => Promise<WatchBuildResult>): Watcher; /** * Watch and generate .d.ts files */ export declare function watchAndGenerate(config: DtsGenerationConfig & WatchConfig, generator: (config: DtsGenerationConfig) => Promise<{ filesProcessed: number, errors: string[] }>): Promise<Watcher>; /** * Format watch build result for display */ export declare function formatWatchResult(result: WatchBuildResult): string; /** * Create a simple console logger for watch mode */ export declare function createWatchLogger(): { onChange: (event: WatchEvent) => void onBuildStart: () => void onBuildComplete: (result: WatchBuildResult) => void onError: (error: Error) => void }; /** * Watch configuration */ export declare interface WatchConfig { root: string include?: string[] exclude?: string[] debounce?: number initialBuild?: boolean clearScreen?: boolean onChange?: (event: WatchEvent) => void | Promise<void> onBuildStart?: () => void | Promise<void> onBuildComplete?: (result: WatchBuildResult) => void | Promise<void> onError?: (error: Error) => void | Promise<void> } /** * Watch event */ export declare interface WatchEvent { type: 'add' | 'change' | 'unlink' path: string relativePath: string } /** * Build result from watch */ export declare interface WatchBuildResult { success: boolean duration: number filesProcessed: number errors: string[] } /** * Watcher instance */ export declare interface Watcher { start: () => Promise<void> stop: () => void rebuild: () => Promise<WatchBuildResult> isWatching: () => boolean getWatchedFiles: () => string[] }