diff --git a/dist/logger.js b/dist/logger.js index 827af8d89c..927f99160f 100644 --- a/dist/logger.js +++ b/dist/logger.js @@ -6,7 +6,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.Vuex = factory()); + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Vuex = factory()); }(this, (function () { 'use strict'; /** diff --git a/dist/vuex.common.js b/dist/vuex.common.js index 6d7873024e..5d91e6123f 100644 --- a/dist/vuex.common.js +++ b/dist/vuex.common.js @@ -288,7 +288,11 @@ ModuleCollection.prototype.isRegistered = function isRegistered (path) { var parent = this.get(path.slice(0, -1)); var key = path[path.length - 1]; - return parent.hasChild(key) + if (parent) { + return parent.hasChild(key) + } + + return false }; function update (path, targetModule, newModule) { diff --git a/dist/vuex.esm.browser.js b/dist/vuex.esm.browser.js index 6628e2d194..37560cd267 100644 --- a/dist/vuex.esm.browser.js +++ b/dist/vuex.esm.browser.js @@ -278,7 +278,11 @@ class ModuleCollection { const parent = this.get(path.slice(0, -1)); const key = path[path.length - 1]; - return parent.hasChild(key) + if (parent) { + return parent.hasChild(key) + } + + return false } } diff --git a/dist/vuex.esm.browser.min.js b/dist/vuex.esm.browser.min.js index b0a5b4354b..2c200da398 100644 --- a/dist/vuex.esm.browser.min.js +++ b/dist/vuex.esm.browser.min.js @@ -3,4 +3,4 @@ * (c) 2020 Evan You * @license MIT */ -const t=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function e(t,s=[]){if(null===t||"object"!=typeof t)return t;const o=(i=e=>e.original===t,s.filter(i)[0]);var i;if(o)return o.copy;const n=Array.isArray(t)?[]:{};return s.push({original:t,copy:n}),Object.keys(t).forEach(o=>{n[o]=e(t[o],s)}),n}function s(t,e){Object.keys(t).forEach(s=>e(t[s],s))}function o(t){return null!==t&&"object"==typeof t}class i{constructor(t,e){this.runtime=e,this._children=Object.create(null),this._rawModule=t;const s=t.state;this.state=("function"==typeof s?s():s)||{}}get namespaced(){return!!this._rawModule.namespaced}addChild(t,e){this._children[t]=e}removeChild(t){delete this._children[t]}getChild(t){return this._children[t]}hasChild(t){return t in this._children}update(t){this._rawModule.namespaced=t.namespaced,t.actions&&(this._rawModule.actions=t.actions),t.mutations&&(this._rawModule.mutations=t.mutations),t.getters&&(this._rawModule.getters=t.getters)}forEachChild(t){s(this._children,t)}forEachGetter(t){this._rawModule.getters&&s(this._rawModule.getters,t)}forEachAction(t){this._rawModule.actions&&s(this._rawModule.actions,t)}forEachMutation(t){this._rawModule.mutations&&s(this._rawModule.mutations,t)}}class n{constructor(t){this.register([],t,!1)}get(t){return t.reduce((t,e)=>t.getChild(e),this.root)}getNamespace(t){let e=this.root;return t.reduce((t,s)=>(e=e.getChild(s),t+(e.namespaced?s+"/":"")),"")}update(t){!function t(e,s,o){if(s.update(o),o.modules)for(const i in o.modules){if(!s.getChild(i))return;t(e.concat(i),s.getChild(i),o.modules[i])}}([],this.root,t)}register(t,e,o=!0){const n=new i(e,o);if(0===t.length)this.root=n;else{this.get(t.slice(0,-1)).addChild(t[t.length-1],n)}e.modules&&s(e.modules,(e,s)=>{this.register(t.concat(s),e,o)})}unregister(t){const e=this.get(t.slice(0,-1)),s=t[t.length-1],o=e.getChild(s);o&&o.runtime&&e.removeChild(s)}isRegistered(t){const e=this.get(t.slice(0,-1)),s=t[t.length-1];return e.hasChild(s)}}let r;class c{constructor(e={}){!r&&"undefined"!=typeof window&&window.Vue&&f(window.Vue);const{plugins:s=[],strict:o=!1}=e;this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new n(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new r,this._makeLocalGettersCache=Object.create(null);const i=this,{dispatch:c,commit:a}=this;this.dispatch=function(t,e){return c.call(i,t,e)},this.commit=function(t,e,s){return a.call(i,t,e,s)},this.strict=o;const u=this._modules.root.state;h(this,u,[],this._modules.root),l(this,u),s.forEach(t=>t(this)),(void 0!==e.devtools?e.devtools:r.config.devtools)&&function(e){t&&(e._devtoolHook=t,t.emit("vuex:init",e),t.on("vuex:travel-to-state",t=>{e.replaceState(t)}),e.subscribe((e,s)=>{t.emit("vuex:mutation",e,s)},{prepend:!0}),e.subscribeAction((e,s)=>{t.emit("vuex:action",e,s)},{prepend:!0}))}(this)}get state(){return this._vm._data.$$state}set state(t){}commit(t,e,s){const{type:o,payload:i,options:n}=p(t,e,s),r={type:o,payload:i},c=this._mutations[o];c&&(this._withCommit(()=>{c.forEach((function(t){t(i)}))}),this._subscribers.slice().forEach(t=>t(r,this.state)))}dispatch(t,e){const{type:s,payload:o}=p(t,e),i={type:s,payload:o},n=this._actions[s];if(!n)return;try{this._actionSubscribers.slice().filter(t=>t.before).forEach(t=>t.before(i,this.state))}catch(t){}const r=n.length>1?Promise.all(n.map(t=>t(o))):n[0](o);return new Promise((t,e)=>{r.then(e=>{try{this._actionSubscribers.filter(t=>t.after).forEach(t=>t.after(i,this.state))}catch(t){}t(e)},t=>{try{this._actionSubscribers.filter(t=>t.error).forEach(e=>e.error(i,this.state,t))}catch(t){}e(t)})})}subscribe(t,e){return a(t,this._subscribers,e)}subscribeAction(t,e){return a("function"==typeof t?{before:t}:t,this._actionSubscribers,e)}watch(t,e,s){return this._watcherVM.$watch(()=>t(this.state,this.getters),e,s)}replaceState(t){this._withCommit(()=>{this._vm._data.$$state=t})}registerModule(t,e,s={}){"string"==typeof t&&(t=[t]),this._modules.register(t,e),h(this,this.state,t,this._modules.get(t),s.preserveState),l(this,this.state)}unregisterModule(t){"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit(()=>{const e=d(this.state,t.slice(0,-1));r.delete(e,t[t.length-1])}),u(this)}hasModule(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)}hotUpdate(t){this._modules.update(t),u(this,!0)}_withCommit(t){const e=this._committing;this._committing=!0,t(),this._committing=e}}function a(t,e,s){return e.indexOf(t)<0&&(s&&s.prepend?e.unshift(t):e.push(t)),()=>{const s=e.indexOf(t);s>-1&&e.splice(s,1)}}function u(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);const s=t.state;h(t,s,[],t._modules.root,!0),l(t,s,e)}function l(t,e,o){const i=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);const n=t._wrappedGetters,c={};s(n,(e,s)=>{c[s]=function(t,e){return function(){return t(e)}}(e,t),Object.defineProperty(t.getters,s,{get:()=>t._vm[s],enumerable:!0})});const a=r.config.silent;r.config.silent=!0,t._vm=new r({data:{$$state:e},computed:c}),r.config.silent=a,t.strict&&function(t){t._vm.$watch((function(){return this._data.$$state}),()=>{},{deep:!0,sync:!0})}(t),i&&(o&&t._withCommit(()=>{i._data.$$state=null}),r.nextTick(()=>i.$destroy()))}function h(t,e,s,o,i){const n=!s.length,c=t._modules.getNamespace(s);if(o.namespaced&&(t._modulesNamespaceMap[c],t._modulesNamespaceMap[c]=o),!n&&!i){const i=d(e,s.slice(0,-1)),n=s[s.length-1];t._withCommit(()=>{r.set(i,n,o.state)})}const a=o.context=function(t,e,s){const o=""===e,i={dispatch:o?t.dispatch:(s,o,i)=>{const n=p(s,o,i),{payload:r,options:c}=n;let{type:a}=n;return c&&c.root||(a=e+a),t.dispatch(a,r)},commit:o?t.commit:(s,o,i)=>{const n=p(s,o,i),{payload:r,options:c}=n;let{type:a}=n;c&&c.root||(a=e+a),t.commit(a,r,c)}};return Object.defineProperties(i,{getters:{get:o?()=>t.getters:()=>function(t,e){if(!t._makeLocalGettersCache[e]){const s={},o=e.length;Object.keys(t.getters).forEach(i=>{if(i.slice(0,o)!==e)return;const n=i.slice(o);Object.defineProperty(s,n,{get:()=>t.getters[i],enumerable:!0})}),t._makeLocalGettersCache[e]=s}return t._makeLocalGettersCache[e]}(t,e)},state:{get:()=>d(t.state,s)}}),i}(t,c,s);o.forEachMutation((e,s)=>{!function(t,e,s,o){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){s.call(t,o.state,e)}))}(t,c+s,e,a)}),o.forEachAction((e,s)=>{const o=e.root?s:c+s,i=e.handler||e;!function(t,e,s,o){(t._actions[e]||(t._actions[e]=[])).push((function(e){let i=s.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e);var n;return(n=i)&&"function"==typeof n.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch(e=>{throw t._devtoolHook.emit("vuex:error",e),e}):i}))}(t,o,i,a)}),o.forEachGetter((e,s)=>{!function(t,e,s,o){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return s(o.state,o.getters,t.state,t.getters)}}(t,c+s,e,a)}),o.forEachChild((o,n)=>{h(t,e,s.concat(n),o,i)})}function d(t,e){return e.reduce((t,e)=>t[e],t)}function p(t,e,s){return o(t)&&t.type&&(s=e,e=t,t=t.type),{type:t,payload:e,options:s}}function f(t){r&&t===r||(r=t,function(t){if(Number(t.version.split(".")[0])>=2)t.mixin({beforeCreate:e});else{const s=t.prototype._init;t.prototype._init=function(t={}){t.init=t.init?[e].concat(t.init):e,s.call(this,t)}}function e(){const t=this.$options;t.store?this.$store="function"==typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}}(r))}const m=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(){let e=this.$store.state,s=this.$store.getters;if(t){const o=$(this.$store,"mapState",t);if(!o)return;e=o.context.state,s=o.context.getters}return"function"==typeof o?o.call(this,e,s):e[o]},s[e].vuex=!0}),s}),g=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(...e){let s=this.$store.commit;if(t){const e=$(this.$store,"mapMutations",t);if(!e)return;s=e.context.commit}return"function"==typeof o?o.apply(this,[s].concat(e)):s.apply(this.$store,[o].concat(e))}}),s}),_=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{o=t+o,s[e]=function(){if(!t||$(this.$store,"mapGetters",t))return this.$store.getters[o]},s[e].vuex=!0}),s}),y=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(...e){let s=this.$store.dispatch;if(t){const e=$(this.$store,"mapActions",t);if(!e)return;s=e.context.dispatch}return"function"==typeof o?o.apply(this,[s].concat(e)):s.apply(this.$store,[o].concat(e))}}),s}),b=t=>({mapState:m.bind(null,t),mapGetters:_.bind(null,t),mapMutations:g.bind(null,t),mapActions:y.bind(null,t)});function w(t){return function(t){return Array.isArray(t)||o(t)}(t)?Array.isArray(t)?t.map(t=>({key:t,val:t})):Object.keys(t).map(e=>({key:e,val:t[e]})):[]}function v(t){return(e,s)=>("string"!=typeof e?(s=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,s))}function $(t,e,s){return t._modulesNamespaceMap[s]}function M({collapsed:t=!0,filter:s=((t,e,s)=>!0),transformer:o=(t=>t),mutationTransformer:i=(t=>t),actionFilter:n=((t,e)=>!0),actionTransformer:r=(t=>t),logMutations:c=!0,logActions:a=!0,logger:u=console}={}){return l=>{let h=e(l.state);void 0!==u&&(c&&l.subscribe((n,r)=>{const c=e(r);if(s(n,h,c)){const e=O(),s=i(n),r=`mutation ${n.type}${e}`;C(u,r,t),u.log("%c prev state","color: #9E9E9E; font-weight: bold",o(h)),u.log("%c mutation","color: #03A9F4; font-weight: bold",s),u.log("%c next state","color: #4CAF50; font-weight: bold",o(c)),E(u)}h=c}),a&&l.subscribeAction((e,s)=>{if(n(e,s)){const s=O(),o=r(e),i=`action ${e.type}${s}`;C(u,i,t),u.log("%c action","color: #03A9F4; font-weight: bold",o),E(u)}}))}}function C(t,e,s){const o=s?t.groupCollapsed:t.group;try{o.call(t,e)}catch(s){t.log(e)}}function E(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function O(){const t=new Date;return` @ ${j(t.getHours(),2)}:${j(t.getMinutes(),2)}:${j(t.getSeconds(),2)}.${j(t.getMilliseconds(),3)}`}function j(t,e){return s="0",o=e-t.toString().length,new Array(o+1).join(s)+t;var s,o}var A={Store:c,install:f,version:"3.5.1",mapState:m,mapMutations:g,mapGetters:_,mapActions:y,createNamespacedHelpers:b,createLogger:M};export default A;export{c as Store,M as createLogger,b as createNamespacedHelpers,f as install,y as mapActions,_ as mapGetters,g as mapMutations,m as mapState}; +const t=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function e(t,s=[]){if(null===t||"object"!=typeof t)return t;const o=(i=e=>e.original===t,s.filter(i)[0]);var i;if(o)return o.copy;const n=Array.isArray(t)?[]:{};return s.push({original:t,copy:n}),Object.keys(t).forEach(o=>{n[o]=e(t[o],s)}),n}function s(t,e){Object.keys(t).forEach(s=>e(t[s],s))}function o(t){return null!==t&&"object"==typeof t}class i{constructor(t,e){this.runtime=e,this._children=Object.create(null),this._rawModule=t;const s=t.state;this.state=("function"==typeof s?s():s)||{}}get namespaced(){return!!this._rawModule.namespaced}addChild(t,e){this._children[t]=e}removeChild(t){delete this._children[t]}getChild(t){return this._children[t]}hasChild(t){return t in this._children}update(t){this._rawModule.namespaced=t.namespaced,t.actions&&(this._rawModule.actions=t.actions),t.mutations&&(this._rawModule.mutations=t.mutations),t.getters&&(this._rawModule.getters=t.getters)}forEachChild(t){s(this._children,t)}forEachGetter(t){this._rawModule.getters&&s(this._rawModule.getters,t)}forEachAction(t){this._rawModule.actions&&s(this._rawModule.actions,t)}forEachMutation(t){this._rawModule.mutations&&s(this._rawModule.mutations,t)}}class n{constructor(t){this.register([],t,!1)}get(t){return t.reduce((t,e)=>t.getChild(e),this.root)}getNamespace(t){let e=this.root;return t.reduce((t,s)=>(e=e.getChild(s),t+(e.namespaced?s+"/":"")),"")}update(t){!function t(e,s,o){if(s.update(o),o.modules)for(const i in o.modules){if(!s.getChild(i))return;t(e.concat(i),s.getChild(i),o.modules[i])}}([],this.root,t)}register(t,e,o=!0){const n=new i(e,o);if(0===t.length)this.root=n;else{this.get(t.slice(0,-1)).addChild(t[t.length-1],n)}e.modules&&s(e.modules,(e,s)=>{this.register(t.concat(s),e,o)})}unregister(t){const e=this.get(t.slice(0,-1)),s=t[t.length-1],o=e.getChild(s);o&&o.runtime&&e.removeChild(s)}isRegistered(t){const e=this.get(t.slice(0,-1)),s=t[t.length-1];return!!e&&e.hasChild(s)}}let r;class c{constructor(e={}){!r&&"undefined"!=typeof window&&window.Vue&&f(window.Vue);const{plugins:s=[],strict:o=!1}=e;this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new n(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new r,this._makeLocalGettersCache=Object.create(null);const i=this,{dispatch:c,commit:a}=this;this.dispatch=function(t,e){return c.call(i,t,e)},this.commit=function(t,e,s){return a.call(i,t,e,s)},this.strict=o;const u=this._modules.root.state;h(this,u,[],this._modules.root),l(this,u),s.forEach(t=>t(this));(void 0!==e.devtools?e.devtools:r.config.devtools)&&function(e){t&&(e._devtoolHook=t,t.emit("vuex:init",e),t.on("vuex:travel-to-state",t=>{e.replaceState(t)}),e.subscribe((e,s)=>{t.emit("vuex:mutation",e,s)},{prepend:!0}),e.subscribeAction((e,s)=>{t.emit("vuex:action",e,s)},{prepend:!0}))}(this)}get state(){return this._vm._data.$$state}set state(t){}commit(t,e,s){const{type:o,payload:i,options:n}=p(t,e,s),r={type:o,payload:i},c=this._mutations[o];c&&(this._withCommit(()=>{c.forEach((function(t){t(i)}))}),this._subscribers.slice().forEach(t=>t(r,this.state)))}dispatch(t,e){const{type:s,payload:o}=p(t,e),i={type:s,payload:o},n=this._actions[s];if(!n)return;try{this._actionSubscribers.slice().filter(t=>t.before).forEach(t=>t.before(i,this.state))}catch(t){}const r=n.length>1?Promise.all(n.map(t=>t(o))):n[0](o);return new Promise((t,e)=>{r.then(e=>{try{this._actionSubscribers.filter(t=>t.after).forEach(t=>t.after(i,this.state))}catch(t){}t(e)},t=>{try{this._actionSubscribers.filter(t=>t.error).forEach(e=>e.error(i,this.state,t))}catch(t){}e(t)})})}subscribe(t,e){return a(t,this._subscribers,e)}subscribeAction(t,e){return a("function"==typeof t?{before:t}:t,this._actionSubscribers,e)}watch(t,e,s){return this._watcherVM.$watch(()=>t(this.state,this.getters),e,s)}replaceState(t){this._withCommit(()=>{this._vm._data.$$state=t})}registerModule(t,e,s={}){"string"==typeof t&&(t=[t]),this._modules.register(t,e),h(this,this.state,t,this._modules.get(t),s.preserveState),l(this,this.state)}unregisterModule(t){"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit(()=>{const e=d(this.state,t.slice(0,-1));r.delete(e,t[t.length-1])}),u(this)}hasModule(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)}hotUpdate(t){this._modules.update(t),u(this,!0)}_withCommit(t){const e=this._committing;this._committing=!0,t(),this._committing=e}}function a(t,e,s){return e.indexOf(t)<0&&(s&&s.prepend?e.unshift(t):e.push(t)),()=>{const s=e.indexOf(t);s>-1&&e.splice(s,1)}}function u(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);const s=t.state;h(t,s,[],t._modules.root,!0),l(t,s,e)}function l(t,e,o){const i=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);const n=t._wrappedGetters,c={};s(n,(e,s)=>{c[s]=function(t,e){return function(){return t(e)}}(e,t),Object.defineProperty(t.getters,s,{get:()=>t._vm[s],enumerable:!0})});const a=r.config.silent;r.config.silent=!0,t._vm=new r({data:{$$state:e},computed:c}),r.config.silent=a,t.strict&&function(t){t._vm.$watch((function(){return this._data.$$state}),()=>{},{deep:!0,sync:!0})}(t),i&&(o&&t._withCommit(()=>{i._data.$$state=null}),r.nextTick(()=>i.$destroy()))}function h(t,e,s,o,i){const n=!s.length,c=t._modules.getNamespace(s);if(o.namespaced&&(t._modulesNamespaceMap[c],t._modulesNamespaceMap[c]=o),!n&&!i){const i=d(e,s.slice(0,-1)),n=s[s.length-1];t._withCommit(()=>{r.set(i,n,o.state)})}const a=o.context=function(t,e,s){const o=""===e,i={dispatch:o?t.dispatch:(s,o,i)=>{const n=p(s,o,i),{payload:r,options:c}=n;let{type:a}=n;return c&&c.root||(a=e+a),t.dispatch(a,r)},commit:o?t.commit:(s,o,i)=>{const n=p(s,o,i),{payload:r,options:c}=n;let{type:a}=n;c&&c.root||(a=e+a),t.commit(a,r,c)}};return Object.defineProperties(i,{getters:{get:o?()=>t.getters:()=>function(t,e){if(!t._makeLocalGettersCache[e]){const s={},o=e.length;Object.keys(t.getters).forEach(i=>{if(i.slice(0,o)!==e)return;const n=i.slice(o);Object.defineProperty(s,n,{get:()=>t.getters[i],enumerable:!0})}),t._makeLocalGettersCache[e]=s}return t._makeLocalGettersCache[e]}(t,e)},state:{get:()=>d(t.state,s)}}),i}(t,c,s);o.forEachMutation((e,s)=>{!function(t,e,s,o){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){s.call(t,o.state,e)}))}(t,c+s,e,a)}),o.forEachAction((e,s)=>{const o=e.root?s:c+s,i=e.handler||e;!function(t,e,s,o){(t._actions[e]||(t._actions[e]=[])).push((function(e){let i=s.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e);var n;return(n=i)&&"function"==typeof n.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch(e=>{throw t._devtoolHook.emit("vuex:error",e),e}):i}))}(t,o,i,a)}),o.forEachGetter((e,s)=>{!function(t,e,s,o){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return s(o.state,o.getters,t.state,t.getters)}}(t,c+s,e,a)}),o.forEachChild((o,n)=>{h(t,e,s.concat(n),o,i)})}function d(t,e){return e.reduce((t,e)=>t[e],t)}function p(t,e,s){return o(t)&&t.type&&(s=e,e=t,t=t.type),{type:t,payload:e,options:s}}function f(t){r&&t===r||(r=t,function(t){if(Number(t.version.split(".")[0])>=2)t.mixin({beforeCreate:e});else{const s=t.prototype._init;t.prototype._init=function(t={}){t.init=t.init?[e].concat(t.init):e,s.call(this,t)}}function e(){const t=this.$options;t.store?this.$store="function"==typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}}(r))}const m=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(){let e=this.$store.state,s=this.$store.getters;if(t){const o=$(this.$store,"mapState",t);if(!o)return;e=o.context.state,s=o.context.getters}return"function"==typeof o?o.call(this,e,s):e[o]},s[e].vuex=!0}),s}),g=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(...e){let s=this.$store.commit;if(t){const e=$(this.$store,"mapMutations",t);if(!e)return;s=e.context.commit}return"function"==typeof o?o.apply(this,[s].concat(e)):s.apply(this.$store,[o].concat(e))}}),s}),_=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{o=t+o,s[e]=function(){if(!t||$(this.$store,"mapGetters",t))return this.$store.getters[o]},s[e].vuex=!0}),s}),y=v((t,e)=>{const s={};return w(e).forEach(({key:e,val:o})=>{s[e]=function(...e){let s=this.$store.dispatch;if(t){const e=$(this.$store,"mapActions",t);if(!e)return;s=e.context.dispatch}return"function"==typeof o?o.apply(this,[s].concat(e)):s.apply(this.$store,[o].concat(e))}}),s}),b=t=>({mapState:m.bind(null,t),mapGetters:_.bind(null,t),mapMutations:g.bind(null,t),mapActions:y.bind(null,t)});function w(t){return function(t){return Array.isArray(t)||o(t)}(t)?Array.isArray(t)?t.map(t=>({key:t,val:t})):Object.keys(t).map(e=>({key:e,val:t[e]})):[]}function v(t){return(e,s)=>("string"!=typeof e?(s=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,s))}function $(t,e,s){return t._modulesNamespaceMap[s]}function M({collapsed:t=!0,filter:s=((t,e,s)=>!0),transformer:o=(t=>t),mutationTransformer:i=(t=>t),actionFilter:n=((t,e)=>!0),actionTransformer:r=(t=>t),logMutations:c=!0,logActions:a=!0,logger:u=console}={}){return l=>{let h=e(l.state);void 0!==u&&(c&&l.subscribe((n,r)=>{const c=e(r);if(s(n,h,c)){const e=O(),s=i(n),r=`mutation ${n.type}${e}`;C(u,r,t),u.log("%c prev state","color: #9E9E9E; font-weight: bold",o(h)),u.log("%c mutation","color: #03A9F4; font-weight: bold",s),u.log("%c next state","color: #4CAF50; font-weight: bold",o(c)),E(u)}h=c}),a&&l.subscribeAction((e,s)=>{if(n(e,s)){const s=O(),o=r(e),i=`action ${e.type}${s}`;C(u,i,t),u.log("%c action","color: #03A9F4; font-weight: bold",o),E(u)}}))}}function C(t,e,s){const o=s?t.groupCollapsed:t.group;try{o.call(t,e)}catch(s){t.log(e)}}function E(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function O(){const t=new Date;return` @ ${j(t.getHours(),2)}:${j(t.getMinutes(),2)}:${j(t.getSeconds(),2)}.${j(t.getMilliseconds(),3)}`}function j(t,e){return s="0",o=e-t.toString().length,new Array(o+1).join(s)+t;var s,o}var A={Store:c,install:f,version:"3.5.1",mapState:m,mapMutations:g,mapGetters:_,mapActions:y,createNamespacedHelpers:b,createLogger:M};export default A;export{c as Store,M as createLogger,b as createNamespacedHelpers,f as install,y as mapActions,_ as mapGetters,g as mapMutations,m as mapState}; diff --git a/dist/vuex.esm.js b/dist/vuex.esm.js index 0a59ceb247..948098c644 100644 --- a/dist/vuex.esm.js +++ b/dist/vuex.esm.js @@ -286,7 +286,11 @@ ModuleCollection.prototype.isRegistered = function isRegistered (path) { var parent = this.get(path.slice(0, -1)); var key = path[path.length - 1]; - return parent.hasChild(key) + if (parent) { + return parent.hasChild(key) + } + + return false }; function update (path, targetModule, newModule) { diff --git a/dist/vuex.js b/dist/vuex.js index 98f199439a..f4085bb50e 100644 --- a/dist/vuex.js +++ b/dist/vuex.js @@ -6,7 +6,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.Vuex = factory()); + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Vuex = factory()); }(this, (function () { 'use strict'; function applyMixin (Vue) { @@ -292,7 +292,11 @@ var parent = this.get(path.slice(0, -1)); var key = path[path.length - 1]; - return parent.hasChild(key) + if (parent) { + return parent.hasChild(key) + } + + return false }; function update (path, targetModule, newModule) { diff --git a/dist/vuex.min.js b/dist/vuex.min.js index 57c88636ce..ba5eab5be2 100644 --- a/dist/vuex.min.js +++ b/dist/vuex.min.js @@ -3,4 +3,4 @@ * (c) 2020 Evan You * @license MIT */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Vuex=e()}(this,(function(){"use strict";var t=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function e(t,n){if(void 0===n&&(n=[]),null===t||"object"!=typeof t)return t;var o,r=(o=function(e){return e.original===t},n.filter(o)[0]);if(r)return r.copy;var i=Array.isArray(t)?[]:{};return n.push({original:t,copy:i}),Object.keys(t).forEach((function(o){i[o]=e(t[o],n)})),i}function n(t,e){Object.keys(t).forEach((function(n){return e(t[n],n)}))}function o(t){return null!==t&&"object"==typeof t}var r=function(t,e){this.runtime=e,this._children=Object.create(null),this._rawModule=t;var n=t.state;this.state=("function"==typeof n?n():n)||{}},i={namespaced:{configurable:!0}};i.namespaced.get=function(){return!!this._rawModule.namespaced},r.prototype.addChild=function(t,e){this._children[t]=e},r.prototype.removeChild=function(t){delete this._children[t]},r.prototype.getChild=function(t){return this._children[t]},r.prototype.hasChild=function(t){return t in this._children},r.prototype.update=function(t){this._rawModule.namespaced=t.namespaced,t.actions&&(this._rawModule.actions=t.actions),t.mutations&&(this._rawModule.mutations=t.mutations),t.getters&&(this._rawModule.getters=t.getters)},r.prototype.forEachChild=function(t){n(this._children,t)},r.prototype.forEachGetter=function(t){this._rawModule.getters&&n(this._rawModule.getters,t)},r.prototype.forEachAction=function(t){this._rawModule.actions&&n(this._rawModule.actions,t)},r.prototype.forEachMutation=function(t){this._rawModule.mutations&&n(this._rawModule.mutations,t)},Object.defineProperties(r.prototype,i);var c,a=function(t){this.register([],t,!1)};a.prototype.get=function(t){return t.reduce((function(t,e){return t.getChild(e)}),this.root)},a.prototype.getNamespace=function(t){var e=this.root;return t.reduce((function(t,n){return t+((e=e.getChild(n)).namespaced?n+"/":"")}),"")},a.prototype.update=function(t){!function t(e,n,o){if(n.update(o),o.modules)for(var r in o.modules){if(!n.getChild(r))return;t(e.concat(r),n.getChild(r),o.modules[r])}}([],this.root,t)},a.prototype.register=function(t,e,o){var i=this;void 0===o&&(o=!0);var c=new r(e,o);0===t.length?this.root=c:this.get(t.slice(0,-1)).addChild(t[t.length-1],c);e.modules&&n(e.modules,(function(e,n){i.register(t.concat(n),e,o)}))},a.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1],o=e.getChild(n);o&&o.runtime&&e.removeChild(n)},a.prototype.isRegistered=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];return e.hasChild(n)};var s=function(e){var n=this;void 0===e&&(e={}),!c&&"undefined"!=typeof window&&window.Vue&&v(window.Vue);var o=e.plugins;void 0===o&&(o=[]);var r=e.strict;void 0===r&&(r=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new a(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new c,this._makeLocalGettersCache=Object.create(null);var i=this,s=this.dispatch,u=this.commit;this.dispatch=function(t,e){return s.call(i,t,e)},this.commit=function(t,e,n){return u.call(i,t,e,n)},this.strict=r;var f=this._modules.root.state;h(this,f,[],this._modules.root),p(this,f),o.forEach((function(t){return t(n)})),(void 0!==e.devtools?e.devtools:c.config.devtools)&&function(e){t&&(e._devtoolHook=t,t.emit("vuex:init",e),t.on("vuex:travel-to-state",(function(t){e.replaceState(t)})),e.subscribe((function(e,n){t.emit("vuex:mutation",e,n)}),{prepend:!0}),e.subscribeAction((function(e,n){t.emit("vuex:action",e,n)}),{prepend:!0}))}(this)},u={state:{configurable:!0}};function f(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function l(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var n=t.state;h(t,n,[],t._modules.root,!0),p(t,n,e)}function p(t,e,o){var r=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);var i=t._wrappedGetters,a={};n(i,(function(e,n){a[n]=function(t,e){return function(){return t(e)}}(e,t),Object.defineProperty(t.getters,n,{get:function(){return t._vm[n]},enumerable:!0})}));var s=c.config.silent;c.config.silent=!0,t._vm=new c({data:{$$state:e},computed:a}),c.config.silent=s,t.strict&&function(t){t._vm.$watch((function(){return this._data.$$state}),(function(){}),{deep:!0,sync:!0})}(t),r&&(o&&t._withCommit((function(){r._data.$$state=null})),c.nextTick((function(){return r.$destroy()})))}function h(t,e,n,o,r){var i=!n.length,a=t._modules.getNamespace(n);if(o.namespaced&&(t._modulesNamespaceMap[a],t._modulesNamespaceMap[a]=o),!i&&!r){var s=d(e,n.slice(0,-1)),u=n[n.length-1];t._withCommit((function(){c.set(s,u,o.state)}))}var f=o.context=function(t,e,n){var o=""===e,r={dispatch:o?t.dispatch:function(n,o,r){var i=m(n,o,r),c=i.payload,a=i.options,s=i.type;return a&&a.root||(s=e+s),t.dispatch(s,c)},commit:o?t.commit:function(n,o,r){var i=m(n,o,r),c=i.payload,a=i.options,s=i.type;a&&a.root||(s=e+s),t.commit(s,c,a)}};return Object.defineProperties(r,{getters:{get:o?function(){return t.getters}:function(){return function(t,e){if(!t._makeLocalGettersCache[e]){var n={},o=e.length;Object.keys(t.getters).forEach((function(r){if(r.slice(0,o)===e){var i=r.slice(o);Object.defineProperty(n,i,{get:function(){return t.getters[r]},enumerable:!0})}})),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}(t,e)}},state:{get:function(){return d(t.state,n)}}}),r}(t,a,n);o.forEachMutation((function(e,n){!function(t,e,n,o){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,o.state,e)}))}(t,a+n,e,f)})),o.forEachAction((function(e,n){var o=e.root?n:a+n,r=e.handler||e;!function(t,e,n,o){(t._actions[e]||(t._actions[e]=[])).push((function(e){var r,i=n.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e);return(r=i)&&"function"==typeof r.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch((function(e){throw t._devtoolHook.emit("vuex:error",e),e})):i}))}(t,o,r,f)})),o.forEachGetter((function(e,n){!function(t,e,n,o){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return n(o.state,o.getters,t.state,t.getters)}}(t,a+n,e,f)})),o.forEachChild((function(o,i){h(t,e,n.concat(i),o,r)}))}function d(t,e){return e.reduce((function(t,e){return t[e]}),t)}function m(t,e,n){return o(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}function v(t){c&&t===c||function(t){if(Number(t.version.split(".")[0])>=2)t.mixin({beforeCreate:n});else{var e=t.prototype._init;t.prototype._init=function(t){void 0===t&&(t={}),t.init=t.init?[n].concat(t.init):n,e.call(this,t)}}function n(){var t=this.$options;t.store?this.$store="function"==typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}}(c=t)}u.state.get=function(){return this._vm._data.$$state},u.state.set=function(t){},s.prototype.commit=function(t,e,n){var o=this,r=m(t,e,n),i=r.type,c=r.payload,a={type:i,payload:c},s=this._mutations[i];s&&(this._withCommit((function(){s.forEach((function(t){t(c)}))})),this._subscribers.slice().forEach((function(t){return t(a,o.state)})))},s.prototype.dispatch=function(t,e){var n=this,o=m(t,e),r=o.type,i=o.payload,c={type:r,payload:i},a=this._actions[r];if(a){try{this._actionSubscribers.slice().filter((function(t){return t.before})).forEach((function(t){return t.before(c,n.state)}))}catch(t){}var s=a.length>1?Promise.all(a.map((function(t){return t(i)}))):a[0](i);return new Promise((function(t,e){s.then((function(e){try{n._actionSubscribers.filter((function(t){return t.after})).forEach((function(t){return t.after(c,n.state)}))}catch(t){}t(e)}),(function(t){try{n._actionSubscribers.filter((function(t){return t.error})).forEach((function(e){return e.error(c,n.state,t)}))}catch(t){}e(t)}))}))}},s.prototype.subscribe=function(t,e){return f(t,this._subscribers,e)},s.prototype.subscribeAction=function(t,e){return f("function"==typeof t?{before:t}:t,this._actionSubscribers,e)},s.prototype.watch=function(t,e,n){var o=this;return this._watcherVM.$watch((function(){return t(o.state,o.getters)}),e,n)},s.prototype.replaceState=function(t){var e=this;this._withCommit((function(){e._vm._data.$$state=t}))},s.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),h(this,this.state,t,this._modules.get(t),n.preserveState),p(this,this.state)},s.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit((function(){var n=d(e.state,t.slice(0,-1));c.delete(n,t[t.length-1])})),l(this)},s.prototype.hasModule=function(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)},s.prototype.hotUpdate=function(t){this._modules.update(t),l(this,!0)},s.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(s.prototype,u);var g=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var o=$(this.$store,"mapState",t);if(!o)return;e=o.context.state,n=o.context.getters}return"function"==typeof r?r.call(this,e,n):e[r]},n[o].vuex=!0})),n})),y=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var o=this.$store.commit;if(t){var i=$(this.$store,"mapMutations",t);if(!i)return;o=i.context.commit}return"function"==typeof r?r.apply(this,[o].concat(e)):o.apply(this.$store,[r].concat(e))}})),n})),_=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;r=t+r,n[o]=function(){if(!t||$(this.$store,"mapGetters",t))return this.$store.getters[r]},n[o].vuex=!0})),n})),b=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var o=this.$store.dispatch;if(t){var i=$(this.$store,"mapActions",t);if(!i)return;o=i.context.dispatch}return"function"==typeof r?r.apply(this,[o].concat(e)):o.apply(this.$store,[r].concat(e))}})),n}));function w(t){return function(t){return Array.isArray(t)||o(t)}(t)?Array.isArray(t)?t.map((function(t){return{key:t,val:t}})):Object.keys(t).map((function(e){return{key:e,val:t[e]}})):[]}function M(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function $(t,e,n){return t._modulesNamespaceMap[n]}function C(t,e,n){var o=n?t.groupCollapsed:t.group;try{o.call(t,e)}catch(n){t.log(e)}}function E(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function O(){var t=new Date;return" @ "+j(t.getHours(),2)+":"+j(t.getMinutes(),2)+":"+j(t.getSeconds(),2)+"."+j(t.getMilliseconds(),3)}function j(t,e){return n="0",o=e-t.toString().length,new Array(o+1).join(n)+t;var n,o}return{Store:s,install:v,version:"3.5.1",mapState:g,mapMutations:y,mapGetters:_,mapActions:b,createNamespacedHelpers:function(t){return{mapState:g.bind(null,t),mapGetters:_.bind(null,t),mapMutations:y.bind(null,t),mapActions:b.bind(null,t)}},createLogger:function(t){void 0===t&&(t={});var n=t.collapsed;void 0===n&&(n=!0);var o=t.filter;void 0===o&&(o=function(t,e,n){return!0});var r=t.transformer;void 0===r&&(r=function(t){return t});var i=t.mutationTransformer;void 0===i&&(i=function(t){return t});var c=t.actionFilter;void 0===c&&(c=function(t,e){return!0});var a=t.actionTransformer;void 0===a&&(a=function(t){return t});var s=t.logMutations;void 0===s&&(s=!0);var u=t.logActions;void 0===u&&(u=!0);var f=t.logger;return void 0===f&&(f=console),function(t){var l=e(t.state);void 0!==f&&(s&&t.subscribe((function(t,c){var a=e(c);if(o(t,l,a)){var s=O(),u=i(t),p="mutation "+t.type+s;C(f,p,n),f.log("%c prev state","color: #9E9E9E; font-weight: bold",r(l)),f.log("%c mutation","color: #03A9F4; font-weight: bold",u),f.log("%c next state","color: #4CAF50; font-weight: bold",r(a)),E(f)}l=a})),u&&t.subscribeAction((function(t,e){if(c(t,e)){var o=O(),r=a(t),i="action "+t.type+o;C(f,i,n),f.log("%c action","color: #03A9F4; font-weight: bold",r),E(f)}})))}}}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Vuex=e()}(this,(function(){"use strict";var t=("undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function e(t,n){if(void 0===n&&(n=[]),null===t||"object"!=typeof t)return t;var o,r=(o=function(e){return e.original===t},n.filter(o)[0]);if(r)return r.copy;var i=Array.isArray(t)?[]:{};return n.push({original:t,copy:i}),Object.keys(t).forEach((function(o){i[o]=e(t[o],n)})),i}function n(t,e){Object.keys(t).forEach((function(n){return e(t[n],n)}))}function o(t){return null!==t&&"object"==typeof t}var r=function(t,e){this.runtime=e,this._children=Object.create(null),this._rawModule=t;var n=t.state;this.state=("function"==typeof n?n():n)||{}},i={namespaced:{configurable:!0}};i.namespaced.get=function(){return!!this._rawModule.namespaced},r.prototype.addChild=function(t,e){this._children[t]=e},r.prototype.removeChild=function(t){delete this._children[t]},r.prototype.getChild=function(t){return this._children[t]},r.prototype.hasChild=function(t){return t in this._children},r.prototype.update=function(t){this._rawModule.namespaced=t.namespaced,t.actions&&(this._rawModule.actions=t.actions),t.mutations&&(this._rawModule.mutations=t.mutations),t.getters&&(this._rawModule.getters=t.getters)},r.prototype.forEachChild=function(t){n(this._children,t)},r.prototype.forEachGetter=function(t){this._rawModule.getters&&n(this._rawModule.getters,t)},r.prototype.forEachAction=function(t){this._rawModule.actions&&n(this._rawModule.actions,t)},r.prototype.forEachMutation=function(t){this._rawModule.mutations&&n(this._rawModule.mutations,t)},Object.defineProperties(r.prototype,i);var c,a=function(t){this.register([],t,!1)};a.prototype.get=function(t){return t.reduce((function(t,e){return t.getChild(e)}),this.root)},a.prototype.getNamespace=function(t){var e=this.root;return t.reduce((function(t,n){return t+((e=e.getChild(n)).namespaced?n+"/":"")}),"")},a.prototype.update=function(t){!function t(e,n,o){if(n.update(o),o.modules)for(var r in o.modules){if(!n.getChild(r))return;t(e.concat(r),n.getChild(r),o.modules[r])}}([],this.root,t)},a.prototype.register=function(t,e,o){var i=this;void 0===o&&(o=!0);var c=new r(e,o);0===t.length?this.root=c:this.get(t.slice(0,-1)).addChild(t[t.length-1],c);e.modules&&n(e.modules,(function(e,n){i.register(t.concat(n),e,o)}))},a.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1],o=e.getChild(n);o&&o.runtime&&e.removeChild(n)},a.prototype.isRegistered=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];return!!e&&e.hasChild(n)};var s=function(e){var n=this;void 0===e&&(e={}),!c&&"undefined"!=typeof window&&window.Vue&&v(window.Vue);var o=e.plugins;void 0===o&&(o=[]);var r=e.strict;void 0===r&&(r=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new a(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new c,this._makeLocalGettersCache=Object.create(null);var i=this,s=this.dispatch,u=this.commit;this.dispatch=function(t,e){return s.call(i,t,e)},this.commit=function(t,e,n){return u.call(i,t,e,n)},this.strict=r;var f=this._modules.root.state;p(this,f,[],this._modules.root),h(this,f),o.forEach((function(t){return t(n)})),(void 0!==e.devtools?e.devtools:c.config.devtools)&&function(e){t&&(e._devtoolHook=t,t.emit("vuex:init",e),t.on("vuex:travel-to-state",(function(t){e.replaceState(t)})),e.subscribe((function(e,n){t.emit("vuex:mutation",e,n)}),{prepend:!0}),e.subscribeAction((function(e,n){t.emit("vuex:action",e,n)}),{prepend:!0}))}(this)},u={state:{configurable:!0}};function f(t,e,n){return e.indexOf(t)<0&&(n&&n.prepend?e.unshift(t):e.push(t)),function(){var n=e.indexOf(t);n>-1&&e.splice(n,1)}}function l(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var n=t.state;p(t,n,[],t._modules.root,!0),h(t,n,e)}function h(t,e,o){var r=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);var i=t._wrappedGetters,a={};n(i,(function(e,n){a[n]=function(t,e){return function(){return t(e)}}(e,t),Object.defineProperty(t.getters,n,{get:function(){return t._vm[n]},enumerable:!0})}));var s=c.config.silent;c.config.silent=!0,t._vm=new c({data:{$$state:e},computed:a}),c.config.silent=s,t.strict&&function(t){t._vm.$watch((function(){return this._data.$$state}),(function(){}),{deep:!0,sync:!0})}(t),r&&(o&&t._withCommit((function(){r._data.$$state=null})),c.nextTick((function(){return r.$destroy()})))}function p(t,e,n,o,r){var i=!n.length,a=t._modules.getNamespace(n);if(o.namespaced&&(t._modulesNamespaceMap[a],t._modulesNamespaceMap[a]=o),!i&&!r){var s=d(e,n.slice(0,-1)),u=n[n.length-1];t._withCommit((function(){c.set(s,u,o.state)}))}var f=o.context=function(t,e,n){var o=""===e,r={dispatch:o?t.dispatch:function(n,o,r){var i=m(n,o,r),c=i.payload,a=i.options,s=i.type;return a&&a.root||(s=e+s),t.dispatch(s,c)},commit:o?t.commit:function(n,o,r){var i=m(n,o,r),c=i.payload,a=i.options,s=i.type;a&&a.root||(s=e+s),t.commit(s,c,a)}};return Object.defineProperties(r,{getters:{get:o?function(){return t.getters}:function(){return function(t,e){if(!t._makeLocalGettersCache[e]){var n={},o=e.length;Object.keys(t.getters).forEach((function(r){if(r.slice(0,o)===e){var i=r.slice(o);Object.defineProperty(n,i,{get:function(){return t.getters[r]},enumerable:!0})}})),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}(t,e)}},state:{get:function(){return d(t.state,n)}}}),r}(t,a,n);o.forEachMutation((function(e,n){!function(t,e,n,o){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,o.state,e)}))}(t,a+n,e,f)})),o.forEachAction((function(e,n){var o=e.root?n:a+n,r=e.handler||e;!function(t,e,n,o){(t._actions[e]||(t._actions[e]=[])).push((function(e){var r,i=n.call(t,{dispatch:o.dispatch,commit:o.commit,getters:o.getters,state:o.state,rootGetters:t.getters,rootState:t.state},e);return(r=i)&&"function"==typeof r.then||(i=Promise.resolve(i)),t._devtoolHook?i.catch((function(e){throw t._devtoolHook.emit("vuex:error",e),e})):i}))}(t,o,r,f)})),o.forEachGetter((function(e,n){!function(t,e,n,o){if(t._wrappedGetters[e])return;t._wrappedGetters[e]=function(t){return n(o.state,o.getters,t.state,t.getters)}}(t,a+n,e,f)})),o.forEachChild((function(o,i){p(t,e,n.concat(i),o,r)}))}function d(t,e){return e.reduce((function(t,e){return t[e]}),t)}function m(t,e,n){return o(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}function v(t){c&&t===c||function(t){if(Number(t.version.split(".")[0])>=2)t.mixin({beforeCreate:n});else{var e=t.prototype._init;t.prototype._init=function(t){void 0===t&&(t={}),t.init=t.init?[n].concat(t.init):n,e.call(this,t)}}function n(){var t=this.$options;t.store?this.$store="function"==typeof t.store?t.store():t.store:t.parent&&t.parent.$store&&(this.$store=t.parent.$store)}}(c=t)}u.state.get=function(){return this._vm._data.$$state},u.state.set=function(t){},s.prototype.commit=function(t,e,n){var o=this,r=m(t,e,n),i=r.type,c=r.payload,a={type:i,payload:c},s=this._mutations[i];s&&(this._withCommit((function(){s.forEach((function(t){t(c)}))})),this._subscribers.slice().forEach((function(t){return t(a,o.state)})))},s.prototype.dispatch=function(t,e){var n=this,o=m(t,e),r=o.type,i=o.payload,c={type:r,payload:i},a=this._actions[r];if(a){try{this._actionSubscribers.slice().filter((function(t){return t.before})).forEach((function(t){return t.before(c,n.state)}))}catch(t){}var s=a.length>1?Promise.all(a.map((function(t){return t(i)}))):a[0](i);return new Promise((function(t,e){s.then((function(e){try{n._actionSubscribers.filter((function(t){return t.after})).forEach((function(t){return t.after(c,n.state)}))}catch(t){}t(e)}),(function(t){try{n._actionSubscribers.filter((function(t){return t.error})).forEach((function(e){return e.error(c,n.state,t)}))}catch(t){}e(t)}))}))}},s.prototype.subscribe=function(t,e){return f(t,this._subscribers,e)},s.prototype.subscribeAction=function(t,e){return f("function"==typeof t?{before:t}:t,this._actionSubscribers,e)},s.prototype.watch=function(t,e,n){var o=this;return this._watcherVM.$watch((function(){return t(o.state,o.getters)}),e,n)},s.prototype.replaceState=function(t){var e=this;this._withCommit((function(){e._vm._data.$$state=t}))},s.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),p(this,this.state,t,this._modules.get(t),n.preserveState),h(this,this.state)},s.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit((function(){var n=d(e.state,t.slice(0,-1));c.delete(n,t[t.length-1])})),l(this)},s.prototype.hasModule=function(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)},s.prototype.hotUpdate=function(t){this._modules.update(t),l(this,!0)},s.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(s.prototype,u);var g=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var o=$(this.$store,"mapState",t);if(!o)return;e=o.context.state,n=o.context.getters}return"function"==typeof r?r.call(this,e,n):e[r]},n[o].vuex=!0})),n})),y=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var o=this.$store.commit;if(t){var i=$(this.$store,"mapMutations",t);if(!i)return;o=i.context.commit}return"function"==typeof r?r.apply(this,[o].concat(e)):o.apply(this.$store,[r].concat(e))}})),n})),_=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;r=t+r,n[o]=function(){if(!t||$(this.$store,"mapGetters",t))return this.$store.getters[r]},n[o].vuex=!0})),n})),b=M((function(t,e){var n={};return w(e).forEach((function(e){var o=e.key,r=e.val;n[o]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var o=this.$store.dispatch;if(t){var i=$(this.$store,"mapActions",t);if(!i)return;o=i.context.dispatch}return"function"==typeof r?r.apply(this,[o].concat(e)):o.apply(this.$store,[r].concat(e))}})),n}));function w(t){return function(t){return Array.isArray(t)||o(t)}(t)?Array.isArray(t)?t.map((function(t){return{key:t,val:t}})):Object.keys(t).map((function(e){return{key:e,val:t[e]}})):[]}function M(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function $(t,e,n){return t._modulesNamespaceMap[n]}function C(t,e,n){var o=n?t.groupCollapsed:t.group;try{o.call(t,e)}catch(n){t.log(e)}}function E(t){try{t.groupEnd()}catch(e){t.log("—— log end ——")}}function O(){var t=new Date;return" @ "+j(t.getHours(),2)+":"+j(t.getMinutes(),2)+":"+j(t.getSeconds(),2)+"."+j(t.getMilliseconds(),3)}function j(t,e){return n="0",o=e-t.toString().length,new Array(o+1).join(n)+t;var n,o}return{Store:s,install:v,version:"3.5.1",mapState:g,mapMutations:y,mapGetters:_,mapActions:b,createNamespacedHelpers:function(t){return{mapState:g.bind(null,t),mapGetters:_.bind(null,t),mapMutations:y.bind(null,t),mapActions:b.bind(null,t)}},createLogger:function(t){void 0===t&&(t={});var n=t.collapsed;void 0===n&&(n=!0);var o=t.filter;void 0===o&&(o=function(t,e,n){return!0});var r=t.transformer;void 0===r&&(r=function(t){return t});var i=t.mutationTransformer;void 0===i&&(i=function(t){return t});var c=t.actionFilter;void 0===c&&(c=function(t,e){return!0});var a=t.actionTransformer;void 0===a&&(a=function(t){return t});var s=t.logMutations;void 0===s&&(s=!0);var u=t.logActions;void 0===u&&(u=!0);var f=t.logger;return void 0===f&&(f=console),function(t){var l=e(t.state);void 0!==f&&(s&&t.subscribe((function(t,c){var a=e(c);if(o(t,l,a)){var s=O(),u=i(t),h="mutation "+t.type+s;C(f,h,n),f.log("%c prev state","color: #9E9E9E; font-weight: bold",r(l)),f.log("%c mutation","color: #03A9F4; font-weight: bold",u),f.log("%c next state","color: #4CAF50; font-weight: bold",r(a)),E(f)}l=a})),u&&t.subscribeAction((function(t,e){if(c(t,e)){var o=O(),r=a(t),i="action "+t.type+o;C(f,i,n),f.log("%c action","color: #03A9F4; font-weight: bold",r),E(f)}})))}}}}));