import { Request } from 'express'; import { Response as ExpressResponse } from "express"; import { StaticHandlerContext, StaticHandler } from 'react-router'; import StreamError from "../constants/stream-error.js"; import { IServerContext } from "../context/server.js"; import { IObtainStreamErrorOut } from "../helpers/obtain-stream-error.js"; import { TApp } from "./entry.js"; import ServerConfig from "../services/server-config.js"; interface IRequestContext> { req: Request; res: ExpressResponse; appProps: NonNullable; html: { header: string; footer: string; }; routerContext?: StaticHandlerContext; serverContext?: IServerContext; isStream?: boolean; hasEarlyHints?: boolean; didError?: StreamError; } type TRender> = (config: ServerConfig, context: IRequestContext, options: IRenderOptions) => Promise; interface IRenderParams> { App: TApp; handler: StaticHandler; } interface IRenderOptions> { abortDelay?: number; onRouterReady?: (params: { context: IRequestContext; }) => Promise | IRouterReadyOut; onShellReady?: (params: { context: IRequestContext; }) => IShellReadyOut; onShellError?: (params: { context: IRequestContext; error: Error; }) => string | undefined | void; onError?: (params: { context: IRequestContext; error: IObtainStreamErrorOut; }) => void; onResponse?: (params: { context: IRequestContext; html: string; }) => string | undefined | void; getState?: (params: { context: IRequestContext; }) => Record> | undefined | void; } interface IRouterReadyOut { isStream?: boolean; } interface IShellReadyOut { header?: string; footer?: string; } /** * Render application */ declare function render({ App, handler }: IRenderParams, // @see entry (bind) config: ServerConfig, context: IRequestContext, { onRouterReady, onShellReady, onResponse, onShellError, onError, getState, abortDelay, }: IRenderOptions): Promise; export { render as default, IRequestContext, TRender, IRenderParams, IRenderOptions, IRouterReadyOut, IShellReadyOut };