浏览代码

release: v3.4.0

ktsn 5 年之前
父节点
当前提交
8691e61fa6
共有 9 个文件被更改,包括 220 次插入148 次删除
  1. 9 0
      CHANGELOG.md
  2. 8 3
      dist/logger.js
  3. 57 43
      dist/vuex.common.js
  4. 41 26
      dist/vuex.esm.browser.js
  5. 2 2
      dist/vuex.esm.browser.min.js
  6. 58 44
      dist/vuex.esm.js
  7. 42 27
      dist/vuex.js
  8. 2 2
      dist/vuex.min.js
  9. 1 1
      package.json

+ 9 - 0
CHANGELOG.md

@@ -1,3 +1,12 @@
+# [3.4.0](https://github.com/vuejs/vuex/compare/v3.3.0...v3.4.0) (2020-05-11)
+
+
+### Features
+
+* Allow action subscribers to catch rejections. ([#1740](https://github.com/vuejs/vuex/issues/1740)) ([6ebbe64](https://github.com/vuejs/vuex/commit/6ebbe64c5821d19e55a41dc8b1d81cfce6cbd195)), closes [#1489](https://github.com/vuejs/vuex/issues/1489) [#1558](https://github.com/vuejs/vuex/issues/1558) [#1625](https://github.com/vuejs/vuex/issues/1625)
+
+
+
 # [3.3.0](https://github.com/vuejs/vuex/compare/v3.2.0...v3.3.0) (2020-04-25)
 
 

+ 8 - 3
dist/logger.js

@@ -1,8 +1,13 @@
+/*!
+ * vuex v3.4.0
+ * (c) 2020 Evan You
+ * @license MIT
+ */
 (function (global, factory) {
   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
   typeof define === 'function' && define.amd ? define(factory) :
-  (global = global || self, global.createVuexLogger = factory());
-}(this, function () { 'use strict';
+  (global = global || self, global.Vuex = factory());
+}(this, (function () { 'use strict';
 
   /**
    * Get the first item that pass the test
@@ -147,4 +152,4 @@
 
   return createLogger;
 
-}));
+})));

+ 57 - 43
dist/vuex.common.js

@@ -1,5 +1,5 @@
-/**
- * vuex v3.3.0
+/*!
+ * vuex v3.4.0
  * (c) 2020 Evan You
  * @license MIT
  */
@@ -201,7 +201,7 @@ ModuleCollection.prototype.register = function register (path, rawModule, runtim
     var this$1 = this;
     if ( runtime === void 0 ) runtime = true;
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assertRawModule(path, rawModule);
   }
 
@@ -237,7 +237,7 @@ ModuleCollection.prototype.isRegistered = function isRegistered (path) {
 };
 
 function update (path, targetModule, newModule) {
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assertRawModule(path, newModule);
   }
 
@@ -248,7 +248,7 @@ function update (path, targetModule, newModule) {
   if (newModule.modules) {
     for (var key in newModule.modules) {
       if (!targetModule.getChild(key)) {
-        if (process.env.NODE_ENV !== 'production') {
+        if ((process.env.NODE_ENV !== 'production')) {
           console.warn(
             "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
             'manual reload is needed'
@@ -319,7 +319,7 @@ var Store = function Store (options) {
     install(window.Vue);
   }
 
-  if (process.env.NODE_ENV !== 'production') {
+  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.");
     assert(this instanceof Store, "store must be called with the new operator.");
@@ -382,7 +382,7 @@ prototypeAccessors$1.state.get = function () {
 };
 
 prototypeAccessors$1.state.set = function (v) {
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(false, "use store.replaceState() to explicit replace store state.");
   }
 };
@@ -399,7 +399,7 @@ Store.prototype.commit = function commit (_type, _payload, _options) {
   var mutation = { type: type, payload: payload };
   var entry = this._mutations[type];
   if (!entry) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] unknown mutation type: " + type));
     }
     return
@@ -415,7 +415,7 @@ Store.prototype.commit = function commit (_type, _payload, _options) {
     .forEach(function (sub) { return sub(mutation, this$1.state); });
 
   if (
-    process.env.NODE_ENV !== 'production' &&
+    (process.env.NODE_ENV !== 'production') &&
     options && options.silent
   ) {
     console.warn(
@@ -436,7 +436,7 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
   var action = { type: type, payload: payload };
   var entry = this._actions[type];
   if (!entry) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] unknown action type: " + type));
     }
     return
@@ -448,7 +448,7 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
       .filter(function (sub) { return sub.before; })
       .forEach(function (sub) { return sub.before(action, this$1.state); });
   } catch (e) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.warn("[vuex] error in before action subscribers: ");
       console.error(e);
     }
@@ -458,18 +458,32 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
     ? Promise.all(entry.map(function (handler) { return handler(payload); }))
     : entry[0](payload);
 
-  return result.then(function (res) {
-    try {
-      this$1._actionSubscribers
-        .filter(function (sub) { return sub.after; })
-        .forEach(function (sub) { return sub.after(action, this$1.state); });
-    } catch (e) {
-      if (process.env.NODE_ENV !== 'production') {
-        console.warn("[vuex] error in after action subscribers: ");
-        console.error(e);
+  return new Promise(function (resolve, reject) {
+    result.then(function (res) {
+      try {
+        this$1._actionSubscribers
+          .filter(function (sub) { return sub.after; })
+          .forEach(function (sub) { return sub.after(action, this$1.state); });
+      } catch (e) {
+        if ((process.env.NODE_ENV !== 'production')) {
+          console.warn("[vuex] error in after action subscribers: ");
+          console.error(e);
+        }
       }
-    }
-    return res
+      resolve(res);
+    }, function (error) {
+      try {
+        this$1._actionSubscribers
+          .filter(function (sub) { return sub.error; })
+          .forEach(function (sub) { return sub.error(action, this$1.state, error); });
+      } catch (e) {
+        if ((process.env.NODE_ENV !== 'production')) {
+          console.warn("[vuex] error in error action subscribers: ");
+          console.error(e);
+        }
+      }
+      reject(error);
+    });
   })
 };
 
@@ -485,7 +499,7 @@ Store.prototype.subscribeAction = function subscribeAction (fn, options) {
 Store.prototype.watch = function watch (getter, cb, options) {
     var this$1 = this;
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(typeof getter === 'function', "store.watch only accepts a function.");
   }
   return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options)
@@ -504,7 +518,7 @@ Store.prototype.registerModule = function registerModule (path, rawModule, optio
 
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
     assert(path.length > 0, 'cannot register the root module by using registerModule.');
   }
@@ -520,7 +534,7 @@ Store.prototype.unregisterModule = function unregisterModule (path) {
 
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
   }
 
@@ -535,7 +549,7 @@ Store.prototype.unregisterModule = function unregisterModule (path) {
 Store.prototype.hasModule = function hasModule (path) {
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
   }
 
@@ -638,7 +652,7 @@ function installModule (store, rootState, path, module, hot) {
 
   // register in namespace map
   if (module.namespaced) {
-    if (store._modulesNamespaceMap[namespace] && process.env.NODE_ENV !== 'production') {
+    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;
@@ -649,7 +663,7 @@ function installModule (store, rootState, path, module, hot) {
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var moduleName = path[path.length - 1];
     store._withCommit(function () {
-      if (process.env.NODE_ENV !== 'production') {
+      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('.')) + "\"")
@@ -699,7 +713,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (process.env.NODE_ENV !== 'production' && !store._actions[type]) {
+        if ((process.env.NODE_ENV !== 'production') && !store._actions[type]) {
           console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
           return
         }
@@ -716,7 +730,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) {
+        if ((process.env.NODE_ENV !== 'production') && !store._mutations[type]) {
           console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
           return
         }
@@ -801,7 +815,7 @@ function registerAction (store, type, handler, local) {
 
 function registerGetter (store, type, rawGetter, local) {
   if (store._wrappedGetters[type]) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] duplicate getter key: " + type));
     }
     return
@@ -818,7 +832,7 @@ function registerGetter (store, type, rawGetter, local) {
 
 function enableStrictMode (store) {
   store._vm.$watch(function () { return this._data.$$state }, function () {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       assert(store._committing, "do not mutate vuex store state outside mutation handlers.");
     }
   }, { deep: true, sync: true });
@@ -835,7 +849,7 @@ function unifyObjectStyle (type, payload, options) {
     type = type.type;
   }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(typeof type === 'string', ("expects string as the type, but found " + (typeof type) + "."));
   }
 
@@ -844,7 +858,7 @@ function unifyObjectStyle (type, payload, options) {
 
 function install (_Vue) {
   if (Vue && _Vue === Vue) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(
         '[vuex] already installed. Vue.use(Vuex) should be called only once.'
       );
@@ -863,7 +877,7 @@ function install (_Vue) {
  */
 var mapState = normalizeNamespace(function (namespace, states) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(states)) {
+  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) {
@@ -899,7 +913,7 @@ var mapState = normalizeNamespace(function (namespace, states) {
  */
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(mutations)) {
+  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) {
@@ -935,7 +949,7 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
  */
 var mapGetters = normalizeNamespace(function (namespace, getters) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(getters)) {
+  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) {
@@ -948,7 +962,7 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
       if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
         return
       }
-      if (process.env.NODE_ENV !== 'production' && !(val in this.$store.getters)) {
+      if ((process.env.NODE_ENV !== 'production') && !(val in this.$store.getters)) {
         console.error(("[vuex] unknown getter: " + val));
         return
       }
@@ -968,7 +982,7 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
  */
 var mapActions = normalizeNamespace(function (namespace, actions) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(actions)) {
+  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) {
@@ -1059,16 +1073,16 @@ function normalizeNamespace (fn) {
  */
 function getModuleByNamespace (store, helper, namespace) {
   var module = store._modulesNamespaceMap[namespace];
-  if (process.env.NODE_ENV !== 'production' && !module) {
+  if ((process.env.NODE_ENV !== 'production') && !module) {
     console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
   }
   return module
 }
 
-var index = {
+var index_cjs = {
   Store: Store,
   install: install,
-  version: '3.3.0',
+  version: '3.4.0',
   mapState: mapState,
   mapMutations: mapMutations,
   mapGetters: mapGetters,
@@ -1076,4 +1090,4 @@ var index = {
   createNamespacedHelpers: createNamespacedHelpers
 };
 
-module.exports = index;
+module.exports = index_cjs;

+ 41 - 26
dist/vuex.esm.browser.js

@@ -1,5 +1,5 @@
-/**
- * vuex v3.3.0
+/*!
+ * vuex v3.4.0
  * (c) 2020 Evan You
  * @license MIT
  */
@@ -403,6 +403,7 @@ class Store {
       .forEach(sub => sub(mutation, this.state));
 
     if (
+      
       options && options.silent
     ) {
       console.warn(
@@ -444,18 +445,32 @@ class Store {
       ? Promise.all(entry.map(handler => handler(payload)))
       : entry[0](payload);
 
-    return result.then(res => {
-      try {
-        this._actionSubscribers
-          .filter(sub => sub.after)
-          .forEach(sub => sub.after(action, this.state));
-      } catch (e) {
-        {
-          console.warn(`[vuex] error in after action subscribers: `);
-          console.error(e);
+    return new Promise((resolve, reject) => {
+      result.then(res => {
+        try {
+          this._actionSubscribers
+            .filter(sub => sub.after)
+            .forEach(sub => sub.after(action, this.state));
+        } catch (e) {
+          {
+            console.warn(`[vuex] error in after action subscribers: `);
+            console.error(e);
+          }
         }
-      }
-      return res
+        resolve(res);
+      }, error => {
+        try {
+          this._actionSubscribers
+            .filter(sub => sub.error)
+            .forEach(sub => sub.error(action, this.state, error));
+        } catch (e) {
+          {
+            console.warn(`[vuex] error in error action subscribers: `);
+            console.error(e);
+          }
+        }
+        reject(error);
+      });
     })
   }
 
@@ -615,7 +630,7 @@ function installModule (store, rootState, path, module, hot) {
 
   // register in namespace map
   if (module.namespaced) {
-    if (store._modulesNamespaceMap[namespace] && "development" !== 'production') {
+    if (store._modulesNamespaceMap[namespace] && true) {
       console.error(`[vuex] duplicate namespace ${namespace} for the namespaced module ${path.join('/')}`);
     }
     store._modulesNamespaceMap[namespace] = module;
@@ -675,7 +690,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (!store._actions[type]) {
+        if ( !store._actions[type]) {
           console.error(`[vuex] unknown local action type: ${args.type}, global type: ${type}`);
           return
         }
@@ -691,7 +706,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (!store._mutations[type]) {
+        if ( !store._mutations[type]) {
           console.error(`[vuex] unknown local mutation type: ${args.type}, global type: ${type}`);
           return
         }
@@ -838,7 +853,7 @@ function install (_Vue) {
  */
 const mapState = normalizeNamespace((namespace, states) => {
   const res = {};
-  if (!isValidMap(states)) {
+  if ( !isValidMap(states)) {
     console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
   }
   normalizeMap(states).forEach(({ key, val }) => {
@@ -871,7 +886,7 @@ const mapState = normalizeNamespace((namespace, states) => {
  */
 const mapMutations = normalizeNamespace((namespace, mutations) => {
   const res = {};
-  if (!isValidMap(mutations)) {
+  if ( !isValidMap(mutations)) {
     console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
   }
   normalizeMap(mutations).forEach(({ key, val }) => {
@@ -901,7 +916,7 @@ const mapMutations = normalizeNamespace((namespace, mutations) => {
  */
 const mapGetters = normalizeNamespace((namespace, getters) => {
   const res = {};
-  if (!isValidMap(getters)) {
+  if ( !isValidMap(getters)) {
     console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
   }
   normalizeMap(getters).forEach(({ key, val }) => {
@@ -911,7 +926,7 @@ const mapGetters = normalizeNamespace((namespace, getters) => {
       if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
         return
       }
-      if (!(val in this.$store.getters)) {
+      if ( !(val in this.$store.getters)) {
         console.error(`[vuex] unknown getter: ${val}`);
         return
       }
@@ -931,7 +946,7 @@ const mapGetters = normalizeNamespace((namespace, getters) => {
  */
 const mapActions = normalizeNamespace((namespace, actions) => {
   const res = {};
-  if (!isValidMap(actions)) {
+  if ( !isValidMap(actions)) {
     console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
   }
   normalizeMap(actions).forEach(({ key, val }) => {
@@ -1016,16 +1031,16 @@ function normalizeNamespace (fn) {
  */
 function getModuleByNamespace (store, helper, namespace) {
   const module = store._modulesNamespaceMap[namespace];
-  if (!module) {
+  if ( !module) {
     console.error(`[vuex] module namespace not found in ${helper}(): ${namespace}`);
   }
   return module
 }
 
-var index_esm = {
+var index = {
   Store,
   install,
-  version: '3.3.0',
+  version: '3.4.0',
   mapState,
   mapMutations,
   mapGetters,
@@ -1033,5 +1048,5 @@ var index_esm = {
   createNamespacedHelpers
 };
 
-export default index_esm;
-export { Store, install, mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers };
+export default index;
+export { Store, createNamespacedHelpers, install, mapActions, mapGetters, mapMutations, mapState };

文件差异内容过多而无法显示
+ 2 - 2
dist/vuex.esm.browser.min.js


+ 58 - 44
dist/vuex.esm.js

@@ -1,5 +1,5 @@
-/**
- * vuex v3.3.0
+/*!
+ * vuex v3.4.0
  * (c) 2020 Evan You
  * @license MIT
  */
@@ -199,7 +199,7 @@ ModuleCollection.prototype.register = function register (path, rawModule, runtim
     var this$1 = this;
     if ( runtime === void 0 ) runtime = true;
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assertRawModule(path, rawModule);
   }
 
@@ -235,7 +235,7 @@ ModuleCollection.prototype.isRegistered = function isRegistered (path) {
 };
 
 function update (path, targetModule, newModule) {
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assertRawModule(path, newModule);
   }
 
@@ -246,7 +246,7 @@ function update (path, targetModule, newModule) {
   if (newModule.modules) {
     for (var key in newModule.modules) {
       if (!targetModule.getChild(key)) {
-        if (process.env.NODE_ENV !== 'production') {
+        if ((process.env.NODE_ENV !== 'production')) {
           console.warn(
             "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
             'manual reload is needed'
@@ -317,7 +317,7 @@ var Store = function Store (options) {
     install(window.Vue);
   }
 
-  if (process.env.NODE_ENV !== 'production') {
+  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.");
     assert(this instanceof Store, "store must be called with the new operator.");
@@ -380,7 +380,7 @@ prototypeAccessors$1.state.get = function () {
 };
 
 prototypeAccessors$1.state.set = function (v) {
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(false, "use store.replaceState() to explicit replace store state.");
   }
 };
@@ -397,7 +397,7 @@ Store.prototype.commit = function commit (_type, _payload, _options) {
   var mutation = { type: type, payload: payload };
   var entry = this._mutations[type];
   if (!entry) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] unknown mutation type: " + type));
     }
     return
@@ -413,7 +413,7 @@ Store.prototype.commit = function commit (_type, _payload, _options) {
     .forEach(function (sub) { return sub(mutation, this$1.state); });
 
   if (
-    process.env.NODE_ENV !== 'production' &&
+    (process.env.NODE_ENV !== 'production') &&
     options && options.silent
   ) {
     console.warn(
@@ -434,7 +434,7 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
   var action = { type: type, payload: payload };
   var entry = this._actions[type];
   if (!entry) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] unknown action type: " + type));
     }
     return
@@ -446,7 +446,7 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
       .filter(function (sub) { return sub.before; })
       .forEach(function (sub) { return sub.before(action, this$1.state); });
   } catch (e) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.warn("[vuex] error in before action subscribers: ");
       console.error(e);
     }
@@ -456,18 +456,32 @@ Store.prototype.dispatch = function dispatch (_type, _payload) {
     ? Promise.all(entry.map(function (handler) { return handler(payload); }))
     : entry[0](payload);
 
-  return result.then(function (res) {
-    try {
-      this$1._actionSubscribers
-        .filter(function (sub) { return sub.after; })
-        .forEach(function (sub) { return sub.after(action, this$1.state); });
-    } catch (e) {
-      if (process.env.NODE_ENV !== 'production') {
-        console.warn("[vuex] error in after action subscribers: ");
-        console.error(e);
+  return new Promise(function (resolve, reject) {
+    result.then(function (res) {
+      try {
+        this$1._actionSubscribers
+          .filter(function (sub) { return sub.after; })
+          .forEach(function (sub) { return sub.after(action, this$1.state); });
+      } catch (e) {
+        if ((process.env.NODE_ENV !== 'production')) {
+          console.warn("[vuex] error in after action subscribers: ");
+          console.error(e);
+        }
       }
-    }
-    return res
+      resolve(res);
+    }, function (error) {
+      try {
+        this$1._actionSubscribers
+          .filter(function (sub) { return sub.error; })
+          .forEach(function (sub) { return sub.error(action, this$1.state, error); });
+      } catch (e) {
+        if ((process.env.NODE_ENV !== 'production')) {
+          console.warn("[vuex] error in error action subscribers: ");
+          console.error(e);
+        }
+      }
+      reject(error);
+    });
   })
 };
 
@@ -483,7 +497,7 @@ Store.prototype.subscribeAction = function subscribeAction (fn, options) {
 Store.prototype.watch = function watch (getter, cb, options) {
     var this$1 = this;
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(typeof getter === 'function', "store.watch only accepts a function.");
   }
   return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options)
@@ -502,7 +516,7 @@ Store.prototype.registerModule = function registerModule (path, rawModule, optio
 
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
     assert(path.length > 0, 'cannot register the root module by using registerModule.');
   }
@@ -518,7 +532,7 @@ Store.prototype.unregisterModule = function unregisterModule (path) {
 
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
   }
 
@@ -533,7 +547,7 @@ Store.prototype.unregisterModule = function unregisterModule (path) {
 Store.prototype.hasModule = function hasModule (path) {
   if (typeof path === 'string') { path = [path]; }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(Array.isArray(path), "module path must be a string or an Array.");
   }
 
@@ -636,7 +650,7 @@ function installModule (store, rootState, path, module, hot) {
 
   // register in namespace map
   if (module.namespaced) {
-    if (store._modulesNamespaceMap[namespace] && process.env.NODE_ENV !== 'production') {
+    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;
@@ -647,7 +661,7 @@ function installModule (store, rootState, path, module, hot) {
     var parentState = getNestedState(rootState, path.slice(0, -1));
     var moduleName = path[path.length - 1];
     store._withCommit(function () {
-      if (process.env.NODE_ENV !== 'production') {
+      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('.')) + "\"")
@@ -697,7 +711,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (process.env.NODE_ENV !== 'production' && !store._actions[type]) {
+        if ((process.env.NODE_ENV !== 'production') && !store._actions[type]) {
           console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
           return
         }
@@ -714,7 +728,7 @@ function makeLocalContext (store, namespace, path) {
 
       if (!options || !options.root) {
         type = namespace + type;
-        if (process.env.NODE_ENV !== 'production' && !store._mutations[type]) {
+        if ((process.env.NODE_ENV !== 'production') && !store._mutations[type]) {
           console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
           return
         }
@@ -799,7 +813,7 @@ function registerAction (store, type, handler, local) {
 
 function registerGetter (store, type, rawGetter, local) {
   if (store._wrappedGetters[type]) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(("[vuex] duplicate getter key: " + type));
     }
     return
@@ -816,7 +830,7 @@ function registerGetter (store, type, rawGetter, local) {
 
 function enableStrictMode (store) {
   store._vm.$watch(function () { return this._data.$$state }, function () {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       assert(store._committing, "do not mutate vuex store state outside mutation handlers.");
     }
   }, { deep: true, sync: true });
@@ -833,7 +847,7 @@ function unifyObjectStyle (type, payload, options) {
     type = type.type;
   }
 
-  if (process.env.NODE_ENV !== 'production') {
+  if ((process.env.NODE_ENV !== 'production')) {
     assert(typeof type === 'string', ("expects string as the type, but found " + (typeof type) + "."));
   }
 
@@ -842,7 +856,7 @@ function unifyObjectStyle (type, payload, options) {
 
 function install (_Vue) {
   if (Vue && _Vue === Vue) {
-    if (process.env.NODE_ENV !== 'production') {
+    if ((process.env.NODE_ENV !== 'production')) {
       console.error(
         '[vuex] already installed. Vue.use(Vuex) should be called only once.'
       );
@@ -861,7 +875,7 @@ function install (_Vue) {
  */
 var mapState = normalizeNamespace(function (namespace, states) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(states)) {
+  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) {
@@ -897,7 +911,7 @@ var mapState = normalizeNamespace(function (namespace, states) {
  */
 var mapMutations = normalizeNamespace(function (namespace, mutations) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(mutations)) {
+  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) {
@@ -933,7 +947,7 @@ var mapMutations = normalizeNamespace(function (namespace, mutations) {
  */
 var mapGetters = normalizeNamespace(function (namespace, getters) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(getters)) {
+  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) {
@@ -946,7 +960,7 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
       if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
         return
       }
-      if (process.env.NODE_ENV !== 'production' && !(val in this.$store.getters)) {
+      if ((process.env.NODE_ENV !== 'production') && !(val in this.$store.getters)) {
         console.error(("[vuex] unknown getter: " + val));
         return
       }
@@ -966,7 +980,7 @@ var mapGetters = normalizeNamespace(function (namespace, getters) {
  */
 var mapActions = normalizeNamespace(function (namespace, actions) {
   var res = {};
-  if (process.env.NODE_ENV !== 'production' && !isValidMap(actions)) {
+  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) {
@@ -1057,16 +1071,16 @@ function normalizeNamespace (fn) {
  */
 function getModuleByNamespace (store, helper, namespace) {
   var module = store._modulesNamespaceMap[namespace];
-  if (process.env.NODE_ENV !== 'production' && !module) {
+  if ((process.env.NODE_ENV !== 'production') && !module) {
     console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
   }
   return module
 }
 
-var index_esm = {
+var index = {
   Store: Store,
   install: install,
-  version: '3.3.0',
+  version: '3.4.0',
   mapState: mapState,
   mapMutations: mapMutations,
   mapGetters: mapGetters,
@@ -1074,5 +1088,5 @@ var index_esm = {
   createNamespacedHelpers: createNamespacedHelpers
 };
 
-export default index_esm;
-export { Store, install, mapState, mapMutations, mapGetters, mapActions, createNamespacedHelpers };
+export default index;
+export { Store, createNamespacedHelpers, install, mapActions, mapGetters, mapMutations, mapState };

+ 42 - 27
dist/vuex.js

@@ -1,5 +1,5 @@
-/**
- * vuex v3.3.0
+/*!
+ * vuex v3.4.0
  * (c) 2020 Evan You
  * @license MIT
  */
@@ -7,7 +7,7 @@
   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
   typeof define === 'function' && define.amd ? define(factory) :
   (global = global || self, global.Vuex = factory());
-}(this, function () { 'use strict';
+}(this, (function () { 'use strict';
 
   function applyMixin (Vue) {
     var version = Number(Vue.version.split('.')[0]);
@@ -419,6 +419,7 @@
       .forEach(function (sub) { return sub(mutation, this$1.state); });
 
     if (
+      
       options && options.silent
     ) {
       console.warn(
@@ -461,18 +462,32 @@
       ? Promise.all(entry.map(function (handler) { return handler(payload); }))
       : entry[0](payload);
 
-    return result.then(function (res) {
-      try {
-        this$1._actionSubscribers
-          .filter(function (sub) { return sub.after; })
-          .forEach(function (sub) { return sub.after(action, this$1.state); });
-      } catch (e) {
-        {
-          console.warn("[vuex] error in after action subscribers: ");
-          console.error(e);
+    return new Promise(function (resolve, reject) {
+      result.then(function (res) {
+        try {
+          this$1._actionSubscribers
+            .filter(function (sub) { return sub.after; })
+            .forEach(function (sub) { return sub.after(action, this$1.state); });
+        } catch (e) {
+          {
+            console.warn("[vuex] error in after action subscribers: ");
+            console.error(e);
+          }
         }
-      }
-      return res
+        resolve(res);
+      }, function (error) {
+        try {
+          this$1._actionSubscribers
+            .filter(function (sub) { return sub.error; })
+            .forEach(function (sub) { return sub.error(action, this$1.state, error); });
+        } catch (e) {
+          {
+            console.warn("[vuex] error in error action subscribers: ");
+            console.error(e);
+          }
+        }
+        reject(error);
+      });
     })
   };
 
@@ -641,7 +656,7 @@
 
     // register in namespace map
     if (module.namespaced) {
-      if (store._modulesNamespaceMap[namespace] && "development" !== 'production') {
+      if (store._modulesNamespaceMap[namespace] && true) {
         console.error(("[vuex] duplicate namespace " + namespace + " for the namespaced module " + (path.join('/'))));
       }
       store._modulesNamespaceMap[namespace] = module;
@@ -702,7 +717,7 @@
 
         if (!options || !options.root) {
           type = namespace + type;
-          if (!store._actions[type]) {
+          if ( !store._actions[type]) {
             console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
             return
           }
@@ -719,7 +734,7 @@
 
         if (!options || !options.root) {
           type = namespace + type;
-          if (!store._mutations[type]) {
+          if ( !store._mutations[type]) {
             console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
             return
           }
@@ -866,7 +881,7 @@
    */
   var mapState = normalizeNamespace(function (namespace, states) {
     var res = {};
-    if (!isValidMap(states)) {
+    if ( !isValidMap(states)) {
       console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
     }
     normalizeMap(states).forEach(function (ref) {
@@ -902,7 +917,7 @@
    */
   var mapMutations = normalizeNamespace(function (namespace, mutations) {
     var res = {};
-    if (!isValidMap(mutations)) {
+    if ( !isValidMap(mutations)) {
       console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
     }
     normalizeMap(mutations).forEach(function (ref) {
@@ -938,7 +953,7 @@
    */
   var mapGetters = normalizeNamespace(function (namespace, getters) {
     var res = {};
-    if (!isValidMap(getters)) {
+    if ( !isValidMap(getters)) {
       console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
     }
     normalizeMap(getters).forEach(function (ref) {
@@ -951,7 +966,7 @@
         if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
           return
         }
-        if (!(val in this.$store.getters)) {
+        if ( !(val in this.$store.getters)) {
           console.error(("[vuex] unknown getter: " + val));
           return
         }
@@ -971,7 +986,7 @@
    */
   var mapActions = normalizeNamespace(function (namespace, actions) {
     var res = {};
-    if (!isValidMap(actions)) {
+    if ( !isValidMap(actions)) {
       console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
     }
     normalizeMap(actions).forEach(function (ref) {
@@ -1062,16 +1077,16 @@
    */
   function getModuleByNamespace (store, helper, namespace) {
     var module = store._modulesNamespaceMap[namespace];
-    if (!module) {
+    if ( !module) {
       console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
     }
     return module
   }
 
-  var index = {
+  var index_cjs = {
     Store: Store,
     install: install,
-    version: '3.3.0',
+    version: '3.4.0',
     mapState: mapState,
     mapMutations: mapMutations,
     mapGetters: mapGetters,
@@ -1079,6 +1094,6 @@
     createNamespacedHelpers: createNamespacedHelpers
   };
 
-  return index;
+  return index_cjs;
 
-}));
+})));

文件差异内容过多而无法显示
+ 2 - 2
dist/vuex.min.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "vuex",
-  "version": "3.3.0",
+  "version": "3.4.0",
   "description": "state management for Vue.js",
   "main": "dist/vuex.common.js",
   "module": "dist/vuex.esm.js",

部分文件因为文件数量过多而无法显示