import { ComponentType, ForwardRefExoticComponent, ReactElement, ReactNode, Ref } from 'react';
export interface DefaultImportedComponent
{
default: ComponentType
;
}
export declare type AnyFunction = (x: any) => any;
export interface Default {
default: T;
}
export interface Stream {
marks: Record;
}
export declare type Mark = string[];
export declare type Promised = () => Promise;
export declare type DefaultComponent = ComponentType
| DefaultImportedComponent
;
export declare type DefaultComponentImport = () => Promise>;
export declare type Defaultable = P | Default
;
/**
* standard "importer" accepted by the package.
* Could be {default:T} or T
*/
export declare type DefaultImport = () => Promise>;
export interface MarkMeta {
loadable: Loadable;
mark: Mark;
chunkName: string;
fileName: string;
}
export declare type LazyImport = () => Promise>;
export interface LoadableComponentState {
loading?: boolean;
error?: any;
}
export interface Loadable {
done: boolean;
error: any;
payload: T | undefined;
mark: Mark;
resolution: Promise;
importer: any;
isLoading(): boolean;
reset(): void;
replaceImportFunction(newImportFunction: Promised): void;
loadIfNeeded(): Promise;
tryResolveSync(then: (x: T) => Y): Promise;
load(): Promise;
reload(): Promise;
then(callback: (x: T) => void, err: () => void): Promise;
}
export interface ComponentOptions {
loadable: DefaultComponentImport
| Loadable>;
LoadingComponent?: ComponentType;
ErrorComponent?: ComponentType;
onError?: (a: any) => void;
async?: boolean;
render?: (Component: ComponentType | undefined, State: LoadableComponentState, props?: K) => ReactElement | null;
forwardRef?: Ref;
forwardProps?: K;
}
export interface HOCOptions {
noAutoImport?: boolean;
}
export interface AdditionalHOC {
done: Promise;
preload(): Promise;
}
export declare type HOCType = ForwardRefExoticComponent>;
}> & AdditionalHOC;
export interface ImportModuleHOCProps {
fallback: NonNullable | null;
}
export interface ImportModuleProps extends ImportModuleHOCProps {
children: (arg: T) => ReactElement | null;
}
export interface FullImportModuleProps extends ImportModuleProps {
import: DefaultImport | Loadable;
}
export declare type ModuleFC = (props: ImportModuleProps) => ReactElement | null;
export declare type HOCModuleType = ModuleFC & AdditionalHOC;
export declare type HOC = (loader: DefaultComponentImport
, options?: Partial> & HOCOptions) => HOCType;
export interface ImportedComponents {
[index: number]: () => Promise>;
}