import type { IHmrManager } from '../../../types/public-types.js'; import type { RouteRegistry } from '../../../router/server/route-registry.js'; import type { ExplicitStaticRouteMatcher } from '../http/explicit-static-route-matcher.js'; import type { FileSystemResponseMatcher } from '../http/fs-server-response-matcher.js'; /** * Configuration parameters for ServerRouteHandler. */ export interface ServerRouteHandlerParams { /** File system router for matching request URLs to route handlers. */ router: RouteRegistry; /** Matcher for handling file system route responses. */ fileSystemResponseMatcher: FileSystemResponseMatcher; /** Optional matcher for explicit static routes like processed images or sitemaps. */ explicitStaticRouteMatcher?: ExplicitStaticRouteMatcher; /** HMR manager for broadcasting hot module reload events in development. */ hmrManager?: IHmrManager; } /** * Handles HTTP requests and routing for the server. * * This class manages the request routing flow with a priority-based approach: * 1. Explicit static routes (highest priority - intentional mappings like /sitemap.xml) * 2. File-based routes without extensions (application routes) * 3. Static file fallback (lowest priority - disk serving) * */ export declare class ServerRouteHandler { private readonly router; private readonly fileSystemResponseMatcher; private readonly explicitStaticRouteMatcher?; private readonly hmrManager?; /** * Creates a new ServerRouteHandler instance. * * @param params - Configuration parameters */ constructor({ router, fileSystemResponseMatcher, explicitStaticRouteMatcher, hmrManager, }: ServerRouteHandlerParams); /** * Handles HTTP requests from the router adapter. * * Priority-based routing flow: * 1. Check explicit static routes first (e.g., /sitemap.xml, /image.webp from plugins) * 2. Match file-based routes without extensions (application routes) * 3. Fall back to static file serving from disk * * @param request - The incoming HTTP request * @returns HTTP response for the matched route */ handleResponse(request: Request): Promise; /** * Handles requests that do not match any routes. * * This is the final fallback that attempts to serve static files from disk. * If the requested path corresponds to an HTML file or no file is found, * a custom 404 response is returned. * * @param request - The HTTP request to handle * @returns Response from file system or error response * @throws HttpError for standard HTTP errors */ handleNoMatch(request: Request): Promise; }