|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * vuex v2.2.0
|
|
|
+ * vuex v2.2.1
|
|
|
* (c) 2017 Evan You
|
|
|
* @license MIT
|
|
|
*/
|
|
@@ -236,122 +236,6 @@ function update (targetModule, newModule) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-var mapState = normalizeNamespace(function (namespace, states) {
|
|
|
- var res = {};
|
|
|
- normalizeMap(states).forEach(function (ref) {
|
|
|
- var key = ref.key;
|
|
|
- var val = ref.val;
|
|
|
-
|
|
|
- res[key] = function mappedState () {
|
|
|
- var state = this.$store.state;
|
|
|
- var getters = this.$store.getters;
|
|
|
- if (namespace) {
|
|
|
- var module = getModuleByNamespace(this.$store, 'mapState', namespace);
|
|
|
- if (!module) {
|
|
|
- return
|
|
|
- }
|
|
|
- state = module.context.state;
|
|
|
- getters = module.context.getters;
|
|
|
- }
|
|
|
- return typeof val === 'function'
|
|
|
- ? val.call(this, state, getters)
|
|
|
- : state[val]
|
|
|
- };
|
|
|
- // mark vuex getter for devtools
|
|
|
- res[key].vuex = true;
|
|
|
- });
|
|
|
- return res
|
|
|
-});
|
|
|
-
|
|
|
-var mapMutations = normalizeNamespace(function (namespace, mutations) {
|
|
|
- var res = {};
|
|
|
- normalizeMap(mutations).forEach(function (ref) {
|
|
|
- var key = ref.key;
|
|
|
- var val = ref.val;
|
|
|
-
|
|
|
- val = namespace + val;
|
|
|
- res[key] = function mappedMutation () {
|
|
|
- var args = [], len = arguments.length;
|
|
|
- while ( len-- ) args[ len ] = arguments[ len ];
|
|
|
-
|
|
|
- if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
|
|
|
- return
|
|
|
- }
|
|
|
- return this.$store.commit.apply(this.$store, [val].concat(args))
|
|
|
- };
|
|
|
- });
|
|
|
- return res
|
|
|
-});
|
|
|
-
|
|
|
-var mapGetters = normalizeNamespace(function (namespace, getters) {
|
|
|
- var res = {};
|
|
|
- normalizeMap(getters).forEach(function (ref) {
|
|
|
- var key = ref.key;
|
|
|
- var val = ref.val;
|
|
|
-
|
|
|
- val = namespace + val;
|
|
|
- res[key] = function mappedGetter () {
|
|
|
- if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
|
|
|
- return
|
|
|
- }
|
|
|
- if (!(val in this.$store.getters)) {
|
|
|
- console.error(("[vuex] unknown getter: " + val));
|
|
|
- return
|
|
|
- }
|
|
|
- return this.$store.getters[val]
|
|
|
- };
|
|
|
- // mark vuex getter for devtools
|
|
|
- res[key].vuex = true;
|
|
|
- });
|
|
|
- return res
|
|
|
-});
|
|
|
-
|
|
|
-var mapActions = normalizeNamespace(function (namespace, actions) {
|
|
|
- var res = {};
|
|
|
- normalizeMap(actions).forEach(function (ref) {
|
|
|
- var key = ref.key;
|
|
|
- var val = ref.val;
|
|
|
-
|
|
|
- val = namespace + val;
|
|
|
- res[key] = function mappedAction () {
|
|
|
- var args = [], len = arguments.length;
|
|
|
- while ( len-- ) args[ len ] = arguments[ len ];
|
|
|
-
|
|
|
- if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
|
|
|
- return
|
|
|
- }
|
|
|
- return this.$store.dispatch.apply(this.$store, [val].concat(args))
|
|
|
- };
|
|
|
- });
|
|
|
- return res
|
|
|
-});
|
|
|
-
|
|
|
-function normalizeMap (map) {
|
|
|
- return Array.isArray(map)
|
|
|
- ? map.map(function (key) { return ({ key: key, val: key }); })
|
|
|
- : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
|
|
|
-}
|
|
|
-
|
|
|
-function normalizeNamespace (fn) {
|
|
|
- return function (namespace, map) {
|
|
|
- if (typeof namespace !== 'string') {
|
|
|
- map = namespace;
|
|
|
- namespace = '';
|
|
|
- } else if (namespace.charAt(namespace.length - 1) !== '/') {
|
|
|
- namespace += '/';
|
|
|
- }
|
|
|
- return fn(namespace, map)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function getModuleByNamespace (store, helper, namespace) {
|
|
|
- var module = store._modulesNamespaceMap[namespace];
|
|
|
- if (!module) {
|
|
|
- console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
|
|
|
- }
|
|
|
- return module
|
|
|
-}
|
|
|
-
|
|
|
var Vue; // bind on install
|
|
|
|
|
|
var Store = function Store (options) {
|
|
@@ -790,14 +674,130 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
install(window.Vue);
|
|
|
}
|
|
|
|
|
|
-var index = {
|
|
|
+var mapState = normalizeNamespace(function (namespace, states) {
|
|
|
+ var res = {};
|
|
|
+ normalizeMap(states).forEach(function (ref) {
|
|
|
+ var key = ref.key;
|
|
|
+ var val = ref.val;
|
|
|
+
|
|
|
+ res[key] = function mappedState () {
|
|
|
+ var state = this.$store.state;
|
|
|
+ var getters = this.$store.getters;
|
|
|
+ if (namespace) {
|
|
|
+ var module = getModuleByNamespace(this.$store, 'mapState', namespace);
|
|
|
+ if (!module) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ state = module.context.state;
|
|
|
+ getters = module.context.getters;
|
|
|
+ }
|
|
|
+ return typeof val === 'function'
|
|
|
+ ? val.call(this, state, getters)
|
|
|
+ : state[val]
|
|
|
+ };
|
|
|
+ // mark vuex getter for devtools
|
|
|
+ res[key].vuex = true;
|
|
|
+ });
|
|
|
+ return res
|
|
|
+});
|
|
|
+
|
|
|
+var mapMutations = normalizeNamespace(function (namespace, mutations) {
|
|
|
+ var res = {};
|
|
|
+ normalizeMap(mutations).forEach(function (ref) {
|
|
|
+ var key = ref.key;
|
|
|
+ var val = ref.val;
|
|
|
+
|
|
|
+ val = namespace + val;
|
|
|
+ res[key] = function mappedMutation () {
|
|
|
+ var args = [], len = arguments.length;
|
|
|
+ while ( len-- ) args[ len ] = arguments[ len ];
|
|
|
+
|
|
|
+ if (namespace && !getModuleByNamespace(this.$store, 'mapMutations', namespace)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return this.$store.commit.apply(this.$store, [val].concat(args))
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return res
|
|
|
+});
|
|
|
+
|
|
|
+var mapGetters = normalizeNamespace(function (namespace, getters) {
|
|
|
+ var res = {};
|
|
|
+ normalizeMap(getters).forEach(function (ref) {
|
|
|
+ var key = ref.key;
|
|
|
+ var val = ref.val;
|
|
|
+
|
|
|
+ val = namespace + val;
|
|
|
+ res[key] = function mappedGetter () {
|
|
|
+ if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!(val in this.$store.getters)) {
|
|
|
+ console.error(("[vuex] unknown getter: " + val));
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return this.$store.getters[val]
|
|
|
+ };
|
|
|
+ // mark vuex getter for devtools
|
|
|
+ res[key].vuex = true;
|
|
|
+ });
|
|
|
+ return res
|
|
|
+});
|
|
|
+
|
|
|
+var mapActions = normalizeNamespace(function (namespace, actions) {
|
|
|
+ var res = {};
|
|
|
+ normalizeMap(actions).forEach(function (ref) {
|
|
|
+ var key = ref.key;
|
|
|
+ var val = ref.val;
|
|
|
+
|
|
|
+ val = namespace + val;
|
|
|
+ res[key] = function mappedAction () {
|
|
|
+ var args = [], len = arguments.length;
|
|
|
+ while ( len-- ) args[ len ] = arguments[ len ];
|
|
|
+
|
|
|
+ if (namespace && !getModuleByNamespace(this.$store, 'mapActions', namespace)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return this.$store.dispatch.apply(this.$store, [val].concat(args))
|
|
|
+ };
|
|
|
+ });
|
|
|
+ return res
|
|
|
+});
|
|
|
+
|
|
|
+function normalizeMap (map) {
|
|
|
+ return Array.isArray(map)
|
|
|
+ ? map.map(function (key) { return ({ key: key, val: key }); })
|
|
|
+ : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
|
|
|
+}
|
|
|
+
|
|
|
+function normalizeNamespace (fn) {
|
|
|
+ return function (namespace, map) {
|
|
|
+ if (typeof namespace !== 'string') {
|
|
|
+ map = namespace;
|
|
|
+ namespace = '';
|
|
|
+ } else if (namespace.charAt(namespace.length - 1) !== '/') {
|
|
|
+ namespace += '/';
|
|
|
+ }
|
|
|
+ return fn(namespace, map)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function getModuleByNamespace (store, helper, namespace) {
|
|
|
+ var module = store._modulesNamespaceMap[namespace];
|
|
|
+ if (!module) {
|
|
|
+ console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
|
|
|
+ }
|
|
|
+ return module
|
|
|
+}
|
|
|
+
|
|
|
+var index_esm = {
|
|
|
Store: Store,
|
|
|
install: install,
|
|
|
- version: '2.2.0',
|
|
|
+ version: '2.2.1',
|
|
|
mapState: mapState,
|
|
|
mapMutations: mapMutations,
|
|
|
mapGetters: mapGetters,
|
|
|
mapActions: mapActions
|
|
|
};
|
|
|
|
|
|
-export default index;
|
|
|
+export { Store, mapState, mapMutations, mapGetters, mapActions };export default index_esm;
|