11import { extractVuexModule } from "./module" ;
22import { VuexModuleConstructor , Map , VuexModule , ProxyWatchers } from "./interfaces" ;
3+ import { getClassPath , toCamelCase } from "./utils" ;
34
45
56export function clearProxyCache < T extends typeof VuexModule > ( cls :T ) {
@@ -114,7 +115,9 @@ export function _createProxy<T>(cls: T, $store: any, namespacedPath = "") {
114115 //@ts -ignore
115116 const VuexClass = cls as VuexModuleConstructor ;
116117 const proxy = { } ;
117- const { state, mutations, actions, getters, modules } = extractVuexModule ( VuexClass ) [ VuexClass . prototype . __namespacedPath__ ] ;
118+
119+ const classPath = getClassPath ( VuexClass . prototype . __namespacedPath__ ) || toCamelCase ( VuexClass . name ) ;
120+ const { state, mutations, actions, getters, modules } = extractVuexModule ( VuexClass ) [ classPath ] ;
118121
119122 createGettersAndMutationProxyFromState ( { cls : VuexClass , proxy, state, $store, namespacedPath, maxDepth : 7 } ) ;
120123 createExplicitMutationsProxy ( VuexClass , proxy , $store , namespacedPath ) ;
@@ -261,7 +264,8 @@ function createLocalWatchers( cls :VuexModuleConstructor, $store :Map, namespace
261264function createSubModuleProxy ( $store :Map , cls :VuexModuleConstructor , proxy :Map , modules :Map ) {
262265 const store = cls . prototype . __store_cache__ || $store ;
263266 for ( let field in modules ) {
264- const subModuleClass = cls . prototype . __submodules_cache__ [ field ] ;
267+ const subModuleClass = cls . prototype . __submodules_cache__ [ field ] as VuexModuleConstructor ;
268+ subModuleClass . prototype . __namespacedPath__ = cls . prototype . __namespacedPath__ + "/" + subModuleClass . prototype . __namespacedPath__ ;
265269 proxy [ field ] = createProxy ( store , subModuleClass ) ;
266270 }
267271
@@ -365,6 +369,8 @@ function createGettersAndGetterMutationsProxy({ cls, getters, mutations, proxy,
365369 }
366370
367371 // The field has only a getter.
372+ if ( proxy [ field ] ) continue ;
373+
368374 Object . defineProperty ( proxy , field , {
369375 get : ( ) => {
370376 if ( $store . getters ) return $store . getters [ namespacedPath + field ] ;
@@ -391,7 +397,6 @@ function runSetterCheck( cls :VuexModuleConstructor, getters :Map ) {
391397 // if there are setters defined that are not in getters.
392398 // throw an error.
393399 const setterMutations = cls . prototype . __mutations_cache__ . __setter_mutations__ ;
394- console . log ( "Setter Mutations" , cls . name , setterMutations ) ;
395400 for ( let field in setterMutations ) {
396401 const setterIsNotInGetters = Object . keys ( getters ) . indexOf ( field ) < 0 ;
397402 if ( setterIsNotInGetters ) {
0 commit comments