/// import { RouteProps, RouteComponentProps, match as Match } from 'react-router-dom'; import { HelmetData } from 'react-helmet'; import { Request, Response } from 'express'; import { History, Location } from 'history'; import { Document as DefaultDoc } from './Document'; export interface CtxBase { req?: Request; res?: Response; history?: History; location?: Location; scrollToTop?: ScrollToTop; } export interface Ctx

extends CtxBase { match: Match

; } export interface AsyncComponent { getInitialProps: (props: Ctx) => any; load?: () => Promise; getChunkName: () => string | undefined; } export declare type AsyncRouteComponentType = React.ComponentType & AsyncComponent; /** * this type handles the component type in the route config object * { * path: "/", * exact: true, * component: ReactComponent <- AsyncRouteableComponent * } */ export declare type AsyncRouteableComponent = React.ComponentType> | React.ComponentType | AsyncRouteComponentType> | AsyncRouteComponentType; export interface AsyncRouteComponentState { Component: AsyncRouteableComponent | null; } export interface AsyncRouteProps extends RouteProps { path?: string; Placeholder?: React.ComponentType; component: AsyncRouteableComponent; redirectTo?: string; } export declare type ScrollToTop = React.RefObject; export declare type InitialData = Promise[]; export interface ServerAppState { afterData: AfterClientData; initialData: InitialData; } export interface InitialProps { match?: AsyncRouteProps; data: InitialData; } export interface AfterClientData { scrollToTop: ScrollToTop; ssg?: boolean; } export interface ServerAppState { afterData: AfterClientData; initialData: InitialData; } export interface RenderResult { html: string; redirect: string; statusCode: number; data: InitialData; } export interface RedirectWithStatuCode { statusCode?: number; redirectTo?: string; } export interface AfterRenderAppOptions { req: Request; res: Response; assets: Assets; routes: AsyncRouteProps[]; document?: typeof DefaultDoc; chunks: Chunks; scrollToTop?: boolean; ssg?: boolean; customRenderer?: (element: React.ReactElement) => { html: string; } | Promise<{ html: string; }>; } export declare type AfterRenderOptions = Omit, 'ssg'>; export declare type AfterRenderStaticOptions = Omit, 'ssg'>; export interface RenderPageResult { html: string; helmet: HelmetData; } export declare type TransitionBehavior = 'blocking' | 'instant'; export interface DocumentgetInitialProps { req: Request; res: Response; helmet: HelmetData; assets: Assets; data: ServerAppState; renderPage: () => Promise; match: Match | null; scripts: string[]; styles: string[]; scrollToTop: ScrollToTop; } export declare type DocumentProps = Omit, 'req' | 'res' | 'renderPage' | 'scrollToTop'> & T; export declare type AfterContext = DocumentProps; export interface GetAssetsParams { chunks: Chunks; route?: AsyncRouteProps; } export declare type Module

= { default?: P; [x: string]: any; } | { exports?: P; [x: string]: any; }; export interface Assets { [name: string]: { [ext: string]: string; }; } export interface Chunks { [key: string]: { css: string[]; js: string[]; }; }