1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
|
"use strict";var vue=require("vue"),devtoolsApi=require("@vue/devtools-api"),storeKey="store";function useStore(t){return vue.inject(null!==(t=void 0===t?null:t)?t:storeKey)}function find(t,e){return t.filter(e)[0]}function deepCopy(e,o){if(void 0===o&&(o=[]),null===e||"object"!=typeof e)return e;var t=find(o,function(t){return t.original===e});if(t)return t.copy;var r=Array.isArray(e)?[]:{};return o.push({original:e,copy:r}),Object.keys(e).forEach(function(t){r[t]=deepCopy(e[t],o)}),r}function forEachValue(e,o){Object.keys(e).forEach(function(t){return o(e[t],t)})}function isObject(t){return null!==t&&"object"==typeof t}function isPromise(t){return t&&"function"==typeof t.then}function assert(t,e){if(!t)throw new Error("[vuex] "+e)}function partial(t,e){return function(){return t(e)}}function genericSubscribe(e,o,t){return o.indexOf(e)<0&&(t&&t.prepend?o.unshift(e):o.push(e)),function(){var t=o.indexOf(e);-1<t&&o.splice(t,1)}}function resetStore(t,e){t._actions=Object.create(null),t._mutations=Object.create(null),t._wrappedGetters=Object.create(null),t._modulesNamespaceMap=Object.create(null);var o=t.state;installModule(t,o,[],t._modules.root,!0),resetStoreState(t,o,e)}function resetStoreState(o,t,e){var r=o._state,n=o._scope,i=(o.getters={},o._makeLocalGettersCache=Object.create(null),o._wrappedGetters),s={},a={},c=vue.effectScope(!0);c.run(function(){forEachValue(i,function(t,e){s[e]=partial(t,o),a[e]=vue.computed(function(){return s[e]()}),Object.defineProperty(o.getters,e,{get:function(){return a[e].value},enumerable:!0})})}),o._state=vue.reactive({data:t}),o._scope=c,o.strict&&enableStrictMode(o),r&&e&&o._withCommit(function(){r.data=null}),n&&n.stop()}function installModule(o,r,n,t,i){var e,s,a=!n.length,c=o._modules.getNamespace(n),u=(t.namespaced&&(o._modulesNamespaceMap[c]&&"production"!==process.env.NODE_ENV&&console.error("[vuex] duplicate namespace "+c+" for the namespaced module "+n.join("/")),o._modulesNamespaceMap[c]=t),a||i||(e=getNestedState(r,n.slice(0,-1)),s=n[n.length-1],o._withCommit(function(){"production"!==process.env.NODE_ENV&&s in e&&console.warn('[vuex] state field "'+s+'" was overridden by a module with the same name at "'+n.join(".")+'"'),e[s]=t.state})),t.context=makeLocalContext(o,c,n));t.forEachMutation(function(t,e){registerMutation(o,c+e,t,u)}),t.forEachAction(function(t,e){e=t.root?e:c+e,t=t.handler||t;registerAction(o,e,t,u)}),t.forEachGetter(function(t,e){registerGetter(o,c+e,t,u)}),t.forEachChild(function(t,e){installModule(o,r,n.concat(e),t,i)})}function makeLocalContext(n,i,t){var e=""===i,o={dispatch:e?n.dispatch:function(t,e,o){var t=unifyObjectStyle(t,e,o),e=t.payload,o=t.options,r=t.type;if(o&&o.root||(r=i+r,"production"===process.env.NODE_ENV||n._actions[r]))return n.dispatch(r,e);console.error("[vuex] unknown local action type: "+t.type+", global type: "+r)},commit:e?n.commit:function(t,e,o){var t=unifyObjectStyle(t,e,o),e=t.payload,o=t.options,r=t.type;o&&o.root||(r=i+r,"production"===process.env.NODE_ENV||n._mutations[r])?n.commit(r,e,o):console.error("[vuex] unknown local mutation type: "+t.type+", global type: "+r)}};return Object.defineProperties(o,{getters:{get:e?function(){return n.getters}:function(){return makeLocalGetters(n,i)}},state:{get:function(){return getNestedState(n.state,t)}}}),o}function makeLocalGetters(o,r){var n,i;return o._makeLocalGettersCache[r]||(n={},i=r.length,Object.keys(o.getters).forEach(function(t){var e;t.slice(0,i)===r&&(e=t.slice(i),Object.defineProperty(n,e,{get:function(){return o.getters[t]},enumerable:!0}))}),o._makeLocalGettersCache[r]=n),o._makeLocalGettersCache[r]}function registerMutation(e,t,o,r){(e._mutations[t]||(e._mutations[t]=[])).push(function(t){o.call(e,r.state,t)})}function registerAction(e,t,o,r){(e._actions[t]||(e._actions[t]=[])).push(function(t){t=o.call(e,{dispatch:r.dispatch,commit:r.commit,getters:r.getters,state:r.state,rootGetters:e.getters,rootState:e.state},t);return isPromise(t)||(t=Promise.resolve(t)),e._devtoolHook?t.catch(function(t){throw e._devtoolHook.emit("vuex:error",t),t}):t})}function registerGetter
|