mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:07:06 +00:00
6 lines
12 KiB
JavaScript
Vendored
6 lines
12 KiB
JavaScript
Vendored
/*!
|
|
* vuex v3.6.2
|
|
* (c) 2021 Evan You
|
|
* @license MIT
|
|
*/function q(t){var e=Number(t.version.split(".")[0]);if(e>=2)t.mixin({beforeCreate:i});else{var r=t.prototype._init;t.prototype._init=function(n){n===void 0&&(n={}),n.init=n.init?[i].concat(n.init):i,r.call(this,n)}}function i(){var n=this.$options;n.store?this.$store=typeof n.store=="function"?n.store():n.store:n.parent&&n.parent.$store&&(this.$store=n.parent.$store)}}var J=typeof window!="undefined"?window:typeof global!="undefined"?global:{},_=J.__VUE_DEVTOOLS_GLOBAL_HOOK__;function Q(t){!_||(t._devtoolHook=_,_.emit("vuex:init",t),_.on("vuex:travel-to-state",function(e){t.replaceState(e)}),t.subscribe(function(e,r){_.emit("vuex:mutation",e,r)},{prepend:!0}),t.subscribeAction(function(e,r){_.emit("vuex:action",e,r)},{prepend:!0}))}function W(t,e){return t.filter(e)[0]}function x(t,e){if(e===void 0&&(e=[]),t===null||typeof t!="object")return t;var r=W(e,function(n){return n.original===t});if(r)return r.copy;var i=Array.isArray(t)?[]:{};return e.push({original:t,copy:i}),Object.keys(t).forEach(function(n){i[n]=x(t[n],e)}),i}function b(t,e){Object.keys(t).forEach(function(r){return e(t[r],r)})}function T(t){return t!==null&&typeof t=="object"}function X(t){return t&&typeof t.then=="function"}function Y(t,e){return function(){return t(e)}}var m=function(e,r){this.runtime=r,this._children=Object.create(null),this._rawModule=e;var i=e.state;this.state=(typeof i=="function"?i():i)||{}},V={namespaced:{configurable:!0}};V.namespaced.get=function(){return!!this._rawModule.namespaced};m.prototype.addChild=function(e,r){this._children[e]=r};m.prototype.removeChild=function(e){delete this._children[e]};m.prototype.getChild=function(e){return this._children[e]};m.prototype.hasChild=function(e){return e in this._children};m.prototype.update=function(e){this._rawModule.namespaced=e.namespaced,e.actions&&(this._rawModule.actions=e.actions),e.mutations&&(this._rawModule.mutations=e.mutations),e.getters&&(this._rawModule.getters=e.getters)};m.prototype.forEachChild=function(e){b(this._children,e)};m.prototype.forEachGetter=function(e){this._rawModule.getters&&b(this._rawModule.getters,e)};m.prototype.forEachAction=function(e){this._rawModule.actions&&b(this._rawModule.actions,e)};m.prototype.forEachMutation=function(e){this._rawModule.mutations&&b(this._rawModule.mutations,e)};Object.defineProperties(m.prototype,V);var y=function(e){this.register([],e,!1)};y.prototype.get=function(e){return e.reduce(function(r,i){return r.getChild(i)},this.root)};y.prototype.getNamespace=function(e){var r=this.root;return e.reduce(function(i,n){return r=r.getChild(n),i+(r.namespaced?n+"/":"")},"")};y.prototype.update=function(e){P([],this.root,e)};y.prototype.register=function(e,r,i){var n=this;i===void 0&&(i=!0);var a=new m(r,i);if(e.length===0)this.root=a;else{var f=this.get(e.slice(0,-1));f.addChild(e[e.length-1],a)}r.modules&&b(r.modules,function(u,c){n.register(e.concat(c),u,i)})};y.prototype.unregister=function(e){var r=this.get(e.slice(0,-1)),i=e[e.length-1],n=r.getChild(i);!n||!n.runtime||r.removeChild(i)};y.prototype.isRegistered=function(e){var r=this.get(e.slice(0,-1)),i=e[e.length-1];return r?r.hasChild(i):!1};function P(t,e,r){if(e.update(r),r.modules)for(var i in r.modules){if(!e.getChild(i))return;P(t.concat(i),e.getChild(i),r.modules[i])}}var p,v=function(e){var r=this;e===void 0&&(e={}),!p&&typeof window!="undefined"&&window.Vue&&R(window.Vue);var i=e.plugins;i===void 0&&(i=[]);var n=e.strict;n===void 0&&(n=!1),this._committing=!1,this._actions=Object.create(null),this._actionSubscribers=[],this._mutations=Object.create(null),this._wrappedGetters=Object.create(null),this._modules=new y(e),this._modulesNamespaceMap=Object.create(null),this._subscribers=[],this._watcherVM=new p,this._makeLocalGettersCache=Object.create(null);var a=this,f=this,u=f.dispatch,c=f.commit;this.dispatch=function(d,h){return u.call(a,d,h)},this.commit=function(d,h,g){return c.call(a,d,h,g)},this.strict=n;var s=this._modules.root.state;M(this,s,[],this._modules.root),j(this,s),i.forEach(function(l){return l(r)});var o=e.devtools!==void 0?e.devtools:p.config.devtools;o&&Q(this)},G={state:{configurable:!0}};G.state.get=function(){return this._vm._data.$$state};G.state.set=function(t){};v.prototype.commit=function(e,r,i){var n=this,a=$(e,r,i),f=a.type,u=a.payload,c={type:f,payload:u},s=this._mutations[f];!s||(this._withCommit(function(){s.forEach(function(l){l(u)})}),this._subscribers.slice().forEach(function(o){return o(c,n.state)}))};v.prototype.dispatch=function(e,r){var i=this,n=$(e,r),a=n.type,f=n.payload,u={type:a,payload:f},c=this._actions[a];if(!!c){try{this._actionSubscribers.slice().filter(function(o){return o.before}).forEach(function(o){return o.before(u,i.state)})}catch{}var s=c.length>1?Promise.all(c.map(function(o){return o(f)})):c[0](f);return new Promise(function(o,l){s.then(function(d){try{i._actionSubscribers.filter(function(h){return h.after}).forEach(function(h){return h.after(u,i.state)})}catch{}o(d)},function(d){try{i._actionSubscribers.filter(function(h){return h.error}).forEach(function(h){return h.error(u,i.state,d)})}catch{}l(d)})})}};v.prototype.subscribe=function(e,r){return F(e,this._subscribers,r)};v.prototype.subscribeAction=function(e,r){var i=typeof e=="function"?{before:e}:e;return F(i,this._actionSubscribers,r)};v.prototype.watch=function(e,r,i){var n=this;return this._watcherVM.$watch(function(){return e(n.state,n.getters)},r,i)};v.prototype.replaceState=function(e){var r=this;this._withCommit(function(){r._vm._data.$$state=e})};v.prototype.registerModule=function(e,r,i){i===void 0&&(i={}),typeof e=="string"&&(e=[e]),this._modules.register(e,r),M(this,this.state,e,this._modules.get(e),i.preserveState),j(this,this.state)};v.prototype.unregisterModule=function(e){var r=this;typeof e=="string"&&(e=[e]),this._modules.unregister(e),this._withCommit(function(){var i=k(r.state,e.slice(0,-1));p.delete(i,e[e.length-1])}),D(this)};v.prototype.hasModule=function(e){return typeof e=="string"&&(e=[e]),this._modules.isRegistered(e)};v.prototype.hotUpdate=function(e){this._modules.update(e),D(this,!0)};v.prototype._withCommit=function(e){var r=this._committing;this._committing=!0,e(),this._committing=r};Object.defineProperties(v.prototype,G);function F(t,e,r){return e.indexOf(t)<0&&(r&&r.prepend?e.unshift(t):e.push(t)),function(){var i=e.indexOf(t);i>-1&&e.splice(i,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 r=t.state;M(t,r,[],t._modules.root,!0),j(t,r,e)}function j(t,e,r){var i=t._vm;t.getters={},t._makeLocalGettersCache=Object.create(null);var n=t._wrappedGetters,a={};b(n,function(u,c){a[c]=Y(u,t),Object.defineProperty(t.getters,c,{get:function(){return t._vm[c]},enumerable:!0})});var f=p.config.silent;p.config.silent=!0,t._vm=new p({data:{$$state:e},computed:a}),p.config.silent=f,t.strict&&nt(t),i&&(r&&t._withCommit(function(){i._data.$$state=null}),p.nextTick(function(){return i.$destroy()}))}function M(t,e,r,i,n){var a=!r.length,f=t._modules.getNamespace(r);if(i.namespaced&&(t._modulesNamespaceMap[f],t._modulesNamespaceMap[f]=i),!a&&!n){var u=k(e,r.slice(0,-1)),c=r[r.length-1];t._withCommit(function(){p.set(u,c,i.state)})}var s=i.context=Z(t,f,r);i.forEachMutation(function(o,l){var d=f+l;et(t,d,o,s)}),i.forEachAction(function(o,l){var d=o.root?l:f+l,h=o.handler||o;rt(t,d,h,s)}),i.forEachGetter(function(o,l){var d=f+l;it(t,d,o,s)}),i.forEachChild(function(o,l){M(t,e,r.concat(l),o,n)})}function Z(t,e,r){var i=e==="",n={dispatch:i?t.dispatch:function(a,f,u){var c=$(a,f,u),s=c.payload,o=c.options,l=c.type;return(!o||!o.root)&&(l=e+l),t.dispatch(l,s)},commit:i?t.commit:function(a,f,u){var c=$(a,f,u),s=c.payload,o=c.options,l=c.type;(!o||!o.root)&&(l=e+l),t.commit(l,s,o)}};return Object.defineProperties(n,{getters:{get:i?function(){return t.getters}:function(){return tt(t,e)}},state:{get:function(){return k(t.state,r)}}}),n}function tt(t,e){if(!t._makeLocalGettersCache[e]){var r={},i=e.length;Object.keys(t.getters).forEach(function(n){if(n.slice(0,i)===e){var a=n.slice(i);Object.defineProperty(r,a,{get:function(){return t.getters[n]},enumerable:!0})}}),t._makeLocalGettersCache[e]=r}return t._makeLocalGettersCache[e]}function et(t,e,r,i){var n=t._mutations[e]||(t._mutations[e]=[]);n.push(function(f){r.call(t,i.state,f)})}function rt(t,e,r,i){var n=t._actions[e]||(t._actions[e]=[]);n.push(function(f){var u=r.call(t,{dispatch:i.dispatch,commit:i.commit,getters:i.getters,state:i.state,rootGetters:t.getters,rootState:t.state},f);return X(u)||(u=Promise.resolve(u)),t._devtoolHook?u.catch(function(c){throw t._devtoolHook.emit("vuex:error",c),c}):u})}function it(t,e,r,i){t._wrappedGetters[e]||(t._wrappedGetters[e]=function(a){return r(i.state,i.getters,a.state,a.getters)})}function nt(t){t._vm.$watch(function(){return this._data.$$state},function(){},{deep:!0,sync:!0})}function k(t,e){return e.reduce(function(r,i){return r[i]},t)}function $(t,e,r){return T(t)&&t.type&&(r=e,e=t,t=t.type),{type:t,payload:e,options:r}}function R(t){p&&t===p||(p=t,q(p))}var B=E(function(t,e){var r={};return C(e).forEach(function(i){var n=i.key,a=i.val;r[n]=function(){var u=this.$store.state,c=this.$store.getters;if(t){var s=A(this.$store,"mapState",t);if(!s)return;u=s.context.state,c=s.context.getters}return typeof a=="function"?a.call(this,u,c):u[a]},r[n].vuex=!0}),r}),U=E(function(t,e){var r={};return C(e).forEach(function(i){var n=i.key,a=i.val;r[n]=function(){for(var u=[],c=arguments.length;c--;)u[c]=arguments[c];var s=this.$store.commit;if(t){var o=A(this.$store,"mapMutations",t);if(!o)return;s=o.context.commit}return typeof a=="function"?a.apply(this,[s].concat(u)):s.apply(this.$store,[a].concat(u))}}),r}),z=E(function(t,e){var r={};return C(e).forEach(function(i){var n=i.key,a=i.val;a=t+a,r[n]=function(){if(!(t&&!A(this.$store,"mapGetters",t)))return this.$store.getters[a]},r[n].vuex=!0}),r}),I=E(function(t,e){var r={};return C(e).forEach(function(i){var n=i.key,a=i.val;r[n]=function(){for(var u=[],c=arguments.length;c--;)u[c]=arguments[c];var s=this.$store.dispatch;if(t){var o=A(this.$store,"mapActions",t);if(!o)return;s=o.context.dispatch}return typeof a=="function"?a.apply(this,[s].concat(u)):s.apply(this.$store,[a].concat(u))}}),r}),ot=function(t){return{mapState:B.bind(null,t),mapGetters:z.bind(null,t),mapMutations:U.bind(null,t),mapActions:I.bind(null,t)}};function C(t){return at(t)?Array.isArray(t)?t.map(function(e){return{key:e,val:e}}):Object.keys(t).map(function(e){return{key:e,val:t[e]}}):[]}function at(t){return Array.isArray(t)||T(t)}function E(t){return function(e,r){return typeof e!="string"?(r=e,e=""):e.charAt(e.length-1)!=="/"&&(e+="/"),t(e,r)}}function A(t,e,r){var i=t._modulesNamespaceMap[r];return i}function ct(t){t===void 0&&(t={});var e=t.collapsed;e===void 0&&(e=!0);var r=t.filter;r===void 0&&(r=function(o,l,d){return!0});var i=t.transformer;i===void 0&&(i=function(o){return o});var n=t.mutationTransformer;n===void 0&&(n=function(o){return o});var a=t.actionFilter;a===void 0&&(a=function(o,l){return!0});var f=t.actionTransformer;f===void 0&&(f=function(o){return o});var u=t.logMutations;u===void 0&&(u=!0);var c=t.logActions;c===void 0&&(c=!0);var s=t.logger;return s===void 0&&(s=console),function(o){var l=x(o.state);typeof s!="undefined"&&(u&&o.subscribe(function(d,h){var g=x(h);if(r(d,l,g)){var S=H(),O=n(d),K="mutation "+d.type+S;N(s,K,e),s.log("%c prev state","color: #9E9E9E; font-weight: bold",i(l)),s.log("%c mutation","color: #03A9F4; font-weight: bold",O),s.log("%c next state","color: #4CAF50; font-weight: bold",i(g)),L(s)}l=g}),c&&o.subscribeAction(function(d,h){if(a(d,h)){var g=H(),S=f(d),O="action "+d.type+g;N(s,O,e),s.log("%c action","color: #03A9F4; font-weight: bold",S),L(s)}}))}}function N(t,e,r){var i=r?t.groupCollapsed:t.group;try{i.call(t,e)}catch{t.log(e)}}function L(t){try{t.groupEnd()}catch{t.log("\u2014\u2014 log end \u2014\u2014")}}function H(){var t=new Date;return" @ "+w(t.getHours(),2)+":"+w(t.getMinutes(),2)+":"+w(t.getSeconds(),2)+"."+w(t.getMilliseconds(),3)}function ut(t,e){return new Array(e+1).join(t)}function w(t,e){return ut("0",e-t.toString().length)+t}var st={Store:v,install:R,version:"3.6.2",mapState:B,mapMutations:U,mapGetters:z,mapActions:I,createNamespacedHelpers:ot,createLogger:ct},ft=st;export{ft as V,z as a,B as m};
|