/**
 * Server Bridge
 * Connects Service Worker requests to virtual HTTP servers
 */
import { Server, ResponseData } from './shims/http';
import { EventEmitter } from './shims/events';
import { Buffer } from './shims/stream';
/**
 * Interface for virtual servers that can be registered with the bridge
 */
export interface IVirtualServer {
    listening: boolean;
    address(): {
        port: number;
        address: string;
        family: string;
    } | null;
    handleRequest(method: string, url: string, headers: Record<string, string>, body?: Buffer | string): Promise<ResponseData>;
}
export interface VirtualServer {
    server: Server | IVirtualServer;
    port: number;
    hostname: string;
}
export interface BridgeOptions {
    baseUrl?: string;
    onServerReady?: (port: number, url: string) => void;
}
export interface InitServiceWorkerOptions {
    /**
     * The URL path to the service worker file
     * @default '/__sw__.js'
     */
    swUrl?: string;
}
/**
 * Server Bridge manages virtual HTTP servers and routes requests
 */
export declare class ServerBridge extends EventEmitter {
    private servers;
    private baseUrl;
    private options;
    private messageChannel;
    private serviceWorkerReady;
    constructor(options?: BridgeOptions);
    /**
     * Register a server on a port
     */
    registerServer(server: Server | IVirtualServer, port: number, hostname?: string): void;
    /**
     * Unregister a server
     */
    unregisterServer(port: number): void;
    /**
     * Get server URL for a port
     */
    getServerUrl(port: number): string;
    /**
     * Get all registered server ports
     */
    getServerPorts(): number[];
    /**
     * Handle an incoming request from Service Worker
     */
    handleRequest(port: number, method: string, url: string, headers: Record<string, string>, body?: ArrayBuffer): Promise<ResponseData>;
    /**
     * Initialize Service Worker communication
     * @param options - Configuration options for the service worker
     * @param options.swUrl - Custom URL path to the service worker file (default: '/__sw__.js')
     */
    initServiceWorker(options?: InitServiceWorkerOptions): Promise<void>;
    /**
     * Handle messages from Service Worker
     */
    private handleServiceWorkerMessage;
    /**
     * Handle a streaming request - sends chunks as they arrive
     */
    private handleStreamingRequest;
    /**
     * Send message to Service Worker
     */
    private notifyServiceWorker;
    /**
     * Create a mock request handler for testing without Service Worker
     */
    createFetchHandler(): (request: Request) => Promise<Response>;
}
/**
 * Get or create the global server bridge
 */
export declare function getServerBridge(options?: BridgeOptions): ServerBridge;
/**
 * Reset the global bridge (for testing)
 */
export declare function resetServerBridge(): void;
export default ServerBridge;
//# sourceMappingURL=server-bridge.d.ts.map