nuxt-typed-vuex
Advanced tools
Comparing version
@@ -5,2 +5,11 @@ # Changelog | ||
### [0.1.3](https://github.com/danielroe/nuxt-typed-vuex/compare/v0.1.2...v0.1.3) (2019-10-05) | ||
### Bug Fixes | ||
* allow partial submodules ([d27bea0](https://github.com/danielroe/nuxt-typed-vuex/commit/d27bea0)) | ||
* allow specifying different rootState ([a837a24](https://github.com/danielroe/nuxt-typed-vuex/commit/a837a24)) | ||
* convert plugin to ts ([ae240eb](https://github.com/danielroe/nuxt-typed-vuex/commit/ae240eb)) | ||
### [0.1.2](https://github.com/danielroe/nuxt-typed-vuex/compare/v0.1.1...v0.1.2) (2019-10-04) | ||
@@ -7,0 +16,0 @@ |
@@ -0,5 +1,5 @@ | ||
import { InjectKey } from 'vue/types/options'; | ||
import { Context } from '@nuxt/types'; | ||
import { InjectKey } from 'vue/types/options'; | ||
declare type Inject = (name: InjectKey, property: unknown) => void; | ||
declare const _default: ({ store }: Context, inject: Inject) => Promise<void>; | ||
export default _default; |
@@ -1,8 +0,9 @@ | ||
import { createStore } from '<%= options.buildDir %>/store' | ||
import { getAccessorFromStore } from '<%= options.libDir %>/utils' | ||
const accessorPattern = getAccessorFromStore(createStore()) | ||
// eslint-disable-next-line | ||
const { createStore } = require('<%= options.buildDir %>/store'); | ||
// eslint-disable-next-line | ||
const { getAccessorFromStore } = require('<%= options.libDir %>/utils'); | ||
const storeAccessor = getAccessorFromStore(createStore()); | ||
export default async ({ store }, inject) => { | ||
inject('accessor', accessorPattern(store)) | ||
} | ||
inject('accessor', storeAccessor(store)); | ||
}; | ||
//# sourceMappingURL=plugin.js.map |
@@ -13,3 +13,3 @@ import { Store, GetterTree, MutationTree, ActionTree, DispatchOptions, CommitOptions } from 'vuex'; | ||
declare type ModuleTransformer<T> = T extends NuxtModules ? { | ||
[P in keyof T]: MergedStoreType<T[P]>; | ||
[P in keyof T]: MergedStoreType<T[P] & BlankStore>; | ||
} : {}; | ||
@@ -29,5 +29,7 @@ interface BlankStore { | ||
} | ||
declare type NuxtModules = Record<string, NuxtStore>; | ||
declare type NuxtModules = Record<string, Partial<NuxtStore> & { | ||
state: () => unknown; | ||
}>; | ||
interface NuxtStoreInput<T extends () => any, G, M, A, S extends { | ||
[key: string]: NuxtStore; | ||
[key: string]: Partial<NuxtStore>; | ||
}> { | ||
@@ -60,9 +62,15 @@ state: T; | ||
}; | ||
export declare const getStoreType: <T extends () => any, G, M, A, S extends Record<string, NuxtStore>>(store: NuxtStoreInput<T, G, M, A, S>) => { | ||
export declare const getStoreType: <T extends () => any, G, M, A, S extends Record<string, Partial<NuxtStore> & { | ||
state: () => unknown; | ||
}>>(store: NuxtStoreInput<T, G, M, A, S>) => { | ||
actionContext: ActionContext<NuxtStoreInput<T, G, M, A, S> & BlankStore>; | ||
storeInstance: ActionContext<NuxtStoreInput<T, G, M, A, S> & BlankStore> & Pick<Store<ReturnType<T>>, "app" | "replaceState" | "subscribe" | "subscribeAction" | "watch" | "registerModule" | "unregisterModule" | "hotUpdate" | "$router">; | ||
}; | ||
export declare const getAccessorType: <T extends () => any, G extends GetterTree<ReturnType<T>, ReturnType<T>>, M extends MutationTree<ReturnType<T>>, A extends ActionTree<ReturnType<T>, ReturnType<T>>, S extends Record<string, NuxtStore>>(store: NuxtStoreInput<T, G, M, A, S>) => MergedStoreType<NuxtStoreInput<T, G, M, A, S> & BlankStore>; | ||
export declare const useAccessor: <T extends () => any, G extends GetterTree<ReturnType<T>, ReturnType<T>>, M extends MutationTree<ReturnType<T>>, A extends ActionTree<ReturnType<T>, ReturnType<T>>, S extends Record<string, NuxtStore>>(store: Store<ReturnType<T>>, input: Required<NuxtStoreInput<T, G, M, A, S>>) => MergedStoreType<NuxtStoreInput<T, G, M, A, S> & BlankStore>; | ||
export declare const getAccessorType: <T extends () => any, G extends GetterTree<ReturnType<T>, any>, M extends MutationTree<ReturnType<T>>, A extends ActionTree<ReturnType<T>, any>, S extends Record<string, Partial<NuxtStore> & { | ||
state: () => unknown; | ||
}>>(store: NuxtStoreInput<T, G, M, A, S>) => MergedStoreType<NuxtStoreInput<T, G, M, A, S> & BlankStore>; | ||
export declare const useAccessor: <T extends () => any, G extends GetterTree<ReturnType<T>, ReturnType<T>>, M extends MutationTree<ReturnType<T>>, A extends ActionTree<ReturnType<T>, ReturnType<T>>, S extends Record<string, Partial<NuxtStore> & { | ||
state: () => unknown; | ||
}>>(store: Store<ReturnType<T>>, input: Required<NuxtStoreInput<T, G, M, A, S>>) => MergedStoreType<NuxtStoreInput<T, G, M, A, S> & BlankStore>; | ||
export declare const getAccessorFromStore: (pattern: any) => (store: Store<any>) => any; | ||
export {}; |
{ | ||
"name": "nuxt-typed-vuex", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A typed store accessor for Nuxt.", | ||
@@ -5,0 +5,0 @@ "repository": "danielroe/nuxt-typed-vuex", |
Sorry, the diff of this file is not supported yet
18153
3.48%162
5.19%