UNPKG

10.3 kBTypeScriptView Raw
1import type { Action, ActionCreator, StoreEnhancer } from 'redux';
2import { compose } from 'redux';
3/**
4 * @public
5 */
6export interface DevToolsEnhancerOptions {
7 /**
8 * the instance name to be showed on the monitor page. Default value is `document.title`.
9 * If not specified and there's no document title, it will consist of `tabId` and `instanceId`.
10 */
11 name?: string;
12 /**
13 * action creators functions to be available in the Dispatcher.
14 */
15 actionCreators?: ActionCreator<any>[] | {
16 [key: string]: ActionCreator<any>;
17 };
18 /**
19 * if more than one action is dispatched in the indicated interval, all new actions will be collected and sent at once.
20 * It is the joint between performance and speed. When set to `0`, all actions will be sent instantly.
21 * Set it to a higher value when experiencing perf issues (also `maxAge` to a lower value).
22 *
23 * @default 500 ms.
24 */
25 latency?: number;
26 /**
27 * (> 1) - maximum allowed actions to be stored in the history tree. The oldest actions are removed once maxAge is reached. It's critical for performance.
28 *
29 * @default 50
30 */
31 maxAge?: number;
32 /**
33 * Customizes how actions and state are serialized and deserialized. Can be a boolean or object. If given a boolean, the behavior is the same as if you
34 * were to pass an object and specify `options` as a boolean. Giving an object allows fine-grained customization using the `replacer` and `reviver`
35 * functions.
36 */
37 serialize?: boolean | {
38 /**
39 * - `undefined` - will use regular `JSON.stringify` to send data (it's the fast mode).
40 * - `false` - will handle also circular references.
41 * - `true` - will handle also date, regex, undefined, error objects, symbols, maps, sets and functions.
42 * - object, which contains `date`, `regex`, `undefined`, `error`, `symbol`, `map`, `set` and `function` keys.
43 * For each of them you can indicate if to include (by setting as `true`).
44 * For `function` key you can also specify a custom function which handles serialization.
45 * See [`jsan`](https://github.com/kolodny/jsan) for more details.
46 */
47 options?: undefined | boolean | {
48 date?: true;
49 regex?: true;
50 undefined?: true;
51 error?: true;
52 symbol?: true;
53 map?: true;
54 set?: true;
55 function?: true | ((fn: (...args: any[]) => any) => string);
56 };
57 /**
58 * [JSON replacer function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) used for both actions and states stringify.
59 * In addition, you can specify a data type by adding a [`__serializedType__`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/helpers/index.js#L4)
60 * key. So you can deserialize it back while importing or persisting data.
61 * Moreover, it will also [show a nice preview showing the provided custom type](https://cloud.githubusercontent.com/assets/7957859/21814330/a17d556a-d761-11e6-85ef-159dd12f36c5.png):
62 */
63 replacer?: (key: string, value: unknown) => any;
64 /**
65 * [JSON `reviver` function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter)
66 * used for parsing the imported actions and states. See [`remotedev-serialize`](https://github.com/zalmoxisus/remotedev-serialize/blob/master/immutable/serialize.js#L8-L41)
67 * as an example on how to serialize special data types and get them back.
68 */
69 reviver?: (key: string, value: unknown) => any;
70 /**
71 * Automatically serialize/deserialize immutablejs via [remotedev-serialize](https://github.com/zalmoxisus/remotedev-serialize).
72 * Just pass the Immutable library. It will support all ImmutableJS structures. You can even export them into a file and get them back.
73 * The only exception is `Record` class, for which you should pass this in addition the references to your classes in `refs`.
74 */
75 immutable?: any;
76 /**
77 * ImmutableJS `Record` classes used to make possible restore its instances back when importing, persisting...
78 */
79 refs?: any;
80 };
81 /**
82 * function which takes `action` object and id number as arguments, and should return `action` object back.
83 */
84 actionSanitizer?: <A extends Action>(action: A, id: number) => A;
85 /**
86 * function which takes `state` object and index as arguments, and should return `state` object back.
87 */
88 stateSanitizer?: <S>(state: S, index: number) => S;
89 /**
90 * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
91 * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
92 * @deprecated Use actionsDenylist instead.
93 */
94 actionsBlacklist?: string | string[];
95 /**
96 * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
97 * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
98 * @deprecated Use actionsAllowlist instead.
99 */
100 actionsWhitelist?: string | string[];
101 /**
102 * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
103 * If `actionsAllowlist` specified, `actionsDenylist` is ignored.
104 */
105 actionsDenylist?: string | string[];
106 /**
107 * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
108 * If `actionsAllowlist` specified, `actionsDenylist` is ignored.
109 */
110 actionsAllowlist?: string | string[];
111 /**
112 * called for every action before sending, takes `state` and `action` object, and returns `true` in case it allows sending the current data to the monitor.
113 * Use it as a more advanced version of `actionsDenylist`/`actionsAllowlist` parameters.
114 */
115 predicate?: <S, A extends Action>(state: S, action: A) => boolean;
116 /**
117 * if specified as `false`, it will not record the changes till clicking on `Start recording` button.
118 * Available only for Redux enhancer, for others use `autoPause`.
119 *
120 * @default true
121 */
122 shouldRecordChanges?: boolean;
123 /**
124 * if specified, whenever clicking on `Pause recording` button and there are actions in the history log, will add this action type.
125 * If not specified, will commit when paused. Available only for Redux enhancer.
126 *
127 * @default "@@PAUSED""
128 */
129 pauseActionType?: string;
130 /**
131 * auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.
132 * Not available for Redux enhancer (as it already does it but storing the data to be sent).
133 *
134 * @default false
135 */
136 autoPause?: boolean;
137 /**
138 * if specified as `true`, it will not allow any non-monitor actions to be dispatched till clicking on `Unlock changes` button.
139 * Available only for Redux enhancer.
140 *
141 * @default false
142 */
143 shouldStartLocked?: boolean;
144 /**
145 * if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Available only for Redux enhancer.
146 *
147 * @default true
148 */
149 shouldHotReload?: boolean;
150 /**
151 * if specified as `true`, whenever there's an exception in reducers, the monitors will show the error message, and next actions will not be dispatched.
152 *
153 * @default false
154 */
155 shouldCatchErrors?: boolean;
156 /**
157 * If you want to restrict the extension, specify the features you allow.
158 * If not specified, all of the features are enabled. When set as an object, only those included as `true` will be allowed.
159 * Note that except `true`/`false`, `import` and `export` can be set as `custom` (which is by default for Redux enhancer), meaning that the importing/exporting occurs on the client side.
160 * Otherwise, you'll get/set the data right from the monitor part.
161 */
162 features?: {
163 /**
164 * start/pause recording of dispatched actions
165 */
166 pause?: boolean;
167 /**
168 * lock/unlock dispatching actions and side effects
169 */
170 lock?: boolean;
171 /**
172 * persist states on page reloading
173 */
174 persist?: boolean;
175 /**
176 * export history of actions in a file
177 */
178 export?: boolean | 'custom';
179 /**
180 * import history of actions from a file
181 */
182 import?: boolean | 'custom';
183 /**
184 * jump back and forth (time travelling)
185 */
186 jump?: boolean;
187 /**
188 * skip (cancel) actions
189 */
190 skip?: boolean;
191 /**
192 * drag and drop actions in the history list
193 */
194 reorder?: boolean;
195 /**
196 * dispatch custom actions or action creators
197 */
198 dispatch?: boolean;
199 /**
200 * generate tests for the selected actions
201 */
202 test?: boolean;
203 };
204 /**
205 * Set to true or a stacktrace-returning function to record call stack traces for dispatched actions.
206 * Defaults to false.
207 */
208 trace?: boolean | (<A extends Action>(action: A) => string);
209 /**
210 * The maximum number of stack trace entries to record per action. Defaults to 10.
211 */
212 traceLimit?: number;
213}
214declare type Compose = typeof compose;
215interface ComposeWithDevTools {
216 (options: DevToolsEnhancerOptions): Compose;
217 <StoreExt>(...funcs: StoreEnhancer<StoreExt>[]): StoreEnhancer<StoreExt>;
218}
219/**
220 * @public
221 */
222export declare const composeWithDevTools: ComposeWithDevTools;
223/**
224 * @public
225 */
226export declare const devToolsEnhancer: {
227 (options: DevToolsEnhancerOptions): StoreEnhancer<any>;
228};
229export {};
230
\No newline at end of file