npm.vuex.00e66f29c2bd7cc309ec.0.1.0.js 11 KB

12
  1. /*! For license information please see npm.vuex.00e66f29c2bd7cc309ec.0.1.0.js.LICENSE.txt */
  2. (window.webpackJsonp=window.webpackJsonp||[]).push([["npm.vuex"],{"2f62":function(t,e,n){"use strict";(function(t){n.d(e,"b",(function(){return w}));var i=("undefined"!=typeof window?window:void 0!==t?t:{}).__VUE_DEVTOOLS_GLOBAL_HOOK__;function o(t){i&&(t._devtoolHook=i,i.emit("vuex:init",t),i.on("vuex:travel-to-state",(function(e){t.replaceState(e)})),t.subscribe((function(t,e){i.emit("vuex:mutation",t,e)}),{prepend:!0}),t.subscribeAction((function(t,e){i.emit("vuex:action",t,e)}),{prepend:!0}))}function r(t,e){Object.keys(t).forEach((function(n){return e(t[n],n)}))}function s(t){return null!==t&&"object"==typeof t}var c=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)||{}},a={namespaced:{configurable:!0}};a.namespaced.get=function(){return!!this._rawModule.namespaced},c.prototype.addChild=function(t,e){this._children[t]=e},c.prototype.removeChild=function(t){delete this._children[t]},c.prototype.getChild=function(t){return this._children[t]},c.prototype.hasChild=function(t){return t in this._children},c.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)},c.prototype.forEachChild=function(t){r(this._children,t)},c.prototype.forEachGetter=function(t){this._rawModule.getters&&r(this._rawModule.getters,t)},c.prototype.forEachAction=function(t){this._rawModule.actions&&r(this._rawModule.actions,t)},c.prototype.forEachMutation=function(t){this._rawModule.mutations&&r(this._rawModule.mutations,t)},Object.defineProperties(c.prototype,a);var u,f=function(t){this.register([],t,!1)};f.prototype.get=function(t){return t.reduce((function(t,e){return t.getChild(e)}),this.root)},f.prototype.getNamespace=function(t){var e=this.root;return t.reduce((function(t,n){return t+((e=e.getChild(n)).namespaced?n+"/":"")}),"")},f.prototype.update=function(t){!function t(e,n,i){if(n.update(i),i.modules)for(var o in i.modules){if(!n.getChild(o))return;t(e.concat(o),n.getChild(o),i.modules[o])}}([],this.root,t)},f.prototype.register=function(t,e,n){var i=this;void 0===n&&(n=!0);var o=new c(e,n);0===t.length?this.root=o:this.get(t.slice(0,-1)).addChild(t[t.length-1],o);e.modules&&r(e.modules,(function(e,o){i.register(t.concat(o),e,n)}))},f.prototype.unregister=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];e.getChild(n).runtime&&e.removeChild(n)},f.prototype.isRegistered=function(t){var e=this.get(t.slice(0,-1)),n=t[t.length-1];return e.hasChild(n)};var h=function(t){var e=this;void 0===t&&(t={}),!u&&"undefined"!=typeof window&&window.Vue&&b(window.Vue);var n=t.plugins;void 0===n&&(n=[]);var i=t.strict;void 0===i&&(i=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new f(t),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new u,this._makeLocalGettersCache=Object.create(null);var r=this,s=this.dispatch,c=this.commit;this.dispatch=function(t,e){return s.call(r,t,e)},this.commit=function(t,e,n){return c.call(r,t,e,n)},this.strict=i;var a=this._modules.root.state;v(this,a,[],this._modules.root),m(this,a),n.forEach((function(t){return t(e)})),(void 0!==t.devtools?t.devtools:u.config.devtools)&&o(this)},p={state:{configurable:!0}};function l(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 d(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;v(t,n,[],t._modules.root,!0),m(t,n,e)}function m(t,e,n){var i=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);var o=t._wrappedGetters,s={};r(o,(function(e,n){s[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 c=u.config.silent;u.config.silent=!0,t._vm=new u({data:{$$state:e},computed:s}),u.config.silent=c,t.strict&&function(t){t._vm.$watch((function(){return this._data.$$state}),(function(){}),{deep:!0,sync:!0})}(t),i&&(n&&t._withCommit((function(){i._data.$$state=null})),u.nextTick((function(){return i.$destroy()})))}function v(t,e,n,i,o){var r=!n.length,s=t._modules.getNamespace(n);if(i.namespaced&&(t._modulesNamespaceMap[s],t._modulesNamespaceMap[s]=i),!r&&!o){var c=y(e,n.slice(0,-1)),a=n[n.length-1];t._withCommit((function(){u.set(c,a,i.state)}))}var f=i.context=function(t,e,n){var i=""===e,o={dispatch:i?t.dispatch:function(n,i,o){var r=g(n,i,o),s=r.payload,c=r.options,a=r.type;return c&&c.root||(a=e+a),t.dispatch(a,s)},commit:i?t.commit:function(n,i,o){var r=g(n,i,o),s=r.payload,c=r.options,a=r.type;c&&c.root||(a=e+a),t.commit(a,s,c)}};return Object.defineProperties(o,{getters:{get:i?function(){return t.getters}:function(){return function(t,e){if(!t._makeLocalGettersCache[e]){var n={},i=e.length;Object.keys(t.getters).forEach((function(o){if(o.slice(0,i)===e){var r=o.slice(i);Object.defineProperty(n,r,{get:function(){return t.getters[o]},enumerable:!0})}})),t._makeLocalGettersCache[e]=n}return t._makeLocalGettersCache[e]}(t,e)}},state:{get:function(){return y(t.state,n)}}}),o}(t,s,n);i.forEachMutation((function(e,n){!function(t,e,n,i){(t._mutations[e]||(t._mutations[e]=[])).push((function(e){n.call(t,i.state,e)}))}(t,s+n,e,f)})),i.forEachAction((function(e,n){var i=e.root?n:s+n,o=e.handler||e;_(t,i,o,f)})),i.forEachGetter((function(e,n){!function(t,e,n,i){t._wrappedGetters[e]||(t._wrappedGetters[e]=function(t){return n(i.state,i.getters,t.state,t.getters)})}(t,s+n,e,f)})),i.forEachChild((function(i,r){v(t,e,n.concat(r),i,o)}))}function _(t,e,n,i){(t._actions[e]||(t._actions[e]=[])).push((function(e){var o=n.call(t,{dispatch:i.dispatch,commit:i.commit,getters:i.getters,state:i.state,rootGetters:t.getters,rootState:t.state},e);return function(t){return t&&"function"==typeof t.then}(o)||(o=Promise.resolve(o)),t._devtoolHook?o.catch((function(e){throw t._devtoolHook.emit("vuex:error",e),e})):o}))}function y(t,e){return e.reduce((function(t,e){return t[e]}),t)}function g(t,e,n){return s(t)&&t.type&&(n=e,e=t,t=t.type),{type:t,payload:e,options:n}}function b(t){u&&t===u||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)}}(u=t)}p.state.get=function(){return this._vm._data.$$state},p.state.set=function(t){},h.prototype.commit=function(t,e,n){var i=this,o=g(t,e,n),r=o.type,s=o.payload,c=(o.options,{type:r,payload:s}),a=this._mutations[r];a&&(this._withCommit((function(){a.forEach((function(t){t(s)}))})),this._subscribers.slice().forEach((function(t){return t(c,i.state)})))},h.prototype.dispatch=function(t,e){var n=this,i=g(t,e),o=i.type,r=i.payload,s={type:o,payload:r},c=this._actions[o];if(c){try{this._actionSubscribers.slice().filter((function(t){return t.before})).forEach((function(t){return t.before(s,n.state)}))}catch(t){}var a=c.length>1?Promise.all(c.map((function(t){return t(r)}))):c[0](r);return new Promise((function(t,e){a.then((function(e){try{n._actionSubscribers.filter((function(t){return t.after})).forEach((function(t){return t.after(s,n.state)}))}catch(t){}t(e)}),(function(t){try{n._actionSubscribers.filter((function(t){return t.error})).forEach((function(e){return e.error(s,n.state,t)}))}catch(t){}e(t)}))}))}},h.prototype.subscribe=function(t,e){return l(t,this._subscribers,e)},h.prototype.subscribeAction=function(t,e){return l("function"==typeof t?{before:t}:t,this._actionSubscribers,e)},h.prototype.watch=function(t,e,n){var i=this;return this._watcherVM.$watch((function(){return t(i.state,i.getters)}),e,n)},h.prototype.replaceState=function(t){var e=this;this._withCommit((function(){e._vm._data.$$state=t}))},h.prototype.registerModule=function(t,e,n){void 0===n&&(n={}),"string"==typeof t&&(t=[t]),this._modules.register(t,e),v(this,this.state,t,this._modules.get(t),n.preserveState),m(this,this.state)},h.prototype.unregisterModule=function(t){var e=this;"string"==typeof t&&(t=[t]),this._modules.unregister(t),this._withCommit((function(){var n=y(e.state,t.slice(0,-1));u.delete(n,t[t.length-1])})),d(this)},h.prototype.hasModule=function(t){return"string"==typeof t&&(t=[t]),this._modules.isRegistered(t)},h.prototype.hotUpdate=function(t){this._modules.update(t),d(this,!0)},h.prototype._withCommit=function(t){var e=this._committing;this._committing=!0,t(),this._committing=e},Object.defineProperties(h.prototype,p);var w=E((function(t,e){var n={};return O(e).forEach((function(e){var i=e.key,o=e.val;n[i]=function(){var e=this.$store.state,n=this.$store.getters;if(t){var i=j(this.$store,"mapState",t);if(!i)return;e=i.context.state,n=i.context.getters}return"function"==typeof o?o.call(this,e,n):e[o]},n[i].vuex=!0})),n})),$=E((function(t,e){var n={};return O(e).forEach((function(e){var i=e.key,o=e.val;n[i]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var i=this.$store.commit;if(t){var r=j(this.$store,"mapMutations",t);if(!r)return;i=r.context.commit}return"function"==typeof o?o.apply(this,[i].concat(e)):i.apply(this.$store,[o].concat(e))}})),n})),M=E((function(t,e){var n={};return O(e).forEach((function(e){var i=e.key,o=e.val;o=t+o,n[i]=function(){if(!t||j(this.$store,"mapGetters",t))return this.$store.getters[o]},n[i].vuex=!0})),n})),C=E((function(t,e){var n={};return O(e).forEach((function(e){var i=e.key,o=e.val;n[i]=function(){for(var e=[],n=arguments.length;n--;)e[n]=arguments[n];var i=this.$store.dispatch;if(t){var r=j(this.$store,"mapActions",t);if(!r)return;i=r.context.dispatch}return"function"==typeof o?o.apply(this,[i].concat(e)):i.apply(this.$store,[o].concat(e))}})),n}));function O(t){return function(t){return Array.isArray(t)||s(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 E(t){return function(e,n){return"string"!=typeof e?(n=e,e=""):"/"!==e.charAt(e.length-1)&&(e+="/"),t(e,n)}}function j(t,e,n){return t._modulesNamespaceMap[n]}var k={Store:h,install:b,version:"3.4.0",mapState:w,mapMutations:$,mapGetters:M,mapActions:C,createNamespacedHelpers:function(t){return{mapState:w.bind(null,t),mapGetters:M.bind(null,t),mapMutations:$.bind(null,t),mapActions:C.bind(null,t)}}};e.a=k}).call(this,n("c8ba"))}}]);