|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * vuex v2.4.0
|
|
|
+ * vuex v2.4.1
|
|
|
* (c) 2017 Evan You
|
|
|
* @license MIT
|
|
|
*/
|
|
@@ -105,7 +105,7 @@ var Module = function Module (rawModule, runtime) {
|
|
|
this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
|
|
|
};
|
|
|
|
|
|
-var prototypeAccessors$1 = { namespaced: {} };
|
|
|
+var prototypeAccessors$1 = { namespaced: { configurable: true } };
|
|
|
|
|
|
prototypeAccessors$1.namespaced.get = function () {
|
|
|
return !!this._rawModule.namespaced
|
|
@@ -273,6 +273,13 @@ var Store = function Store (options) {
|
|
|
var this$1 = this;
|
|
|
if ( options === void 0 ) options = {};
|
|
|
|
|
|
+ // Auto install if it is not done yet and `window` has `Vue`.
|
|
|
+ // To allow users to avoid auto-installation in some cases,
|
|
|
+ // this code should be placed here. See #731
|
|
|
+ if (!Vue && typeof window !== 'undefined' && window.Vue) {
|
|
|
+ install(window.Vue);
|
|
|
+ }
|
|
|
+
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
assert(Vue, "must call Vue.use(Vuex) before creating a store instance.");
|
|
|
assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
|
|
@@ -329,7 +336,7 @@ var Store = function Store (options) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-var prototypeAccessors = { state: {} };
|
|
|
+var prototypeAccessors = { state: { configurable: true } };
|
|
|
|
|
|
prototypeAccessors.state.get = function () {
|
|
|
return this._vm._data.$$state
|
|
@@ -727,7 +734,7 @@ function unifyObjectStyle (type, payload, options) {
|
|
|
}
|
|
|
|
|
|
function install (_Vue) {
|
|
|
- if (Vue) {
|
|
|
+ if (Vue && _Vue === Vue) {
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
console.error(
|
|
|
'[vuex] already installed. Vue.use(Vuex) should be called only once.'
|
|
@@ -739,11 +746,6 @@ function install (_Vue) {
|
|
|
applyMixin(Vue);
|
|
|
}
|
|
|
|
|
|
-// auto install in dist mode
|
|
|
-if (typeof window !== 'undefined' && window.Vue) {
|
|
|
- install(window.Vue);
|
|
|
-}
|
|
|
-
|
|
|
var mapState = normalizeNamespace(function (namespace, states) {
|
|
|
var res = {};
|
|
|
normalizeMap(states).forEach(function (ref) {
|
|
@@ -777,15 +779,21 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
|
|
|
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
|
|
|
+ var commit = this.$store.commit;
|
|
|
+ if (namespace) {
|
|
|
+ var module = getModuleByNamespace(this.$store, 'mapMutations', namespace);
|
|
|
+ if (!module) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ commit = module.context.commit;
|
|
|
}
|
|
|
- return this.$store.commit.apply(this.$store, [val].concat(args))
|
|
|
+ return typeof val === 'function'
|
|
|
+ ? val.apply(this, [commit].concat(args))
|
|
|
+ : commit.apply(this.$store, [val].concat(args))
|
|
|
};
|
|
|
});
|
|
|
return res
|
|
@@ -820,15 +828,21 @@ var mapActions = normalizeNamespace(function (namespace, actions) {
|
|
|
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
|
|
|
+ var dispatch = this.$store.dispatch;
|
|
|
+ if (namespace) {
|
|
|
+ var module = getModuleByNamespace(this.$store, 'mapActions', namespace);
|
|
|
+ if (!module) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ dispatch = module.context.dispatch;
|
|
|
}
|
|
|
- return this.$store.dispatch.apply(this.$store, [val].concat(args))
|
|
|
+ return typeof val === 'function'
|
|
|
+ ? val.apply(this, [dispatch].concat(args))
|
|
|
+ : dispatch.apply(this.$store, [val].concat(args))
|
|
|
};
|
|
|
});
|
|
|
return res
|
|
@@ -870,7 +884,7 @@ function getModuleByNamespace (store, helper, namespace) {
|
|
|
var index_esm = {
|
|
|
Store: Store,
|
|
|
install: install,
|
|
|
- version: '2.4.0',
|
|
|
+ version: '2.4.1',
|
|
|
mapState: mapState,
|
|
|
mapMutations: mapMutations,
|
|
|
mapGetters: mapGetters,
|
|
@@ -878,4 +892,5 @@ var index_esm = {
|
|
|
createNamespacedHelpers: createNamespacedHelpers
|
|
|
};
|
|
|
|
|
|
-export { Store, mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers };export default index_esm;
|
|
|
+export { Store, install, mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers };
|
|
|
+export default index_esm;
|