import type { RouteComponentProps } from 'react-router-dom' import type { IConfig } from '../config' import type { ISSRContext, ISSRMidwayContext, ISSRMidwayKoaContext, ISSRNestContext } from '../ctx' import type { Action } from './component' export interface LayoutProps { ctx?: ISSRContext config?: IConfig children?: JSX.Element staticList?: StaticList injectState?: any } export interface StaticList { injectCss: JSX.Element[] injectScript: JSX.Element[] } export interface ProvisionalFeRouteItem { path?: string layout: string fetch?: string component?: string } export interface Params { ctx?: ISSRContext routerProps?: RouteComponentProps state?: any } export interface ParamsMidway { ctx?: ISSRMidwayContext routerProps?: RouteComponentProps state?: any } export interface ParamsMidwayKoa { ctx?: ISSRMidwayKoaContext routerProps?: RouteComponentProps state?: any } export interface ParamsNest { ctx?: ISSRNestContext routerProps?: RouteComponentProps state?: any } export type ReactFetch = (params: Params) => Promise export type ReactMidwayFetch = (params: ParamsMidway) => Promise export type ReactMidwayKoaFetch = (params: ParamsMidwayKoa) => Promise export type ReactNestFetch = (params: ParamsNest) => Promise export type ReactESMFetch = () => Promise<{ default: ReactFetch }> export type ESMLayout = () => Promise> export interface StaticFC extends React.FC { fetch?: ReactESMFetch layoutFetch?: ReactFetch } export interface DynamicFC extends React.FC { (): Promise<{ default: StaticFC }> name: 'dynamicComponent' fetch?: ReactESMFetch layoutFetch?: ReactFetch } export type ReactESMFeRouteItem = { path: string childPath?: string fetch?: ReactESMFetch component: DynamicFC webpackChunkName: string children?: Array> } & U export type ReactESMPreloadFeRouteItem = { path: string childPath?: string fetch?: ReactESMFetch component: DynamicFC | StaticFC webpackChunkName: string } & U export interface ReactRoutesType { Layout: React.FC App?: (props: LayoutProps) => JSX.Element layoutFetch: ReactFetch FeRoutes: ReactESMFeRouteItem[] state?: any reducer?: any store?: any } export interface IContext { state?: T dispatch?: React.Dispatch } export interface PipeableStream { abort: () => void pipe: (destination: Writable) => Writable }