direct-vuex
Advanced tools
Comparing version 0.10.3 to 0.10.4
@@ -58,2 +58,3 @@ import Vuex from 'vuex'; | ||
createDirectStore, defineModule, defineModules, defineGetters, defineMutations, defineActions, | ||
localGetterContext, localActionContext, | ||
createModule, createModules, createGetters, createMutations, createActions | ||
@@ -60,0 +61,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
import Vuex from"vuex";function createDirectStore(t){const e=new Vuex.Store(t),o={get state(){return e.state},getters:toDirectGetters(t,e.getters),commit:toDirectCommit(t,e.commit),dispatch:toDirectDispatch(t,e.dispatch),original:e};return e.direct=o,{store:o,rootGetterContext:([e,o])=>getModuleGetterContext([e,o,e,o],t,t),moduleGetterContext:(e,o)=>getModuleGetterContext(e,o,t),rootActionContext:e=>getModuleActionContext(e,t,t),moduleActionContext:(e,o)=>getModuleActionContext(e,o,t)}}function localGetterContext([t,e],o){return getModuleGetterContext([t,e,void 0,void 0],o)}function localActionContext(t,e){return getModuleActionContext(t,e)}function defineModule(t){return t}function defineModules(){return t=>t}function defineGetters(){return t=>t}function defineMutations(){return t=>t}function defineActions(t){return t}const createModule=obsolete(defineModule,"createModule","defineModule"),createModules=obsolete(defineModules,"createModules","defineModules"),createGetters=obsolete(defineGetters,"createGetters","defineGetters"),createMutations=obsolete(defineMutations,"createMutations","defineMutations"),createActions=obsolete(defineActions,"createActions","defineActions");function obsolete(t,e,o){return(...r)=>(console.warn(`Function '${e}' is obsolete, please use '${o}'.`),t(...r))}var directVuex={createDirectStore:createDirectStore,defineModule:defineModule,defineModules:defineModules,defineGetters:defineGetters,defineMutations:defineMutations,defineActions:defineActions,createModule:createModule,createModules:createModules,createGetters:createGetters,createMutations:createMutations,createActions:createActions};const gettersCache=new WeakMap;function toDirectGetters(t,e){let o=gettersCache.get(e);return o||(o=gettersFromOptions({},t,e),gettersCache.set(e,o)),o}function gettersFromOptions(t,e,o,r=[]){if(e.getters&&createDirectGetters(t,e.getters,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=gettersFromOptions({},c,o,[...r,n]):gettersFromOptions(t,c,o,r)}return t}function createDirectGetters(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))Object.defineProperties(t,{[r]:{get:()=>o[`${n}${r}`]}})}const commitCache=new WeakMap;function toDirectCommit(t,e){let o=commitCache.get(e);return o||(o=commitFromOptions({},t,e),commitCache.set(e,o)),o}const rootCommitCache=new WeakMap;function toDirectRootCommit(t,e){let o=rootCommitCache.get(e);if(!o){o=commitFromOptions({},t,(t,o)=>e(t,o,{root:!0})),rootCommitCache.set(e,o)}return o}function commitFromOptions(t,e,o,r=[]){if(e.mutations&&createDirectMutations(t,e.mutations,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=commitFromOptions({},c,o,[...r,n]):commitFromOptions(t,c,o,r)}return t}function createDirectMutations(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))t[r]=t=>o(`${n}${r}`,t)}const dispatchCache=new WeakMap;function toDirectDispatch(t,e){let o=dispatchCache.get(e);return o||(o=dispatchFromOptions({},t,e),dispatchCache.set(e,o)),o}const rootDispatchCache=new WeakMap;function toDirectRootDispatch(t,e){let o=rootDispatchCache.get(e);if(!o){o=dispatchFromOptions({},t,(t,o)=>e(t,o,{root:!0})),rootDispatchCache.set(e,o)}return o}function dispatchFromOptions(t,e,o,r=[]){if(e.actions&&createDirectActions(t,e.actions,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=dispatchFromOptions({},c,o,[...r,n]):dispatchFromOptions(t,c,o,r)}return t}function createDirectActions(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))t[r]=t=>o(`${n}${r}`,t)}const getterContextCache=new WeakMap;function getModuleGetterContext(t,e,o){const[r,n,c,i]=t;let s=actionContextCache.get(r);return s||(s=o?{get rootState(){return c},get rootGetters(){return toDirectGetters(o,i)},get state(){return r},get getters(){return toDirectGetters(e,n)}}:{get state(){return r},get getters(){return toDirectGetters(e,n)}},r&&getterContextCache.set(r,s)),s}const actionContextCache=new WeakMap;function getModuleActionContext(t,e,o){let r=actionContextCache.get(t.state);return r||(r=o?{get rootState(){return t.rootState},get rootGetters(){return toDirectGetters(o,t.rootGetters)},get rootCommit(){return toDirectRootCommit(o,t.commit)},get rootDispatch(){return toDirectRootDispatch(o,t.dispatch)},get state(){return t.state},get getters(){return toDirectGetters(e,t.getters)},get commit(){return toDirectCommit(e,t.commit)},get dispatch(){return toDirectDispatch(e,t.dispatch)}}:{get state(){return t.state},get getters(){return toDirectGetters(e,t.getters)},get commit(){return toDirectCommit(e,t.commit)},get dispatch(){return toDirectDispatch(e,t.dispatch)}},t.state&&actionContextCache.set(t.state,r)),r}export default directVuex;export{createActions,createDirectStore,createGetters,createModule,createModules,createMutations,defineActions,defineGetters,defineModule,defineModules,defineMutations,localActionContext,localGetterContext}; | ||
import Vuex from"vuex";function createDirectStore(t){const e=new Vuex.Store(t),o={get state(){return e.state},getters:toDirectGetters(t,e.getters),commit:toDirectCommit(t,e.commit),dispatch:toDirectDispatch(t,e.dispatch),original:e};return e.direct=o,{store:o,rootGetterContext:([e,o])=>getModuleGetterContext([e,o,e,o],t,t),moduleGetterContext:(e,o)=>getModuleGetterContext(e,o,t),rootActionContext:e=>getModuleActionContext(e,t,t),moduleActionContext:(e,o)=>getModuleActionContext(e,o,t)}}function localGetterContext([t,e],o){return getModuleGetterContext([t,e,void 0,void 0],o)}function localActionContext(t,e){return getModuleActionContext(t,e)}function defineModule(t){return t}function defineModules(){return t=>t}function defineGetters(){return t=>t}function defineMutations(){return t=>t}function defineActions(t){return t}const createModule=obsolete(defineModule,"createModule","defineModule"),createModules=obsolete(defineModules,"createModules","defineModules"),createGetters=obsolete(defineGetters,"createGetters","defineGetters"),createMutations=obsolete(defineMutations,"createMutations","defineMutations"),createActions=obsolete(defineActions,"createActions","defineActions");function obsolete(t,e,o){return(...r)=>(console.warn(`Function '${e}' is obsolete, please use '${o}'.`),t(...r))}var directVuex={createDirectStore:createDirectStore,defineModule:defineModule,defineModules:defineModules,defineGetters:defineGetters,defineMutations:defineMutations,defineActions:defineActions,localGetterContext:localGetterContext,localActionContext:localActionContext,createModule:createModule,createModules:createModules,createGetters:createGetters,createMutations:createMutations,createActions:createActions};const gettersCache=new WeakMap;function toDirectGetters(t,e){let o=gettersCache.get(e);return o||(o=gettersFromOptions({},t,e),gettersCache.set(e,o)),o}function gettersFromOptions(t,e,o,r=[]){if(e.getters&&createDirectGetters(t,e.getters,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=gettersFromOptions({},c,o,[...r,n]):gettersFromOptions(t,c,o,r)}return t}function createDirectGetters(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))Object.defineProperties(t,{[r]:{get:()=>o[`${n}${r}`]}})}const commitCache=new WeakMap;function toDirectCommit(t,e){let o=commitCache.get(e);return o||(o=commitFromOptions({},t,e),commitCache.set(e,o)),o}const rootCommitCache=new WeakMap;function toDirectRootCommit(t,e){let o=rootCommitCache.get(e);if(!o){o=commitFromOptions({},t,(t,o)=>e(t,o,{root:!0})),rootCommitCache.set(e,o)}return o}function commitFromOptions(t,e,o,r=[]){if(e.mutations&&createDirectMutations(t,e.mutations,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=commitFromOptions({},c,o,[...r,n]):commitFromOptions(t,c,o,r)}return t}function createDirectMutations(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))t[r]=t=>o(`${n}${r}`,t)}const dispatchCache=new WeakMap;function toDirectDispatch(t,e){let o=dispatchCache.get(e);return o||(o=dispatchFromOptions({},t,e),dispatchCache.set(e,o)),o}const rootDispatchCache=new WeakMap;function toDirectRootDispatch(t,e){let o=rootDispatchCache.get(e);if(!o){o=dispatchFromOptions({},t,(t,o)=>e(t,o,{root:!0})),rootDispatchCache.set(e,o)}return o}function dispatchFromOptions(t,e,o,r=[]){if(e.actions&&createDirectActions(t,e.actions,o,r),e.modules)for(const n of Object.keys(e.modules)){const c=e.modules[n];c.namespaced?t[n]=dispatchFromOptions({},c,o,[...r,n]):dispatchFromOptions(t,c,o,r)}return t}function createDirectActions(t,e,o,r){const n=r&&0!==r.length?`${r.join("/")}/`:"";for(const r of Object.keys(e))t[r]=t=>o(`${n}${r}`,t)}const getterContextCache=new WeakMap;function getModuleGetterContext(t,e,o){const[r,n,c,i]=t;let s=actionContextCache.get(r);return s||(s=o?{get rootState(){return c},get rootGetters(){return toDirectGetters(o,i)},get state(){return r},get getters(){return toDirectGetters(e,n)}}:{get state(){return r},get getters(){return toDirectGetters(e,n)}},r&&getterContextCache.set(r,s)),s}const actionContextCache=new WeakMap;function getModuleActionContext(t,e,o){let r=actionContextCache.get(t.state);return r||(r=o?{get rootState(){return t.rootState},get rootGetters(){return toDirectGetters(o,t.rootGetters)},get rootCommit(){return toDirectRootCommit(o,t.commit)},get rootDispatch(){return toDirectRootDispatch(o,t.dispatch)},get state(){return t.state},get getters(){return toDirectGetters(e,t.getters)},get commit(){return toDirectCommit(e,t.commit)},get dispatch(){return toDirectDispatch(e,t.dispatch)}}:{get state(){return t.state},get getters(){return toDirectGetters(e,t.getters)},get commit(){return toDirectCommit(e,t.commit)},get dispatch(){return toDirectDispatch(e,t.dispatch)}},t.state&&actionContextCache.set(t.state,r)),r}export default directVuex;export{createActions,createDirectStore,createGetters,createModule,createModules,createMutations,defineActions,defineGetters,defineModule,defineModules,defineMutations,localActionContext,localGetterContext}; |
@@ -81,2 +81,3 @@ (function (global, factory) { | ||
createDirectStore: createDirectStore, defineModule: defineModule, defineModules: defineModules, defineGetters: defineGetters, defineMutations: defineMutations, defineActions: defineActions, | ||
localGetterContext: localGetterContext, localActionContext: localActionContext, | ||
createModule: createModule, createModules: createModules, createGetters: createGetters, createMutations: createMutations, createActions: createActions | ||
@@ -83,0 +84,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vuex")):"function"==typeof define&&define.amd?define(["exports","vuex"],t):t((e=e||self).DirectVuex={},e.Vuex)}(this,(function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var u=arguments[t],i=0,a=u.length;i<a;i++,o++)n[o]=u[i];return n};function n(e){var r=new t.Store(e),n={get state(){return r.state},getters:M(e,r.getters),commit:y(e,r.commit),dispatch:G(e,r.dispatch),original:r};return r.direct=n,{store:n,rootGetterContext:function(t){var r=t[0],n=t[1];return O([r,n,r,n],e,e)},moduleGetterContext:function(t,r){return O(t,r,e)},rootActionContext:function(t){return W(t,e,e)},moduleActionContext:function(t,r){return W(t,r,e)}}}function o(e){return e}function u(){return function(e){return e}}function i(){return function(e){return e}}function a(){return function(e){return e}}function c(e){return e}var s=v(o,"createModule","defineModule"),f=v(u,"createModules","defineModules"),d=v(i,"createGetters","defineGetters"),l=v(a,"createMutations","defineMutations"),g=v(c,"createActions","defineActions");function v(e,t,r){return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return console.warn("Function '"+t+"' is obsolete, please use '"+r+"'."),e.apply(void 0,n)}}var m={createDirectStore:n,defineModule:o,defineModules:u,defineGetters:i,defineMutations:a,defineActions:c,createModule:s,createModules:f,createGetters:d,createMutations:l,createActions:g},p=new WeakMap;function M(e,t){var n=p.get(t);return n||(n=function e(t,n,o,u){void 0===u&&(u=[]);n.getters&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){var n;Object.defineProperties(e,((n={})[t]={get:function(){return r[""+o+t]}},n))},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(t,n.getters,o,u);if(n.modules)for(var i=0,a=Object.keys(n.modules);i<a.length;i++){var c=a[i],s=n.modules[c];s.namespaced?t[c]=e({},s,o,r(u,[c])):e(t,s,o,u)}return t}({},e,t),p.set(t,n)),n}var h=new WeakMap;function y(e,t){var r=h.get(t);return r||(r=x({},e,t),h.set(t,r)),r}var k=new WeakMap;function x(e,t,n,o){if(void 0===o&&(o=[]),t.mutations&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){e[t]=function(e){return r(""+o+t,e)}},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(e,t.mutations,n,o),t.modules)for(var u=0,i=Object.keys(t.modules);u<i.length;u++){var a=i[u],c=t.modules[a];c.namespaced?e[a]=x({},c,n,r(o,[a])):x(e,c,n,o)}return e}var j=new WeakMap;function G(e,t){var r=j.get(t);return r||(r=b({},e,t),j.set(t,r)),r}var A=new WeakMap;function b(e,t,n,o){if(void 0===o&&(o=[]),t.actions&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){e[t]=function(e){return r(""+o+t,e)}},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(e,t.actions,n,o),t.modules)for(var u=0,i=Object.keys(t.modules);u<i.length;u++){var a=i[u],c=t.modules[a];c.namespaced?e[a]=b({},c,n,r(o,[a])):b(e,c,n,o)}return e}var w=new WeakMap;function O(e,t,r){var n=e[0],o=e[1],u=e[2],i=e[3],a=C.get(n);return a||(a=r?{get rootState(){return u},get rootGetters(){return M(r,i)},get state(){return n},get getters(){return M(t,o)}}:{get state(){return n},get getters(){return M(t,o)}},n&&w.set(n,a)),a}var C=new WeakMap;function W(e,t,r){var n=C.get(e.state);return n||(n=r?{get rootState(){return e.rootState},get rootGetters(){return M(r,e.rootGetters)},get rootCommit(){return function(e,t){var r=k.get(t);if(!r){r=x({},e,(function(e,r){return t(e,r,{root:!0})})),k.set(t,r)}return r}(r,e.commit)},get rootDispatch(){return function(e,t){var r=A.get(t);if(!r){r=b({},e,(function(e,r){return t(e,r,{root:!0})})),A.set(t,r)}return r}(r,e.dispatch)},get state(){return e.state},get getters(){return M(t,e.getters)},get commit(){return y(t,e.commit)},get dispatch(){return G(t,e.dispatch)}}:{get state(){return e.state},get getters(){return M(t,e.getters)},get commit(){return y(t,e.commit)},get dispatch(){return G(t,e.dispatch)}},e.state&&C.set(e.state,n)),n}e.createActions=g,e.createDirectStore=n,e.createGetters=d,e.createModule=s,e.createModules=f,e.createMutations=l,e.default=m,e.defineActions=c,e.defineGetters=i,e.defineModule=o,e.defineModules=u,e.defineMutations=a,e.localActionContext=function(e,t){return W(e,t)},e.localGetterContext=function(e,t){return O([e[0],e[1],void 0,void 0],t)},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vuex")):"function"==typeof define&&define.amd?define(["exports","vuex"],t):t((e=e||self).DirectVuex={},e.Vuex)}(this,(function(e,t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var u=arguments[t],i=0,a=u.length;i<a;i++,o++)n[o]=u[i];return n};function n(e){var r=new t.Store(e),n={get state(){return r.state},getters:x(e,r.getters),commit:k(e,r.commit),dispatch:b(e,r.dispatch),original:r};return r.direct=n,{store:n,rootGetterContext:function(t){var r=t[0],n=t[1];return W([r,n,r,n],e,e)},moduleGetterContext:function(t,r){return W(t,r,e)},rootActionContext:function(t){return D(t,e,e)},moduleActionContext:function(t,r){return D(t,r,e)}}}function o(e,t){return W([e[0],e[1],void 0,void 0],t)}function u(e,t){return D(e,t)}function i(e){return e}function a(){return function(e){return e}}function c(){return function(e){return e}}function s(){return function(e){return e}}function f(e){return e}var d=p(i,"createModule","defineModule"),l=p(a,"createModules","defineModules"),g=p(c,"createGetters","defineGetters"),v=p(s,"createMutations","defineMutations"),m=p(f,"createActions","defineActions");function p(e,t,r){return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return console.warn("Function '"+t+"' is obsolete, please use '"+r+"'."),e.apply(void 0,n)}}var M={createDirectStore:n,defineModule:i,defineModules:a,defineGetters:c,defineMutations:s,defineActions:f,localGetterContext:o,localActionContext:u,createModule:d,createModules:l,createGetters:g,createMutations:v,createActions:m},h=new WeakMap;function x(e,t){var n=h.get(t);return n||(n=function e(t,n,o,u){void 0===u&&(u=[]);n.getters&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){var n;Object.defineProperties(e,((n={})[t]={get:function(){return r[""+o+t]}},n))},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(t,n.getters,o,u);if(n.modules)for(var i=0,a=Object.keys(n.modules);i<a.length;i++){var c=a[i],s=n.modules[c];s.namespaced?t[c]=e({},s,o,r(u,[c])):e(t,s,o,u)}return t}({},e,t),h.set(t,n)),n}var y=new WeakMap;function k(e,t){var r=y.get(t);return r||(r=j({},e,t),y.set(t,r)),r}var G=new WeakMap;function j(e,t,n,o){if(void 0===o&&(o=[]),t.mutations&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){e[t]=function(e){return r(""+o+t,e)}},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(e,t.mutations,n,o),t.modules)for(var u=0,i=Object.keys(t.modules);u<i.length;u++){var a=i[u],c=t.modules[a];c.namespaced?e[a]=j({},c,n,r(o,[a])):j(e,c,n,o)}return e}var A=new WeakMap;function b(e,t){var r=A.get(t);return r||(r=C({},e,t),A.set(t,r)),r}var w=new WeakMap;function C(e,t,n,o){if(void 0===o&&(o=[]),t.actions&&function(e,t,r,n){for(var o=n&&0!==n.length?n.join("/")+"/":"",u=function(t){e[t]=function(e){return r(""+o+t,e)}},i=0,a=Object.keys(t);i<a.length;i++){var c=a[i];u(c)}}(e,t.actions,n,o),t.modules)for(var u=0,i=Object.keys(t.modules);u<i.length;u++){var a=i[u],c=t.modules[a];c.namespaced?e[a]=C({},c,n,r(o,[a])):C(e,c,n,o)}return e}var O=new WeakMap;function W(e,t,r){var n=e[0],o=e[1],u=e[2],i=e[3],a=S.get(n);return a||(a=r?{get rootState(){return u},get rootGetters(){return x(r,i)},get state(){return n},get getters(){return x(t,o)}}:{get state(){return n},get getters(){return x(t,o)}},n&&O.set(n,a)),a}var S=new WeakMap;function D(e,t,r){var n=S.get(e.state);return n||(n=r?{get rootState(){return e.rootState},get rootGetters(){return x(r,e.rootGetters)},get rootCommit(){return function(e,t){var r=G.get(t);if(!r){r=j({},e,(function(e,r){return t(e,r,{root:!0})})),G.set(t,r)}return r}(r,e.commit)},get rootDispatch(){return function(e,t){var r=w.get(t);if(!r){r=C({},e,(function(e,r){return t(e,r,{root:!0})})),w.set(t,r)}return r}(r,e.dispatch)},get state(){return e.state},get getters(){return x(t,e.getters)},get commit(){return k(t,e.commit)},get dispatch(){return b(t,e.dispatch)}}:{get state(){return e.state},get getters(){return x(t,e.getters)},get commit(){return k(t,e.commit)},get dispatch(){return b(t,e.dispatch)}},e.state&&S.set(e.state,n)),n}e.createActions=m,e.createDirectStore=n,e.createGetters=g,e.createModule=d,e.createModules=l,e.createMutations=v,e.default=M,e.defineActions=f,e.defineGetters=c,e.defineModule=i,e.defineModules=a,e.defineMutations=s,e.localActionContext=u,e.localGetterContext=o,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "direct-vuex", | ||
"version": "0.10.3", | ||
"version": "0.10.4", | ||
"description": "Use and implement your Vuex store with TypeScript types. Compatible with the Vue 3 composition API.", | ||
@@ -5,0 +5,0 @@ "author": "Paleo", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62893
788