/**
 * NextDevServer - Next.js-compatible dev server for browser environment
 * Implements file-based routing, API routes, and HMR
 */
import { DevServer, DevServerOptions, ResponseData } from '../dev-server';
import { VirtualFS } from '../virtual-fs';
import { Buffer } from '../shims/stream';
export interface NextDevServerOptions extends DevServerOptions {
    /** Pages directory (default: '/pages') */
    pagesDir?: string;
    /** App directory for App Router (default: '/app') */
    appDir?: string;
    /** Public directory for static assets (default: '/public') */
    publicDir?: string;
    /** Prefer App Router over Pages Router (default: auto-detect) */
    preferAppRouter?: boolean;
    /** Environment variables (NEXT_PUBLIC_* are available in browser code via process.env) */
    env?: Record<string, string>;
}
/**
 * NextDevServer - A lightweight Next.js-compatible development server
 *
 * Supports both routing paradigms:
 *
 * 1. PAGES ROUTER (legacy, /pages directory):
 *    - /pages/index.jsx        -> /
 *    - /pages/about.jsx        -> /about
 *    - /pages/users/[id].jsx   -> /users/:id (dynamic)
 *    - /pages/api/hello.js     -> /api/hello (API route)
 *    - Uses next/router for navigation
 *
 * 2. APP ROUTER (new, /app directory):
 *    - /app/page.jsx           -> /
 *    - /app/about/page.jsx     -> /about
 *    - /app/users/[id]/page.jsx -> /users/:id (dynamic)
 *    - /app/layout.jsx         -> Root layout (wraps all pages)
 *    - /app/about/layout.jsx   -> Nested layout (wraps /about/*)
 *    - Uses next/navigation for navigation
 *
 * The server auto-detects which router to use based on directory existence,
 * preferring App Router if both exist. Can be overridden via options.
 */
export declare class NextDevServer extends DevServer {
    /** Pages Router directory (default: '/pages') */
    private pagesDir;
    /** App Router directory (default: '/app') */
    private appDir;
    /** Static assets directory (default: '/public') */
    private publicDir;
    /** Whether to use App Router (true) or Pages Router (false) */
    private useAppRouter;
    /** Cleanup function for file watchers */
    private watcherCleanup;
    /** Target window for HMR updates (iframe contentWindow) */
    private hmrTargetWindow;
    /** Store options for later access (e.g., env vars) */
    private options;
    constructor(vfs: VirtualFS, options: NextDevServerOptions);
    /**
     * Set an environment variable at runtime
     * NEXT_PUBLIC_* variables will be available via process.env in browser code
     */
    setEnv(key: string, value: string): void;
    /**
     * Get current environment variables
     */
    getEnv(): Record<string, string>;
    /**
     * Set the target window for HMR updates (typically iframe.contentWindow)
     * This enables HMR to work with sandboxed iframes via postMessage
     */
    setHMRTarget(targetWindow: Window): void;
    /**
     * Generate a script tag that defines process.env with NEXT_PUBLIC_* variables
     * This makes environment variables available to browser code via process.env.NEXT_PUBLIC_*
     */
    private generateEnvScript;
    /**
     * Check if App Router is available
     */
    private hasAppRouter;
    /**
     * Handle an incoming HTTP request
     */
    handleRequest(method: string, url: string, headers: Record<string, string>, body?: Buffer): Promise<ResponseData>;
    /**
     * Serve Next.js shims (link, router, head, navigation)
     */
    private serveNextShim;
    /**
     * Serve static assets from /_next/static/
     */
    private serveStaticAsset;
    /**
     * Handle API route requests
     */
    private handleApiRoute;
    /**
     * Handle streaming API route requests
     * This is called by the server bridge for requests that need streaming support
     */
    handleStreamingRequest(method: string, url: string, headers: Record<string, string>, body: Buffer | undefined, onStart: (statusCode: number, statusMessage: string, headers: Record<string, string>) => void, onChunk: (chunk: string | Uint8Array) => void, onEnd: () => void): Promise<void>;
    /**
     * Create a streaming mock response that calls callbacks as data is written
     */
    private createStreamingMockResponse;
    /**
     * Resolve API route to file path
     */
    private resolveApiFile;
    /**
     * Create mock Next.js request object
     */
    private createMockRequest;
    /**
     * Parse cookie header
     */
    private parseCookies;
    /**
     * Create mock Next.js response object with streaming support
     */
    private createMockResponse;
    /**
     * Execute API handler code
     */
    private executeApiHandler;
    /**
     * Handle page route requests
     */
    private handlePageRoute;
    /**
     * Handle App Router page requests
     */
    private handleAppRouterPage;
    /**
     * Resolve App Router route to page and layout files
     */
    private resolveAppRoute;
    /**
     * Resolve dynamic App Router routes like /app/[id]/page.jsx
     */
    private resolveAppDynamicRoute;
    /**
     * Generate HTML for App Router with nested layouts
     */
    private generateAppRouterHtml;
    /**
     * Resolve URL pathname to page file
     */
    private resolvePageFile;
    /**
     * Resolve dynamic routes like /users/[id]
     */
    private resolveDynamicRoute;
    /**
     * Generate HTML shell for a page
     */
    private generatePageHtml;
    /**
     * Serve a basic 404 page
     */
    private serve404Page;
    /**
     * Check if a file needs transformation
     */
    private needsTransform;
    /**
     * Transform and serve a JSX/TS file
     */
    private transformAndServe;
    /**
     * Transform JSX/TS code to browser-compatible JavaScript (ESM for browser)
     */
    private transformCode;
    /**
     * Strip CSS imports from code (they are loaded via <link> tags instead)
     * Handles: import './styles.css', import '../globals.css', etc.
     */
    private stripCssImports;
    /**
     * Transform API handler code to CommonJS for eval execution
     */
    private transformApiHandler;
    /**
     * Add React Refresh registration to transformed code
     */
    private addReactRefresh;
    /**
     * Start file watching for HMR
     */
    startWatching(): void;
    /**
     * Handle file change event
     */
    private handleFileChange;
    /**
     * Stop the server
     */
    stop(): void;
}
export default NextDevServer;
//# sourceMappingURL=next-dev-server.d.ts.map