/**
 * Bun Dev Server
 *
 * Spawns Bun with --hot as a subprocess. Bun's --hot mode re-evaluates changed
 * modules and hot-swaps the default export's `fetch` handler on the running
 * server — no process restart, no port rebind, no dropped connections.
 *
 * The user's app.ts exports the result of createApp() which includes `fetch`
 * and `port` properties that Bun uses to manage the server lifecycle.
 *
 * Key requirements for bun --hot:
 * - app.ts MUST have `export default` with { fetch, port } properties
 * - Without export default, Bun runs the code but never starts an HTTP server
 */
import type { Logger } from '../../../types';
/**
 * Minimal handle for the spawned Bun subprocess. Mirrors the shape used
 * elsewhere (procManager, killBunSubprocess) so callers can register
 * the process with their tracking layer without depending on Bun-specific
 * Subprocess types.
 */
export interface BunSubprocessHandle {
    kill: (signal?: number | NodeJS.Signals) => void;
    exitCode: number | null;
    pid?: number;
}
export interface BunDevServerOptions {
    rootDir: string;
    port?: number;
    logger: Logger;
    vitePort: number;
    inspect?: boolean;
    inspectWait?: boolean;
    inspectBrk?: boolean;
    /**
     * Optional callback fired the moment `Bun.spawn` returns, BEFORE the
     * readiness wait. Lets callers register the subprocess with a process
     * manager / shutdown handler immediately, eliminating the multi-second
     * window during which a SIGINT could orphan the child.
     *
     * If this throws, the subprocess is killed and the error is rethrown.
     */
    onSpawn?: (proc: BunSubprocessHandle) => void;
}
export interface BunDevServerResult {
    bunServerPort: number;
}
/**
 * Validation result for app.ts entry point.
 */
interface AppValidationResult {
    /** Whether app.ts has a default export */
    hasDefaultExport: boolean;
    /** Whether app.ts calls createApp() */
    hasCreateApp: boolean;
    /** Whether it's the v1 pattern (destructuring without export) */
    isV1Pattern: boolean;
    /** Any validation hints to show */
    hints: string[];
}
/**
 * Validate app.ts for common issues that prevent Bun --hot from starting.
 *
 * Bun --hot requires `export default { fetch, port }` to start a server.
 * Common mistakes:
 * - No `export default` (v1 pattern: destructuring result without exporting)
 * - Calling createApp() but not exporting it
 *
 * @internal Exported for testing only
 */
export declare function validateAppTs(appPath: string): Promise<AppValidationResult>;
/**
 * Build a detailed error message with validation hints and captured output.
 *
 * @internal Exported for testing only
 */
export declare function buildStartupErrorMessage(port: number, timeoutMs: number, stderr: string, validation: AppValidationResult, stdout?: string): string;
/**
 * Start Bun dev server with --hot (Vite asset server must already be running).
 *
 * Uses `bun --hot` so Bun watches all imported files and hot-swaps the fetch
 * handler on the running server. The server stays up — only the changed modules
 * are re-evaluated.
 */
export declare function startBunDevServer(options: BunDevServerOptions): Promise<BunDevServerResult>;
export {};
//# sourceMappingURL=bun-dev-server.d.ts.map