1
1
/* eslint-disable no-unused-vars */
2
2
3
+ import { filterObjectByKeys } from '../shared/helpers' ;
3
4
import { ray } from '../shared/VueRay' ;
4
5
5
6
export let vuexStateRay : any = null ;
6
7
7
8
class VuexState {
8
9
public state : any ;
9
10
10
- constructor ( state : any ) {
11
- this . state = state ;
11
+ constructor ( state : any , options : RayVuexPluginOptions = { } ) {
12
+ this . state = filterObjectByKeys ( Object . assign ( { } , state ) , options . trackingOptions ?. propNames ?? [ 'one' ] ) ;
12
13
}
13
14
}
14
15
@@ -26,6 +27,10 @@ export interface RayVuexPluginOptions {
26
27
logActions ?: boolean ;
27
28
loggedMutationColor ?: RayVuexPluginLogColor ;
28
29
loggedActionColor ?: RayVuexPluginLogColor ;
30
+ trackingOptions ?: {
31
+ moduleNames ?: string [ ] ;
32
+ propNames ?: string [ ] ;
33
+ } ;
29
34
}
30
35
31
36
const DefaultVuexPluginOptions : RayVuexPluginOptions = {
@@ -34,6 +39,10 @@ const DefaultVuexPluginOptions: RayVuexPluginOptions = {
34
39
logActions : false ,
35
40
loggedMutationColor : 'none' ,
36
41
loggedActionColor : 'none' ,
42
+ trackingOptions : {
43
+ moduleNames : [ '*' ] ,
44
+ propNames : [ '*' ] ,
45
+ } ,
37
46
} ;
38
47
39
48
const decorateEventType = ( name : RayVuexPluginEventType , color : string ) => {
@@ -78,7 +87,7 @@ export const VuexPlugin = (
78
87
vuexStateRay = rayInstance ( ) ;
79
88
}
80
89
81
- vuexStateRay = vuexStateRay . send ( new VuexState ( copiedState ) ) ;
90
+ vuexStateRay = vuexStateRay . send ( new VuexState ( copiedState , options ) ) ;
82
91
} ) ;
83
92
}
84
93
0 commit comments