@@ -7,20 +7,22 @@ import {
7
7
generateId ,
8
8
stringify ,
9
9
getSeralizeParameter ,
10
- } from 'remotedev- utils' ;
11
- import importState from 'remotedev-utils /lib/importState' ;
10
+ } from 'redux-devtools-core/lib/ utils' ;
11
+ import importState from 'redux-devtools-core /lib/utils /importState' ;
12
12
import {
13
13
getLocalFilter ,
14
14
isFiltered ,
15
15
filterStagedActions ,
16
16
filterState ,
17
- } from 'remotedev-utils /lib/filters' ;
17
+ } from 'redux-devtools-core /lib/utils /filters' ;
18
18
19
19
function configureStore ( next , subscriber , options ) {
20
20
return instrument ( subscriber , options ) ( next ) ;
21
21
}
22
22
23
- const instances = { /* [id]: { name, store, ... } */ } ;
23
+ const instances = {
24
+ /* [id]: { name, store, ... } */
25
+ } ;
24
26
25
27
let lastAction ;
26
28
let isExcess ;
@@ -34,9 +36,12 @@ function getLiftedState(store, filters) {
34
36
35
37
function relay ( type , state , instance , action , nextActionId ) {
36
38
const {
37
- filters, predicate,
38
- stateSanitizer, actionSanitizer,
39
- serializeState, serializeAction,
39
+ filters,
40
+ predicate,
41
+ stateSanitizer,
42
+ actionSanitizer,
43
+ serializeState,
44
+ serializeAction,
40
45
} = instance ;
41
46
42
47
const message = {
@@ -45,12 +50,21 @@ function relay(type, state, instance, action, nextActionId) {
45
50
name : instance . name ,
46
51
} ;
47
52
if ( state ) {
48
- message . payload = type === 'ERROR' ?
49
- state :
50
- stringify (
51
- filterState ( state , type , filters , stateSanitizer , actionSanitizer , nextActionId , predicate ) ,
52
- serializeState
53
- ) ;
53
+ message . payload =
54
+ type === 'ERROR'
55
+ ? state
56
+ : stringify (
57
+ filterState (
58
+ state ,
59
+ type ,
60
+ filters ,
61
+ stateSanitizer ,
62
+ actionSanitizer ,
63
+ nextActionId ,
64
+ predicate
65
+ ) ,
66
+ serializeState
67
+ ) ;
54
68
}
55
69
if ( type === 'ACTION' ) {
56
70
message . action = stringify (
@@ -103,9 +117,9 @@ function exportState({ id: instanceId, store, serializeState }) {
103
117
type : 'EXPORT' ,
104
118
payload : stringify ( payload , serializeState ) ,
105
119
committedState :
106
- typeof liftedState . committedState !== 'undefined' ?
107
- stringify ( liftedState . committedState , serializeState ) :
108
- undefined ,
120
+ typeof liftedState . committedState !== 'undefined'
121
+ ? stringify ( liftedState . committedState , serializeState )
122
+ : undefined ,
109
123
instanceId,
110
124
} ,
111
125
} ) ;
@@ -228,16 +242,14 @@ export default function devToolsEnhancer(options = {}) {
228
242
const serializeAction = getSeralizeParameter ( options , 'serializeAction' ) ;
229
243
230
244
return next => ( reducer , initialState ) => {
231
- const store = configureStore (
232
- next , monitorReducer , {
233
- maxAge,
234
- shouldCatchErrors,
235
- shouldHotReload,
236
- shouldRecordChanges,
237
- shouldStartLocked,
238
- pauseActionType,
239
- }
240
- ) ( reducer , initialState ) ;
245
+ const store = configureStore ( next , monitorReducer , {
246
+ maxAge,
247
+ shouldCatchErrors,
248
+ shouldHotReload,
249
+ shouldRecordChanges,
250
+ shouldStartLocked,
251
+ pauseActionType,
252
+ } ) ( reducer , initialState ) ;
241
253
242
254
instances [ id ] = {
243
255
name : name || id ,
@@ -266,20 +278,17 @@ export default function devToolsEnhancer(options = {}) {
266
278
} ;
267
279
}
268
280
269
- const preEnhancer = instanceId => next =>
270
- ( reducer , initialState , enhancer ) => {
271
- const store = next ( reducer , initialState , enhancer ) ;
281
+ const preEnhancer = instanceId => next => ( reducer , initialState , enhancer ) => {
282
+ const store = next ( reducer , initialState , enhancer ) ;
272
283
273
- if ( instances [ instanceId ] ) {
274
- instances [ instanceId ] . store = store ;
275
- }
276
- return {
277
- ...store ,
278
- dispatch : ( action ) => (
279
- locked ? action : store . dispatch ( action )
280
- ) ,
281
- } ;
284
+ if ( instances [ instanceId ] ) {
285
+ instances [ instanceId ] . store = store ;
286
+ }
287
+ return {
288
+ ...store ,
289
+ dispatch : action => ( locked ? action : store . dispatch ( action ) ) ,
282
290
} ;
291
+ } ;
283
292
284
293
devToolsEnhancer . updateStore = ( newStore , instanceId ) => {
285
294
console . warn (
@@ -309,7 +318,8 @@ devToolsEnhancer.updateStore = (newStore, instanceId) => {
309
318
const compose = options => ( ...funcs ) => ( ...args ) => {
310
319
const instanceId = generateId ( options . instanceId ) ;
311
320
return [ preEnhancer ( instanceId ) , ...funcs ] . reduceRight (
312
- ( composed , f ) => f ( composed ) , devToolsEnhancer ( { ...options , instanceId } ) ( ...args )
321
+ ( composed , f ) => f ( composed ) ,
322
+ devToolsEnhancer ( { ...options , instanceId } ) ( ...args )
313
323
) ;
314
324
} ;
315
325
0 commit comments