Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

direct-vuex

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

direct-vuex - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

21

dist/direct-vuex.esm.js

@@ -19,4 +19,4 @@ import Vuex from 'vuex';

moduleActionContext: (originalContext, moduleOptions) => getModuleActionContext(originalContext, moduleOptions, options),
rootGetterContext: (state, getters) => getModuleGetterContext(state, getters, state, getters, options, options),
moduleGetterContext: (state, getters, rootState, rootGetters, moduleOptions) => getModuleGetterContext(state, getters, rootState, rootGetters, moduleOptions, options)
rootGetterContext: ([state, getters]) => getModuleGetterContext([state, getters, state, getters], options, options),
moduleGetterContext: (args, moduleOptions) => getModuleGetterContext(args, moduleOptions, options)
};

@@ -59,3 +59,3 @@ }

let getters = gettersCache.get(originalGetters);
// console.log(">> to-getters", getters ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-getters", getters ? "FROM_CACHE" : "CREATE", options)
if (!getters) {

@@ -95,3 +95,3 @@ getters = gettersFromOptions({}, options, originalGetters);

let commit = commitCache.get(originalCommit);
// console.log(">> to-commit", commit ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-commit", commit ? "FROM_CACHE" : "CREATE", options)
if (!commit) {

@@ -106,3 +106,3 @@ commit = commitFromOptions({}, options, originalCommit);

let commit = rootCommitCache.get(originalCommit);
// console.log(">> to-rootCommit", commit ? "FROM_CACHE" : "CREATE", rootOptions);
// console.log(">> to-rootCommit", commit ? "FROM_CACHE" : "CREATE", rootOptions)
if (!commit) {

@@ -138,3 +138,3 @@ const origCall = (mutation, payload) => originalCommit(mutation, payload, { root: true });

let dispatch = dispatchCache.get(originalDispatch);
// console.log(">> to-dispatch", dispatch ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-dispatch", dispatch ? "FROM_CACHE" : "CREATE", options)
if (!dispatch) {

@@ -149,3 +149,3 @@ dispatch = dispatchFromOptions({}, options, originalDispatch);

let dispatch = rootDispatchCache.get(originalDispatch);
// console.log(">> to-rootDispatch", dispatch ? "FROM_CACHE" : "CREATE", rootOptions);
// console.log(">> to-rootDispatch", dispatch ? "FROM_CACHE" : "CREATE", rootOptions)
if (!dispatch) {

@@ -181,3 +181,3 @@ const origCall = (mutation, payload) => originalDispatch(mutation, payload, { root: true });

let context = actionContextCache.get(originalContext.state);
// console.log(">> to-actionContext", context ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-actionContext", context ? "FROM_CACHE" : "CREATE", options)
if (!context) {

@@ -217,5 +217,6 @@ context = {

const getterContextCache = new WeakMap();
function getModuleGetterContext(state, getters, rootState, rootGetters, options, rootOptions) {
function getModuleGetterContext(args, options, rootOptions) {
const [state, getters, rootState, rootGetters] = args;
let context = actionContextCache.get(state);
// console.log(">> to-getterContext", context ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-getterContext", context ? "FROM_CACHE" : "CREATE", options)
if (!context) {

@@ -222,0 +223,0 @@ context = {

@@ -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,rootActionContext:e=>getModuleActionContext(e,t,t),moduleActionContext:(e,o)=>getModuleActionContext(e,o,t),rootGetterContext:(e,o)=>getModuleGetterContext(e,o,e,o,t,t),moduleGetterContext:(e,o,r,n,c)=>getModuleGetterContext(e,o,r,n,c,t)}}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 actionContextCache=new WeakMap;function getModuleActionContext(t,e,o){let r=actionContextCache.get(t.state);return r||(r={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)}},t.state&&actionContextCache.set(t.state,r)),r}const getterContextCache=new WeakMap;function getModuleGetterContext(t,e,o,r,n,c){let i=actionContextCache.get(t);return i||(i={get rootState(){return o},get rootGetters(){return toDirectGetters(c,r)},get state(){return t},get getters(){return toDirectGetters(n,e)}},t&&getterContextCache.set(t,i)),i}export default directVuex;export{createActions,createDirectStore,createGetters,createModule,createModules,createMutations,defineActions,defineGetters,defineModule,defineModules,defineMutations};
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,rootActionContext:e=>getModuleActionContext(e,t,t),moduleActionContext:(e,o)=>getModuleActionContext(e,o,t),rootGetterContext:([e,o])=>getModuleGetterContext([e,o,e,o],t,t),moduleGetterContext:(e,o)=>getModuleGetterContext(e,o,t)}}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 actionContextCache=new WeakMap;function getModuleActionContext(t,e,o){let r=actionContextCache.get(t.state);return r||(r={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)}},t.state&&actionContextCache.set(t.state,r)),r}const getterContextCache=new WeakMap;function getModuleGetterContext(t,e,o){const[r,n,c,i]=t;let s=actionContextCache.get(r);return s||(s={get rootState(){return c},get rootGetters(){return toDirectGetters(o,i)},get state(){return r},get getters(){return toDirectGetters(e,n)}},r&&getterContextCache.set(r,s)),s}export default directVuex;export{createActions,createDirectStore,createGetters,createModule,createModules,createMutations,defineActions,defineGetters,defineModule,defineModules,defineMutations};

@@ -32,5 +32,8 @@ (function (global, factory) {

moduleActionContext: function (originalContext, moduleOptions) { return getModuleActionContext(originalContext, moduleOptions, options); },
rootGetterContext: function (state, getters) { return getModuleGetterContext(state, getters, state, getters, options, options); },
moduleGetterContext: function (state, getters, rootState, rootGetters, moduleOptions) {
return getModuleGetterContext(state, getters, rootState, rootGetters, moduleOptions, options);
rootGetterContext: function (_a) {
var state = _a[0], getters = _a[1];
return getModuleGetterContext([state, getters, state, getters], options, options);
},
moduleGetterContext: function (args, moduleOptions) {
return getModuleGetterContext(args, moduleOptions, options);
}

@@ -78,3 +81,3 @@ };

var getters = gettersCache.get(originalGetters);
// console.log(">> to-getters", getters ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-getters", getters ? "FROM_CACHE" : "CREATE", options)
if (!getters) {

@@ -121,3 +124,3 @@ getters = gettersFromOptions({}, options, originalGetters);

var commit = commitCache.get(originalCommit);
// console.log(">> to-commit", commit ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-commit", commit ? "FROM_CACHE" : "CREATE", options)
if (!commit) {

@@ -132,3 +135,3 @@ commit = commitFromOptions({}, options, originalCommit);

var commit = rootCommitCache.get(originalCommit);
// console.log(">> to-rootCommit", commit ? "FROM_CACHE" : "CREATE", rootOptions);
// console.log(">> to-rootCommit", commit ? "FROM_CACHE" : "CREATE", rootOptions)
if (!commit) {

@@ -171,3 +174,3 @@ var origCall = function (mutation, payload) { return originalCommit(mutation, payload, { root: true }); };

var dispatch = dispatchCache.get(originalDispatch);
// console.log(">> to-dispatch", dispatch ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-dispatch", dispatch ? "FROM_CACHE" : "CREATE", options)
if (!dispatch) {

@@ -182,3 +185,3 @@ dispatch = dispatchFromOptions({}, options, originalDispatch);

var dispatch = rootDispatchCache.get(originalDispatch);
// console.log(">> to-rootDispatch", dispatch ? "FROM_CACHE" : "CREATE", rootOptions);
// console.log(">> to-rootDispatch", dispatch ? "FROM_CACHE" : "CREATE", rootOptions)
if (!dispatch) {

@@ -221,3 +224,3 @@ var origCall = function (mutation, payload) { return originalDispatch(mutation, payload, { root: true }); };

var context = actionContextCache.get(originalContext.state);
// console.log(">> to-actionContext", context ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-actionContext", context ? "FROM_CACHE" : "CREATE", options)
if (!context) {

@@ -257,5 +260,6 @@ context = {

var getterContextCache = new WeakMap();
function getModuleGetterContext(state, getters, rootState, rootGetters, options, rootOptions) {
function getModuleGetterContext(args, options, rootOptions) {
var state = args[0], getters = args[1], rootState = args[2], rootGetters = args[3];
var context = actionContextCache.get(state);
// console.log(">> to-getterContext", context ? "FROM_CACHE" : "CREATE", options);
// console.log(">> to-getterContext", context ? "FROM_CACHE" : "CREATE", options)
if (!context) {

@@ -262,0 +266,0 @@ context = {

@@ -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,rootActionContext:function(t){return O(t,e,e)},moduleActionContext:function(t,r){return O(t,r,e)},rootGetterContext:function(t,r){return S(t,r,t,r,e,e)},moduleGetterContext:function(t,r,n,o,u){return S(t,r,n,o,u,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=j({},e,t),h.set(t,r)),r}var k=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 x=new WeakMap;function G(e,t){var r=x.get(t);return r||(r=w({},e,t),x.set(t,r)),r}var b=new WeakMap;function w(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]=w({},c,n,r(o,[a])):w(e,c,n,o)}return e}var A=new WeakMap;function O(e,t,r){var n=A.get(e.state);return n||(n={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=j({},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=b.get(t);if(!r){r=w({},e,(function(e,r){return t(e,r,{root:!0})})),b.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)}},e.state&&A.set(e.state,n)),n}var W=new WeakMap;function S(e,t,r,n,o,u){var i=A.get(e);return i||(i={get rootState(){return r},get rootGetters(){return M(u,n)},get state(){return e},get getters(){return M(o,t)}},e&&W.set(e,i)),i}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,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:M(e,r.getters),commit:y(e,r.commit),dispatch:G(e,r.dispatch),original:r};return r.direct=n,{store:n,rootActionContext:function(t){return O(t,e,e)},moduleActionContext:function(t,r){return O(t,r,e)},rootGetterContext:function(t){var r=t[0],n=t[1];return S([r,n,r,n],e,e)},moduleGetterContext:function(t,r){return S(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=j({},e,t),h.set(t,r)),r}var k=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 x=new WeakMap;function G(e,t){var r=x.get(t);return r||(r=w({},e,t),x.set(t,r)),r}var b=new WeakMap;function w(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]=w({},c,n,r(o,[a])):w(e,c,n,o)}return e}var A=new WeakMap;function O(e,t,r){var n=A.get(e.state);return n||(n={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=j({},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=b.get(t);if(!r){r=w({},e,(function(e,r){return t(e,r,{root:!0})})),b.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)}},e.state&&A.set(e.state,n)),n}var W=new WeakMap;function S(e,t,r){var n=e[0],o=e[1],u=e[2],i=e[3],a=A.get(n);return a||(a={get rootState(){return u},get rootGetters(){return M(r,i)},get state(){return n},get getters(){return M(t,o)}},n&&W.set(n,a)),a}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,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "direct-vuex",
"version": "0.10.0",
"version": "0.10.1",
"description": "Use and implement your Vuex store with TypeScript types. Compatible with the Vue 3 composition API.",

@@ -5,0 +5,0 @@ "author": "Paleo",

@@ -12,4 +12,2 @@ # direct-vuex

**_Warning! BREAKING CHANGE in version 0.8: do not use `as const` with `createDirectStore`. Additionally, there is a new limitation on [how to declare a state](#a-limitation-on-how-to-declare-a-state). See also the section: [Implement a Vuex Store with typed helpers](#implement-a-vuex-store-with-typed-helpers)._**
## Install

@@ -192,7 +190,10 @@

const mod1ActionContext = (context: any) => moduleActionContext(context, mod1)
const mod1GetterContext = (...args: any[]) => moduleGetterContext(...args, mod1)
const mod1GetterContext = (args: [any, any, any, any]) => moduleGetterContext(args, mod1)
```
Warning: Types in the context of actions implies that TypeScript should never infer the return type of an action from the context of the action. Indeed, this kind of typing would be recursive, since the context includes the return value of the action. When this happens, TypeScript passes the whole context to `any`. _Tl;dr; Declare the return type of actions where it exists!_
Warning:
* Types in the context of actions implies that TypeScript should never infer the return type of an action from the context of the action. Indeed, this kind of typing would be recursive, since the context includes the return value of the action. When this happens, TypeScript passes the whole context to `any`. **Tl;dr; Declare the return type of actions where it exists!**
* For the same reason, **Tl;dr; Declare the return type of getters each time a getter context generated by `moduleGetterContext` is used!**
### Get the typed context of a Vuex Action, but in the root store

@@ -218,3 +219,3 @@

getterInTheRootStore(...args) {
const { state, getters, rootState, rootGetters } = rootGetterContext(...args)
const { state, getters, rootState, rootGetters } = rootGetterContext(args)
// Here, 'getters', 'state', 'rootGetters' and 'rootState' are typed.

@@ -235,4 +236,4 @@ // Without 'rootGetterContext' only 'state' would be typed.

export default defineGetters<Mod1State>()({
getter1(state) {
const { state, getters, rootState, rootGetters } = mod1GetterContext(...args)
getter1(...args) {
const { state, getters, rootState, rootGetters } = mod1GetterContext(args)
// Here, 'getters', 'state', 'rootGetters' and 'rootState' are typed.

@@ -289,3 +290,3 @@ // Without 'mod1GetterContext' only 'state' would be typed.

p1OrDefault(...args) {
const { state, getters, rootState, rootGetters } = mod1GetterContext(...args(state, ...args)
const { state, getters, rootState, rootGetters } = mod1GetterContext(args)
// …

@@ -304,3 +305,3 @@ }

const mod1ActionContext = (context: any) => moduleActionContext(context, mod1)
const mod1GetterContext = (...args: any[]) => moduleGetterContext(...args, mod1)
const mod1GetterContext = (args: [any, any, any, any]) => moduleGetterContext(args, mod1)
```

@@ -307,0 +308,0 @@

@@ -7,3 +7,3 @@ import { ActionContext, Store } from "vuex"

rootActionContext: (originalContext: ActionContext<any, any>) => DirectActionContext<R, R>
rootActionContext(originalContext: ActionContext<any, any>): DirectActionContext<R, R>
moduleActionContext<O extends ModuleOptions>(

@@ -13,9 +13,6 @@ originalContext: ActionContext<any, any>,

): DirectActionContext<R, O>
rootGetterContext: (
state: any,
getters: any
) => DirectGetterContext<R, R>
moduleGetterContext: <O extends ModuleOptions>(
state: any, getters: any, rootState: any, rootGetters: any, module: O
) => DirectGetterContext<R, O>
rootGetterContext(args: [any, any]): DirectGetterContext<R, R>
moduleGetterContext<O extends ModuleOptions>(
args: [any, any, any, any], module: O
): DirectGetterContext<R, O>
}

@@ -22,0 +19,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc