1 | import { Action, ActionCreator, StoreEnhancer, compose } from 'redux'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export interface EnhancerOptions {
|
7 | |
8 |
|
9 |
|
10 |
|
11 | name?: string
|
12 | |
13 |
|
14 |
|
15 | actionCreators?: ActionCreator<any>[] | { [key: string]: ActionCreator<any> }
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | latency?: number
|
24 | |
25 |
|
26 |
|
27 |
|
28 |
|
29 | maxAge?: number
|
30 | |
31 |
|
32 |
|
33 | serialize?:
|
34 | | boolean
|
35 | | {
|
36 | options?:
|
37 | | boolean
|
38 | | {
|
39 | date?: boolean
|
40 | regex?: boolean
|
41 | undefined?: boolean
|
42 | error?: boolean
|
43 | symbol?: boolean
|
44 | map?: boolean
|
45 | set?: boolean
|
46 | function?: boolean | Function
|
47 | }
|
48 | replacer?: (key: string, value: unknown) => unknown
|
49 | reviver?: (key: string, value: unknown) => unknown
|
50 | immutable?: unknown
|
51 | refs?: unknown[]
|
52 | }
|
53 | /**
|
54 | * function which takes `action` object and id number as arguments, and should return `action` object back.
|
55 | */
|
56 | actionSanitizer?: <A extends Action>(action: A, id: number) => A
|
57 | /**
|
58 | * function which takes `state` object and index as arguments, and should return `state` object back.
|
59 | */
|
60 | stateSanitizer?: <S>(state: S, index: number) => S
|
61 | /**
|
62 | * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
63 | * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
|
64 | */
|
65 | actionsBlacklist?: string | string[]
|
66 | /**
|
67 | * *string or array of strings as regex* - actions types to be hidden / shown in the monitors (while passed to the reducers).
|
68 | * If `actionsWhitelist` specified, `actionsBlacklist` is ignored.
|
69 | */
|
70 | actionsWhitelist?: string | string[]
|
71 | /**
|
72 | * 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.
|
73 | * Use it as a more advanced version of `actionsBlacklist`/`actionsWhitelist` parameters.
|
74 | */
|
75 | predicate?: <S, A extends Action>(state: S, action: A) => boolean
|
76 | /**
|
77 | * if specified as `false`, it will not record the changes till clicking on `Start recording` button.
|
78 | * Available only for Redux enhancer, for others use `autoPause`.
|
79 | *
|
80 | * @default true
|
81 | */
|
82 | shouldRecordChanges?: boolean
|
83 | /**
|
84 | * if specified, whenever clicking on `Pause recording` button and there are actions in the history log, will add this action type.
|
85 | * If not specified, will commit when paused. Available only for Redux enhancer.
|
86 | *
|
87 | * @default "@@PAUSED""
|
88 | */
|
89 | pauseActionType?: string
|
90 | /**
|
91 | * auto pauses when the extension’s window is not opened, and so has zero impact on your app when not in use.
|
92 | * Not available for Redux enhancer (as it already does it but storing the data to be sent).
|
93 | *
|
94 | * @default false
|
95 | */
|
96 | autoPause?: boolean
|
97 | /**
|
98 | * if specified as `true`, it will not allow any non-monitor actions to be dispatched till clicking on `Unlock changes` button.
|
99 | * Available only for Redux enhancer.
|
100 | *
|
101 | * @default false
|
102 | */
|
103 | shouldStartLocked?: boolean
|
104 | /**
|
105 | * if set to `false`, will not recompute the states on hot reloading (or on replacing the reducers). Available only for Redux enhancer.
|
106 | *
|
107 | * @default true
|
108 | */
|
109 | shouldHotReload?: boolean
|
110 | /**
|
111 | * 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.
|
112 | *
|
113 | * @default false
|
114 | */
|
115 | shouldCatchErrors?: boolean
|
116 | /**
|
117 | * If you want to restrict the extension, specify the features you allow.
|
118 | * If not specified, all of the features are enabled. When set as an object, only those included as `true` will be allowed.
|
119 | * 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.
|
120 | * Otherwise, you'll get/set the data right from the monitor part.
|
121 | */
|
122 | features?: {
|
123 | /**
|
124 | * start/pause recording of dispatched actions
|
125 | */
|
126 | pause?: boolean
|
127 | /**
|
128 | * lock/unlock dispatching actions and side effects
|
129 | */
|
130 | lock?: boolean
|
131 | /**
|
132 | * persist states on page reloading
|
133 | */
|
134 | persist?: boolean
|
135 | /**
|
136 | * export history of actions in a file
|
137 | */
|
138 | export?: boolean | 'custom'
|
139 | /**
|
140 | * import history of actions from a file
|
141 | */
|
142 | import?: boolean | 'custom'
|
143 | /**
|
144 | * jump back and forth (time travelling)
|
145 | */
|
146 | jump?: boolean
|
147 | /**
|
148 | * skip (cancel) actions
|
149 | */
|
150 | skip?: boolean
|
151 | /**
|
152 | * drag and drop actions in the history list
|
153 | */
|
154 | reorder?: boolean
|
155 | /**
|
156 | * dispatch custom actions or action creators
|
157 | */
|
158 | dispatch?: boolean
|
159 | /**
|
160 | * generate tests for the selected actions
|
161 | */
|
162 | test?: boolean
|
163 | }
|
164 | /**
|
165 | * Set to true or a stacktrace-returning function to record call stack traces for dispatched actions.
|
166 | * Defaults to false.
|
167 | */
|
168 | trace?: boolean | (<A extends Action>(action: A) => string)
|
169 | /**
|
170 | * The maximum number of stack trace entries to record per action. Defaults to 10.
|
171 | */
|
172 | traceLimit?: number
|
173 | }
|
174 |
|
175 | /**
|
176 | * @public
|
177 | */
|
178 | export const composeWithDevTools: {
|
179 | (options: EnhancerOptions): typeof compose
|
180 | <StoreExt>(...funcs: Array<StoreEnhancer<StoreExt>>): StoreEnhancer<StoreExt>
|
181 | } =
|
182 | typeof window !== 'undefined' &&
|
183 | (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
184 | ? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
185 | : function() {
|
186 | if (arguments.length === 0) return undefined
|
187 | if (typeof arguments[0] === 'object') return compose
|
188 | return compose.apply(null, (arguments as any) as Function[])
|
189 | }
|
190 |
|
191 | /**
|
192 | * @public
|
193 | */
|
194 | export const devToolsEnhancer: {
|
195 | (options: EnhancerOptions): StoreEnhancer<any>
|
196 | } =
|
197 | typeof window !== 'undefined' && (window as any).__REDUX_DEVTOOLS_EXTENSION__
|
198 | ? (window as any).__REDUX_DEVTOOLS_EXTENSION__
|
199 | : function() {
|
200 | return function(noop) {
|
201 | return noop
|
202 | }
|
203 | }
|
204 |
|
\ | No newline at end of file |