1 | import * as React from 'react';
|
2 |
|
3 | interface ErrorReporterProps {
|
4 | error: any;
|
5 | }
|
6 |
|
7 | export interface AppContainerProps {
|
8 | errorBoundary?: boolean;
|
9 | errorReporter?: React.ComponentType<ErrorReporterProps>;
|
10 | }
|
11 |
|
12 | export interface AppChildren {
|
13 | children?: React.ReactElement<any>;
|
14 | }
|
15 |
|
16 | export class AppContainer extends React.Component<AppContainerProps & AppChildren> {}
|
17 |
|
18 | /**
|
19 | * Marks module and a returns a HOC to mark a Component inside it as hot-exported
|
20 | * @param {NodeModuleObject} module ALWAYS should be just "module".
|
21 | * @return {function} "hot" HOC.
|
22 | *
|
23 | * @example marks current module as hot, and export MyComponent as HotExportedMyComponent
|
24 | * export default hot(module)(MyComponent)
|
25 | */
|
26 | export function hot(module: any): <T = React.ComponentType<any>>(Component: T, props?: AppContainerProps) => T;
|
27 |
|
28 | /**
|
29 | * Marks component as `cold`, and making it invisible for React-Hot-Loader.
|
30 | * Any changes to that component will cause local state loss.
|
31 | * @param {React.ComponentType} component to chill
|
32 | * @return {React.ComponentType} component, as it was passed in.
|
33 | *
|
34 | * @example marks some component as cold
|
35 | * export default cold(MyComponent)
|
36 | */
|
37 | export function cold<T = React.ComponentType<any>>(component: T): T;
|
38 |
|
39 | /**
|
40 | * Tests are types of two components equal
|
41 | * @param {Component} typeA
|
42 | * @param {Component} typeB
|
43 | * @return {boolean} are they equal
|
44 | *
|
45 | * @example test that some rendered component(ReactElement), has the same type as BaseComponent
|
46 | * areComponentEqual(RenderedComponent.type, BaseComponent)
|
47 | */
|
48 | export function areComponentsEqual<T>(typeA: React.ComponentType<T>, typeB: React.ComponentType<T>): boolean;
|
49 |
|
50 | export interface HotError {
|
51 | error: Error;
|
52 | errorInfo?: React.ErrorInfo;
|
53 | }
|
54 |
|
55 | export interface Config {
|
56 | /**
|
57 | * Specify loglLevel, default to 'error', set it to false to disable logs.
|
58 | * Available levels: ['debug', 'log', 'warn', 'error']
|
59 | */
|
60 | logLevel: string;
|
61 |
|
62 | /**
|
63 | *
|
64 | * @param {any} type being registered. This could be ANY top level variable among project.
|
65 | * @param {string} uniqueLocalName - variable name
|
66 | * @param {string} fileName - origin file
|
67 | * @return {any}
|
68 | */
|
69 | onComponentRegister: (type: any, uniqueLocalName: string, fileName: string) => any;
|
70 |
|
71 | /**
|
72 | *
|
73 | * @param type {any} type being rendered. The first argument of React.createElement
|
74 | * @param displayName {string} type display name (if exists)
|
75 | */
|
76 | onComponentCreate: (type: any, displayName: string) => any;
|
77 |
|
78 | /**
|
79 | * Allows using SFC without changes. leading to some components not updated
|
80 | */
|
81 | pureSFC: boolean;
|
82 |
|
83 | /**
|
84 | * keep render method unpatched, moving sideEffect to componentDidUpdate
|
85 | */
|
86 | pureRender: boolean;
|
87 |
|
88 | /**
|
89 | * Allows SFC to be used, enables "intermediate" components used by Relay, should be disabled for Preact
|
90 | */
|
91 | allowSFC: boolean;
|
92 |
|
93 | /**
|
94 | * Disable "hot-replacement-render"
|
95 | */
|
96 | disableHotRenderer: boolean;
|
97 |
|
98 | /**
|
99 | * Disable "hot-replacement-render" when injection into react-dom are made
|
100 | */
|
101 | disableHotRendererWhenInjected: boolean;
|
102 |
|
103 | /**
|
104 | * flag to completely disable RHL for SFC
|
105 | */
|
106 | ignoreSFC: boolean;
|
107 |
|
108 | /**
|
109 | * flag to completely disable RHL for Components
|
110 | */
|
111 | ignoreComponents: boolean;
|
112 |
|
113 | /**
|
114 | * default value for AppContainer errorOverlay
|
115 | */
|
116 | errorReporter: React.ComponentType<HotError>;
|
117 |
|
118 | /**
|
119 | * Global error overlay
|
120 | */
|
121 | ErrorOverlay: React.ComponentType<{ errors: Array<HotError> }>;
|
122 | }
|
123 |
|
124 | /**
|
125 | * Confugures how React Hot Loader works
|
126 | * @param {Config} config
|
127 | */
|
128 | export function setConfig(config: Partial<Config>): void;
|