little-state-machine
Advanced tools
Comparing version 4.1.0 to 4.1.1
@@ -1,2 +0,2 @@ | ||
import{createContext as e,useState as t,createElement as n,useContext as r,useMemo as o}from"react";var a=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),i=e(void 0),s=function(e){var r=e.children,o=t(a.state);return n(i.Provider,{value:{state:o[0],setState:o[1]}},r)};function _(e,t){var n,r,o;void 0===t&&(t={name:"__LSM__",middleWares:[]}),t.name&&(a.name=t.name),t.storageType&&(a.storageType=t.storageType),t.middleWares&&a.updateMiddleWares(t.middleWares),"production"!==process.env.NODE_ENV&&(n=a.storageType,r=a.name,o=a.state,"undefined"!=typeof window&&(window.__LSM__=r,window.__LSM_NAME__=r,window.__LSM_DEBUG__=function(e){return n.setItem("___LSM_DEBUG__",e)},window.__LSM_RESET__=function(){return n.removeItem(r)},window.__LSM_GET_STORE__=function(){return n.getItem(r)},window.__LSM_SAVE_TO__=function(e){return window.localStorage.setItem(e,JSON.stringify(o))},window.__LSM_LOAD__=function(e){return n.setItem(r||"___LSM_DEBUG__",e.data||window.localStorage.getItem(e.storeName)||"")})),a.updateStore(e)}function d(e){var t,n=(t=r(i),"production"!==process.env.NODE_ENV&&(t||console.error("StateMachine context is undefined, please verify you are calling useStateMachine() as child of a <StateMachineProvider> component.")),t),s=n.state,_=n.setState;return o(function(){return{actions:e?Object.entries(e).reduce(function(e,t){var n;return Object.assign({},e,((n={})[t[0]]=function(e,t){return function(n){"production"!==process.env.NODE_ENV&&(window.__LSM_NAME__=t?t.name:""),a.state=t(a.state,n),a.storageType.setItem(a.name,JSON.stringify(a.state)),a.middleWares.length&&(a.state=a.middleWares.reduce(function(e,r){return r(e,t.name,n)||e},a.state)),e(a.state)}}(_,t[1]),n))},{}):{},state:s}},[s,_,e])}export{s as StateMachineProvider,_ as createStore,d as useStateMachine}; | ||
import{createContext as e,useState as t,createElement as n,useContext as r,useMemo as o}from"react";var a=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),i=e(void 0),s=function(e){var r=e.children,o=t(a.state);return n(i.Provider,{value:{state:o[0],setState:o[1]}},r)};function _(e,t){var n,r,o;void 0===t&&(t={name:"__LSM__",middleWares:[]}),t.name&&(a.name=t.name),t.storageType&&(a.storageType=t.storageType),t.middleWares&&a.updateMiddleWares(t.middleWares),"production"!==process.env.NODE_ENV&&(n=a.storageType,r=a.name,o=a.state,"undefined"!=typeof window&&(window.__LSM__=r,window.__LSM_NAME__=r,window.__LSM_DEBUG__=function(e){return n.setItem("___LSM_DEBUG__",e)},window.__LSM_RESET__=function(){return n.removeItem(r)},window.__LSM_GET_STORE__=function(){return n.getItem(r)},window.__LSM_SAVE_TO__=function(e){return window.localStorage.setItem(e,JSON.stringify(o))},window.__LSM_LOAD__=function(e){return n.setItem(r||"___LSM_DEBUG__",e.data||window.localStorage.getItem(e.storeName)||"")})),a.updateStore(e)}function d(e){var t,n=(t=r(i),"production"!==process.env.NODE_ENV&&(t||console.error("StateMachine context is undefined, please verify you are calling useStateMachine() as child of a <StateMachineProvider> component.")),t),s=n.state,_=n.setState;return o(function(){return{actions:e?Object.entries(e).reduce(function(e,t){var n;return Object.assign({},e,((n={})[t[0]]=function(e,t){return function(n){"production"!==process.env.NODE_ENV&&(window.__LSM_NAME__=t?t.name:""),a.state=t(a.state,n),a.storageType.setItem(a.name,JSON.stringify(a.state)),a.middleWares.length&&(a.state=a.middleWares.reduce(function(e,r){return r(e,t.name,n)||e},a.state)),e(a.state)}}(_,t[1]),n))},{}):{},state:s}},[s,_])}export{s as StateMachineProvider,_ as createStore,d as useStateMachine}; | ||
//# sourceMappingURL=little-state-machine.es.js.map |
@@ -1,2 +0,2 @@ | ||
var e=require("react"),t=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),r=e.createContext(void 0);exports.StateMachineProvider=function(a){var n=a.children,s=e.useState(t.state);return e.createElement(r.Provider,{value:{state:s[0],setState:s[1]}},n)},exports.createStore=function(e,r){void 0===r&&(r={name:"__LSM__",middleWares:[]}),r.name&&(t.name=r.name),r.storageType&&(t.storageType=r.storageType),r.middleWares&&t.updateMiddleWares(r.middleWares),t.updateStore(e)},exports.useStateMachine=function(a){var n=e.useContext(r),s=n.state,i=n.setState;return e.useMemo(function(){return{actions:a?Object.entries(a).reduce(function(e,r){var a;return Object.assign({},e,((a={})[r[0]]=function(e,r){return function(a){t.state=r(t.state,a),t.storageType.setItem(t.name,JSON.stringify(t.state)),t.middleWares.length&&(t.state=t.middleWares.reduce(function(e,t){return t(e,r.name,a)||e},t.state)),e(t.state)}}(i,r[1]),a))},{}):{},state:s}},[s,i,a])}; | ||
var e=require("react"),t=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),r=e.createContext(void 0);exports.StateMachineProvider=function(a){var n=a.children,s=e.useState(t.state);return e.createElement(r.Provider,{value:{state:s[0],setState:s[1]}},n)},exports.createStore=function(e,r){void 0===r&&(r={name:"__LSM__",middleWares:[]}),r.name&&(t.name=r.name),r.storageType&&(t.storageType=r.storageType),r.middleWares&&t.updateMiddleWares(r.middleWares),t.updateStore(e)},exports.useStateMachine=function(a){var n=e.useContext(r),s=n.state,i=n.setState;return e.useMemo(function(){return{actions:a?Object.entries(a).reduce(function(e,r){var a;return Object.assign({},e,((a={})[r[0]]=function(e,r){return function(a){t.state=r(t.state,a),t.storageType.setItem(t.name,JSON.stringify(t.state)),t.middleWares.length&&(t.state=t.middleWares.reduce(function(e,t){return t(e,r.name,a)||e},t.state)),e(t.state)}}(i,r[1]),a))},{}):{},state:s}},[s,i])}; | ||
//# sourceMappingURL=little-state-machine.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).littleStateMachine={},e.react)}(this,function(e,t){var n=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),r=t.createContext(void 0);e.StateMachineProvider=function(e){var a=e.children,s=t.useState(n.state);return t.createElement(r.Provider,{value:{state:s[0],setState:s[1]}},a)},e.createStore=function(e,t){void 0===t&&(t={name:"__LSM__",middleWares:[]}),t.name&&(n.name=t.name),t.storageType&&(n.storageType=t.storageType),t.middleWares&&n.updateMiddleWares(t.middleWares),n.updateStore(e)},e.useStateMachine=function(e){var a=t.useContext(r),s=a.state,i=a.setState;return t.useMemo(function(){return{actions:e?Object.entries(e).reduce(function(e,t){var r;return Object.assign({},e,((r={})[t[0]]=function(e,t){return function(r){n.state=t(n.state,r),n.storageType.setItem(n.name,JSON.stringify(n.state)),n.middleWares.length&&(n.state=n.middleWares.reduce(function(e,n){return n(e,t.name,r)||e},n.state)),e(n.state)}}(i,t[1]),r))},{}):{},state:s}},[s,i,e])}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).littleStateMachine={},e.react)}(this,function(e,t){var n=new(function(){function e(e){void 0===e&&(e="__LSM__"),this.name=e,this.state={},this.middleWares=[];try{this.storageType="undefined"!=typeof sessionStorage?window.sessionStorage:{}}catch(e){this.storageType={}}}var t=e.prototype;return t.updateStore=function(e){this.state=function(e,t){try{return JSON.parse(e.getItem(t))}catch(e){return null}}(this.storageType,this.name)||e},t.updateMiddleWares=function(e){return this.middleWares=e},e}()),r=t.createContext(void 0);e.StateMachineProvider=function(e){var a=e.children,s=t.useState(n.state);return t.createElement(r.Provider,{value:{state:s[0],setState:s[1]}},a)},e.createStore=function(e,t){void 0===t&&(t={name:"__LSM__",middleWares:[]}),t.name&&(n.name=t.name),t.storageType&&(n.storageType=t.storageType),t.middleWares&&n.updateMiddleWares(t.middleWares),n.updateStore(e)},e.useStateMachine=function(e){var a=t.useContext(r),s=a.state,i=a.setState;return t.useMemo(function(){return{actions:e?Object.entries(e).reduce(function(e,t){var r;return Object.assign({},e,((r={})[t[0]]=function(e,t){return function(r){n.state=t(n.state,r),n.storageType.setItem(n.name,JSON.stringify(n.state)),n.middleWares.length&&(n.state=n.middleWares.reduce(function(e,n){return n(e,t.name,r)||e},n.state)),e(n.state)}}(i,t[1]),r))},{}):{},state:s}},[s,i])}}); | ||
//# sourceMappingURL=little-state-machine.umd.js.map |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"main": "dist/little-state-machine.js", | ||
@@ -11,0 +11,0 @@ "module": "dist/little-state-machine.es.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
41310