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

react-model

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-model - npm Package Compare versions

Comparing version 4.3.0-alpha.0 to 4.3.0-alpha.1

3

dist/index.d.ts

@@ -8,3 +8,2 @@ /// <reference path="../src/index.d.ts" />

declare function useModel<S>(state: S | (() => S)): [S, (state: Partial<S> | ((state: S) => S | void)) => void];
declare function useAtom<S>(state: S | (() => S)): [S, (state: Partial<S> | ((state: S) => S | void)) => void];
declare function createStore<S>(useHook: CustomModelHook<S>): LaneAPI<S>;

@@ -74,2 +73,2 @@ declare function createStore<S>(name: string, useHook: CustomModelHook<S>): LaneAPI<S>;

};
export { actionMiddlewares, createStore, useAtom, useModel, Model, middlewares, Provider, Consumer, connect, getState, getInitialState };
export { actionMiddlewares, createStore, useModel, Model, middlewares, Provider, Consumer, connect, getState, getInitialState };

@@ -1,1 +0,1 @@

import t,{enableES5 as e}from"immer";import{createContext as n,useContext as r,useState as o,useRef as i,createElement as c,useEffect as a,useLayoutEffect as s,PureComponent as u}from"react";function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function f(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var m={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},S={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},d=function(t,e){try{var n=t.next;return Promise.resolve(S.tryCatch.enable?n(e).catch(function(t){return console.log(t)}):n(e))}catch(t){return Promise.reject(t)}},b=function(t,e){try{var n=function(){return Promise.resolve(a(e))},r=t.action,o=t.modelName,i=t.consumerActions,c=t.params,a=t.next,s=t.Global,u=t.type,f=function(){if("u"!==u)return Promise.resolve(r(c,l({actions:i(s.Actions[o],{modelName:o}),state:s.State[o]},s.Context.__global||{},s.Context[o]||{}))).then(function(e){t.newState=e||null});t.newState=r()}();return Promise.resolve(f&&f.then?f.then(n):n())}catch(t){return Promise.reject(t)}},p=function(t,e){try{var n=t.modelName,r=t.newState,o=t.next,i=t.Global,c=t.type;return i.Setter.functionSetter[n]&&!t.disableSelectorUpdate&&Object.keys(i.Setter.functionSetter[n]).map(function(t){var e=i.Setter.functionSetter[n][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(i.State[n]))}),Promise.resolve(function(){if(r||"u"===c)return x(n,r||{}),Promise.resolve(o(e))}())}catch(t){return Promise.reject(t)}},v=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i=t.__hash,c=o.Setter.functionSetter[n];return"f"===t.type&&i&&c&&c[i]&&c[i].setState&&c[i].setState(o.State[n]),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},_=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i="u"===t.type?o.subscriptions[n]:o.subscriptions[n+"_"+t.actionName];return i&&i.forEach(function(e){e(t)}),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},h=function(t,e){try{var n=t.Global;return!0===S.logger.enable||"function"==typeof S.logger.enable&&S.logger.enable(t)?(console.group("%c "+t.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",n.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params),Promise.resolve(t.next(e)).then(function(e){return console.log("%c Next","color: #4CAF50; font-weight: bold",n.State[t.modelName]),console.groupEnd(),e})):Promise.resolve(t.next(e))}catch(t){return Promise.reject(t)}},y=function(t,e){try{var n=t.Global;return Promise.resolve(t.next(e)).then(function(e){return n.withDevTools&&S.devtools.enable&&n.devTools.send(t.modelName+"_"+t.actionName,n.State),e})}catch(t){return Promise.reject(t)}},g=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i=t.disableSelectorUpdate;return o.Setter.classSetter&&"u"!==t.type&&o.Setter.classSetter(o.State),o.Setter.functionSetter[n]&&Object.keys(o.Setter.functionSetter[n]).map(function(t){var e=o.Setter.functionSetter[n][t];if(e)if(!e.selector||i)e.setState(o.State[n]);else{var r=e.selector(o.State[n]);I(r,e.selectorRef)||(e.selectorRef=r,e.setState(o.State[n]))}}),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},P=[d,h,y,b,p,v,g,_],w={communicator:g,consoleDebugger:h,devToolsListener:y,getNewState:b,getNewStateWithCache:function(t){return void 0===t&&(t=5e3),function(e,n){try{var r=e.Global,o=e.modelName,i=e.next,c=e.actionName;return Promise.resolve(Promise.race([(0,e.action)(e.params,{actions:(0,e.consumerActions)(r.Actions[o],{modelName:o}),state:r.State[o]}),C(t,G(o,c))])).then(function(t){return e.newState=t||null,Promise.resolve(i(n))})}catch(t){return Promise.reject(t)}}},setNewState:p,stateUpdater:v,subscription:_,tryCatch:d,config:S},O=function(t,e){try{return e.next=function(t){return t.length>0?t[0](e,t.slice(1)):e.newState},Promise.resolve(t[0](e,t.slice(1)))}catch(t){return Promise.reject(t)}},N=n({}),j=N.Consumer;if(!console.group){var A=[],E="-".repeat(80);console.group=function(t){A.push(t),console.log("%c \nBEGIN GROUP: %c",E,t),console.groupEnd=function(){console.log("END GROUP: %c\n%c",A.pop(),E)}}}var R=function(t,e){var n={};return Object.keys(t).forEach(function(r){n[r]=function(t,e){return function(n,r){try{return Promise.resolve(O(P,{Global:m,action:t,actionName:t.name,consumerActions:R,middlewareConfig:r,modelName:e.modelName,newState:null,params:n,type:"o"}))}catch(t){return Promise.reject(t)}}}(t[r],e)}),n},x=function(e,n){if("function"==typeof n){var r=m.State[e];r=t(r,n),m.State=t(m.State,function(t){t[e]=r})}else m.State=t(m.State,function(t){t[e]=l({},t[e],n)});return m.State},C=function(t,e){return new Promise(function(n){return setTimeout(function(){console.log(t),n(e)},t)})},T=function(e,n){try{var r={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(m.State).map(function(o){try{var i=n&&n.prefix||"",c=function(){if(!e||!e.modelName||o===i+e.modelName||-1!==e.modelName.indexOf(i+o)){var c=function(e){n&&n.isServer?r[o]=e:m.State=t(m.State,function(t){t[o]=l({},t[o],e)})},a=m.AsyncState[o];return a?Promise.resolve(a(e)).then(c):c({})}}();return Promise.resolve(c&&c.then?c.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}))).then(function(){return n&&n.isServer?r:m.State})}catch(t){return Promise.reject(t)}},G=function(t,e){var n=localStorage.getItem("__REACT_MODELX__"+t+"_"+e);return n?JSON.parse(n):null},I=function(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(e,n[o])||t[n[o]]!==e[n[o]])return!1;return!0};e();var D="undefined"==typeof window?a:s;function M(e){var n=m.currentStoreId,r=m.mutableState[n].count;return m.mutableState[n].count+=1,m.mutableState[n].hasOwnProperty(r)||(m.mutableState[n][r]="function"==typeof e?e():e),[m.mutableState[n][r],function(e){try{return m.mutableState[n][r]="function"==typeof e?t(m.mutableState[n][r],e):m.mutableState[n][r]&&e&&"Object"===m.mutableState[n][r].constructor.name&&"Object"===e.constructor.name?l({},m.mutableState[n][r],e):e,Promise.resolve(O(P,{Global:m,action:function(){return"function"==typeof e?m.mutableState[n][r]:e},actionName:"setter",consumerActions:R,disableSelectorUpdate:!0,middlewareConfig:{},modelName:n,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]}function k(e){var n=m.currentStoreId,o=m.mutableState[n].count;m.mutableState[n].count+=1;var i=r(N);return m.mutableState[n].hasOwnProperty(o)||(m.mutableState[n][o]="function"==typeof e?e():e),[void 0===i[n][o]?m.mutableState[n][o]:i[n][o],function(e){try{return Promise.resolve(O(P,{Global:m,action:function(){m.Setter.classSetter&&m.Setter.classSetter("function"==typeof e?function(r){var i;return i=r[n].hasOwnProperty(o)?t(r[n][o],e):t(m.mutableState[n][o],e),t(r,function(t){t[n][o]=i})}:function(r){return t(r,r[n][o]&&e&&"Object"===r[n][o].constructor.name&&"Object"===e.constructor.name?function(t){t[n][o]=l({},t[n][o],e)}:"Object"!==e.constructor.name||r[n][o]||"Object"!==m.mutableState[n][o].constructor.name?function(t){t[n][o]=e}:function(t){t[n][o]=l({},m.mutableState[n][o],e)})})},actionName:"setter",consumerActions:R,disableSelectorUpdate:!0,middlewareConfig:{},modelName:n,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]}function U(e,n){var r="string"==typeof e;m.storeId+=r?0:1;var o=r?e:m.storeId.toString();m.Actions[o]||(m.Actions[o]={}),m.mutableState[o]||(m.mutableState[o]={count:0}),m.State[o]||(m.State=t(m.State,function(t){t[o]={}}));var i=function(){return m.mutableState[o].count=0,m.currentStoreId=o,n?n():e()};return m.mutableState[o].selector=i,{useStore:function(){return J(o,i)},getState:function(){return i()},subscribe:function(t){m.subscriptions[o]||(m.subscriptions[o]=[]),m.subscriptions[o].push(t)},unsubscribe:function(t){if(m.subscriptions[o]&&t){var e=m.subscriptions[o].indexOf(t);e>=0&&m.subscriptions[o].splice(e,1)}}}}function F(e,n,r){if(void 0!==e.state){m.storeId+=1;var o="__"+m.storeId;m.State=t(m.State,function(t){t[o]=e.state}),e.middlewares&&(m.Middlewares[o]=e.middlewares),m.Actions[o]=e.actions,m.AsyncState[o]=e.asyncState,n&&(m.Context[o]=n);var i=B(o);return{__id:o,actions:i,getState:function(){return X(o)},subscribe:function(t,e){return L(o,t,e)},unsubscribe:function(t){return V(o,t)},useStore:function(t){return J(o,t)}}}n?m.gid=1:m.gid+=1;var c="";if(m.gid>1&&(c=m.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);var a=function(t){return function(){return t}};return{__ERROR__:!0,actions:a({}),getActions:a({}),getInitialState:a({}),getState:a({}),subscribe:a(),unsubscribe:a(),useStore:a([{},{}])}}n&&!n.__FROM_SERVER__&&(m.State=t(m.State,function(t){Object.assign(t,n||{})})),r&&(m.Context.__global=r);var s={};return Object.keys(e).forEach(function(r){var o=c+r,i=e[r];if(i.__ERROR__)return console.error(o+" model's schema is invalid"),m.State=t(m.State,function(t){t[o]={}}),void(m.Actions[o]={});!function(t){return void 0!==t.useStore}(i)?(n&&n.__FROM_SERVER__?m.State=t(m.State,function(t){t[o]=l({},i.state,n[o])}):m.State[o]||(m.State=t(m.State,function(t){t[o]=i.state})),i.middlewares&&(m.Middlewares[o]=i.middlewares),m.Actions[o]=i.actions,m.AsyncState[o]=i.asyncState):(m.State[o]&&n||(m.State=t(m.State,function(t){t[o]=t[i.__id]})),n&&n.__FROM_SERVER__&&(m.State=t(m.State,function(t){t[o]=l({},t[i.__id],n[o])})),m.Actions[o]=m.Actions[i.__id],m.AsyncState[o]=m.AsyncState[i.__id],m.Middlewares[o]=m.Middlewares[i.__id],m.Context[o]=m.Context[i.__id]),s[r]=B(o)}),m.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,m.withDevTools&&w.config.devtools.enable&&(m.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,m.devTools.connect()),{actions:s,getActions:function(t){return B(c+t)},getInitialState:function(t,e){try{return Promise.resolve(T(t,l({},e,{prefix:c})))}catch(t){return Promise.reject(t)}},getState:function(t){return X(c+t)},subscribe:function(t,e,n){return L(c+t,e,n)},unsubscribe:function(t,e){return V(c+t,e)},useStore:function(t,e){return J(c+t,e)}}}var V=function(t,e){L(t,e,void 0)},L=function(t,e,n){Array.isArray(e)?e.forEach(function(e){m.subscriptions[t+"_"+e]||(m.subscriptions[t+"_"+e]=[]),n?m.subscriptions[t+"_"+e].push(n):m.subscriptions[t+"_"+e]=[]}):(m.subscriptions[t+"_"+e]||(m.subscriptions[t+"_"+e]=[]),n?m.subscriptions[t+"_"+e].push(n):m.subscriptions[t+"_"+e]=[])},X=function(t){return m.State[t]},B=function(t,e){void 0===e&&(e={type:"o"});var n={};return Object.keys(m.Actions[t]).forEach(function(r){return n[r]=function(n,o){try{var i=l({action:m.Actions[t][r],actionName:r,consumerActions:R,middlewareConfig:o,modelName:t,newState:null,params:n},e,{Global:m});return Promise.resolve(O(m.Middlewares[t]?m.Middlewares[t]:P,i))}catch(t){return Promise.reject(t)}}}),n},J=function(t,e){var n,r=o({})[1],c=i(""),a=(n=[t],function(t){return n.reduce(function(t,e){return t&&t[e]?t[e]:null},t)})(m.mutableState),s=!!a,u=s?a.selector:e,l=s?a:X(t);if(D(function(){m.uid+=1;var e=""+m.uid;return c.current=e,m.Setter.functionSetter[t]||(m.Setter.functionSetter[t]={}),m.Setter.functionSetter[t][e]={setState:r,selector:u},function(){delete m.Setter.functionSetter[t][e]}},[]),s)return u(l);var f=B(t,{__hash:c.current,type:"f"});return[u?u(l):l,f]},W=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state=m.State,e}return f(e,t),e.prototype.render=function(){var t=this.props.children;return m.Setter.classSetter=this.setState.bind(this),c(N.Provider,{value:l({},this.state)},t)},e}(u),q=function(t,e,n){return function(r){return function(o){function i(){return o.apply(this,arguments)||this}return f(i,o),i.prototype.render=function(){var o=this,i=this.props,a=i.state,s=void 0===a?{}:a,u=i.actions,f=void 0===u?{}:u;return c(j,null,function(i){var a=i[""+t],u=m.Actions[t];return c(r,Object.assign({},o.props,{state:l({},s,e?e(a):a),actions:l({},f,n?n(R(u,{modelName:t})):R(u,{modelName:t}))}))})},i}(u)}};export{j as Consumer,F as Model,W as Provider,P as actionMiddlewares,q as connect,U as createStore,T as getInitialState,X as getState,w as middlewares,k as useAtom,M as useModel};
import t,{enableES5 as e}from"immer";import{createContext as r,useState as n,useRef as o,createElement as i,useEffect as c,useLayoutEffect as a,PureComponent as s}from"react";function u(){return(u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var f={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},m={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},S=function(t,e){try{var r=t.next;return Promise.resolve(m.tryCatch.enable?r(e).catch(function(t){return console.log(t)}):r(e))}catch(t){return Promise.reject(t)}},d=function(t,e){try{var r=function(){return Promise.resolve(a(e))},n=t.action,o=t.modelName,i=t.consumerActions,c=t.params,a=t.next,s=t.Global,l=t.type,f=function(){if("u"!==l)return Promise.resolve(n(c,u({actions:i(s.Actions[o],{modelName:o}),state:s.State[o]},s.Context.__global||{},s.Context[o]||{}))).then(function(e){t.newState=e||null});t.newState=n()}();return Promise.resolve(f&&f.then?f.then(r):r())}catch(t){return Promise.reject(t)}},b=function(t,e){try{var r=t.modelName,n=t.newState,o=t.next,i=t.Global,c=t.type;return i.Setter.functionSetter[r]&&!t.disableSelectorUpdate&&Object.keys(i.Setter.functionSetter[r]).map(function(t){var e=i.Setter.functionSetter[r][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(i.State[r]))}),Promise.resolve(function(){if(n||"u"===c)return R(r,n||{}),Promise.resolve(o(e))}())}catch(t){return Promise.reject(t)}},v=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,i=t.__hash,c=o.Setter.functionSetter[r];return"f"===t.type&&i&&c&&c[i]&&c[i].setState&&c[i].setState(o.State[r]),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},p=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,i="u"===t.type?o.subscriptions[r]:o.subscriptions[r+"_"+t.actionName];return i&&i.forEach(function(e){e(t)}),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},_=function(t,e){try{var r=t.Global;return!0===m.logger.enable||"function"==typeof m.logger.enable&&m.logger.enable(t)?(console.group("%c "+t.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",r.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params),Promise.resolve(t.next(e)).then(function(e){return console.log("%c Next","color: #4CAF50; font-weight: bold",r.State[t.modelName]),console.groupEnd(),e})):Promise.resolve(t.next(e))}catch(t){return Promise.reject(t)}},h=function(t,e){try{var r=t.Global;return Promise.resolve(t.next(e)).then(function(e){return r.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,r.withDevTools&&P.config.devtools.enable&&!r.devTools&&(r.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,r.devTools.connect()),r.withDevTools&&m.devtools.enable&&r.devTools.send("u"===t.type&&t.disableSelectorUpdate?"store["+t.modelName+"].update":t.modelName+"_"+t.actionName,r.mutableState[t.modelName],void 0,t.modelName),e})}catch(t){return Promise.reject(t)}},y=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,i=t.disableSelectorUpdate;return o.Setter.classSetter&&o.Setter.classSetter(o.State),o.Setter.functionSetter[r]&&Object.keys(o.Setter.functionSetter[r]).map(function(t){var e=o.Setter.functionSetter[r][t];if(e)if(!e.selector||i)e.setState(o.State[r]);else{var n=e.selector(o.State[r]);G(n,e.selectorRef)||(e.selectorRef=n,e.setState(o.State[r]))}}),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},g=[S,_,h,d,b,v,y,p],P={communicator:y,consoleDebugger:_,devToolsListener:h,getNewState:d,getNewStateWithCache:function(t){return void 0===t&&(t=5e3),function(e,r){try{var n=e.Global,o=e.modelName,i=e.next,c=e.actionName;return Promise.resolve(Promise.race([(0,e.action)(e.params,{actions:(0,e.consumerActions)(n.Actions[o],{modelName:o}),state:n.State[o]}),x(t,T(o,c))])).then(function(t){return e.newState=t||null,Promise.resolve(i(r))})}catch(t){return Promise.reject(t)}}},setNewState:b,stateUpdater:v,subscription:p,tryCatch:S,config:m},w=function(t,e){try{return e.next=function(t){return t.length>0?t[0](e,t.slice(1)):e.newState},Promise.resolve(t[0](e,t.slice(1)))}catch(t){return Promise.reject(t)}},N=r({}),O=N.Consumer;if(!console.group){var j=[],A="-".repeat(80);console.group=function(t){j.push(t),console.log("%c \nBEGIN GROUP: %c",A,t),console.groupEnd=function(){console.log("END GROUP: %c\n%c",j.pop(),A)}}}var E=function(t,e){var r={};return Object.keys(t).forEach(function(n){r[n]=function(t,e){return function(r,n){try{return Promise.resolve(w(g,{Global:f,action:t,actionName:t.name,consumerActions:E,middlewareConfig:n,modelName:e.modelName,newState:null,params:r,type:"o"}))}catch(t){return Promise.reject(t)}}}(t[n],e)}),r},R=function(e,r){if("function"==typeof r){var n=f.State[e];n=t(n,r),f.State=t(f.State,function(t){t[e]=n})}else f.State=t(f.State,function(t){t[e]=u({},t[e],r)});return f.State},x=function(t,e){return new Promise(function(r){return setTimeout(function(){console.log(t),r(e)},t)})},C=function(e,r){try{var n={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(f.State).map(function(o){try{var i=r&&r.prefix||"",c=function(){if(!e||!e.modelName||o===i+e.modelName||-1!==e.modelName.indexOf(i+o)){var c=function(e){r&&r.isServer?n[o]=e:f.State=t(f.State,function(t){t[o]=u({},t[o],e)})},a=f.AsyncState[o];return a?Promise.resolve(a(e)).then(c):c({})}}();return Promise.resolve(c&&c.then?c.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}))).then(function(){return r&&r.isServer?n:f.State})}catch(t){return Promise.reject(t)}},T=function(t,e){var r=localStorage.getItem("__REACT_MODELX__"+t+"_"+e);return r?JSON.parse(r):null},G=function(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||t[r[o]]!==e[r[o]])return!1;return!0};e();var I="undefined"==typeof window?c:a;function D(e){var r=f.currentStoreId,n=f.mutableState[r].count;return f.mutableState[r].count+=1,f.mutableState[r].hasOwnProperty(n)||(f.mutableState[r][n]="function"==typeof e?e():e),[f.mutableState[r][n],function(e){try{return f.mutableState[r][n]="function"==typeof e?t(f.mutableState[r][n],e):f.mutableState[r][n]&&e&&"Object"===f.mutableState[r][n].constructor.name&&"Object"===e.constructor.name?u({},f.mutableState[r][n],e):e,Promise.resolve(w(g,{Global:f,action:function(){return"function"==typeof e?f.mutableState[r][n]:e},actionName:"setter",consumerActions:E,disableSelectorUpdate:!0,middlewareConfig:{},modelName:r,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]}function M(t,e){var r="string"==typeof t;f.storeId+=r?0:1;var n=r?t:f.storeId.toString();f.Actions[n]||(f.Actions[n]={}),f.mutableState[n]||(f.mutableState[n]={count:0,cachedResult:void 0});var o=function(){return f.mutableState[n].count=0,f.currentStoreId=n,f.mutableState[n].cachedResult=e?e():t(),f.mutableState[n].cachedResult};return f.mutableState[n].selector=o,{useStore:function(){return X(n,o)},getState:function(){return o()},getStore:function(){return f.mutableState[n].cachedResult},subscribe:function(t){f.subscriptions[n]||(f.subscriptions[n]=[]),f.subscriptions[n].push(t)},unsubscribe:function(t){if(f.subscriptions[n]&&t){var e=f.subscriptions[n].indexOf(t);e>=0&&f.subscriptions[n].splice(e,1)}}}}function k(e,r,n){if(void 0!==e.state){f.storeId+=1;var o="__"+f.storeId;f.State=t(f.State,function(t){t[o]=e.state}),e.middlewares&&(f.Middlewares[o]=e.middlewares),f.Actions[o]=e.actions,f.AsyncState[o]=e.asyncState,r&&(f.Context[o]=r);var i=L(o);return{__id:o,actions:i,getState:function(){return V(o)},subscribe:function(t,e){return F(o,t,e)},unsubscribe:function(t){return U(o,t)},useStore:function(t){return X(o,t)}}}r?f.gid=1:f.gid+=1;var c="";if(f.gid>1&&(c=f.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);var a=function(t){return function(){return t}};return{__ERROR__:!0,actions:a({}),getActions:a({}),getInitialState:a({}),getState:a({}),subscribe:a(),unsubscribe:a(),useStore:a([{},{}])}}r&&!r.__FROM_SERVER__&&(f.State=t(f.State,function(t){Object.assign(t,r||{})})),n&&(f.Context.__global=n);var s={};return Object.keys(e).forEach(function(n){var o=c+n,i=e[n];if(i.__ERROR__)return console.error(o+" model's schema is invalid"),f.State=t(f.State,function(t){t[o]={}}),void(f.Actions[o]={});!function(t){return void 0!==t.useStore}(i)?(r&&r.__FROM_SERVER__?f.State=t(f.State,function(t){t[o]=u({},i.state,r[o])}):f.State[o]||(f.State=t(f.State,function(t){t[o]=i.state})),i.middlewares&&(f.Middlewares[o]=i.middlewares),f.Actions[o]=i.actions,f.AsyncState[o]=i.asyncState):(f.State[o]&&r||(f.State=t(f.State,function(t){t[o]=t[i.__id]})),r&&r.__FROM_SERVER__&&(f.State=t(f.State,function(t){t[o]=u({},t[i.__id],r[o])})),f.Actions[o]=f.Actions[i.__id],f.AsyncState[o]=f.AsyncState[i.__id],f.Middlewares[o]=f.Middlewares[i.__id],f.Context[o]=f.Context[i.__id]),s[n]=L(o)}),{actions:s,getActions:function(t){return L(c+t)},getInitialState:function(t,e){try{return Promise.resolve(C(t,u({},e,{prefix:c})))}catch(t){return Promise.reject(t)}},getState:function(t){return V(c+t)},subscribe:function(t,e,r){return F(c+t,e,r)},unsubscribe:function(t,e){return U(c+t,e)},useStore:function(t,e){return X(c+t,e)}}}var U=function(t,e){F(t,e,void 0)},F=function(t,e,r){Array.isArray(e)?e.forEach(function(e){f.subscriptions[t+"_"+e]||(f.subscriptions[t+"_"+e]=[]),r?f.subscriptions[t+"_"+e].push(r):f.subscriptions[t+"_"+e]=[]}):(f.subscriptions[t+"_"+e]||(f.subscriptions[t+"_"+e]=[]),r?f.subscriptions[t+"_"+e].push(r):f.subscriptions[t+"_"+e]=[])},V=function(t){return f.State[t]},L=function(t,e){void 0===e&&(e={type:"o"});var r={};return Object.keys(f.Actions[t]).forEach(function(n){return r[n]=function(r,o){try{var i=u({action:f.Actions[t][n],actionName:n,consumerActions:E,middlewareConfig:o,modelName:t,newState:null,params:r},e,{Global:f});return Promise.resolve(w(f.Middlewares[t]?f.Middlewares[t]:g,i))}catch(t){return Promise.reject(t)}}}),r},X=function(t,e){var r,i=n({})[1],c=o(""),a=(r=[t],function(t){return r.reduce(function(t,e){return t&&t[e]?t[e]:null},t)})(f.mutableState),s=!!a,u=s?a.selector:e,l=s?a:V(t);if(I(function(){f.uid+=1;var e=""+f.uid;return c.current=e,f.Setter.functionSetter[t]||(f.Setter.functionSetter[t]={}),f.Setter.functionSetter[t][e]={setState:i,selector:u},function(){delete f.Setter.functionSetter[t][e]}},[]),s)return u(l);var m=L(t,{__hash:c.current,type:"f"});return[u?u(l):l,m]},B=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state=f.State,e}return l(e,t),e.prototype.render=function(){var t=this.props.children;return f.Setter.classSetter=this.setState.bind(this),i(N.Provider,{value:u({},this.state)},t)},e}(s),J=function(t,e,r){return function(n){return function(o){function c(){return o.apply(this,arguments)||this}return l(c,o),c.prototype.render=function(){var o=this,c=this.props,a=c.state,s=void 0===a?{}:a,l=c.actions,m=void 0===l?{}:l;return i(O,null,function(c){var a=c[""+t],l=f.Actions[t];return i(n,Object.assign({},o.props,{state:u({},s,e?e(a):a),actions:u({},m,r?r(E(l,{modelName:t})):E(l,{modelName:t}))}))})},c}(s)}};export{O as Consumer,k as Model,B as Provider,g as actionMiddlewares,J as connect,M as createStore,C as getInitialState,V as getState,P as middlewares,D as useModel};

@@ -1,1 +0,1 @@

var t,e=require("immer"),r=(t=e)&&"object"==typeof t&&"default"in t?t.default:t,n=require("react");function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var c={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},i={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},s=function(t,e){try{var r=t.next;return Promise.resolve(i.tryCatch.enable?r(e).catch(function(t){return console.log(t)}):r(e))}catch(t){return Promise.reject(t)}},u=function(t,e){try{var r=function(){return Promise.resolve(s(e))},n=t.action,a=t.modelName,c=t.consumerActions,i=t.params,s=t.next,u=t.Global,l=t.type,f=function(){if("u"!==l)return Promise.resolve(n(i,o({actions:c(u.Actions[a],{modelName:a}),state:u.State[a]},u.Context.__global||{},u.Context[a]||{}))).then(function(e){t.newState=e||null});t.newState=n()}();return Promise.resolve(f&&f.then?f.then(r):r())}catch(t){return Promise.reject(t)}},l=function(t,e){try{var r=t.modelName,n=t.newState,o=t.next,a=t.Global,c=t.type;return a.Setter.functionSetter[r]&&!t.disableSelectorUpdate&&Object.keys(a.Setter.functionSetter[r]).map(function(t){var e=a.Setter.functionSetter[r][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(a.State[r]))}),Promise.resolve(function(){if(n||"u"===c)return O(r,n||{}),Promise.resolve(o(e))}())}catch(t){return Promise.reject(t)}},f=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,a=t.__hash,c=o.Setter.functionSetter[r];return"f"===t.type&&a&&c&&c[a]&&c[a].setState&&c[a].setState(o.State[r]),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},m=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,a="u"===t.type?o.subscriptions[r]:o.subscriptions[r+"_"+t.actionName];return a&&a.forEach(function(e){e(t)}),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},S=function(t,e){try{var r=t.Global;return!0===i.logger.enable||"function"==typeof i.logger.enable&&i.logger.enable(t)?(console.group("%c "+t.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",r.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params),Promise.resolve(t.next(e)).then(function(e){return console.log("%c Next","color: #4CAF50; font-weight: bold",r.State[t.modelName]),console.groupEnd(),e})):Promise.resolve(t.next(e))}catch(t){return Promise.reject(t)}},d=function(t,e){try{var r=t.Global;return Promise.resolve(t.next(e)).then(function(e){return r.withDevTools&&i.devtools.enable&&r.devTools.send(t.modelName+"_"+t.actionName,r.State),e})}catch(t){return Promise.reject(t)}},b=function(t,e){try{var r=t.modelName,n=t.next,o=t.Global,a=t.disableSelectorUpdate;return o.Setter.classSetter&&"u"!==t.type&&o.Setter.classSetter(o.State),o.Setter.functionSetter[r]&&Object.keys(o.Setter.functionSetter[r]).map(function(t){var e=o.Setter.functionSetter[r][t];if(e)if(!e.selector||a)e.setState(o.State[r]);else{var n=e.selector(o.State[r]);x(n,e.selectorRef)||(e.selectorRef=n,e.setState(o.State[r]))}}),Promise.resolve(n(e))}catch(t){return Promise.reject(t)}},p=[s,S,d,u,l,f,b,m],v={communicator:b,consoleDebugger:S,devToolsListener:d,getNewState:u,getNewStateWithCache:function(t){return void 0===t&&(t=5e3),function(e,r){try{var n=e.Global,o=e.modelName,a=e.next,c=e.actionName;return Promise.resolve(Promise.race([(0,e.action)(e.params,{actions:(0,e.consumerActions)(n.Actions[o],{modelName:o}),state:n.State[o]}),N(t,E(o,c))])).then(function(t){return e.newState=t||null,Promise.resolve(a(r))})}catch(t){return Promise.reject(t)}}},setNewState:l,stateUpdater:f,subscription:m,tryCatch:s,config:i},_=function(t,e){try{return e.next=function(t){return t.length>0?t[0](e,t.slice(1)):e.newState},Promise.resolve(t[0](e,t.slice(1)))}catch(t){return Promise.reject(t)}},h=n.createContext({}),y=h.Consumer;if(!console.group){var g=[],P="-".repeat(80);console.group=function(t){g.push(t),console.log("%c \nBEGIN GROUP: %c",P,t),console.groupEnd=function(){console.log("END GROUP: %c\n%c",g.pop(),P)}}}var w=function(t,e){var r={};return Object.keys(t).forEach(function(n){r[n]=function(t,e){return function(r,n){try{return Promise.resolve(_(p,{Global:c,action:t,actionName:t.name,consumerActions:w,middlewareConfig:n,modelName:e.modelName,newState:null,params:r,type:"o"}))}catch(t){return Promise.reject(t)}}}(t[n],e)}),r},O=function(t,e){if("function"==typeof e){var n=c.State[t];n=r(n,e),c.State=r(c.State,function(e){e[t]=n})}else c.State=r(c.State,function(r){r[t]=o({},r[t],e)});return c.State},N=function(t,e){return new Promise(function(r){return setTimeout(function(){console.log(t),r(e)},t)})},j=function(t,e){try{var n={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(c.State).map(function(a){try{var i=e&&e.prefix||"",s=function(){if(!t||!t.modelName||a===i+t.modelName||-1!==t.modelName.indexOf(i+a)){var s=function(t){e&&e.isServer?n[a]=t:c.State=r(c.State,function(e){e[a]=o({},e[a],t)})},u=c.AsyncState[a];return u?Promise.resolve(u(t)).then(s):s({})}}();return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}))).then(function(){return e&&e.isServer?n:c.State})}catch(t){return Promise.reject(t)}},E=function(t,e){var r=localStorage.getItem("__REACT_MODELX__"+t+"_"+e);return r?JSON.parse(r):null},x=function(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||t[r[o]]!==e[r[o]])return!1;return!0};e.enableES5();var A="undefined"==typeof window?n.useEffect:n.useLayoutEffect,R=function(t,e){C(t,e,void 0)},C=function(t,e,r){Array.isArray(e)?e.forEach(function(e){c.subscriptions[t+"_"+e]||(c.subscriptions[t+"_"+e]=[]),r?c.subscriptions[t+"_"+e].push(r):c.subscriptions[t+"_"+e]=[]}):(c.subscriptions[t+"_"+e]||(c.subscriptions[t+"_"+e]=[]),r?c.subscriptions[t+"_"+e].push(r):c.subscriptions[t+"_"+e]=[])},I=function(t){return c.State[t]},T=function(t,e){void 0===e&&(e={type:"o"});var r={};return Object.keys(c.Actions[t]).forEach(function(n){return r[n]=function(r,a){try{var i=o({action:c.Actions[t][n],actionName:n,consumerActions:w,middlewareConfig:a,modelName:t,newState:null,params:r},e,{Global:c});return Promise.resolve(_(c.Middlewares[t]?c.Middlewares[t]:p,i))}catch(t){return Promise.reject(t)}}}),r},G=function(t,e){var r,o=n.useState({})[1],a=n.useRef(""),i=(r=[t],function(t){return r.reduce(function(t,e){return t&&t[e]?t[e]:null},t)})(c.mutableState),s=!!i,u=s?i.selector:e,l=s?i:I(t);if(A(function(){c.uid+=1;var e=""+c.uid;return a.current=e,c.Setter.functionSetter[t]||(c.Setter.functionSetter[t]={}),c.Setter.functionSetter[t][e]={setState:o,selector:u},function(){delete c.Setter.functionSetter[t][e]}},[]),s)return u(l);var f=T(t,{__hash:a.current,type:"f"});return[u?u(l):l,f]},M=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state=c.State,e}return a(e,t),e.prototype.render=function(){var t=this.props.children;return c.Setter.classSetter=this.setState.bind(this),n.createElement(h.Provider,{value:o({},this.state)},t)},e}(n.PureComponent);exports.Consumer=y,exports.Model=function(t,e,n){if(void 0!==t.state){c.storeId+=1;var a="__"+c.storeId;c.State=r(c.State,function(e){e[a]=t.state}),t.middlewares&&(c.Middlewares[a]=t.middlewares),c.Actions[a]=t.actions,c.AsyncState[a]=t.asyncState,e&&(c.Context[a]=e);var i=T(a);return{__id:a,actions:i,getState:function(){return I(a)},subscribe:function(t,e){return C(a,t,e)},unsubscribe:function(t){return R(a,t)},useStore:function(t){return G(a,t)}}}e?c.gid=1:c.gid+=1;var s="";if(c.gid>1&&(s=c.gid+"_"),t.actions){console.error("invalid model(s) schema: ",t);var u=function(t){return function(){return t}};return{__ERROR__:!0,actions:u({}),getActions:u({}),getInitialState:u({}),getState:u({}),subscribe:u(),unsubscribe:u(),useStore:u([{},{}])}}e&&!e.__FROM_SERVER__&&(c.State=r(c.State,function(t){Object.assign(t,e||{})})),n&&(c.Context.__global=n);var l={};return Object.keys(t).forEach(function(n){var a=s+n,i=t[n];if(i.__ERROR__)return console.error(a+" model's schema is invalid"),c.State=r(c.State,function(t){t[a]={}}),void(c.Actions[a]={});void 0===i.useStore?(e&&e.__FROM_SERVER__?c.State=r(c.State,function(t){t[a]=o({},i.state,e[a])}):c.State[a]||(c.State=r(c.State,function(t){t[a]=i.state})),i.middlewares&&(c.Middlewares[a]=i.middlewares),c.Actions[a]=i.actions,c.AsyncState[a]=i.asyncState):(c.State[a]&&e||(c.State=r(c.State,function(t){t[a]=t[i.__id]})),e&&e.__FROM_SERVER__&&(c.State=r(c.State,function(t){t[a]=o({},t[i.__id],e[a])})),c.Actions[a]=c.Actions[i.__id],c.AsyncState[a]=c.AsyncState[i.__id],c.Middlewares[a]=c.Middlewares[i.__id],c.Context[a]=c.Context[i.__id]),l[n]=T(a)}),c.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,c.withDevTools&&v.config.devtools.enable&&(c.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,c.devTools.connect()),{actions:l,getActions:function(t){return T(s+t)},getInitialState:function(t,e){try{return Promise.resolve(j(t,o({},e,{prefix:s})))}catch(t){return Promise.reject(t)}},getState:function(t){return I(s+t)},subscribe:function(t,e,r){return C(s+t,e,r)},unsubscribe:function(t,e){return R(s+t,e)},useStore:function(t,e){return G(s+t,e)}}},exports.Provider=M,exports.actionMiddlewares=p,exports.connect=function(t,e,r){return function(i){return function(s){function u(){return s.apply(this,arguments)||this}return a(u,s),u.prototype.render=function(){var a=this,s=this.props,u=s.state,l=void 0===u?{}:u,f=s.actions,m=void 0===f?{}:f;return n.createElement(y,null,function(s){var u=s[""+t],f=c.Actions[t];return n.createElement(i,Object.assign({},a.props,{state:o({},l,e?e(u):u),actions:o({},m,r?r(w(f,{modelName:t})):w(f,{modelName:t}))}))})},u}(n.PureComponent)}},exports.createStore=function(t,e){var n="string"==typeof t;c.storeId+=n?0:1;var o=n?t:c.storeId.toString();c.Actions[o]||(c.Actions[o]={}),c.mutableState[o]||(c.mutableState[o]={count:0}),c.State[o]||(c.State=r(c.State,function(t){t[o]={}}));var a=function(){return c.mutableState[o].count=0,c.currentStoreId=o,e?e():t()};return c.mutableState[o].selector=a,{useStore:function(){return G(o,a)},getState:function(){return a()},subscribe:function(t){c.subscriptions[o]||(c.subscriptions[o]=[]),c.subscriptions[o].push(t)},unsubscribe:function(t){if(c.subscriptions[o]&&t){var e=c.subscriptions[o].indexOf(t);e>=0&&c.subscriptions[o].splice(e,1)}}}},exports.getInitialState=j,exports.getState=I,exports.middlewares=v,exports.useAtom=function(t){var e=c.currentStoreId,a=c.mutableState[e].count;c.mutableState[e].count+=1;var i=n.useContext(h);return c.mutableState[e].hasOwnProperty(a)||(c.mutableState[e][a]="function"==typeof t?t():t),[void 0===i[e][a]?c.mutableState[e][a]:i[e][a],function(t){try{return Promise.resolve(_(p,{Global:c,action:function(){c.Setter.classSetter&&c.Setter.classSetter("function"==typeof t?function(n){var o;return o=n[e].hasOwnProperty(a)?r(n[e][a],t):r(c.mutableState[e][a],t),r(n,function(t){t[e][a]=o})}:function(n){return r(n,n[e][a]&&t&&"Object"===n[e][a].constructor.name&&"Object"===t.constructor.name?function(r){r[e][a]=o({},r[e][a],t)}:"Object"!==t.constructor.name||n[e][a]||"Object"!==c.mutableState[e][a].constructor.name?function(r){r[e][a]=t}:function(r){r[e][a]=o({},c.mutableState[e][a],t)})})},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:e,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]},exports.useModel=function(t){var e=c.currentStoreId,n=c.mutableState[e].count;return c.mutableState[e].count+=1,c.mutableState[e].hasOwnProperty(n)||(c.mutableState[e][n]="function"==typeof t?t():t),[c.mutableState[e][n],function(t){try{return c.mutableState[e][n]="function"==typeof t?r(c.mutableState[e][n],t):c.mutableState[e][n]&&t&&"Object"===c.mutableState[e][n].constructor.name&&"Object"===t.constructor.name?o({},c.mutableState[e][n],t):t,Promise.resolve(_(p,{Global:c,action:function(){return"function"==typeof t?c.mutableState[e][n]:t},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:e,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]};
var e,t=require("immer"),r=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,n=require("react");function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var a={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},c={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},s=function(e,t){try{var r=e.next;return Promise.resolve(c.tryCatch.enable?r(t).catch(function(e){return console.log(e)}):r(t))}catch(e){return Promise.reject(e)}},u=function(e,t){try{var r=function(){return Promise.resolve(s(t))},n=e.action,i=e.modelName,a=e.consumerActions,c=e.params,s=e.next,u=e.Global,l=e.type,f=function(){if("u"!==l)return Promise.resolve(n(c,o({actions:a(u.Actions[i],{modelName:i}),state:u.State[i]},u.Context.__global||{},u.Context[i]||{}))).then(function(t){e.newState=t||null});e.newState=n()}();return Promise.resolve(f&&f.then?f.then(r):r())}catch(e){return Promise.reject(e)}},l=function(e,t){try{var r=e.modelName,n=e.newState,o=e.next,i=e.Global,a=e.type;return i.Setter.functionSetter[r]&&!e.disableSelectorUpdate&&Object.keys(i.Setter.functionSetter[r]).map(function(e){var t=i.Setter.functionSetter[r][e];t&&t.selector&&!t.selectorRef&&(t.selectorRef=t.selector(i.State[r]))}),Promise.resolve(function(){if(n||"u"===a)return N(r,n||{}),Promise.resolve(o(t))}())}catch(e){return Promise.reject(e)}},f=function(e,t){try{var r=e.modelName,n=e.next,o=e.Global,i=e.__hash,a=o.Setter.functionSetter[r];return"f"===e.type&&i&&a&&a[i]&&a[i].setState&&a[i].setState(o.State[r]),Promise.resolve(n(t))}catch(e){return Promise.reject(e)}},m=function(e,t){try{var r=e.modelName,n=e.next,o=e.Global,i="u"===e.type?o.subscriptions[r]:o.subscriptions[r+"_"+e.actionName];return i&&i.forEach(function(t){t(e)}),Promise.resolve(n(t))}catch(e){return Promise.reject(e)}},S=function(e,t){try{var r=e.Global;return!0===c.logger.enable||"function"==typeof c.logger.enable&&c.logger.enable(e)?(console.group("%c "+e.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",r.State[e.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",e.actionName,"payload: "+e.params),Promise.resolve(e.next(t)).then(function(t){return console.log("%c Next","color: #4CAF50; font-weight: bold",r.State[e.modelName]),console.groupEnd(),t})):Promise.resolve(e.next(t))}catch(e){return Promise.reject(e)}},d=function(e,t){try{var r=e.Global;return Promise.resolve(e.next(t)).then(function(t){return r.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,r.withDevTools&&v.config.devtools.enable&&!r.devTools&&(r.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,r.devTools.connect()),r.withDevTools&&c.devtools.enable&&r.devTools.send("u"===e.type&&e.disableSelectorUpdate?"store["+e.modelName+"].update":e.modelName+"_"+e.actionName,r.mutableState[e.modelName],void 0,e.modelName),t})}catch(e){return Promise.reject(e)}},p=function(e,t){try{var r=e.modelName,n=e.next,o=e.Global,i=e.disableSelectorUpdate;return o.Setter.classSetter&&o.Setter.classSetter(o.State),o.Setter.functionSetter[r]&&Object.keys(o.Setter.functionSetter[r]).map(function(e){var t=o.Setter.functionSetter[r][e];if(t)if(!t.selector||i)t.setState(o.State[r]);else{var n=t.selector(o.State[r]);x(n,t.selectorRef)||(t.selectorRef=n,t.setState(o.State[r]))}}),Promise.resolve(n(t))}catch(e){return Promise.reject(e)}},b=[s,S,d,u,l,f,p,m],v={communicator:p,consoleDebugger:S,devToolsListener:d,getNewState:u,getNewStateWithCache:function(e){return void 0===e&&(e=5e3),function(t,r){try{var n=t.Global,o=t.modelName,i=t.next,a=t.actionName;return Promise.resolve(Promise.race([(0,t.action)(t.params,{actions:(0,t.consumerActions)(n.Actions[o],{modelName:o}),state:n.State[o]}),E(e,j(o,a))])).then(function(e){return t.newState=e||null,Promise.resolve(i(r))})}catch(e){return Promise.reject(e)}}},setNewState:l,stateUpdater:f,subscription:m,tryCatch:s,config:c},_=function(e,t){try{return t.next=function(e){return e.length>0?e[0](t,e.slice(1)):t.newState},Promise.resolve(e[0](t,e.slice(1)))}catch(e){return Promise.reject(e)}},h=n.createContext({}),y=h.Consumer;if(!console.group){var g=[],P="-".repeat(80);console.group=function(e){g.push(e),console.log("%c \nBEGIN GROUP: %c",P,e),console.groupEnd=function(){console.log("END GROUP: %c\n%c",g.pop(),P)}}}var w=function(e,t){var r={};return Object.keys(e).forEach(function(n){r[n]=function(e,t){return function(r,n){try{return Promise.resolve(_(b,{Global:a,action:e,actionName:e.name,consumerActions:w,middlewareConfig:n,modelName:t.modelName,newState:null,params:r,type:"o"}))}catch(e){return Promise.reject(e)}}}(e[n],t)}),r},N=function(e,t){if("function"==typeof t){var n=a.State[e];n=r(n,t),a.State=r(a.State,function(t){t[e]=n})}else a.State=r(a.State,function(r){r[e]=o({},r[e],t)});return a.State},E=function(e,t){return new Promise(function(r){return setTimeout(function(){console.log(e),r(t)},e)})},O=function(e,t){try{var n={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(a.State).map(function(i){try{var c=t&&t.prefix||"",s=function(){if(!e||!e.modelName||i===c+e.modelName||-1!==e.modelName.indexOf(c+i)){var s=function(e){t&&t.isServer?n[i]=e:a.State=r(a.State,function(t){t[i]=o({},t[i],e)})},u=a.AsyncState[i];return u?Promise.resolve(u(e)).then(s):s({})}}();return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}))).then(function(){return t&&t.isServer?n:a.State})}catch(e){return Promise.reject(e)}},j=function(e,t){var r=localStorage.getItem("__REACT_MODELX__"+e+"_"+t);return r?JSON.parse(r):null},x=function(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(t,r[o])||e[r[o]]!==t[r[o]])return!1;return!0};t.enableES5();var A="undefined"==typeof window?n.useEffect:n.useLayoutEffect,R=function(e,t){C(e,t,void 0)},C=function(e,t,r){Array.isArray(t)?t.forEach(function(t){a.subscriptions[e+"_"+t]||(a.subscriptions[e+"_"+t]=[]),r?a.subscriptions[e+"_"+t].push(r):a.subscriptions[e+"_"+t]=[]}):(a.subscriptions[e+"_"+t]||(a.subscriptions[e+"_"+t]=[]),r?a.subscriptions[e+"_"+t].push(r):a.subscriptions[e+"_"+t]=[])},T=function(e){return a.State[e]},I=function(e,t){void 0===t&&(t={type:"o"});var r={};return Object.keys(a.Actions[e]).forEach(function(n){return r[n]=function(r,i){try{var c=o({action:a.Actions[e][n],actionName:n,consumerActions:w,middlewareConfig:i,modelName:e,newState:null,params:r},t,{Global:a});return Promise.resolve(_(a.Middlewares[e]?a.Middlewares[e]:b,c))}catch(e){return Promise.reject(e)}}}),r},M=function(e,t){var r,o=n.useState({})[1],i=n.useRef(""),c=(r=[e],function(e){return r.reduce(function(e,t){return e&&e[t]?e[t]:null},e)})(a.mutableState),s=!!c,u=s?c.selector:t,l=s?c:T(e);if(A(function(){a.uid+=1;var t=""+a.uid;return i.current=t,a.Setter.functionSetter[e]||(a.Setter.functionSetter[e]={}),a.Setter.functionSetter[e][t]={setState:o,selector:u},function(){delete a.Setter.functionSetter[e][t]}},[]),s)return u(l);var f=I(e,{__hash:i.current,type:"f"});return[u?u(l):l,f]},G=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).state=a.State,t}return i(t,e),t.prototype.render=function(){var e=this.props.children;return a.Setter.classSetter=this.setState.bind(this),n.createElement(h.Provider,{value:o({},this.state)},e)},t}(n.PureComponent);exports.Consumer=y,exports.Model=function(e,t,n){if(void 0!==e.state){a.storeId+=1;var i="__"+a.storeId;a.State=r(a.State,function(t){t[i]=e.state}),e.middlewares&&(a.Middlewares[i]=e.middlewares),a.Actions[i]=e.actions,a.AsyncState[i]=e.asyncState,t&&(a.Context[i]=t);var c=I(i);return{__id:i,actions:c,getState:function(){return T(i)},subscribe:function(e,t){return C(i,e,t)},unsubscribe:function(e){return R(i,e)},useStore:function(e){return M(i,e)}}}t?a.gid=1:a.gid+=1;var s="";if(a.gid>1&&(s=a.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);var u=function(e){return function(){return e}};return{__ERROR__:!0,actions:u({}),getActions:u({}),getInitialState:u({}),getState:u({}),subscribe:u(),unsubscribe:u(),useStore:u([{},{}])}}t&&!t.__FROM_SERVER__&&(a.State=r(a.State,function(e){Object.assign(e,t||{})})),n&&(a.Context.__global=n);var l={};return Object.keys(e).forEach(function(n){var i=s+n,c=e[n];if(c.__ERROR__)return console.error(i+" model's schema is invalid"),a.State=r(a.State,function(e){e[i]={}}),void(a.Actions[i]={});void 0===c.useStore?(t&&t.__FROM_SERVER__?a.State=r(a.State,function(e){e[i]=o({},c.state,t[i])}):a.State[i]||(a.State=r(a.State,function(e){e[i]=c.state})),c.middlewares&&(a.Middlewares[i]=c.middlewares),a.Actions[i]=c.actions,a.AsyncState[i]=c.asyncState):(a.State[i]&&t||(a.State=r(a.State,function(e){e[i]=e[c.__id]})),t&&t.__FROM_SERVER__&&(a.State=r(a.State,function(e){e[i]=o({},e[c.__id],t[i])})),a.Actions[i]=a.Actions[c.__id],a.AsyncState[i]=a.AsyncState[c.__id],a.Middlewares[i]=a.Middlewares[c.__id],a.Context[i]=a.Context[c.__id]),l[n]=I(i)}),{actions:l,getActions:function(e){return I(s+e)},getInitialState:function(e,t){try{return Promise.resolve(O(e,o({},t,{prefix:s})))}catch(e){return Promise.reject(e)}},getState:function(e){return T(s+e)},subscribe:function(e,t,r){return C(s+e,t,r)},unsubscribe:function(e,t){return R(s+e,t)},useStore:function(e,t){return M(s+e,t)}}},exports.Provider=G,exports.actionMiddlewares=b,exports.connect=function(e,t,r){return function(c){return function(s){function u(){return s.apply(this,arguments)||this}return i(u,s),u.prototype.render=function(){var i=this,s=this.props,u=s.state,l=void 0===u?{}:u,f=s.actions,m=void 0===f?{}:f;return n.createElement(y,null,function(s){var u=s[""+e],f=a.Actions[e];return n.createElement(c,Object.assign({},i.props,{state:o({},l,t?t(u):u),actions:o({},m,r?r(w(f,{modelName:e})):w(f,{modelName:e}))}))})},u}(n.PureComponent)}},exports.createStore=function(e,t){var r="string"==typeof e;a.storeId+=r?0:1;var n=r?e:a.storeId.toString();a.Actions[n]||(a.Actions[n]={}),a.mutableState[n]||(a.mutableState[n]={count:0,cachedResult:void 0});var o=function(){return a.mutableState[n].count=0,a.currentStoreId=n,a.mutableState[n].cachedResult=t?t():e(),a.mutableState[n].cachedResult};return a.mutableState[n].selector=o,{useStore:function(){return M(n,o)},getState:function(){return o()},getStore:function(){return a.mutableState[n].cachedResult},subscribe:function(e){a.subscriptions[n]||(a.subscriptions[n]=[]),a.subscriptions[n].push(e)},unsubscribe:function(e){if(a.subscriptions[n]&&e){var t=a.subscriptions[n].indexOf(e);t>=0&&a.subscriptions[n].splice(t,1)}}}},exports.getInitialState=O,exports.getState=T,exports.middlewares=v,exports.useModel=function(e){var t=a.currentStoreId,n=a.mutableState[t].count;return a.mutableState[t].count+=1,a.mutableState[t].hasOwnProperty(n)||(a.mutableState[t][n]="function"==typeof e?e():e),[a.mutableState[t][n],function(e){try{return a.mutableState[t][n]="function"==typeof e?r(a.mutableState[t][n],e):a.mutableState[t][n]&&e&&"Object"===a.mutableState[t][n].constructor.name&&"Object"===e.constructor.name?o({},a.mutableState[t][n],e):e,Promise.resolve(_(b,{Global:a,action:function(){return"function"==typeof e?a.mutableState[t][n]:e},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:t,newState:{},params:void 0,type:"u"}))}catch(e){return Promise.reject(e)}}]};

@@ -1,1 +0,1 @@

import t,{enableES5 as e}from"immer";import{createContext as o,useContext as n,useState as a,useRef as s,PureComponent as r,createElement as c,useEffect as i,useLayoutEffect as l}from"react";var u={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1};const S={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},d=async(t,e)=>{const{next:o}=t;return S.tryCatch.enable?await o(e).catch(t=>console.log(t)):await o(e)},m=async(t,e)=>{const{action:o,modelName:n,consumerActions:a,params:s,next:r,Global:c,type:i}=t;return t.newState="u"===i?o():await o(s,{actions:a(c.Actions[n],{modelName:n}),state:c.State[n],...c.Context.__global||{},...c.Context[n]||{}})||null,await r(e)},b=async(t,e)=>{const{modelName:o,newState:n,next:a,Global:s,disableSelectorUpdate:r,type:c}=t;if(s.Setter.functionSetter[o]&&!r&&Object.keys(s.Setter.functionSetter[o]).map(t=>{const e=s.Setter.functionSetter[o][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(s.State[o]))}),n||"u"===c)return v(o,n||{}),await a(e)},p=async(t,e)=>{const{modelName:o,next:n,Global:a,__hash:s}=t,r=a.Setter.functionSetter[o];return"f"===t.type&&s&&r&&r[s]&&r[s].setState&&r[s].setState(a.State[o]),await n(e)},f=async(t,e)=>{const{modelName:o,actionName:n,next:a,Global:s}=t,r="u"===t.type?s.subscriptions[o]:s.subscriptions[`${o}_${n}`];return r&&r.forEach(e=>{e(t)}),await a(e)},_=async(t,e)=>{const{Global:o}=t;if(!0===S.logger.enable||"function"==typeof S.logger.enable&&S.logger.enable(t)){console.group(`%c ${t.modelName} State Change %c ${(new Date).toLocaleTimeString()}`,"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",o.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params);const n=await t.next(e);return console.log("%c Next","color: #4CAF50; font-weight: bold",o.State[t.modelName]),console.groupEnd(),n}return await t.next(e)},w=async(t,e)=>{const{Global:o}=t,n=await t.next(e);return o.withDevTools&&S.devtools.enable&&o.devTools.send(`${t.modelName}_${t.actionName}`,o.State),n},y=async(t,e)=>{const{modelName:o,next:n,Global:a,disableSelectorUpdate:s,type:r}=t;return a.Setter.classSetter&&"u"!==r&&a.Setter.classSetter(a.State),a.Setter.functionSetter[o]&&Object.keys(a.Setter.functionSetter[o]).map(t=>{const e=a.Setter.functionSetter[o][t];if(e)if(!e.selector||s)e.setState(a.State[o]);else{const t=e.selector(a.State[o]);j(t,e.selectorRef)||(e.selectorRef=t,e.setState(a.State[o]))}}),await n(e)},g=[d,_,w,m,b,p,y,f],h={communicator:y,consoleDebugger:_,devToolsListener:w,getNewState:m,getNewStateWithCache:(t=5e3)=>async(e,o)=>{const{action:n,Global:a,modelName:s,consumerActions:r,params:c,next:i,actionName:l}=e;return e.newState=await Promise.race([n(c,{actions:r(a.Actions[s],{modelName:s}),state:a.State[s]}),R(t,$(s,l))])||null,await i(o)},setNewState:b,stateUpdater:p,subscription:f,tryCatch:d,config:S},N=async(t,e)=>(e.next=t=>t.length>0?t[0](e,t.slice(1)):e.newState,await t[0](e,t.slice(1))),O=o({}),A=O.Consumer;if(!console.group){const t=[],e="-".repeat(80);console.group=function(o){t.push(o),console.log("%c \nBEGIN GROUP: %c",e,o),console.groupEnd=function(){console.log("END GROUP: %c\n%c",t.pop(),e)}}}const E=(t,e)=>{const o={};return Object.keys(t).forEach(n=>{o[n]=((t,e)=>async(o,n)=>{const a={Global:u,action:t,actionName:t.name,consumerActions:E,middlewareConfig:n,modelName:e.modelName,newState:null,params:o,type:"o"};return await N(g,a)})(t[n],e)}),o},v=(e,o)=>{if("function"==typeof o){let n=u.State[e];n=t(n,o),u.State=t(u.State,t=>{t[e]=n})}else u.State=t(u.State,t=>{t[e]={...t[e],...o}});return u.State},R=(t,e)=>new Promise(o=>setTimeout(()=>{console.log(t),o(e)},t)),x=async(e,o)=>{const n={__FROM_SERVER__:!0};return await Promise.all(Object.keys(u.State).map(async a=>{let s=o&&o.prefix||"";if(!e||!e.modelName||a===s+e.modelName||-1!==e.modelName.indexOf(s+a)){const s=u.AsyncState[a],r=s?await s(e):{};o&&o.isServer?n[a]=r:u.State=t(u.State,t=>{t[a]={...t[a],...r}})}})),o&&o.isServer?n:u.State},$=(t,e)=>{const o=localStorage.getItem(`__REACT_MODELX__${t}_${e}`);return o?JSON.parse(o):null},j=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let n=0;n<o.length;n++)if(!Object.prototype.hasOwnProperty.call(e,o[n])||t[o[n]]!==e[o[n]])return!1;return!0};e();const C="undefined"==typeof window?i:l;function T(e){const o=u.currentStoreId,n=u.mutableState[o].count;return u.mutableState[o].count+=1,u.mutableState[o].hasOwnProperty(n)||(u.mutableState[o][n]="function"==typeof e?e():e),[u.mutableState[o][n],async e=>{u.mutableState[o][n]="function"==typeof e?t(u.mutableState[o][n],e):u.mutableState[o][n]&&e&&"Object"===u.mutableState[o][n].constructor.name&&"Object"===e.constructor.name?{...u.mutableState[o][n],...e}:e;const a={Global:u,action:()=>"function"==typeof e?u.mutableState[o][n]:e,actionName:"setter",consumerActions:E,disableSelectorUpdate:!0,middlewareConfig:{},modelName:o,newState:{},params:void 0,type:"u"};return await N(g,a)}]}function G(e){const o=u.currentStoreId,a=u.mutableState[o].count;u.mutableState[o].count+=1;const s=n(O);return u.mutableState[o].hasOwnProperty(a)||(u.mutableState[o][a]="function"==typeof e?e():e),[void 0===s[o][a]?u.mutableState[o][a]:s[o][a],async e=>{const n={Global:u,action:()=>{u.Setter.classSetter&&u.Setter.classSetter("function"==typeof e?n=>{let s;return s=n[o].hasOwnProperty(a)?t(n[o][a],e):t(u.mutableState[o][a],e),t(n,t=>{t[o][a]=s})}:n=>t(n,n[o][a]&&e&&"Object"===n[o][a].constructor.name&&"Object"===e.constructor.name?t=>{t[o][a]={...t[o][a],...e}}:"Object"!==e.constructor.name||n[o][a]||"Object"!==u.mutableState[o][a].constructor.name?t=>{t[o][a]=e}:t=>{t[o][a]={...u.mutableState[o][a],...e}}))},actionName:"setter",consumerActions:E,disableSelectorUpdate:!0,middlewareConfig:{},modelName:o,newState:{},params:void 0,type:"u"};return await N(g,n)}]}function I(e,o){const n="string"==typeof e;u.storeId+=n?0:1;const a=n?e:u.storeId.toString();u.Actions[a]||(u.Actions[a]={}),u.mutableState[a]||(u.mutableState[a]={count:0}),u.State[a]||(u.State=t(u.State,t=>{t[a]={}}));const s=()=>(u.mutableState[a].count=0,u.currentStoreId=a,o?o():e());return u.mutableState[a].selector=s,{useStore:()=>F(a,s),getState:()=>s(),subscribe:t=>{u.subscriptions[a]||(u.subscriptions[a]=[]),u.subscriptions[a].push(t)},unsubscribe:t=>{if(u.subscriptions[a]&&t){const e=u.subscriptions[a].indexOf(t);e>=0&&u.subscriptions[a].splice(e,1)}}}}function D(e,o,n){if(void 0!==e.state){u.storeId+=1;const n="__"+u.storeId;u.State=t(u.State,t=>{t[n]=e.state}),e.middlewares&&(u.Middlewares[n]=e.middlewares),u.Actions[n]=e.actions,u.AsyncState[n]=e.asyncState,o&&(u.Context[n]=o);const a=U(n);return{__id:n,actions:a,getState:()=>k(n),subscribe:(t,e)=>P(n,t,e),unsubscribe:t=>M(n,t),useStore:t=>F(n,t)}}{o?u.gid=1:u.gid+=1;let a="";if(u.gid>1&&(a=u.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);const t=t=>(...e)=>t;return{__ERROR__:!0,actions:t({}),getActions:t({}),getInitialState:t({}),getState:t({}),subscribe:t(),unsubscribe:t(),useStore:t([{},{}])}}o&&!o.__FROM_SERVER__&&(u.State=t(u.State,t=>{Object.assign(t,o||{})})),n&&(u.Context.__global=n);let s={};return Object.keys(e).forEach(n=>{let r=a+n;const c=e[n];if(c.__ERROR__)return console.error(r+" model's schema is invalid"),u.State=t(u.State,t=>{t[r]={}}),void(u.Actions[r]={});(t=>void 0!==t.useStore)(c)?(u.State[r]&&o||(u.State=t(u.State,t=>{t[r]=t[c.__id]})),o&&o.__FROM_SERVER__&&(u.State=t(u.State,t=>{t[r]={...t[c.__id],...o[r]}})),u.Actions[r]=u.Actions[c.__id],u.AsyncState[r]=u.AsyncState[c.__id],u.Middlewares[r]=u.Middlewares[c.__id],u.Context[r]=u.Context[c.__id]):(o&&o.__FROM_SERVER__?u.State=t(u.State,t=>{t[r]={...c.state,...o[r]}}):u.State[r]||(u.State=t(u.State,t=>{t[r]=c.state})),c.middlewares&&(u.Middlewares[r]=c.middlewares),u.Actions[r]=c.actions,u.AsyncState[r]=c.asyncState),s[n]=U(r)}),u.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,u.withDevTools&&h.config.devtools.enable&&(u.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,u.devTools.connect()),{actions:s,getActions:t=>U(a+t),getInitialState:async(t,e)=>x(t,{...e,prefix:a}),getState:t=>k(a+t),subscribe:(t,e,o)=>P(a+t,e,o),unsubscribe:(t,e)=>M(a+t,e),useStore:(t,e)=>F(a+t,e)}}}const M=(t,e)=>{P(t,e,void 0)},P=(t,e,o)=>{Array.isArray(e)?e.forEach(e=>{u.subscriptions[`${t}_${e}`]||(u.subscriptions[`${t}_${e}`]=[]),o?u.subscriptions[`${t}_${e}`].push(o):u.subscriptions[`${t}_${e}`]=[]}):(u.subscriptions[`${t}_${e}`]||(u.subscriptions[`${t}_${e}`]=[]),o?u.subscriptions[`${t}_${e}`].push(o):u.subscriptions[`${t}_${e}`]=[])},k=t=>u.State[t],U=(t,e={type:"o"})=>{const o={};return Object.keys(u.Actions[t]).forEach(n=>o[n]=async(o,a)=>{const s={action:u.Actions[t][n],actionName:n,consumerActions:E,middlewareConfig:a,modelName:t,newState:null,params:o,...e,Global:u};return u.Middlewares[t]?await N(u.Middlewares[t],s):await N(g,s)}),o},F=(t,e)=>{const o=a({})[1],n=s(""),r=(c=[t],t=>c.reduce((t,e)=>t&&t[e]?t[e]:null,t))(u.mutableState);var c;const i=!!r,l=i?r.selector:e,S=i?r:k(t);if(C(()=>{u.uid+=1;const e=""+u.uid;return n.current=e,u.Setter.functionSetter[t]||(u.Setter.functionSetter[t]={}),u.Setter.functionSetter[t][e]={setState:o,selector:l},function(){delete u.Setter.functionSetter[t][e]}},[]),i)return l(S);{const e=U(t,{__hash:n.current,type:"f"});return[l?l(S):S,e]}};class V extends r{constructor(){super(...arguments),this.state=u.State}render(){const{children:t}=this.props;return u.Setter.classSetter=this.setState.bind(this),c(O.Provider,{value:{...this.state}},t)}}const L=(t,e,o)=>n=>class extends r{render(){const{state:a={},actions:s={}}=this.props;return c(A,null,r=>{const{[""+t]:i}=r,l=u.Actions[t];return c(n,Object.assign({},this.props,{state:{...a,...e?e(i):i},actions:{...s,...o?o(E(l,{modelName:t})):E(l,{modelName:t})}}))})}};export{A as Consumer,D as Model,V as Provider,g as actionMiddlewares,L as connect,I as createStore,x as getInitialState,k as getState,h as middlewares,G as useAtom,T as useModel};
import t,{enableES5 as e}from"immer";import{createContext as o,useState as a,useRef as n,PureComponent as s,createElement as c,useEffect as r,useLayoutEffect as i}from"react";var l={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1};const u={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},S=async(t,e)=>{const{next:o}=t;return u.tryCatch.enable?await o(e).catch(t=>console.log(t)):await o(e)},d=async(t,e)=>{const{action:o,modelName:a,consumerActions:n,params:s,next:c,Global:r,type:i}=t;return t.newState="u"===i?o():await o(s,{actions:n(r.Actions[a],{modelName:a}),state:r.State[a],...r.Context.__global||{},...r.Context[a]||{}})||null,await c(e)},m=async(t,e)=>{const{modelName:o,newState:a,next:n,Global:s,disableSelectorUpdate:c,type:r}=t;if(s.Setter.functionSetter[o]&&!c&&Object.keys(s.Setter.functionSetter[o]).map(t=>{const e=s.Setter.functionSetter[o][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(s.State[o]))}),a||"u"===r)return E(o,a||{}),await n(e)},b=async(t,e)=>{const{modelName:o,next:a,Global:n,__hash:s}=t,c=n.Setter.functionSetter[o];return"f"===t.type&&s&&c&&c[s]&&c[s].setState&&c[s].setState(n.State[o]),await a(e)},p=async(t,e)=>{const{modelName:o,actionName:a,next:n,Global:s}=t,c="u"===t.type?s.subscriptions[o]:s.subscriptions[`${o}_${a}`];return c&&c.forEach(e=>{e(t)}),await n(e)},_=async(t,e)=>{const{Global:o}=t;if(!0===u.logger.enable||"function"==typeof u.logger.enable&&u.logger.enable(t)){console.group(`%c ${t.modelName} State Change %c ${(new Date).toLocaleTimeString()}`,"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",o.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params);const a=await t.next(e);return console.log("%c Next","color: #4CAF50; font-weight: bold",o.State[t.modelName]),console.groupEnd(),a}return await t.next(e)},f=async(t,e)=>{const{Global:o}=t,a=await t.next(e);return o.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,o.withDevTools&&y.config.devtools.enable&&!o.devTools&&(o.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,o.devTools.connect()),o.withDevTools&&u.devtools.enable&&o.devTools.send("u"===t.type&&t.disableSelectorUpdate?`store[${t.modelName}].update`:`${t.modelName}_${t.actionName}`,o.mutableState[t.modelName],void 0,t.modelName),a},g=async(t,e)=>{const{modelName:o,next:a,Global:n,disableSelectorUpdate:s}=t;return n.Setter.classSetter&&n.Setter.classSetter(n.State),n.Setter.functionSetter[o]&&Object.keys(n.Setter.functionSetter[o]).map(t=>{const e=n.Setter.functionSetter[o][t];if(e)if(!e.selector||s)e.setState(n.State[o]);else{const t=e.selector(n.State[o]);$(t,e.selectorRef)||(e.selectorRef=t,e.setState(n.State[o]))}}),await a(e)},w=[S,_,f,d,m,b,g,p],y={communicator:g,consoleDebugger:_,devToolsListener:f,getNewState:d,getNewStateWithCache:(t=5e3)=>async(e,o)=>{const{action:a,Global:n,modelName:s,consumerActions:c,params:r,next:i,actionName:l}=e;return e.newState=await Promise.race([a(r,{actions:c(n.Actions[s],{modelName:s}),state:n.State[s]}),v(t,x(s,l))])||null,await i(o)},setNewState:m,stateUpdater:b,subscription:p,tryCatch:S,config:u},h=async(t,e)=>(e.next=t=>t.length>0?t[0](e,t.slice(1)):e.newState,await t[0](e,t.slice(1))),N=o({}),O=N.Consumer;if(!console.group){const t=[],e="-".repeat(80);console.group=function(o){t.push(o),console.log("%c \nBEGIN GROUP: %c",e,o),console.groupEnd=function(){console.log("END GROUP: %c\n%c",t.pop(),e)}}}const A=(t,e)=>{const o={};return Object.keys(t).forEach(a=>{o[a]=((t,e)=>async(o,a)=>{const n={Global:l,action:t,actionName:t.name,consumerActions:A,middlewareConfig:a,modelName:e.modelName,newState:null,params:o,type:"o"};return await h(w,n)})(t[a],e)}),o},E=(e,o)=>{if("function"==typeof o){let a=l.State[e];a=t(a,o),l.State=t(l.State,t=>{t[e]=a})}else l.State=t(l.State,t=>{t[e]={...t[e],...o}});return l.State},v=(t,e)=>new Promise(o=>setTimeout(()=>{console.log(t),o(e)},t)),R=async(e,o)=>{const a={__FROM_SERVER__:!0};return await Promise.all(Object.keys(l.State).map(async n=>{let s=o&&o.prefix||"";if(!e||!e.modelName||n===s+e.modelName||-1!==e.modelName.indexOf(s+n)){const s=l.AsyncState[n],c=s?await s(e):{};o&&o.isServer?a[n]=c:l.State=t(l.State,t=>{t[n]={...t[n],...c}})}})),o&&o.isServer?a:l.State},x=(t,e)=>{const o=localStorage.getItem(`__REACT_MODELX__${t}_${e}`);return o?JSON.parse(o):null},$=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const o=Object.keys(t),a=Object.keys(e);if(o.length!==a.length)return!1;for(let a=0;a<o.length;a++)if(!Object.prototype.hasOwnProperty.call(e,o[a])||t[o[a]]!==e[o[a]])return!1;return!0};e();const C="undefined"==typeof window?r:i;function T(e){const o=l.currentStoreId,a=l.mutableState[o].count;return l.mutableState[o].count+=1,l.mutableState[o].hasOwnProperty(a)||(l.mutableState[o][a]="function"==typeof e?e():e),[l.mutableState[o][a],async e=>{l.mutableState[o][a]="function"==typeof e?t(l.mutableState[o][a],e):l.mutableState[o][a]&&e&&"Object"===l.mutableState[o][a].constructor.name&&"Object"===e.constructor.name?{...l.mutableState[o][a],...e}:e;const n={Global:l,action:()=>"function"==typeof e?l.mutableState[o][a]:e,actionName:"setter",consumerActions:A,disableSelectorUpdate:!0,middlewareConfig:{},modelName:o,newState:{},params:void 0,type:"u"};return await h(w,n)}]}function j(t,e){const o="string"==typeof t;l.storeId+=o?0:1;const a=o?t:l.storeId.toString();l.Actions[a]||(l.Actions[a]={}),l.mutableState[a]||(l.mutableState[a]={count:0,cachedResult:void 0});const n=()=>(l.mutableState[a].count=0,l.currentStoreId=a,l.mutableState[a].cachedResult=e?e():t(),l.mutableState[a].cachedResult);return l.mutableState[a].selector=n,{useStore:()=>P(a,n),getState:()=>n(),getStore:()=>l.mutableState[a].cachedResult,subscribe:t=>{l.subscriptions[a]||(l.subscriptions[a]=[]),l.subscriptions[a].push(t)},unsubscribe:t=>{if(l.subscriptions[a]&&t){const e=l.subscriptions[a].indexOf(t);e>=0&&l.subscriptions[a].splice(e,1)}}}}function G(e,o,a){if(void 0!==e.state){l.storeId+=1;const a="__"+l.storeId;l.State=t(l.State,t=>{t[a]=e.state}),e.middlewares&&(l.Middlewares[a]=e.middlewares),l.Actions[a]=e.actions,l.AsyncState[a]=e.asyncState,o&&(l.Context[a]=o);const n=k(a);return{__id:a,actions:n,getState:()=>M(a),subscribe:(t,e)=>D(a,t,e),unsubscribe:t=>I(a,t),useStore:t=>P(a,t)}}{o?l.gid=1:l.gid+=1;let n="";if(l.gid>1&&(n=l.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);const t=t=>(...e)=>t;return{__ERROR__:!0,actions:t({}),getActions:t({}),getInitialState:t({}),getState:t({}),subscribe:t(),unsubscribe:t(),useStore:t([{},{}])}}o&&!o.__FROM_SERVER__&&(l.State=t(l.State,t=>{Object.assign(t,o||{})})),a&&(l.Context.__global=a);let s={};return Object.keys(e).forEach(a=>{let c=n+a;const r=e[a];if(r.__ERROR__)return console.error(c+" model's schema is invalid"),l.State=t(l.State,t=>{t[c]={}}),void(l.Actions[c]={});(t=>void 0!==t.useStore)(r)?(l.State[c]&&o||(l.State=t(l.State,t=>{t[c]=t[r.__id]})),o&&o.__FROM_SERVER__&&(l.State=t(l.State,t=>{t[c]={...t[r.__id],...o[c]}})),l.Actions[c]=l.Actions[r.__id],l.AsyncState[c]=l.AsyncState[r.__id],l.Middlewares[c]=l.Middlewares[r.__id],l.Context[c]=l.Context[r.__id]):(o&&o.__FROM_SERVER__?l.State=t(l.State,t=>{t[c]={...r.state,...o[c]}}):l.State[c]||(l.State=t(l.State,t=>{t[c]=r.state})),r.middlewares&&(l.Middlewares[c]=r.middlewares),l.Actions[c]=r.actions,l.AsyncState[c]=r.asyncState),s[a]=k(c)}),{actions:s,getActions:t=>k(n+t),getInitialState:async(t,e)=>R(t,{...e,prefix:n}),getState:t=>M(n+t),subscribe:(t,e,o)=>D(n+t,e,o),unsubscribe:(t,e)=>I(n+t,e),useStore:(t,e)=>P(n+t,e)}}}const I=(t,e)=>{D(t,e,void 0)},D=(t,e,o)=>{Array.isArray(e)?e.forEach(e=>{l.subscriptions[`${t}_${e}`]||(l.subscriptions[`${t}_${e}`]=[]),o?l.subscriptions[`${t}_${e}`].push(o):l.subscriptions[`${t}_${e}`]=[]}):(l.subscriptions[`${t}_${e}`]||(l.subscriptions[`${t}_${e}`]=[]),o?l.subscriptions[`${t}_${e}`].push(o):l.subscriptions[`${t}_${e}`]=[])},M=t=>l.State[t],k=(t,e={type:"o"})=>{const o={};return Object.keys(l.Actions[t]).forEach(a=>o[a]=async(o,n)=>{const s={action:l.Actions[t][a],actionName:a,consumerActions:A,middlewareConfig:n,modelName:t,newState:null,params:o,...e,Global:l};return l.Middlewares[t]?await h(l.Middlewares[t],s):await h(w,s)}),o},P=(t,e)=>{const o=a({})[1],s=n(""),c=(r=[t],t=>r.reduce((t,e)=>t&&t[e]?t[e]:null,t))(l.mutableState);var r;const i=!!c,u=i?c.selector:e,S=i?c:M(t);if(C(()=>{l.uid+=1;const e=""+l.uid;return s.current=e,l.Setter.functionSetter[t]||(l.Setter.functionSetter[t]={}),l.Setter.functionSetter[t][e]={setState:o,selector:u},function(){delete l.Setter.functionSetter[t][e]}},[]),i)return u(S);{const e=k(t,{__hash:s.current,type:"f"});return[u?u(S):S,e]}};class U extends s{constructor(){super(...arguments),this.state=l.State}render(){const{children:t}=this.props;return l.Setter.classSetter=this.setState.bind(this),c(N.Provider,{value:{...this.state}},t)}}const F=(t,e,o)=>a=>class extends s{render(){const{state:n={},actions:s={}}=this.props;return c(O,null,r=>{const{[""+t]:i}=r,u=l.Actions[t];return c(a,Object.assign({},this.props,{state:{...n,...e?e(i):i},actions:{...s,...o?o(A(u,{modelName:t})):A(u,{modelName:t})}}))})}};export{O as Consumer,G as Model,U as Provider,w as actionMiddlewares,F as connect,j as createStore,R as getInitialState,M as getState,y as middlewares,T as useModel};

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("immer"),require("react")):"function"==typeof define&&define.amd?define(["exports","immer","react"],e):e((t=t||self).reactModel={},t.immer,t.react)}(this,function(t,e,n){var r="default"in e?e.default:e;function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function i(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var c={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},a={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},u=function(t,e){try{var n=t.next;return Promise.resolve(a.tryCatch.enable?n(e).catch(function(t){return console.log(t)}):n(e))}catch(t){return Promise.reject(t)}},s=function(t,e){try{var n=function(){return Promise.resolve(u(e))},r=t.action,i=t.modelName,c=t.consumerActions,a=t.params,u=t.next,s=t.Global,l=t.type,f=function(){if("u"!==l)return Promise.resolve(r(a,o({actions:c(s.Actions[i],{modelName:i}),state:s.State[i]},s.Context.__global||{},s.Context[i]||{}))).then(function(e){t.newState=e||null});t.newState=r()}();return Promise.resolve(f&&f.then?f.then(n):n())}catch(t){return Promise.reject(t)}},l=function(t,e){try{var n=t.modelName,r=t.newState,o=t.next,i=t.Global,c=t.type;return i.Setter.functionSetter[n]&&!t.disableSelectorUpdate&&Object.keys(i.Setter.functionSetter[n]).map(function(t){var e=i.Setter.functionSetter[n][t];e&&e.selector&&!e.selectorRef&&(e.selectorRef=e.selector(i.State[n]))}),Promise.resolve(function(){if(r||"u"===c)return O(n,r||{}),Promise.resolve(o(e))}())}catch(t){return Promise.reject(t)}},f=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i=t.__hash,c=o.Setter.functionSetter[n];return"f"===t.type&&i&&c&&c[i]&&c[i].setState&&c[i].setState(o.State[n]),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},m=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i="u"===t.type?o.subscriptions[n]:o.subscriptions[n+"_"+t.actionName];return i&&i.forEach(function(e){e(t)}),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},S=function(t,e){try{var n=t.Global;return!0===a.logger.enable||"function"==typeof a.logger.enable&&a.logger.enable(t)?(console.group("%c "+t.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",n.State[t.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",t.actionName,"payload: "+t.params),Promise.resolve(t.next(e)).then(function(e){return console.log("%c Next","color: #4CAF50; font-weight: bold",n.State[t.modelName]),console.groupEnd(),e})):Promise.resolve(t.next(e))}catch(t){return Promise.reject(t)}},d=function(t,e){try{var n=t.Global;return Promise.resolve(t.next(e)).then(function(e){return n.withDevTools&&a.devtools.enable&&n.devTools.send(t.modelName+"_"+t.actionName,n.State),e})}catch(t){return Promise.reject(t)}},b=function(t,e){try{var n=t.modelName,r=t.next,o=t.Global,i=t.disableSelectorUpdate;return o.Setter.classSetter&&"u"!==t.type&&o.Setter.classSetter(o.State),o.Setter.functionSetter[n]&&Object.keys(o.Setter.functionSetter[n]).map(function(t){var e=o.Setter.functionSetter[n][t];if(e)if(!e.selector||i)e.setState(o.State[n]);else{var r=e.selector(o.State[n]);A(r,e.selectorRef)||(e.selectorRef=r,e.setState(o.State[n]))}}),Promise.resolve(r(e))}catch(t){return Promise.reject(t)}},p=[u,S,d,s,l,f,b,m],v={communicator:b,consoleDebugger:S,devToolsListener:d,getNewState:s,getNewStateWithCache:function(t){return void 0===t&&(t=5e3),function(e,n){try{var r=e.Global,o=e.modelName,i=e.next,c=e.actionName;return Promise.resolve(Promise.race([(0,e.action)(e.params,{actions:(0,e.consumerActions)(r.Actions[o],{modelName:o}),state:r.State[o]}),N(t,E(o,c))])).then(function(t){return e.newState=t||null,Promise.resolve(i(n))})}catch(t){return Promise.reject(t)}}},setNewState:l,stateUpdater:f,subscription:m,tryCatch:u,config:a},_=function(t,e){try{return e.next=function(t){return t.length>0?t[0](e,t.slice(1)):e.newState},Promise.resolve(t[0](e,t.slice(1)))}catch(t){return Promise.reject(t)}},h=n.createContext({}),y=h.Consumer;if(!console.group){var g=[],P="-".repeat(80);console.group=function(t){g.push(t),console.log("%c \nBEGIN GROUP: %c",P,t),console.groupEnd=function(){console.log("END GROUP: %c\n%c",g.pop(),P)}}}var w=function(t,e){var n={};return Object.keys(t).forEach(function(r){n[r]=function(t,e){return function(n,r){try{return Promise.resolve(_(p,{Global:c,action:t,actionName:t.name,consumerActions:w,middlewareConfig:r,modelName:e.modelName,newState:null,params:n,type:"o"}))}catch(t){return Promise.reject(t)}}}(t[r],e)}),n},O=function(t,e){if("function"==typeof e){var n=c.State[t];n=r(n,e),c.State=r(c.State,function(e){e[t]=n})}else c.State=r(c.State,function(n){n[t]=o({},n[t],e)});return c.State},N=function(t,e){return new Promise(function(n){return setTimeout(function(){console.log(t),n(e)},t)})},j=function(t,e){try{var n={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(c.State).map(function(i){try{var a=e&&e.prefix||"",u=function(){if(!t||!t.modelName||i===a+t.modelName||-1!==t.modelName.indexOf(a+i)){var u=function(t){e&&e.isServer?n[i]=t:c.State=r(c.State,function(e){e[i]=o({},e[i],t)})},s=c.AsyncState[i];return s?Promise.resolve(s(t)).then(u):u({})}}();return Promise.resolve(u&&u.then?u.then(function(){}):void 0)}catch(t){return Promise.reject(t)}}))).then(function(){return e&&e.isServer?n:c.State})}catch(t){return Promise.reject(t)}},E=function(t,e){var n=localStorage.getItem("__REACT_MODELX__"+t+"_"+e);return n?JSON.parse(n):null},A=function(t,e){if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(e,n[o])||t[n[o]]!==e[n[o]])return!1;return!0};e.enableES5();var x="undefined"==typeof window?n.useEffect:n.useLayoutEffect,R=function(t,e){C(t,e,void 0)},C=function(t,e,n){Array.isArray(e)?e.forEach(function(e){c.subscriptions[t+"_"+e]||(c.subscriptions[t+"_"+e]=[]),n?c.subscriptions[t+"_"+e].push(n):c.subscriptions[t+"_"+e]=[]}):(c.subscriptions[t+"_"+e]||(c.subscriptions[t+"_"+e]=[]),n?c.subscriptions[t+"_"+e].push(n):c.subscriptions[t+"_"+e]=[])},I=function(t){return c.State[t]},M=function(t,e){void 0===e&&(e={type:"o"});var n={};return Object.keys(c.Actions[t]).forEach(function(r){return n[r]=function(n,i){try{var a=o({action:c.Actions[t][r],actionName:r,consumerActions:w,middlewareConfig:i,modelName:t,newState:null,params:n},e,{Global:c});return Promise.resolve(_(c.Middlewares[t]?c.Middlewares[t]:p,a))}catch(t){return Promise.reject(t)}}}),n},T=function(t,e){var r,o=n.useState({})[1],i=n.useRef(""),a=(r=[t],function(t){return r.reduce(function(t,e){return t&&t[e]?t[e]:null},t)})(c.mutableState),u=!!a,s=u?a.selector:e,l=u?a:I(t);if(x(function(){c.uid+=1;var e=""+c.uid;return i.current=e,c.Setter.functionSetter[t]||(c.Setter.functionSetter[t]={}),c.Setter.functionSetter[t][e]={setState:o,selector:s},function(){delete c.Setter.functionSetter[t][e]}},[]),u)return s(l);var f=M(t,{__hash:i.current,type:"f"});return[s?s(l):l,f]},G=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).state=c.State,e}return i(e,t),e.prototype.render=function(){var t=this.props.children;return c.Setter.classSetter=this.setState.bind(this),n.createElement(h.Provider,{value:o({},this.state)},t)},e}(n.PureComponent);t.Consumer=y,t.Model=function(t,e,n){if(void 0!==t.state){c.storeId+=1;var i="__"+c.storeId;c.State=r(c.State,function(e){e[i]=t.state}),t.middlewares&&(c.Middlewares[i]=t.middlewares),c.Actions[i]=t.actions,c.AsyncState[i]=t.asyncState,e&&(c.Context[i]=e);var a=M(i);return{__id:i,actions:a,getState:function(){return I(i)},subscribe:function(t,e){return C(i,t,e)},unsubscribe:function(t){return R(i,t)},useStore:function(t){return T(i,t)}}}e?c.gid=1:c.gid+=1;var u="";if(c.gid>1&&(u=c.gid+"_"),t.actions){console.error("invalid model(s) schema: ",t);var s=function(t){return function(){return t}};return{__ERROR__:!0,actions:s({}),getActions:s({}),getInitialState:s({}),getState:s({}),subscribe:s(),unsubscribe:s(),useStore:s([{},{}])}}e&&!e.__FROM_SERVER__&&(c.State=r(c.State,function(t){Object.assign(t,e||{})})),n&&(c.Context.__global=n);var l={};return Object.keys(t).forEach(function(n){var i=u+n,a=t[n];if(a.__ERROR__)return console.error(i+" model's schema is invalid"),c.State=r(c.State,function(t){t[i]={}}),void(c.Actions[i]={});void 0===a.useStore?(e&&e.__FROM_SERVER__?c.State=r(c.State,function(t){t[i]=o({},a.state,e[i])}):c.State[i]||(c.State=r(c.State,function(t){t[i]=a.state})),a.middlewares&&(c.Middlewares[i]=a.middlewares),c.Actions[i]=a.actions,c.AsyncState[i]=a.asyncState):(c.State[i]&&e||(c.State=r(c.State,function(t){t[i]=t[a.__id]})),e&&e.__FROM_SERVER__&&(c.State=r(c.State,function(t){t[i]=o({},t[a.__id],e[i])})),c.Actions[i]=c.Actions[a.__id],c.AsyncState[i]=c.AsyncState[a.__id],c.Middlewares[i]=c.Middlewares[a.__id],c.Context[i]=c.Context[a.__id]),l[n]=M(i)}),c.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,c.withDevTools&&v.config.devtools.enable&&(c.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,c.devTools.connect()),{actions:l,getActions:function(t){return M(u+t)},getInitialState:function(t,e){try{return Promise.resolve(j(t,o({},e,{prefix:u})))}catch(t){return Promise.reject(t)}},getState:function(t){return I(u+t)},subscribe:function(t,e,n){return C(u+t,e,n)},unsubscribe:function(t,e){return R(u+t,e)},useStore:function(t,e){return T(u+t,e)}}},t.Provider=G,t.actionMiddlewares=p,t.connect=function(t,e,r){return function(a){return function(u){function s(){return u.apply(this,arguments)||this}return i(s,u),s.prototype.render=function(){var i=this,u=this.props,s=u.state,l=void 0===s?{}:s,f=u.actions,m=void 0===f?{}:f;return n.createElement(y,null,function(u){var s=u[""+t],f=c.Actions[t];return n.createElement(a,Object.assign({},i.props,{state:o({},l,e?e(s):s),actions:o({},m,r?r(w(f,{modelName:t})):w(f,{modelName:t}))}))})},s}(n.PureComponent)}},t.createStore=function(t,e){var n="string"==typeof t;c.storeId+=n?0:1;var o=n?t:c.storeId.toString();c.Actions[o]||(c.Actions[o]={}),c.mutableState[o]||(c.mutableState[o]={count:0}),c.State[o]||(c.State=r(c.State,function(t){t[o]={}}));var i=function(){return c.mutableState[o].count=0,c.currentStoreId=o,e?e():t()};return c.mutableState[o].selector=i,{useStore:function(){return T(o,i)},getState:function(){return i()},subscribe:function(t){c.subscriptions[o]||(c.subscriptions[o]=[]),c.subscriptions[o].push(t)},unsubscribe:function(t){if(c.subscriptions[o]&&t){var e=c.subscriptions[o].indexOf(t);e>=0&&c.subscriptions[o].splice(e,1)}}}},t.getInitialState=j,t.getState=I,t.middlewares=v,t.useAtom=function(t){var e=c.currentStoreId,i=c.mutableState[e].count;c.mutableState[e].count+=1;var a=n.useContext(h);return c.mutableState[e].hasOwnProperty(i)||(c.mutableState[e][i]="function"==typeof t?t():t),[void 0===a[e][i]?c.mutableState[e][i]:a[e][i],function(t){try{return Promise.resolve(_(p,{Global:c,action:function(){c.Setter.classSetter&&c.Setter.classSetter("function"==typeof t?function(n){var o;return o=n[e].hasOwnProperty(i)?r(n[e][i],t):r(c.mutableState[e][i],t),r(n,function(t){t[e][i]=o})}:function(n){return r(n,n[e][i]&&t&&"Object"===n[e][i].constructor.name&&"Object"===t.constructor.name?function(n){n[e][i]=o({},n[e][i],t)}:"Object"!==t.constructor.name||n[e][i]||"Object"!==c.mutableState[e][i].constructor.name?function(n){n[e][i]=t}:function(n){n[e][i]=o({},c.mutableState[e][i],t)})})},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:e,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]},t.useModel=function(t){var e=c.currentStoreId,n=c.mutableState[e].count;return c.mutableState[e].count+=1,c.mutableState[e].hasOwnProperty(n)||(c.mutableState[e][n]="function"==typeof t?t():t),[c.mutableState[e][n],function(t){try{return c.mutableState[e][n]="function"==typeof t?r(c.mutableState[e][n],t):c.mutableState[e][n]&&t&&"Object"===c.mutableState[e][n].constructor.name&&"Object"===t.constructor.name?o({},c.mutableState[e][n],t):t,Promise.resolve(_(p,{Global:c,action:function(){return"function"==typeof t?c.mutableState[e][n]:t},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:e,newState:{},params:void 0,type:"u"}))}catch(t){return Promise.reject(t)}}]}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("immer"),require("react")):"function"==typeof define&&define.amd?define(["exports","immer","react"],t):t((e=e||self).reactModel={},e.immer,e.react)}(this,function(e,t,n){var r="default"in t?t.default:t;function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var a={Actions:{},AsyncState:{},Context:{__global:{}},Middlewares:{},Setter:{classSetter:void 0,functionSetter:{}},State:{},devTools:void 0,subscriptions:{},mutableState:{},gid:0,uid:0,storeId:0,currentStoreId:"0",withDevTools:!1},c={logger:{enable:!1},devtools:{enable:!1},tryCatch:{enable:!0}},s=function(e,t){try{var n=e.next;return Promise.resolve(c.tryCatch.enable?n(t).catch(function(e){return console.log(e)}):n(t))}catch(e){return Promise.reject(e)}},u=function(e,t){try{var n=function(){return Promise.resolve(s(t))},r=e.action,i=e.modelName,a=e.consumerActions,c=e.params,s=e.next,u=e.Global,l=e.type,f=function(){if("u"!==l)return Promise.resolve(r(c,o({actions:a(u.Actions[i],{modelName:i}),state:u.State[i]},u.Context.__global||{},u.Context[i]||{}))).then(function(t){e.newState=t||null});e.newState=r()}();return Promise.resolve(f&&f.then?f.then(n):n())}catch(e){return Promise.reject(e)}},l=function(e,t){try{var n=e.modelName,r=e.newState,o=e.next,i=e.Global,a=e.type;return i.Setter.functionSetter[n]&&!e.disableSelectorUpdate&&Object.keys(i.Setter.functionSetter[n]).map(function(e){var t=i.Setter.functionSetter[n][e];t&&t.selector&&!t.selectorRef&&(t.selectorRef=t.selector(i.State[n]))}),Promise.resolve(function(){if(r||"u"===a)return N(n,r||{}),Promise.resolve(o(t))}())}catch(e){return Promise.reject(e)}},f=function(e,t){try{var n=e.modelName,r=e.next,o=e.Global,i=e.__hash,a=o.Setter.functionSetter[n];return"f"===e.type&&i&&a&&a[i]&&a[i].setState&&a[i].setState(o.State[n]),Promise.resolve(r(t))}catch(e){return Promise.reject(e)}},m=function(e,t){try{var n=e.modelName,r=e.next,o=e.Global,i="u"===e.type?o.subscriptions[n]:o.subscriptions[n+"_"+e.actionName];return i&&i.forEach(function(t){t(e)}),Promise.resolve(r(t))}catch(e){return Promise.reject(e)}},d=function(e,t){try{var n=e.Global;return!0===c.logger.enable||"function"==typeof c.logger.enable&&c.logger.enable(e)?(console.group("%c "+e.modelName+" State Change %c "+(new Date).toLocaleTimeString(),"color: gray; font-weight: lighter;","color: black; font-weight: bold;"),console.log("%c Previous","color: #9E9E9E; font-weight: bold",n.State[e.modelName]),console.log("%c Action","color: #03A9F4; font-weight: bold",e.actionName,"payload: "+e.params),Promise.resolve(e.next(t)).then(function(t){return console.log("%c Next","color: #4CAF50; font-weight: bold",n.State[e.modelName]),console.groupEnd(),t})):Promise.resolve(e.next(t))}catch(e){return Promise.reject(e)}},S=function(e,t){try{var n=e.Global;return Promise.resolve(e.next(t)).then(function(t){return n.withDevTools="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__,n.withDevTools&&v.config.devtools.enable&&!n.devTools&&(n.devTools=window.__REDUX_DEVTOOLS_EXTENSION__,n.devTools.connect()),n.withDevTools&&c.devtools.enable&&n.devTools.send("u"===e.type&&e.disableSelectorUpdate?"store["+e.modelName+"].update":e.modelName+"_"+e.actionName,n.mutableState[e.modelName],void 0,e.modelName),t})}catch(e){return Promise.reject(e)}},b=function(e,t){try{var n=e.modelName,r=e.next,o=e.Global,i=e.disableSelectorUpdate;return o.Setter.classSetter&&o.Setter.classSetter(o.State),o.Setter.functionSetter[n]&&Object.keys(o.Setter.functionSetter[n]).map(function(e){var t=o.Setter.functionSetter[n][e];if(t)if(!t.selector||i)t.setState(o.State[n]);else{var r=t.selector(o.State[n]);A(r,t.selectorRef)||(t.selectorRef=r,t.setState(o.State[n]))}}),Promise.resolve(r(t))}catch(e){return Promise.reject(e)}},p=[s,d,S,u,l,f,b,m],v={communicator:b,consoleDebugger:d,devToolsListener:S,getNewState:u,getNewStateWithCache:function(e){return void 0===e&&(e=5e3),function(t,n){try{var r=t.Global,o=t.modelName,i=t.next,a=t.actionName;return Promise.resolve(Promise.race([(0,t.action)(t.params,{actions:(0,t.consumerActions)(r.Actions[o],{modelName:o}),state:r.State[o]}),E(e,j(o,a))])).then(function(e){return t.newState=e||null,Promise.resolve(i(n))})}catch(e){return Promise.reject(e)}}},setNewState:l,stateUpdater:f,subscription:m,tryCatch:s,config:c},_=function(e,t){try{return t.next=function(e){return e.length>0?e[0](t,e.slice(1)):t.newState},Promise.resolve(e[0](t,e.slice(1)))}catch(e){return Promise.reject(e)}},h=n.createContext({}),y=h.Consumer;if(!console.group){var g=[],P="-".repeat(80);console.group=function(e){g.push(e),console.log("%c \nBEGIN GROUP: %c",P,e),console.groupEnd=function(){console.log("END GROUP: %c\n%c",g.pop(),P)}}}var w=function(e,t){var n={};return Object.keys(e).forEach(function(r){n[r]=function(e,t){return function(n,r){try{return Promise.resolve(_(p,{Global:a,action:e,actionName:e.name,consumerActions:w,middlewareConfig:r,modelName:t.modelName,newState:null,params:n,type:"o"}))}catch(e){return Promise.reject(e)}}}(e[r],t)}),n},N=function(e,t){if("function"==typeof t){var n=a.State[e];n=r(n,t),a.State=r(a.State,function(t){t[e]=n})}else a.State=r(a.State,function(n){n[e]=o({},n[e],t)});return a.State},E=function(e,t){return new Promise(function(n){return setTimeout(function(){console.log(e),n(t)},e)})},O=function(e,t){try{var n={__FROM_SERVER__:!0};return Promise.resolve(Promise.all(Object.keys(a.State).map(function(i){try{var c=t&&t.prefix||"",s=function(){if(!e||!e.modelName||i===c+e.modelName||-1!==e.modelName.indexOf(c+i)){var s=function(e){t&&t.isServer?n[i]=e:a.State=r(a.State,function(t){t[i]=o({},t[i],e)})},u=a.AsyncState[i];return u?Promise.resolve(u(e)).then(s):s({})}}();return Promise.resolve(s&&s.then?s.then(function(){}):void 0)}catch(e){return Promise.reject(e)}}))).then(function(){return t&&t.isServer?n:a.State})}catch(e){return Promise.reject(e)}},j=function(e,t){var n=localStorage.getItem("__REACT_MODELX__"+e+"_"+t);return n?JSON.parse(n):null},A=function(e,t){if(e===t)return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(var o=0;o<n.length;o++)if(!Object.prototype.hasOwnProperty.call(t,n[o])||e[n[o]]!==t[n[o]])return!1;return!0};t.enableES5();var R="undefined"==typeof window?n.useEffect:n.useLayoutEffect,x=function(e,t){C(e,t,void 0)},C=function(e,t,n){Array.isArray(t)?t.forEach(function(t){a.subscriptions[e+"_"+t]||(a.subscriptions[e+"_"+t]=[]),n?a.subscriptions[e+"_"+t].push(n):a.subscriptions[e+"_"+t]=[]}):(a.subscriptions[e+"_"+t]||(a.subscriptions[e+"_"+t]=[]),n?a.subscriptions[e+"_"+t].push(n):a.subscriptions[e+"_"+t]=[])},T=function(e){return a.State[e]},M=function(e,t){void 0===t&&(t={type:"o"});var n={};return Object.keys(a.Actions[e]).forEach(function(r){return n[r]=function(n,i){try{var c=o({action:a.Actions[e][r],actionName:r,consumerActions:w,middlewareConfig:i,modelName:e,newState:null,params:n},t,{Global:a});return Promise.resolve(_(a.Middlewares[e]?a.Middlewares[e]:p,c))}catch(e){return Promise.reject(e)}}}),n},I=function(e,t){var r,o=n.useState({})[1],i=n.useRef(""),c=(r=[e],function(e){return r.reduce(function(e,t){return e&&e[t]?e[t]:null},e)})(a.mutableState),s=!!c,u=s?c.selector:t,l=s?c:T(e);if(R(function(){a.uid+=1;var t=""+a.uid;return i.current=t,a.Setter.functionSetter[e]||(a.Setter.functionSetter[e]={}),a.Setter.functionSetter[e][t]={setState:o,selector:u},function(){delete a.Setter.functionSetter[e][t]}},[]),s)return u(l);var f=M(e,{__hash:i.current,type:"f"});return[u?u(l):l,f]},G=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).state=a.State,t}return i(t,e),t.prototype.render=function(){var e=this.props.children;return a.Setter.classSetter=this.setState.bind(this),n.createElement(h.Provider,{value:o({},this.state)},e)},t}(n.PureComponent);e.Consumer=y,e.Model=function(e,t,n){if(void 0!==e.state){a.storeId+=1;var i="__"+a.storeId;a.State=r(a.State,function(t){t[i]=e.state}),e.middlewares&&(a.Middlewares[i]=e.middlewares),a.Actions[i]=e.actions,a.AsyncState[i]=e.asyncState,t&&(a.Context[i]=t);var c=M(i);return{__id:i,actions:c,getState:function(){return T(i)},subscribe:function(e,t){return C(i,e,t)},unsubscribe:function(e){return x(i,e)},useStore:function(e){return I(i,e)}}}t?a.gid=1:a.gid+=1;var s="";if(a.gid>1&&(s=a.gid+"_"),e.actions){console.error("invalid model(s) schema: ",e);var u=function(e){return function(){return e}};return{__ERROR__:!0,actions:u({}),getActions:u({}),getInitialState:u({}),getState:u({}),subscribe:u(),unsubscribe:u(),useStore:u([{},{}])}}t&&!t.__FROM_SERVER__&&(a.State=r(a.State,function(e){Object.assign(e,t||{})})),n&&(a.Context.__global=n);var l={};return Object.keys(e).forEach(function(n){var i=s+n,c=e[n];if(c.__ERROR__)return console.error(i+" model's schema is invalid"),a.State=r(a.State,function(e){e[i]={}}),void(a.Actions[i]={});void 0===c.useStore?(t&&t.__FROM_SERVER__?a.State=r(a.State,function(e){e[i]=o({},c.state,t[i])}):a.State[i]||(a.State=r(a.State,function(e){e[i]=c.state})),c.middlewares&&(a.Middlewares[i]=c.middlewares),a.Actions[i]=c.actions,a.AsyncState[i]=c.asyncState):(a.State[i]&&t||(a.State=r(a.State,function(e){e[i]=e[c.__id]})),t&&t.__FROM_SERVER__&&(a.State=r(a.State,function(e){e[i]=o({},e[c.__id],t[i])})),a.Actions[i]=a.Actions[c.__id],a.AsyncState[i]=a.AsyncState[c.__id],a.Middlewares[i]=a.Middlewares[c.__id],a.Context[i]=a.Context[c.__id]),l[n]=M(i)}),{actions:l,getActions:function(e){return M(s+e)},getInitialState:function(e,t){try{return Promise.resolve(O(e,o({},t,{prefix:s})))}catch(e){return Promise.reject(e)}},getState:function(e){return T(s+e)},subscribe:function(e,t,n){return C(s+e,t,n)},unsubscribe:function(e,t){return x(s+e,t)},useStore:function(e,t){return I(s+e,t)}}},e.Provider=G,e.actionMiddlewares=p,e.connect=function(e,t,r){return function(c){return function(s){function u(){return s.apply(this,arguments)||this}return i(u,s),u.prototype.render=function(){var i=this,s=this.props,u=s.state,l=void 0===u?{}:u,f=s.actions,m=void 0===f?{}:f;return n.createElement(y,null,function(s){var u=s[""+e],f=a.Actions[e];return n.createElement(c,Object.assign({},i.props,{state:o({},l,t?t(u):u),actions:o({},m,r?r(w(f,{modelName:e})):w(f,{modelName:e}))}))})},u}(n.PureComponent)}},e.createStore=function(e,t){var n="string"==typeof e;a.storeId+=n?0:1;var r=n?e:a.storeId.toString();a.Actions[r]||(a.Actions[r]={}),a.mutableState[r]||(a.mutableState[r]={count:0,cachedResult:void 0});var o=function(){return a.mutableState[r].count=0,a.currentStoreId=r,a.mutableState[r].cachedResult=t?t():e(),a.mutableState[r].cachedResult};return a.mutableState[r].selector=o,{useStore:function(){return I(r,o)},getState:function(){return o()},getStore:function(){return a.mutableState[r].cachedResult},subscribe:function(e){a.subscriptions[r]||(a.subscriptions[r]=[]),a.subscriptions[r].push(e)},unsubscribe:function(e){if(a.subscriptions[r]&&e){var t=a.subscriptions[r].indexOf(e);t>=0&&a.subscriptions[r].splice(t,1)}}}},e.getInitialState=O,e.getState=T,e.middlewares=v,e.useModel=function(e){var t=a.currentStoreId,n=a.mutableState[t].count;return a.mutableState[t].count+=1,a.mutableState[t].hasOwnProperty(n)||(a.mutableState[t][n]="function"==typeof e?e():e),[a.mutableState[t][n],function(e){try{return a.mutableState[t][n]="function"==typeof e?r(a.mutableState[t][n],e):a.mutableState[t][n]&&e&&"Object"===a.mutableState[t][n].constructor.name&&"Object"===e.constructor.name?o({},a.mutableState[t][n],e):e,Promise.resolve(_(p,{Global:a,action:function(){return"function"==typeof e?a.mutableState[t][n]:e},actionName:"setter",consumerActions:w,disableSelectorUpdate:!0,middlewareConfig:{},modelName:t,newState:{},params:void 0,type:"u"}))}catch(e){return Promise.reject(e)}}]}});
{
"name": "react-model",
"version": "4.3.0-alpha.0",
"version": "4.3.0-alpha.1",
"description": "The State management library for React",

@@ -5,0 +5,0 @@ "main": "./dist/react-model.js",

@@ -29,3 +29,3 @@ # react-model &middot; ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg) [![npm version](https://img.shields.io/npm/v/react-model.svg?style=flat)](https://www.npmjs.com/package/react-model) [![minified size](https://badgen.net/bundlephobia/min/react)](https://bundlephobia.com/result?p=react-model) [![Build Status](https://travis-ci.org/byte-fe/react-model.svg?branch=master)](https://travis-ci.org/byte-fe/react-model) [![size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js?compression=gzip)](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/react-model/dist/react-model.js) [![downloads](https://img.shields.io/npm/dt/react-model.svg)](https://www.npmjs.com/package/react-model) [![Coverage Status](https://codecov.io/gh/byte-fe/react-model/branch/master/graph/badge.svg)](https://codecov.io/gh/byte-fe/react-model) [![Greenkeeper badge](https://badges.greenkeeper.io/byte-fe/react-model.svg)](https://greenkeeper.io/) ![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)

// Model Register
const { useStore } = createStore(Todo)
const { useStore } = createStore(useTodo)

@@ -32,0 +32,0 @@ const App = () => {

@@ -160,2 +160,3 @@ type Setter = {

getState: () => S
getStore: () => S | undefined
subscribe: (callback: () => void) => void

@@ -162,0 +163,0 @@ unsubscribe: (callback: () => void) => void

@@ -171,6 +171,23 @@ import { getCache, setPartialState, timeout, shallowEqual } from './helper'

const ret = await context.next(restMiddlewares)
Global.withDevTools =
typeof window !== 'undefined' &&
(window as any).__REDUX_DEVTOOLS_EXTENSION__
if (
Global.withDevTools &&
middlewares.config.devtools.enable &&
!Global.devTools
) {
Global.devTools = (window as any).__REDUX_DEVTOOLS_EXTENSION__
Global.devTools.connect()
}
if (Global.withDevTools && config.devtools.enable) {
const actionName =
context.type === 'u' && context.disableSelectorUpdate
? `store[${context.modelName}].update`
: `${context.modelName}_${context.actionName}`
Global.devTools.send(
`${context.modelName}_${context.actionName}`,
Global.State
actionName,
Global.mutableState[context.modelName],
undefined,
context.modelName
)

@@ -182,4 +199,4 @@ }

const communicator: Middleware = async (context, restMiddlewares) => {
const { modelName, next, Global, disableSelectorUpdate, type } = context
if (Global.Setter.classSetter && type !== 'u') {
const { modelName, next, Global, disableSelectorUpdate } = context
if (Global.Setter.classSetter) {
Global.Setter.classSetter(Global.State)

@@ -186,0 +203,0 @@ }

Sorry, the diff of this file is not supported yet

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