Ver Fonte

[build] 3.1.2

ktsn há 5 anos atrás
pai
commit
1ed9a03b5d
6 ficheiros alterados com 250 adições e 94 exclusões
  1. 62 23
      dist/vuex.common.js
  2. 62 23
      dist/vuex.esm.browser.js
  3. 1 1
      dist/vuex.esm.browser.min.js
  4. 62 23
      dist/vuex.esm.js
  5. 62 23
      dist/vuex.js
  6. 1 1
      dist/vuex.min.js

+ 62 - 23
dist/vuex.common.js

@@ -1,5 +1,5 @@
 /**
 /**
- * vuex v3.1.1
+ * vuex v3.1.2
  * (c) 2019 Evan You
  * (c) 2019 Evan You
  * @license MIT
  * @license MIT
  */
  */
@@ -323,6 +323,7 @@ var Store = function Store (options) {
   this._modulesNamespaceMap = Object.create(null);
   this._modulesNamespaceMap = Object.create(null);
   this._subscribers = [];
   this._subscribers = [];
   this._watcherVM = new Vue();
   this._watcherVM = new Vue();
+  this._makeLocalGettersCache = Object.create(null);
 
 
   // bind commit and dispatch to self
   // bind commit and dispatch to self
   var store = this;
   var store = this;
@@ -555,12 +556,14 @@ function resetStoreVM (store, state, hot) {
 
 
   // bind store public getters
   // bind store public getters
   store.getters = {};
   store.getters = {};
+  // reset local getters cache
+  store._makeLocalGettersCache = Object.create(null);
   var wrappedGetters = store._wrappedGetters;
   var wrappedGetters = store._wrappedGetters;
   var computed = {};
   var computed = {};
   forEachValue(wrappedGetters, function (fn, key) {
   forEachValue(wrappedGetters, function (fn, key) {
     // use computed to leverage its lazy-caching mechanism
     // use computed to leverage its lazy-caching mechanism
     // direct inline function use will lead to closure preserving oldVm.
     // direct inline function use will lead to closure preserving oldVm.
-    // using partial to return function with only arguments preserved in closure enviroment.
+    // using partial to return function with only arguments preserved in closure environment.
     computed[key] = partial(fn, store);
     computed[key] = partial(fn, store);
     Object.defineProperty(store.getters, key, {
     Object.defineProperty(store.getters, key, {
       get: function () { return store._vm[key]; },
       get: function () { return store._vm[key]; },
@@ -604,6 +607,9 @@ function installModule (store, rootState, path, module, hot) {
 
 
   // register in namespace map
   // register in namespace map
   if (module.namespaced) {
   if (module.namespaced) {
+    if (store._modulesNamespaceMap[namespace] && process.env.NODE_ENV !== 'production') {
+      console.error(("[vuex] duplicate namespace " + namespace + " for the namespaced module " + (path.join('/'))));
+    }
     store._modulesNamespaceMap[namespace] = module;
     store._modulesNamespaceMap[namespace] = module;
   }
   }
 
 
@@ -612,6 +618,13 @@ function installModule (store, rootState, path, module, hot) {
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var moduleName = path[path.length - 1];
     var moduleName = path[path.length - 1];
     store._withCommit(function () {
     store._withCommit(function () {
+      if (process.env.NODE_ENV !== 'production') {
+        if (moduleName in parentState) {
+          console.warn(
+            ("[vuex] state field \"" + moduleName + "\" was overridden by a module with the same name at \"" + (path.join('.')) + "\"")
+          );
+        }
+      }
       Vue.set(parentState, moduleName, module.state);
       Vue.set(parentState, moduleName, module.state);
     });
     });
   }
   }
@@ -699,26 +712,28 @@ function makeLocalContext (store, namespace, path) {
 }
 }
 
 
 function makeLocalGetters (store, namespace) {
 function makeLocalGetters (store, namespace) {
-  var gettersProxy = {};
-
-  var splitPos = namespace.length;
-  Object.keys(store.getters).forEach(function (type) {
-    // skip if the target getter is not match this namespace
-    if (type.slice(0, splitPos) !== namespace) { return }
-
-    // extract local getter type
-    var localType = type.slice(splitPos);
-
-    // Add a port to the getters proxy.
-    // Define as getter property because
-    // we do not want to evaluate the getters in this time.
-    Object.defineProperty(gettersProxy, localType, {
-      get: function () { return store.getters[type]; },
-      enumerable: true
+  if (!store._makeLocalGettersCache[namespace]) {
+    var gettersProxy = {};
+    var splitPos = namespace.length;
+    Object.keys(store.getters).forEach(function (type) {
+      // skip if the target getter is not match this namespace
+      if (type.slice(0, splitPos) !== namespace) { return }
+
+      // extract local getter type
+      var localType = type.slice(splitPos);
+
+      // Add a port to the getters proxy.
+      // Define as getter property because
+      // we do not want to evaluate the getters in this time.
+      Object.defineProperty(gettersProxy, localType, {
+        get: function () { return store.getters[type]; },
+        enumerable: true
+      });
     });
     });
-  });
+    store._makeLocalGettersCache[namespace] = gettersProxy;
+  }
 
 
-  return gettersProxy
+  return store._makeLocalGettersCache[namespace]
 }
 }
 
 
 function registerMutation (store, type, handler, local) {
 function registerMutation (store, type, handler, local) {
@@ -730,7 +745,7 @@ function registerMutation (store, type, handler, local) {
 
 
 function registerAction (store, type, handler, local) {
 function registerAction (store, type, handler, local) {
   var entry = store._actions[type] || (store._actions[type] = []);
   var entry = store._actions[type] || (store._actions[type] = []);
-  entry.push(function wrappedActionHandler (payload, cb) {
+  entry.push(function wrappedActionHandler (payload) {
     var res = handler.call(store, {
     var res = handler.call(store, {
       dispatch: local.dispatch,
       dispatch: local.dispatch,
       commit: local.commit,
       commit: local.commit,
@@ -738,7 +753,7 @@ function registerAction (store, type, handler, local) {
       state: local.state,
       state: local.state,
       rootGetters: store.getters,
       rootGetters: store.getters,
       rootState: store.state
       rootState: store.state
-    }, payload, cb);
+    }, payload);
     if (!isPromise(res)) {
     if (!isPromise(res)) {
       res = Promise.resolve(res);
       res = Promise.resolve(res);
     }
     }
@@ -819,6 +834,9 @@ function install (_Vue) {
  */
  */
 var mapState = normalizeNamespace(function (namespace, states) {
 var mapState = normalizeNamespace(function (namespace, states) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(states)) {
+    console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(states).forEach(function (ref) {
   normalizeMap(states).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -852,6 +870,9 @@ var mapState = normalizeNamespace(function (namespace, states) {
  */
  */
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(mutations)) {
+    console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(mutations).forEach(function (ref) {
   normalizeMap(mutations).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -885,6 +906,9 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
  */
  */
 var mapGetters = normalizeNamespace(function (namespace, getters) {
 var mapGetters = normalizeNamespace(function (namespace, getters) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(getters)) {
+    console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(getters).forEach(function (ref) {
   normalizeMap(getters).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -915,6 +939,9 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
  */
  */
 var mapActions = normalizeNamespace(function (namespace, actions) {
 var mapActions = normalizeNamespace(function (namespace, actions) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(actions)) {
+    console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(actions).forEach(function (ref) {
   normalizeMap(actions).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -960,11 +987,23 @@ var createNamespacedHelpers = function (namespace) { return ({
  * @return {Object}
  * @return {Object}
  */
  */
 function normalizeMap (map) {
 function normalizeMap (map) {
+  if (!isValidMap(map)) {
+    return []
+  }
   return Array.isArray(map)
   return Array.isArray(map)
     ? map.map(function (key) { return ({ key: key, val: key }); })
     ? map.map(function (key) { return ({ key: key, val: key }); })
     : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
     : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
 }
 }
 
 
+/**
+ * Validate whether given map is valid or not
+ * @param {*} map
+ * @return {Boolean}
+ */
+function isValidMap (map) {
+  return Array.isArray(map) || isObject(map)
+}
+
 /**
 /**
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * @param {Function} fn
  * @param {Function} fn
@@ -1000,7 +1039,7 @@ function getModuleByNamespace (store, helper, namespace) {
 var index = {
 var index = {
   Store: Store,
   Store: Store,
   install: install,
   install: install,
-  version: '3.1.1',
+  version: '3.1.2',
   mapState: mapState,
   mapState: mapState,
   mapMutations: mapMutations,
   mapMutations: mapMutations,
   mapGetters: mapGetters,
   mapGetters: mapGetters,

+ 62 - 23
dist/vuex.esm.browser.js

@@ -1,5 +1,5 @@
 /**
 /**
- * vuex v3.1.1
+ * vuex v3.1.2
  * (c) 2019 Evan You
  * (c) 2019 Evan You
  * @license MIT
  * @license MIT
  */
  */
@@ -316,6 +316,7 @@ class Store {
     this._modulesNamespaceMap = Object.create(null);
     this._modulesNamespaceMap = Object.create(null);
     this._subscribers = [];
     this._subscribers = [];
     this._watcherVM = new Vue();
     this._watcherVM = new Vue();
+    this._makeLocalGettersCache = Object.create(null);
 
 
     // bind commit and dispatch to self
     // bind commit and dispatch to self
     const store = this;
     const store = this;
@@ -532,12 +533,14 @@ function resetStoreVM (store, state, hot) {
 
 
   // bind store public getters
   // bind store public getters
   store.getters = {};
   store.getters = {};
+  // reset local getters cache
+  store._makeLocalGettersCache = Object.create(null);
   const wrappedGetters = store._wrappedGetters;
   const wrappedGetters = store._wrappedGetters;
   const computed = {};
   const computed = {};
   forEachValue(wrappedGetters, (fn, key) => {
   forEachValue(wrappedGetters, (fn, key) => {
     // use computed to leverage its lazy-caching mechanism
     // use computed to leverage its lazy-caching mechanism
     // direct inline function use will lead to closure preserving oldVm.
     // direct inline function use will lead to closure preserving oldVm.
-    // using partial to return function with only arguments preserved in closure enviroment.
+    // using partial to return function with only arguments preserved in closure environment.
     computed[key] = partial(fn, store);
     computed[key] = partial(fn, store);
     Object.defineProperty(store.getters, key, {
     Object.defineProperty(store.getters, key, {
       get: () => store._vm[key],
       get: () => store._vm[key],
@@ -581,6 +584,9 @@ function installModule (store, rootState, path, module, hot) {
 
 
   // register in namespace map
   // register in namespace map
   if (module.namespaced) {
   if (module.namespaced) {
+    if (store._modulesNamespaceMap[namespace] && "development" !== 'production') {
+      console.error(`[vuex] duplicate namespace ${namespace} for the namespaced module ${path.join('/')}`);
+    }
     store._modulesNamespaceMap[namespace] = module;
     store._modulesNamespaceMap[namespace] = module;
   }
   }
 
 
@@ -589,6 +595,13 @@ function installModule (store, rootState, path, module, hot) {
     const parentState = getNestedState(rootState, path.slice(0, -1));
     const parentState = getNestedState(rootState, path.slice(0, -1));
     const moduleName = path[path.length - 1];
     const moduleName = path[path.length - 1];
     store._withCommit(() => {
     store._withCommit(() => {
+      {
+        if (moduleName in parentState) {
+          console.warn(
+            `[vuex] state field "${moduleName}" was overridden by a module with the same name at "${path.join('.')}"`
+          );
+        }
+      }
       Vue.set(parentState, moduleName, module.state);
       Vue.set(parentState, moduleName, module.state);
     });
     });
   }
   }
@@ -674,26 +687,28 @@ function makeLocalContext (store, namespace, path) {
 }
 }
 
 
 function makeLocalGetters (store, namespace) {
 function makeLocalGetters (store, namespace) {
-  const gettersProxy = {};
-
-  const splitPos = namespace.length;
-  Object.keys(store.getters).forEach(type => {
-    // skip if the target getter is not match this namespace
-    if (type.slice(0, splitPos) !== namespace) return
-
-    // extract local getter type
-    const localType = type.slice(splitPos);
-
-    // Add a port to the getters proxy.
-    // Define as getter property because
-    // we do not want to evaluate the getters in this time.
-    Object.defineProperty(gettersProxy, localType, {
-      get: () => store.getters[type],
-      enumerable: true
+  if (!store._makeLocalGettersCache[namespace]) {
+    const gettersProxy = {};
+    const splitPos = namespace.length;
+    Object.keys(store.getters).forEach(type => {
+      // skip if the target getter is not match this namespace
+      if (type.slice(0, splitPos) !== namespace) return
+
+      // extract local getter type
+      const localType = type.slice(splitPos);
+
+      // Add a port to the getters proxy.
+      // Define as getter property because
+      // we do not want to evaluate the getters in this time.
+      Object.defineProperty(gettersProxy, localType, {
+        get: () => store.getters[type],
+        enumerable: true
+      });
     });
     });
-  });
+    store._makeLocalGettersCache[namespace] = gettersProxy;
+  }
 
 
-  return gettersProxy
+  return store._makeLocalGettersCache[namespace]
 }
 }
 
 
 function registerMutation (store, type, handler, local) {
 function registerMutation (store, type, handler, local) {
@@ -705,7 +720,7 @@ function registerMutation (store, type, handler, local) {
 
 
 function registerAction (store, type, handler, local) {
 function registerAction (store, type, handler, local) {
   const entry = store._actions[type] || (store._actions[type] = []);
   const entry = store._actions[type] || (store._actions[type] = []);
-  entry.push(function wrappedActionHandler (payload, cb) {
+  entry.push(function wrappedActionHandler (payload) {
     let res = handler.call(store, {
     let res = handler.call(store, {
       dispatch: local.dispatch,
       dispatch: local.dispatch,
       commit: local.commit,
       commit: local.commit,
@@ -713,7 +728,7 @@ function registerAction (store, type, handler, local) {
       state: local.state,
       state: local.state,
       rootGetters: store.getters,
       rootGetters: store.getters,
       rootState: store.state
       rootState: store.state
-    }, payload, cb);
+    }, payload);
     if (!isPromise(res)) {
     if (!isPromise(res)) {
       res = Promise.resolve(res);
       res = Promise.resolve(res);
     }
     }
@@ -794,6 +809,9 @@ function install (_Vue) {
  */
  */
 const mapState = normalizeNamespace((namespace, states) => {
 const mapState = normalizeNamespace((namespace, states) => {
   const res = {};
   const res = {};
+  if (!isValidMap(states)) {
+    console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(states).forEach(({ key, val }) => {
   normalizeMap(states).forEach(({ key, val }) => {
     res[key] = function mappedState () {
     res[key] = function mappedState () {
       let state = this.$store.state;
       let state = this.$store.state;
@@ -824,6 +842,9 @@ const mapState = normalizeNamespace((namespace, states) => {
  */
  */
 const mapMutations = normalizeNamespace((namespace, mutations) => {
 const mapMutations = normalizeNamespace((namespace, mutations) => {
   const res = {};
   const res = {};
+  if (!isValidMap(mutations)) {
+    console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(mutations).forEach(({ key, val }) => {
   normalizeMap(mutations).forEach(({ key, val }) => {
     res[key] = function mappedMutation (...args) {
     res[key] = function mappedMutation (...args) {
       // Get the commit method from store
       // Get the commit method from store
@@ -851,6 +872,9 @@ const mapMutations = normalizeNamespace((namespace, mutations) => {
  */
  */
 const mapGetters = normalizeNamespace((namespace, getters) => {
 const mapGetters = normalizeNamespace((namespace, getters) => {
   const res = {};
   const res = {};
+  if (!isValidMap(getters)) {
+    console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(getters).forEach(({ key, val }) => {
   normalizeMap(getters).forEach(({ key, val }) => {
     // The namespace has been mutated by normalizeNamespace
     // The namespace has been mutated by normalizeNamespace
     val = namespace + val;
     val = namespace + val;
@@ -878,6 +902,9 @@ const mapGetters = normalizeNamespace((namespace, getters) => {
  */
  */
 const mapActions = normalizeNamespace((namespace, actions) => {
 const mapActions = normalizeNamespace((namespace, actions) => {
   const res = {};
   const res = {};
+  if (!isValidMap(actions)) {
+    console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(actions).forEach(({ key, val }) => {
   normalizeMap(actions).forEach(({ key, val }) => {
     res[key] = function mappedAction (...args) {
     res[key] = function mappedAction (...args) {
       // get dispatch function from store
       // get dispatch function from store
@@ -917,11 +944,23 @@ const createNamespacedHelpers = (namespace) => ({
  * @return {Object}
  * @return {Object}
  */
  */
 function normalizeMap (map) {
 function normalizeMap (map) {
+  if (!isValidMap(map)) {
+    return []
+  }
   return Array.isArray(map)
   return Array.isArray(map)
     ? map.map(key => ({ key, val: key }))
     ? map.map(key => ({ key, val: key }))
     : Object.keys(map).map(key => ({ key, val: map[key] }))
     : Object.keys(map).map(key => ({ key, val: map[key] }))
 }
 }
 
 
+/**
+ * Validate whether given map is valid or not
+ * @param {*} map
+ * @return {Boolean}
+ */
+function isValidMap (map) {
+  return Array.isArray(map) || isObject(map)
+}
+
 /**
 /**
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * @param {Function} fn
  * @param {Function} fn
@@ -957,7 +996,7 @@ function getModuleByNamespace (store, helper, namespace) {
 var index_esm = {
 var index_esm = {
   Store,
   Store,
   install,
   install,
-  version: '3.1.1',
+  version: '3.1.2',
   mapState,
   mapState,
   mapMutations,
   mapMutations,
   mapGetters,
   mapGetters,

Diff do ficheiro suprimidas por serem muito extensas
+ 1 - 1
dist/vuex.esm.browser.min.js


+ 62 - 23
dist/vuex.esm.js

@@ -1,5 +1,5 @@
 /**
 /**
- * vuex v3.1.1
+ * vuex v3.1.2
  * (c) 2019 Evan You
  * (c) 2019 Evan You
  * @license MIT
  * @license MIT
  */
  */
@@ -321,6 +321,7 @@ var Store = function Store (options) {
   this._modulesNamespaceMap = Object.create(null);
   this._modulesNamespaceMap = Object.create(null);
   this._subscribers = [];
   this._subscribers = [];
   this._watcherVM = new Vue();
   this._watcherVM = new Vue();
+  this._makeLocalGettersCache = Object.create(null);
 
 
   // bind commit and dispatch to self
   // bind commit and dispatch to self
   var store = this;
   var store = this;
@@ -553,12 +554,14 @@ function resetStoreVM (store, state, hot) {
 
 
   // bind store public getters
   // bind store public getters
   store.getters = {};
   store.getters = {};
+  // reset local getters cache
+  store._makeLocalGettersCache = Object.create(null);
   var wrappedGetters = store._wrappedGetters;
   var wrappedGetters = store._wrappedGetters;
   var computed = {};
   var computed = {};
   forEachValue(wrappedGetters, function (fn, key) {
   forEachValue(wrappedGetters, function (fn, key) {
     // use computed to leverage its lazy-caching mechanism
     // use computed to leverage its lazy-caching mechanism
     // direct inline function use will lead to closure preserving oldVm.
     // direct inline function use will lead to closure preserving oldVm.
-    // using partial to return function with only arguments preserved in closure enviroment.
+    // using partial to return function with only arguments preserved in closure environment.
     computed[key] = partial(fn, store);
     computed[key] = partial(fn, store);
     Object.defineProperty(store.getters, key, {
     Object.defineProperty(store.getters, key, {
       get: function () { return store._vm[key]; },
       get: function () { return store._vm[key]; },
@@ -602,6 +605,9 @@ function installModule (store, rootState, path, module, hot) {
 
 
   // register in namespace map
   // register in namespace map
   if (module.namespaced) {
   if (module.namespaced) {
+    if (store._modulesNamespaceMap[namespace] && process.env.NODE_ENV !== 'production') {
+      console.error(("[vuex] duplicate namespace " + namespace + " for the namespaced module " + (path.join('/'))));
+    }
     store._modulesNamespaceMap[namespace] = module;
     store._modulesNamespaceMap[namespace] = module;
   }
   }
 
 
@@ -610,6 +616,13 @@ function installModule (store, rootState, path, module, hot) {
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var moduleName = path[path.length - 1];
     var moduleName = path[path.length - 1];
     store._withCommit(function () {
     store._withCommit(function () {
+      if (process.env.NODE_ENV !== 'production') {
+        if (moduleName in parentState) {
+          console.warn(
+            ("[vuex] state field \"" + moduleName + "\" was overridden by a module with the same name at \"" + (path.join('.')) + "\"")
+          );
+        }
+      }
       Vue.set(parentState, moduleName, module.state);
       Vue.set(parentState, moduleName, module.state);
     });
     });
   }
   }
@@ -697,26 +710,28 @@ function makeLocalContext (store, namespace, path) {
 }
 }
 
 
 function makeLocalGetters (store, namespace) {
 function makeLocalGetters (store, namespace) {
-  var gettersProxy = {};
-
-  var splitPos = namespace.length;
-  Object.keys(store.getters).forEach(function (type) {
-    // skip if the target getter is not match this namespace
-    if (type.slice(0, splitPos) !== namespace) { return }
-
-    // extract local getter type
-    var localType = type.slice(splitPos);
-
-    // Add a port to the getters proxy.
-    // Define as getter property because
-    // we do not want to evaluate the getters in this time.
-    Object.defineProperty(gettersProxy, localType, {
-      get: function () { return store.getters[type]; },
-      enumerable: true
+  if (!store._makeLocalGettersCache[namespace]) {
+    var gettersProxy = {};
+    var splitPos = namespace.length;
+    Object.keys(store.getters).forEach(function (type) {
+      // skip if the target getter is not match this namespace
+      if (type.slice(0, splitPos) !== namespace) { return }
+
+      // extract local getter type
+      var localType = type.slice(splitPos);
+
+      // Add a port to the getters proxy.
+      // Define as getter property because
+      // we do not want to evaluate the getters in this time.
+      Object.defineProperty(gettersProxy, localType, {
+        get: function () { return store.getters[type]; },
+        enumerable: true
+      });
     });
     });
-  });
+    store._makeLocalGettersCache[namespace] = gettersProxy;
+  }
 
 
-  return gettersProxy
+  return store._makeLocalGettersCache[namespace]
 }
 }
 
 
 function registerMutation (store, type, handler, local) {
 function registerMutation (store, type, handler, local) {
@@ -728,7 +743,7 @@ function registerMutation (store, type, handler, local) {
 
 
 function registerAction (store, type, handler, local) {
 function registerAction (store, type, handler, local) {
   var entry = store._actions[type] || (store._actions[type] = []);
   var entry = store._actions[type] || (store._actions[type] = []);
-  entry.push(function wrappedActionHandler (payload, cb) {
+  entry.push(function wrappedActionHandler (payload) {
     var res = handler.call(store, {
     var res = handler.call(store, {
       dispatch: local.dispatch,
       dispatch: local.dispatch,
       commit: local.commit,
       commit: local.commit,
@@ -736,7 +751,7 @@ function registerAction (store, type, handler, local) {
       state: local.state,
       state: local.state,
       rootGetters: store.getters,
       rootGetters: store.getters,
       rootState: store.state
       rootState: store.state
-    }, payload, cb);
+    }, payload);
     if (!isPromise(res)) {
     if (!isPromise(res)) {
       res = Promise.resolve(res);
       res = Promise.resolve(res);
     }
     }
@@ -817,6 +832,9 @@ function install (_Vue) {
  */
  */
 var mapState = normalizeNamespace(function (namespace, states) {
 var mapState = normalizeNamespace(function (namespace, states) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(states)) {
+    console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(states).forEach(function (ref) {
   normalizeMap(states).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -850,6 +868,9 @@ var mapState = normalizeNamespace(function (namespace, states) {
  */
  */
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(mutations)) {
+    console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(mutations).forEach(function (ref) {
   normalizeMap(mutations).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -883,6 +904,9 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
  */
  */
 var mapGetters = normalizeNamespace(function (namespace, getters) {
 var mapGetters = normalizeNamespace(function (namespace, getters) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(getters)) {
+    console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(getters).forEach(function (ref) {
   normalizeMap(getters).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -913,6 +937,9 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
  */
  */
 var mapActions = normalizeNamespace(function (namespace, actions) {
 var mapActions = normalizeNamespace(function (namespace, actions) {
   var res = {};
   var res = {};
+  if (process.env.NODE_ENV !== 'production' && !isValidMap(actions)) {
+    console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
+  }
   normalizeMap(actions).forEach(function (ref) {
   normalizeMap(actions).forEach(function (ref) {
     var key = ref.key;
     var key = ref.key;
     var val = ref.val;
     var val = ref.val;
@@ -958,11 +985,23 @@ var createNamespacedHelpers = function (namespace) { return ({
  * @return {Object}
  * @return {Object}
  */
  */
 function normalizeMap (map) {
 function normalizeMap (map) {
+  if (!isValidMap(map)) {
+    return []
+  }
   return Array.isArray(map)
   return Array.isArray(map)
     ? map.map(function (key) { return ({ key: key, val: key }); })
     ? map.map(function (key) { return ({ key: key, val: key }); })
     : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
     : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
 }
 }
 
 
+/**
+ * Validate whether given map is valid or not
+ * @param {*} map
+ * @return {Boolean}
+ */
+function isValidMap (map) {
+  return Array.isArray(map) || isObject(map)
+}
+
 /**
 /**
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  * @param {Function} fn
  * @param {Function} fn
@@ -998,7 +1037,7 @@ function getModuleByNamespace (store, helper, namespace) {
 var index_esm = {
 var index_esm = {
   Store: Store,
   Store: Store,
   install: install,
   install: install,
-  version: '3.1.1',
+  version: '3.1.2',
   mapState: mapState,
   mapState: mapState,
   mapMutations: mapMutations,
   mapMutations: mapMutations,
   mapGetters: mapGetters,
   mapGetters: mapGetters,

+ 62 - 23
dist/vuex.js

@@ -1,5 +1,5 @@
 /**
 /**
- * vuex v3.1.1
+ * vuex v3.1.2
  * (c) 2019 Evan You
  * (c) 2019 Evan You
  * @license MIT
  * @license MIT
  */
  */
@@ -327,6 +327,7 @@
     this._modulesNamespaceMap = Object.create(null);
     this._modulesNamespaceMap = Object.create(null);
     this._subscribers = [];
     this._subscribers = [];
     this._watcherVM = new Vue();
     this._watcherVM = new Vue();
+    this._makeLocalGettersCache = Object.create(null);
 
 
     // bind commit and dispatch to self
     // bind commit and dispatch to self
     var store = this;
     var store = this;
@@ -558,12 +559,14 @@
 
 
     // bind store public getters
     // bind store public getters
     store.getters = {};
     store.getters = {};
+    // reset local getters cache
+    store._makeLocalGettersCache = Object.create(null);
     var wrappedGetters = store._wrappedGetters;
     var wrappedGetters = store._wrappedGetters;
     var computed = {};
     var computed = {};
     forEachValue(wrappedGetters, function (fn, key) {
     forEachValue(wrappedGetters, function (fn, key) {
       // use computed to leverage its lazy-caching mechanism
       // use computed to leverage its lazy-caching mechanism
       // direct inline function use will lead to closure preserving oldVm.
       // direct inline function use will lead to closure preserving oldVm.
-      // using partial to return function with only arguments preserved in closure enviroment.
+      // using partial to return function with only arguments preserved in closure environment.
       computed[key] = partial(fn, store);
       computed[key] = partial(fn, store);
       Object.defineProperty(store.getters, key, {
       Object.defineProperty(store.getters, key, {
         get: function () { return store._vm[key]; },
         get: function () { return store._vm[key]; },
@@ -607,6 +610,9 @@
 
 
     // register in namespace map
     // register in namespace map
     if (module.namespaced) {
     if (module.namespaced) {
+      if (store._modulesNamespaceMap[namespace] && "development" !== 'production') {
+        console.error(("[vuex] duplicate namespace " + namespace + " for the namespaced module " + (path.join('/'))));
+      }
       store._modulesNamespaceMap[namespace] = module;
       store._modulesNamespaceMap[namespace] = module;
     }
     }
 
 
@@ -615,6 +621,13 @@
       var parentState = getNestedState(rootState, path.slice(0, -1));
       var parentState = getNestedState(rootState, path.slice(0, -1));
       var moduleName = path[path.length - 1];
       var moduleName = path[path.length - 1];
       store._withCommit(function () {
       store._withCommit(function () {
+        {
+          if (moduleName in parentState) {
+            console.warn(
+              ("[vuex] state field \"" + moduleName + "\" was overridden by a module with the same name at \"" + (path.join('.')) + "\"")
+            );
+          }
+        }
         Vue.set(parentState, moduleName, module.state);
         Vue.set(parentState, moduleName, module.state);
       });
       });
     }
     }
@@ -702,26 +715,28 @@
   }
   }
 
 
   function makeLocalGetters (store, namespace) {
   function makeLocalGetters (store, namespace) {
-    var gettersProxy = {};
-
-    var splitPos = namespace.length;
-    Object.keys(store.getters).forEach(function (type) {
-      // skip if the target getter is not match this namespace
-      if (type.slice(0, splitPos) !== namespace) { return }
-
-      // extract local getter type
-      var localType = type.slice(splitPos);
-
-      // Add a port to the getters proxy.
-      // Define as getter property because
-      // we do not want to evaluate the getters in this time.
-      Object.defineProperty(gettersProxy, localType, {
-        get: function () { return store.getters[type]; },
-        enumerable: true
+    if (!store._makeLocalGettersCache[namespace]) {
+      var gettersProxy = {};
+      var splitPos = namespace.length;
+      Object.keys(store.getters).forEach(function (type) {
+        // skip if the target getter is not match this namespace
+        if (type.slice(0, splitPos) !== namespace) { return }
+
+        // extract local getter type
+        var localType = type.slice(splitPos);
+
+        // Add a port to the getters proxy.
+        // Define as getter property because
+        // we do not want to evaluate the getters in this time.
+        Object.defineProperty(gettersProxy, localType, {
+          get: function () { return store.getters[type]; },
+          enumerable: true
+        });
       });
       });
-    });
+      store._makeLocalGettersCache[namespace] = gettersProxy;
+    }
 
 
-    return gettersProxy
+    return store._makeLocalGettersCache[namespace]
   }
   }
 
 
   function registerMutation (store, type, handler, local) {
   function registerMutation (store, type, handler, local) {
@@ -733,7 +748,7 @@
 
 
   function registerAction (store, type, handler, local) {
   function registerAction (store, type, handler, local) {
     var entry = store._actions[type] || (store._actions[type] = []);
     var entry = store._actions[type] || (store._actions[type] = []);
-    entry.push(function wrappedActionHandler (payload, cb) {
+    entry.push(function wrappedActionHandler (payload) {
       var res = handler.call(store, {
       var res = handler.call(store, {
         dispatch: local.dispatch,
         dispatch: local.dispatch,
         commit: local.commit,
         commit: local.commit,
@@ -741,7 +756,7 @@
         state: local.state,
         state: local.state,
         rootGetters: store.getters,
         rootGetters: store.getters,
         rootState: store.state
         rootState: store.state
-      }, payload, cb);
+      }, payload);
       if (!isPromise(res)) {
       if (!isPromise(res)) {
         res = Promise.resolve(res);
         res = Promise.resolve(res);
       }
       }
@@ -822,6 +837,9 @@
    */
    */
   var mapState = normalizeNamespace(function (namespace, states) {
   var mapState = normalizeNamespace(function (namespace, states) {
     var res = {};
     var res = {};
+    if (!isValidMap(states)) {
+      console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
+    }
     normalizeMap(states).forEach(function (ref) {
     normalizeMap(states).forEach(function (ref) {
       var key = ref.key;
       var key = ref.key;
       var val = ref.val;
       var val = ref.val;
@@ -855,6 +873,9 @@
    */
    */
   var mapMutations = normalizeNamespace(function (namespace, mutations) {
   var mapMutations = normalizeNamespace(function (namespace, mutations) {
     var res = {};
     var res = {};
+    if (!isValidMap(mutations)) {
+      console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
+    }
     normalizeMap(mutations).forEach(function (ref) {
     normalizeMap(mutations).forEach(function (ref) {
       var key = ref.key;
       var key = ref.key;
       var val = ref.val;
       var val = ref.val;
@@ -888,6 +909,9 @@
    */
    */
   var mapGetters = normalizeNamespace(function (namespace, getters) {
   var mapGetters = normalizeNamespace(function (namespace, getters) {
     var res = {};
     var res = {};
+    if (!isValidMap(getters)) {
+      console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
+    }
     normalizeMap(getters).forEach(function (ref) {
     normalizeMap(getters).forEach(function (ref) {
       var key = ref.key;
       var key = ref.key;
       var val = ref.val;
       var val = ref.val;
@@ -918,6 +942,9 @@
    */
    */
   var mapActions = normalizeNamespace(function (namespace, actions) {
   var mapActions = normalizeNamespace(function (namespace, actions) {
     var res = {};
     var res = {};
+    if (!isValidMap(actions)) {
+      console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
+    }
     normalizeMap(actions).forEach(function (ref) {
     normalizeMap(actions).forEach(function (ref) {
       var key = ref.key;
       var key = ref.key;
       var val = ref.val;
       var val = ref.val;
@@ -963,11 +990,23 @@
    * @return {Object}
    * @return {Object}
    */
    */
   function normalizeMap (map) {
   function normalizeMap (map) {
+    if (!isValidMap(map)) {
+      return []
+    }
     return Array.isArray(map)
     return Array.isArray(map)
       ? map.map(function (key) { return ({ key: key, val: key }); })
       ? map.map(function (key) { return ({ key: key, val: key }); })
       : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
       : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
   }
   }
 
 
+  /**
+   * Validate whether given map is valid or not
+   * @param {*} map
+   * @return {Boolean}
+   */
+  function isValidMap (map) {
+    return Array.isArray(map) || isObject(map)
+  }
+
   /**
   /**
    * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
    * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
    * @param {Function} fn
    * @param {Function} fn
@@ -1003,7 +1042,7 @@
   var index = {
   var index = {
     Store: Store,
     Store: Store,
     install: install,
     install: install,
-    version: '3.1.1',
+    version: '3.1.2',
     mapState: mapState,
     mapState: mapState,
     mapMutations: mapMutations,
     mapMutations: mapMutations,
     mapGetters: mapGetters,
     mapGetters: mapGetters,

Diff do ficheiro suprimidas por serem muito extensas
+ 1 - 1
dist/vuex.min.js


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff