import { AbstractServerAdapter } from '../../abstract/server-adapter.js'; import type { ServerAdapterOptions, ServerAdapterResult } from '../../abstract/server-adapter.js'; import { RouteRendererFactory } from '../../../route-renderer/route-renderer.js'; import { RouteRegistry } from '../../../router/server/route-registry.js'; import { SchemaValidationService } from '../../../services/validation/schema-validation-service.js'; import { StaticSiteGenerator } from '../../../static-site-generator/static-site-generator.js'; import { ServerStaticBuilder } from './server-static-builder.js'; import { FileSystemResponseMatcher } from '../http/fs-server-response-matcher.js'; import { ServerRouteHandler } from './server-route-handler.js'; import { ApiRequestPipeline } from '../http/api-request-pipeline.js'; import type { ApiHandler, CacheInvalidator, ErrorHandler, IHmrManager, RenderContext, StaticRoute } from '../../../types/public-types.js'; type SharedHmrAssetManager = IHmrManager; type SharedRequestContext = { apiHandlers: ApiHandler[]; errorHandler?: ErrorHandler; serverInstance?: TServer; hmrManager?: SharedHmrAssetManager; }; export declare abstract class SharedServerAdapter extends AbstractServerAdapter { protected router: RouteRegistry; protected fileSystemResponseMatcher: FileSystemResponseMatcher; protected routeRendererFactory: RouteRendererFactory; protected routeHandler: ServerRouteHandler; protected staticSiteGenerator: StaticSiteGenerator; protected staticBuilder: ServerStaticBuilder; protected schemaValidator: SchemaValidationService; protected readonly apiRequestPipeline: ApiRequestPipeline; protected hostOwnsDevClient: boolean; private devStaticRoutePrewarmStarted; private sharedPageCacheService; /** * Warms declared static paths after the final watch-mode response pipeline exists. */ protected startDevStaticRoutePrewarmWhenReady(): Promise; protected initializeSharedRouteHandling(options: { staticRoutes: StaticRoute[]; hmrManager?: SharedHmrAssetManager; }): Promise; private ensureRouteRendererFactory; protected createSharedWatchRefreshCallback(options: { staticRoutes: StaticRoute[]; hmrManager?: SharedHmrAssetManager; onRoutesReady?: () => Promise | void; onError?: (error: Error) => Promise | void; }): () => Promise; /** * Scans the filesystem and dynamically constructs the Route Registry. * * This process runs identically across both Bun and Node wrappers. It analyzes the configured pages * directory, building a map of all available UI routes and API endpoints. * The resulting `RouteRegistry` instance becomes the central nervous system for mapping WinterCG incoming * Web Requests (`Request`) to their corresponding internal execution paths. */ protected initSharedRouter(): Promise; private createRouteRegistryPageModuleAdapter; /** * Sets up the unified rendering pipeline and response matching chain. * * It bridges several sub-systems together so that when an incoming request is received, the adapter knows: * 1. How to render React/Lit pages via `RouteRendererFactory` * 2. How to match logical routes to physical filesystem artifacts via `FileSystemResponseMatcher` * 3. Whether to serve the response from the embedded `PageCacheService` or generate it fresh on the fly. * * @param staticRoutes - A map of explicitly served static assets. * @param hmrManager - The runtime-specific Hot Module Replacement orchestrator (if watching). */ protected configureSharedResponseHandlers(staticRoutes: StaticRoute[], hmrManager?: IHmrManager): void; private createSharedResponseHandlerDependencies; private getOrCreateSharedPageCacheService; protected getCacheService(): CacheInvalidator | null; protected getRenderContext(): RenderContext; private tryHandleSharedDevClientRequest; private tryHandleSharedHmrRequest; private injectSharedHmrHtmlResponse; private tryHandleSharedApiRequest; /** * Universally processes an incoming WinterCG Web standard Request. * * 1. Resolves static Hot Module Replacement runtime blobs if development. * 2. Checks if the incoming request matches any parsed API route schemas. * - Routes through `ApiRequestPipeline` which performs strict validation. * 3. Falls through to standard `ServerRouteHandler` for React/Lit filesystem pages. * * Both Bun and Node bindings fall back to this exact function once they have mapped their * native HTTP objects into Web Standard Requests. */ handleSharedRequest(request: Request, context: SharedRequestContext): Promise; } export {};