react-hooks-global-states 7.0.14 → 7.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/GlobalStore.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("react")):"function"==typeof define&&define.amd?define(["./generateStackHash.js","./isRecord.js","./shallowCompare.js","./throwWrongKeyOnActionCollectionConfig.js","./uniqueId.js","./uniqueSymbol.js","react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("react")):t["react-hooks-global-states"]=e(t["./generateStackHash.js"],t["./isRecord.js"],t["./shallowCompare.js"],t["./throwWrongKeyOnActionCollectionConfig.js"],t["./uniqueId.js"],t["./uniqueSymbol.js"],t.react)}(this,((t,e,r,n,i,o,a)=>(()=>{var s={244:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isFunction=void 0,e.isFunction=function(t){return"function"==typeof t||t instanceof Function}})(),t})()},125:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isNil=void 0,e.isNil=function(t){return null==t}})(),t})()},281:function(t){t.exports=(()=>{"use strict";var t={};return(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:!0}),e.isString=void 0,e.isString=function(t){return"string"==typeof t}})(),t})()},109:e=>{"use strict";e.exports=t},664:t=>{"use strict";t.exports=e},682:t=>{"use strict";t.exports=r},286:t=>{"use strict";t.exports=n},865:t=>{"use strict";t.exports=i},69:t=>{"use strict";t.exports=o},156:t=>{"use strict";t.exports=a}},u={};function c(t){var e=u[t];if(void 0!==e)return e.exports;var r=u[t]={exports:{}};return s[t].call(r.exports,r,r.exports,c),r.exports}var l={};return(()=>{"use strict";var t=l;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||n(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function o(){o=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),s=new C(n||[]);return i(a,"_invoke",{value:E(t,r,s)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var d={};function h(){}function v(){}function b(){}var g={};l(g,s,(function(){return this}));var y=Object.getPrototypeOf,S=y&&y(y(k([])));S&&S!==r&&n.call(S,s)&&(g=S);var m=b.prototype=h.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function o(i,a,s,u){var c=p(t[i],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){o("next",t,s,u)}),(function(t){o("throw",t,s,u)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return o("throw",t,s,u)}))}u(c.arg)}var a;i(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){o(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function E(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return T()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=_(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function _(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,_(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var i=p(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function k(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=b,i(m,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:v,configurable:!0}),v.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,u,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new O(f(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),l(m,c,"Generator"),l(m,s,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var s=n.call(o,"catchLoc"),u=n.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===e(r)?r:String(r)}var u=function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{u(n.next(t))}catch(t){o(t)}}function s(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var f=c(156),p=c(244),d=c(125),h=c(281),v=c(664),b=c(682),g=c(286),y=c(865),S=c(69),m=c(109),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,d.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var i,a=this,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return u(a,void 0,void 0,o().mark((function t(){var e,r,n,i,a,s;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,i=null!==(r=this.callbacks)&&void 0!==r?r:{},a=i.onInit,n||a){t.next=6;break}return t.abrupt("return");case 6:s=this.getConfigCallbackParam(),null==n||n(s),(0,d.isNil)(a)||null==a||a(s);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,n,i=t.selector,o=t.callback,s=t.currentState,u=t.config;if(!e.forceUpdate&&(null!==(r=null==u?void 0:u.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(n=null==u?void 0:u.isEqual)&&void 0!==n?n:function(t,e){return t===e})(s,c)?{didUpdate:!1}:(a.partialUpdateSubscription(t.subscriptionId,{currentState:c}),o({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,i=e.forceUpdate,o=e.identifier,s=a.stateWrapper.state;if(i||s!==r){a.stateWrapper={state:r};var u,c={forceUpdate:i,newRootState:r,currentRootState:s,identifier:o},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}(a.subscribers.values());try{for(l.s();!(u=l.n()).done;){var f=u.value;a.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,p.isFunction)(t)?t(a.metadata):t;a.metadata=e},this.getMetadata=function(){return a.metadata},this.getState=function(t,e,r){var n;if(!t)return a.stateWrapper.state;var i=(0,p.isFunction)(e),o=i?t:void 0,s=i?e:t,u=null!==(n=i?r:e)&&void 0!==n?n:void 0,c=o?o(a.stateWrapper.state):a.stateWrapper.state;(null==u?void 0:u.skipFirst)||s(c);var l=(0,y.uniqueId)("gs:");return a.setOrUpdateSubscription({subscriptionId:l,selector:o,config:u,currentState:c,callback:function(t){var e=t.state;return s(e)},isSetStateCallback:!1}),function(){a.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=a.setMetadata,e=a.getMetadata,r=a.getState,n=a.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:a.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=a.subscribers.get(e);return(0,v.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(a.executeOnSubscribed(),a.subscribers.set(e,t),a.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=a.subscribers.get(t);(0,v.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=a.onSubscribed,r=null===(t=a.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var n=a.getConfigCallbackParam();null==e||e(n),null==r||r(n)}},this.getHook=function(){var t=function(t){var e,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(a.wasDisposed)throw new Error("The global state was disposed");var o=Array.isArray(i)?{dependencies:i}:null!=i?i:{},s=(0,f.useRef)({subscriptionId:null,tempInitialRootState:a.stateWrapper.state}),u=function(){return t?{state:t(a.stateWrapper.state)}:a.stateWrapper},c=r((0,f.useState)(u),2),l=c[0],p=c[1];(0,f.useEffect)((function(){if(!(0,d.isNil)(s.current)){(0,d.isNil)(s.current.subscriptionId)&&(s.current.subscriptionId=(0,y.uniqueId)("ss:"));var e=s.current.subscriptionId,r={subscriptionId:e,currentState:l.state,selector:t,config:o,callback:p,isSetStateCallback:!0};return a.setOrUpdateSubscription(r).isNewSubscription&&(a.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:a.stateWrapper.state,currentRootState:s.current.tempInitialRootState===S.uniqueSymbol?a.stateWrapper.state:s.current.tempInitialRootState,identifier:"on mount state update"}),s.current.tempInitialRootState=S.uniqueSymbol),function(){a.subscribers.delete(e)}}}),[]);var v=(0,h.isString)(null===(e=s.current)||void 0===e?void 0:e.subscriptionId)?s.current.subscriptionId:"",b=a.subscribers.get(v),g=(null!==(n=null==b?void 0:b.config)&&void 0!==n?n:{dependencies:o.dependencies}).dependencies;return a.partialUpdateSubscription(v,{currentState:l.state,selector:t,config:o,callback:p}),[a.computeSelectedState({selector:t,subscriptionId:v,config:o,currentDependencies:g,computeChildState:u,stateWrapperRef:l}),a.getStateOrchestrator(),a.metadata]};return t.stateControls=a.stateControls,t.createSelectorHook=a.createSelectorHook,t.createObservable=a.createObservable,t.removeSubscriptions=a.removeSubscriptions,t.dispose=a.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,n=t.config,i=t.currentDependencies,o=t.computeChildState,s=t.stateWrapperRef;if(!e||!r)return s.state;var u=n.dependencies;if(i===u)return s.state;if((null==i?void 0:i.length)===(null==u?void 0:u.length)&&(0,b.shallowCompare)(i,u))return s.state;var c=o().state;return a.partialUpdateSubscription(r,{currentState:c}),s.state=c,c},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isEqualRoot,o=n.isEqual,s=n.name,u=r(a.stateControls(),3),c=u[0],l=u[1],f=u[2],d=c(),h=(null!=e?e:function(t){return t})(d),v=new t(h,{name:null!=s?s:(0,y.uniqueId)("sh:")}),b=r(v.stateControls(),2),g=b[0],S=b[1],m=c((function(t){if(!(null!=i?i:Object.is)(d,t)){d=t;var r=e(t);(null!=o?o:Object.is)(h,r)||(h=r,S(r))}}),{skipFirst:!0}),w=v.getHook(),O=function(t,e){return[r((0,p.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[g,l,f]},O.createSelectorHook=a.createSelectorHook.bind(O),O.createObservable=a.createObservable.bind(O),O.removeSubscriptions=function(){m(),v.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),v.dispose()},O},this.stateControls=function(){var t=a.getStateOrchestrator(),e=a.getMetadata;return[a.getState,t,e]},this.getStateOrchestrator=function(){return a.actions?a.actions:a.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.forceUpdate,o=n.identifier,s=a.stateWrapper.state,u=(0,p.isFunction)(t)?t(s):t;if(i||a.stateWrapper.state!==u){var c=a.setMetadata,l=a.getMetadata,f=a.getState,d=a.actions,h={setMetadata:c,getMetadata:l,setState:a.setState,getState:f,actions:d,previousState:s,state:u,identifier:o},v=a.computePreventStateChange,b=null===(e=a.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(v||b)if((null==v?void 0:v(h))||(null==b?void 0:b(h)))return;a.setState({state:u},{forceUpdate:i,identifier:o});var g=a.onStateChanged,y=null===(r=a.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(h),null==y||y(h))}},this.getStoreActionsMap=function(){if(!(0,v.isRecord)(a.actionsConfig))return null;var t=a.actionsConfig,e=a.setMetadata,r=a.setStateWrapper,n=a.getState,i=a.getMetadata,o=Object.keys(t).reduce((function(a,u){var c,l,f;return Object.assign(a,(c={},f=function(){for(var a=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=a.apply(o,c);return"function"!=typeof f&&(0,g.throwWrongKeyOnActionCollectionConfig)(u),f.call(o,{setState:r,getState:n,setMetadata:e,getMetadata:i,actions:o})},(l=s(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),a}),{});return o},this.removeSubscriptions=function(){a.subscribers.clear()},this.dispose=function(){a.wasDisposed=!0,a.removeSubscriptions(),a._name="",a.actionsConfig=null,a.callbacks=null,a.metadata={},a.actions=null,a.subscribers.clear(),a.stateWrapper={state:null}};var l=c.metadata,O=c.callbacks,E=c.actions,_=c.name;this.stateWrapper={state:e},this._name=null!=_?_:(0,y.uniqueId)("gs:"),this.metadata=null!=l?l:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=E?E:null;var j="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(j=(0,m.generateStackHash)(null!==(i=(new Error).stack)&&void 0!==i?i:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,c,j);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var x=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,C=void 0!==globalThis.WeakRef?new globalThis.WeakRef(c):c;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(j,[x,C])}this.constructor!==t||this.initialize()}var e,i,c;return e=t,i=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,i=e.isEqual,o=e.name,a=r(this.stateControls(),1)[0],s=[],u=a(),c=(null!=t?t:function(t){return t})(a()),l=a((function(e){if(!(null!=n?n:Object.is)(u,e)){u=e;var r=t(e);(null!=i?i:Object.is)(c,r)||(c=r,s.forEach((function(t){return t()})))}}),{skipFirst:!0}),f=function(t,e,r){var n;if(!t)return c;var i=(0,p.isFunction)(e),o=i?t:void 0,a=i?e:t,u=null!==(n=i?r:e)&&void 0!==n?n:void 0,l=function(){return a(o?o(c):c)};(null==u?void 0:u.skipFirst)||l();var f=function(){l()};return s.push(f),function(){s.splice(s.indexOf(f),1)}};return f._name=null!=o?o:(0,y.uniqueId)("ob:"),f.createObservable=this.createObservable.bind(f),f.removeSubscriptions=function(){s.forEach((function(t){return t()})),s.length=0,l()},f.stateControls=function(){return[f]},f}}],i&&a(e.prototype,i),c&&a(e,c),Object.defineProperty(e,"prototype",{writable:!1}),t}();t.GlobalStore=O,t.default=O})(),l})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isString"),require("react")):"function"==typeof define&&define.amd?define(["./generateStackHash.js","./isRecord.js","./shallowCompare.js","./throwWrongKeyOnActionCollectionConfig.js","./uniqueId.js","./uniqueSymbol.js","json-storage-formatter/isFunction","json-storage-formatter/isNil","json-storage-formatter/isString","react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./generateStackHash.js"),require("./isRecord.js"),require("./shallowCompare.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./uniqueId.js"),require("./uniqueSymbol.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isString"),require("react")):t["react-hooks-global-states"]=e(t["./generateStackHash.js"],t["./isRecord.js"],t["./shallowCompare.js"],t["./throwWrongKeyOnActionCollectionConfig.js"],t["./uniqueId.js"],t["./uniqueSymbol.js"],t["json-storage-formatter/isFunction"],t["json-storage-formatter/isNil"],t["json-storage-formatter/isString"],t.react)}(this,((t,e,r,n,o,i,a,s,u,c)=>(()=>{"use strict";var l={109:e=>{e.exports=t},664:t=>{t.exports=e},682:t=>{t.exports=r},286:t=>{t.exports=n},865:t=>{t.exports=o},69:t=>{t.exports=i},122:t=>{t.exports=a},538:t=>{t.exports=s},582:t=>{t.exports=u},156:t=>{t.exports=c}},f={};function p(t){var e=f[t];if(void 0!==e)return e.exports;var r=f[t]={exports:{}};return l[t](r,r.exports,p),r.exports}var d={};return(()=>{var t=d;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||n(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(){i=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),s=new C(n||[]);return o(a,"_invoke",{value:j(t,r,s)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var d={};function h(){}function v(){}function b(){}var g={};l(g,s,(function(){return this}));var y=Object.getPrototypeOf,S=y&&y(y(k([])));S&&S!==r&&n.call(S,s)&&(g=S);var m=b.prototype=h.prototype=Object.create(g);function w(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,r){function i(o,a,s,u){var c=p(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){i("next",t,s,u)}),(function(t){i("throw",t,s,u)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return i("throw",t,s,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,e){function n(){return new r((function(r,n){i(t,e,r,n)}))}return a=a?a.then(n,n):n()}})}function j(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=E(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=p(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function k(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return v.prototype=b,o(m,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=l(b,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(O.prototype),l(O.prototype,u,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(m),l(m,c,"Generator"),l(m,s,(function(){return this})),l(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,s(n.key),n)}}function s(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,r||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"===e(r)?r:String(r)}var u=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var c=p(156),l=p(122),f=p(538),h=p(582),v=p(664),b=p(682),g=p(286),y=p(865),S=p(69),m=p(109),w=globalThis;!function(){if(!w.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,f.isNil)(w.sessionStorage)){try{if(!w.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}w.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){w.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var O=function(){function t(e){var o,a=this,p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return u(a,void 0,void 0,i().mark((function t(){var e,r,n,o,a,s;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},a=o.onInit,n||a){t.next=6;break}return t.abrupt("return");case 6:s=this.getConfigCallbackParam(),null==n||n(s),(0,f.isNil)(a)||null==a||a(s);case 9:case"end":return t.stop()}}),t,this)})))},this.executeSetStateForSubscriber=function(t,e){var r,n,o=t.selector,i=t.callback,s=t.currentState,u=t.config;if(!e.forceUpdate&&(null!==(r=null==u?void 0:u.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var c=o?o(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(n=null==u?void 0:u.isEqual)&&void 0!==n?n:function(t,e){return t===e})(s,c)?{didUpdate:!1}:(a.partialUpdateSubscription(t.subscriptionId,{currentState:c}),i({state:c},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,i=e.identifier,s=a.stateWrapper.state;if(o||s!==r){a.stateWrapper={state:r};var u,c={forceUpdate:o,newRootState:r,currentRootState:s,identifier:i},l=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function(){};return{s:i,n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){u=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(u)throw a}}}}(a.subscribers.values());try{for(l.s();!(u=l.n()).done;){var f=u.value;a.executeSetStateForSubscriber(f,c)}}catch(t){l.e(t)}finally{l.f()}}},this.setMetadata=function(t){var e=(0,l.isFunction)(t)?t(a.metadata):t;a.metadata=e},this.getMetadata=function(){return a.metadata},this.getState=function(t,e,r){var n;if(!t)return a.stateWrapper.state;var o=(0,l.isFunction)(e),i=o?t:void 0,s=o?e:t,u=null!==(n=o?r:e)&&void 0!==n?n:void 0,c=i?i(a.stateWrapper.state):a.stateWrapper.state;(null==u?void 0:u.skipFirst)||s(c);var f=(0,y.uniqueId)("gs:");return a.setOrUpdateSubscription({subscriptionId:f,selector:i,config:u,currentState:c,callback:function(t){var e=t.state;return s(e)},isSetStateCallback:!1}),function(){a.subscribers.delete(f)}},this.getConfigCallbackParam=function(){var t=a.setMetadata,e=a.getMetadata,r=a.getState,n=a.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:a.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=a.subscribers.get(e);return(0,v.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(a.executeOnSubscribed(),a.subscribers.set(e,t),a.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=a.subscribers.get(t);(0,v.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=a.onSubscribed,r=null===(t=a.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var n=a.getConfigCallbackParam();null==e||e(n),null==r||r(n)}},this.getHook=function(){var t=function(t){var e,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(a.wasDisposed)throw new Error("The global state was disposed");var i=Array.isArray(o)?{dependencies:o}:null!=o?o:{},s=(0,c.useRef)({subscriptionId:null,tempInitialRootState:a.stateWrapper.state}),u=function(){return t?{state:t(a.stateWrapper.state)}:a.stateWrapper},l=r((0,c.useState)(u),2),p=l[0],d=l[1];(0,c.useEffect)((function(){if(!(0,f.isNil)(s.current)){(0,f.isNil)(s.current.subscriptionId)&&(s.current.subscriptionId=(0,y.uniqueId)("ss:"));var e=s.current.subscriptionId,r={subscriptionId:e,currentState:p.state,selector:t,config:i,callback:d,isSetStateCallback:!0};return a.setOrUpdateSubscription(r).isNewSubscription&&(a.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:a.stateWrapper.state,currentRootState:s.current.tempInitialRootState===S.uniqueSymbol?a.stateWrapper.state:s.current.tempInitialRootState,identifier:"on mount state update"}),s.current.tempInitialRootState=S.uniqueSymbol),function(){a.subscribers.delete(e)}}}),[]);var v=(0,h.isString)(null===(e=s.current)||void 0===e?void 0:e.subscriptionId)?s.current.subscriptionId:"",b=a.subscribers.get(v),g=(null!==(n=null==b?void 0:b.config)&&void 0!==n?n:{dependencies:i.dependencies}).dependencies;return a.partialUpdateSubscription(v,{currentState:p.state,selector:t,config:i,callback:d}),[a.computeSelectedState({selector:t,subscriptionId:v,config:i,currentDependencies:g,computeChildState:u,stateWrapperRef:p}),a.getStateOrchestrator(),a.metadata]};return t.stateControls=a.stateControls,t.createSelectorHook=a.createSelectorHook,t.createObservable=a.createObservable,t.removeSubscriptions=a.removeSubscriptions,t.dispose=a.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,n=t.config,o=t.currentDependencies,i=t.computeChildState,s=t.stateWrapperRef;if(!e||!r)return s.state;var u=n.dependencies;if(o===u)return s.state;if((null==o?void 0:o.length)===(null==u?void 0:u.length)&&(0,b.shallowCompare)(o,u))return s.state;var c=i().state;return a.partialUpdateSubscription(r,{currentState:c}),s.state=c,c},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.isEqualRoot,i=n.isEqual,s=n.name,u=r(a.stateControls(),3),c=u[0],f=u[1],p=u[2],d=c(),h=(null!=e?e:function(t){return t})(d),v=new t(h,{name:null!=s?s:(0,y.uniqueId)("sh:")}),b=r(v.stateControls(),2),g=b[0],S=b[1],m=c((function(t){if(!(null!=o?o:Object.is)(d,t)){d=t;var r=e(t);(null!=i?i:Object.is)(h,r)||(h=r,S(r))}}),{skipFirst:!0}),w=v.getHook(),O=function(t,e){return[r((0,l.isFunction)(t)?w(t,e):w(),1)[0],f,p]};return O.stateControls=function(){return[g,f,p]},O.createSelectorHook=a.createSelectorHook.bind(O),O.createObservable=a.createObservable.bind(O),O.removeSubscriptions=function(){m(),v.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),v.dispose()},O},this.stateControls=function(){var t=a.getStateOrchestrator(),e=a.getMetadata;return[a.getState,t,e]},this.getStateOrchestrator=function(){return a.actions?a.actions:a.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,s=a.stateWrapper.state,u=(0,l.isFunction)(t)?t(s):t;if(o||a.stateWrapper.state!==u){var c=a.setMetadata,f=a.getMetadata,p=a.getState,d=a.actions,h={setMetadata:c,getMetadata:f,setState:a.setState,getState:p,actions:d,previousState:s,state:u,identifier:i},v=a.computePreventStateChange,b=null===(e=a.callbacks)||void 0===e?void 0:e.computePreventStateChange;if(v||b)if((null==v?void 0:v(h))||(null==b?void 0:b(h)))return;a.setState({state:u},{forceUpdate:o,identifier:i});var g=a.onStateChanged,y=null===(r=a.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(h),null==y||y(h))}},this.getStoreActionsMap=function(){if(!(0,v.isRecord)(a.actionsConfig))return null;var t=a.actionsConfig,e=a.setMetadata,r=a.setStateWrapper,n=a.getState,o=a.getMetadata,i=Object.keys(t).reduce((function(a,u){var c,l,f;return Object.assign(a,(c={},f=function(){for(var a=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=a.apply(i,c);return"function"!=typeof f&&(0,g.throwWrongKeyOnActionCollectionConfig)(u),f.call(i,{setState:r,getState:n,setMetadata:e,getMetadata:o,actions:i})},(l=s(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),a}),{});return i},this.removeSubscriptions=function(){a.subscribers.clear()},this.dispose=function(){a.wasDisposed=!0,a.removeSubscriptions(),a._name="",a.actionsConfig=null,a.callbacks=null,a.metadata={},a.actions=null,a.subscribers.clear(),a.stateWrapper={state:null}};var d=p.metadata,O=p.callbacks,j=p.actions,E=p.name;this.stateWrapper={state:e},this._name=null!=E?E:(0,y.uniqueId)("gs:"),this.metadata=null!=d?d:{},this.callbacks=null!=O?O:null,this.actionsConfig=null!=j?j:null;var _="";if((w.REACT_GLOBAL_STATE_HOOK_DEBUG||w.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(_=(0,m.generateStackHash)(null!==(o=(new Error).stack)&&void 0!==o?o:"")),w.REACT_GLOBAL_STATE_HOOK_DEBUG)w.REACT_GLOBAL_STATE_HOOK_DEBUG(this,p,_);else if(w.REACT_GLOBAL_STATE_TEMP_HOOKS){var x=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,C=void 0!==globalThis.WeakRef?new globalThis.WeakRef(p):p;w.REACT_GLOBAL_STATE_TEMP_HOOKS.set(_,[x,C])}this.constructor!==t||this.initialize()}var e,o,p;return e=t,o=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,o=e.isEqual,i=e.name,a=r(this.stateControls(),1)[0],s=[],u=a(),c=(null!=t?t:function(t){return t})(a()),f=a((function(e){if(!(null!=n?n:Object.is)(u,e)){u=e;var r=t(e);(null!=o?o:Object.is)(c,r)||(c=r,s.forEach((function(t){return t()})))}}),{skipFirst:!0}),p=function(t,e,r){var n;if(!t)return c;var o=(0,l.isFunction)(e),i=o?t:void 0,a=o?e:t,u=null!==(n=o?r:e)&&void 0!==n?n:void 0,f=function(){return a(i?i(c):c)};(null==u?void 0:u.skipFirst)||f();var p=function(){f()};return s.push(p),function(){s.splice(s.indexOf(p),1)}};return p._name=null!=i?i:(0,y.uniqueId)("ob:"),p.createObservable=this.createObservable.bind(p),p.removeSubscriptions=function(){s.forEach((function(t){return t()})),s.length=0,f()},p.stateControls=function(){return[p]},p}}],o&&a(e.prototype,o),p&&a(e,p),Object.defineProperty(e,"prototype",{writable:!1}),t}();t.GlobalStore=O,t.default=O})(),d})()));
package/createContext.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js"),require("./useStableState.js"),require("react")):"function"==typeof define&&define.amd?define(["./GlobalStore.js","./useStableState.js","react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js"),require("./useStableState.js"),require("react")):e["react-hooks-global-states"]=t(e["./GlobalStore.js"],e["./useStableState.js"],e.react)}(this,((e,t,r)=>{return o={564:(e,t,r)=>{"use strict";function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,u,a,i=[],l=!0,s=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;l=!1}else for(;!(l=(o=u.call(r)).done)&&(i.push(o.value),i.length!==t);l=!0);}catch(e){s=!0,n=e}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}Object.defineProperty(t,"__esModule",{value:!0}),t.createContext=void 0;var u=r(156),a=r(352),i=r(244),l=r(125),s=r(503);t.createContext=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,u.createContext)(null),n=function(){var e=(0,u.useContext)(r);if(!e)throw new Error("ContextHook must be used within a ContextProvider");return e()};n.createSelectorHook=function(e,t){return function(){var n=(0,u.useContext)(r);if((0,l.isNil)(n))throw new Error("SelectorHook must be used within a ContextProvider");return o((0,s.useStableState)((function(){return n.createSelectorHook(e,t)}),(function(e){return e.removeSubscriptions()}),[n]),1)[0].value.apply(void 0,arguments)}};var c=function(){var e=(0,u.useContext)(r);if((0,l.isNil)(e))throw new Error("useStateControls must be used within a ContextProvider");return e.stateControls()},f=function(e,t){var o=(0,u.useContext)(r);if((0,l.isNil)(o))throw new Error("useObservableBuilder must be used within a ContextProvider");return o.createObservable(e,t)};return n.stateControls=function(){return[c,f]},[n,function(n){var c=n.children,f=n.value,v=n.ref,d=o((0,s.useStableState)((function(){var r,o=function(){return(0,i.isFunction)(e)?e():e},n=(0,l.isNil)(f)?o():(0,i.isFunction)(f)?f(o()):f,u=new a.GlobalStore(n,Object.assign(Object.assign({},t),{metadata:null!==(r=(0,i.isFunction)(t.metadata)?t.metadata():t.metadata)&&void 0!==r?r:{}})),s=u.getHook();return{store:u,parentHook:s}}),(function(e){var t,r,o,n;e.store.dispose(),null===(r=null===(t=d.value.store.callbacks)||void 0===t?void 0:t.onUnMount)||void 0===r||r.call(t),null===(n=(o=d.value.store).__onUnMountContext)||void 0===n||n.call(o,d.value.store,d.value.parentHook)}),[]),1)[0];return(0,u.useImperativeHandle)(v,(function(){return v?d.value.store.getConfigCallbackParam():{}}),[d.value.store,v]),(0,u.createElement)(r.Provider,{value:d.value.parentHook},c)}]},t.default=t.createContext},244:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e||e instanceof Function}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},352:t=>{"use strict";t.exports=e},503:e=>{"use strict";e.exports=t},156:e=>{"use strict";e.exports=r}},n={},function e(t){var r=n[t];if(void 0!==r)return r.exports;var u=n[t]={exports:{}};return o[t].call(u.exports,u,u.exports,e),u.exports}(564);var o,n}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js"),require("./useStableState.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("react")):"function"==typeof define&&define.amd?define(["./GlobalStore.js","./useStableState.js","json-storage-formatter/isFunction","json-storage-formatter/isNil","react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js"),require("./useStableState.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("react")):e["react-hooks-global-states"]=t(e["./GlobalStore.js"],e["./useStableState.js"],e["json-storage-formatter/isFunction"],e["json-storage-formatter/isNil"],e.react)}(this,((e,t,r,o,n)=>(()=>{"use strict";var a={564:(e,t,r)=>{function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o,n,a,i,u=[],s=!0,l=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(o=a.call(r)).done)&&(u.push(o.value),u.length!==t);s=!0);}catch(e){l=!0,n=e}finally{try{if(!s&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw n}}return u}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}Object.defineProperty(t,"__esModule",{value:!0}),t.createContext=void 0;var a=r(156),i=r(352),u=r(122),s=r(538),l=r(503);t.createContext=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=(0,a.createContext)(null),n=function(){var e=(0,a.useContext)(r);if(!e)throw new Error("ContextHook must be used within a ContextProvider");return e()};n.createSelectorHook=function(e,t){return function(){var n=(0,a.useContext)(r);if((0,s.isNil)(n))throw new Error("SelectorHook must be used within a ContextProvider");return o((0,l.useStableState)((function(){return n.createSelectorHook(e,t)}),(function(e){return e.removeSubscriptions()}),[n]),1)[0].value.apply(void 0,arguments)}};var c=function(){var e=(0,a.useContext)(r);if((0,s.isNil)(e))throw new Error("useStateControls must be used within a ContextProvider");return e.stateControls()},f=function(e,t){var o=(0,a.useContext)(r);if((0,s.isNil)(o))throw new Error("useObservableBuilder must be used within a ContextProvider");return o.createObservable(e,t)};return n.stateControls=function(){return[c,f]},[n,function(n){var c=n.children,f=n.value,v=n.ref,d=o((0,l.useStableState)((function(){var r,o=function(){return(0,u.isFunction)(e)?e():e},n=(0,s.isNil)(f)?o():(0,u.isFunction)(f)?f(o()):f,a=new i.GlobalStore(n,Object.assign(Object.assign({},t),{metadata:null!==(r=(0,u.isFunction)(t.metadata)?t.metadata():t.metadata)&&void 0!==r?r:{}})),l=a.getHook();return{store:a,parentHook:l}}),(function(e){var t,r,o,n;e.store.dispose(),null===(r=null===(t=d.value.store.callbacks)||void 0===t?void 0:t.onUnMount)||void 0===r||r.call(t),null===(n=(o=d.value.store).__onUnMountContext)||void 0===n||n.call(o,d.value.store,d.value.parentHook)}),[]),1)[0];return(0,a.useImperativeHandle)(v,(function(){return v?d.value.store.getConfigCallbackParam():{}}),[d.value.store,v]),(0,a.createElement)(r.Provider,{value:d.value.parentHook},c)}]},t.default=t.createContext},352:t=>{t.exports=e},503:e=>{e.exports=t},122:e=>{e.exports=r},538:e=>{e.exports=o},156:e=>{e.exports=n}},i={};var u=function e(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return a[t](o,o.exports,e),o.exports}(564);return u})()));
package/isRecord.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-hooks-global-states"]=t():e["react-hooks-global-states"]=t()}(this,(()=>{return e={143:(e,t,o)=>{"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.isRecord=void 0;var n=o(125);t.isRecord=function(e){return!(0,n.isNil)(e)&&"object"===r(e)},t.default=t.isRecord},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()}},t={},function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,o),i.exports}(143);var e,t}));
1
+ !function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/isNil")):"function"==typeof define&&define.amd?define(["json-storage-formatter/isNil"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("json-storage-formatter/isNil")):o["react-hooks-global-states"]=t(o["json-storage-formatter/isNil"])}(this,(o=>(()=>{"use strict";var t={143:(o,t,e)=>{function r(o){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},r(o)}Object.defineProperty(t,"__esModule",{value:!0}),t.isRecord=void 0;var s=e(538);t.isRecord=function(o){return!(0,s.isNil)(o)&&"object"===r(o)},t.default=t.isRecord},538:t=>{t.exports=o}},e={};var r=function o(r){var s=e[r];if(void 0!==s)return s.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,o),i.exports}(143);return r})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hooks-global-states",
3
- "version": "7.0.14",
3
+ "version": "7.0.16",
4
4
  "description": "This is a package to easily handling global-state across your react-components using hooks.",
5
5
  "main": "./bundle.js",
6
6
  "types": "./index.d.ts",
package/shallowCompare.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./isRecord.js")):"function"==typeof define&&define.amd?define(["./isRecord.js"],r):"object"==typeof exports?exports["react-hooks-global-states"]=r(require("./isRecord.js")):e["react-hooks-global-states"]=r(e["./isRecord.js"])}(this,(e=>{return r={561:(e,r,t)=>{"use strict";function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,i,u,a=[],f=!0,l=!1;try{if(i=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=i.call(t)).done)&&(a.push(n.value),a.length!==r);f=!0);}catch(e){l=!0,o=e}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(l)throw o}}return a}}(e,r)||i(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=i(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,f=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return a=e.done,e},e:function(e){f=!0,u=e},f:function(){try{a||null==t.return||t.return()}finally{if(f)throw u}}}}function i(e,r){if(e){if("string"==typeof e)return u(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?u(e,r):void 0}}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.shallowCompare=void 0;var f=t(416),l=t(231),s=t(125),c=t(664);r.shallowCompare=function(e,r){if(e===r)return!0;var t=a(e),i=a(r);if(t!==i)return!1;if((0,s.isNil)(e)||(0,s.isNil)(r)||(0,f.isPrimitive)(e)&&(0,f.isPrimitive)(r)||(0,l.isDate)(e)&&(0,l.isDate)(r)||"function"===t&&"function"===i)return e===r;if(Array.isArray(e)){var u=e,y=r;if(u.length!==y.length)return!1;for(var v=0;v<u.length;v++)if(u[v]!==y[v])return!1}if(e instanceof Map){var p=e,d=r;if(p.size!==d.size)return!1;var b,m=o(p);try{for(m.s();!(b=m.n()).done;){var h=n(b.value,2),j=h[0];if(h[1]!==d.get(j))return!1}}catch(e){m.e(e)}finally{m.f()}}if(e instanceof Set){var S=e,g=r;if(S.size!==g.size)return!1;var x,_=o(S);try{for(_.s();!(x=_.n()).done;){var O=x.value;if(!g.has(O))return!1}}catch(e){_.e(e)}finally{_.f()}}if(!(0,c.isRecord)(e)||!(0,c.isRecord)(r))return e===r;var P=Object.keys(e),w=Object.keys(r);if(P.length!==w.length)return!1;for(var A=0,M=P;A<M.length;A++){var N=M[A];if(e[N]!==r[N])return!1}return!0},r.default=r.shallowCompare},231:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.isDate=void 0,r.isDate=function(e){return e instanceof Date}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.isNil=void 0,r.isNil=function(e){return null==e}})(),e})()},416:function(e){e.exports=(()=>{"use strict";var e={112:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isBoolean=void 0,r.isBoolean=function(e){return"boolean"==typeof e}},243:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isNil=void 0,r.isNil=function(e){return null==e}},11:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isNumber=void 0,r.isNumber=function(e){return"number"==typeof e}},671:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.isString=void 0,r.isString=function(e){return"string"==typeof e}}},r={};function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n](i,i.exports,t),i.exports}var n={};return(()=>{var e=n;function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.isPrimitive=void 0;var o=t(112),i=t(243),u=t(11),a=t(671);e.isPrimitive=function(e){return(0,i.isNil)(e)||(0,u.isNumber)(e)||(0,o.isBoolean)(e)||(0,a.isString)(e)||"symbol"===r(e)}})(),n})()},664:r=>{"use strict";r.exports=e}},t={},function e(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return r[n].call(i.exports,i,i.exports,e),i.exports}(561);var r,t}));
1
+ !function(r,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./isRecord.js"),require("json-storage-formatter/isDate"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):"function"==typeof define&&define.amd?define(["./isRecord.js","json-storage-formatter/isDate","json-storage-formatter/isNil","json-storage-formatter/isPrimitive"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./isRecord.js"),require("json-storage-formatter/isDate"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):r["react-hooks-global-states"]=t(r["./isRecord.js"],r["json-storage-formatter/isDate"],r["json-storage-formatter/isNil"],r["json-storage-formatter/isPrimitive"])}(this,((r,t,e,o)=>(()=>{"use strict";var n={561:(r,t,e)=>{function o(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var o,n,i,a,s=[],f=!0,u=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;f=!1}else for(;!(f=(o=i.call(e)).done)&&(s.push(o.value),s.length!==t);f=!0);}catch(r){u=!0,n=r}finally{try{if(!f&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(u)throw n}}return s}}(r,t)||i(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(r,t){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=i(r))||t&&r&&"number"==typeof r.length){e&&(r=e);var o=0,n=function(){};return{s:n,n:function(){return o>=r.length?{done:!0}:{done:!1,value:r[o++]}},e:function(r){throw r},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,f=!1;return{s:function(){e=e.call(r)},n:function(){var r=e.next();return s=r.done,r},e:function(r){f=!0,a=r},f:function(){try{s||null==e.return||e.return()}finally{if(f)throw a}}}}function i(r,t){if(r){if("string"==typeof r)return a(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(r,t):void 0}}function a(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,o=new Array(t);e<t;e++)o[e]=r[e];return o}function s(r){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},s(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.shallowCompare=void 0;var f=e(834),u=e(266),l=e(538),c=e(664);t.shallowCompare=function(r,t){if(r===t)return!0;var e=s(r),i=s(t);if(e!==i)return!1;if((0,l.isNil)(r)||(0,l.isNil)(t)||(0,f.isPrimitive)(r)&&(0,f.isPrimitive)(t)||(0,u.isDate)(r)&&(0,u.isDate)(t)||"function"===e&&"function"===i)return r===t;if(Array.isArray(r)){var a=r,y=t;if(a.length!==y.length)return!1;for(var m=0;m<a.length;m++){if(a[m]!==y[m])return!1}}if(r instanceof Map){var v=r,p=t;if(v.size!==p.size)return!1;var d,b=n(v);try{for(b.s();!(d=b.n()).done;){var h=o(d.value,2),g=h[0];if(h[1]!==p.get(g))return!1}}catch(r){b.e(r)}finally{b.f()}}if(r instanceof Set){var j=r,x=t;if(j.size!==x.size)return!1;var S,w=n(j);try{for(w.s();!(S=w.n()).done;){var A=S.value;if(!x.has(A))return!1}}catch(r){w.e(r)}finally{w.f()}}if(!(0,c.isRecord)(r)||!(0,c.isRecord)(t))return r===t;var q=Object.keys(r),O=Object.keys(t);if(q.length!==O.length)return!1;for(var P=0,D=q;P<D.length;P++){var N=D[P];if(r[N]!==t[N])return!1}return!0},t.default=t.shallowCompare},664:t=>{t.exports=r},266:r=>{r.exports=t},538:r=>{r.exports=e},834:r=>{r.exports=o}},i={};var a=function r(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return n[t](o,o.exports,r),o.exports}(561);return a})()));
package/useStableState.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./shallowCompare.js"),require("react")):"function"==typeof define&&define.amd?define(["./shallowCompare.js","react"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./shallowCompare.js"),require("react")):e["react-hooks-global-states"]=t(e["./shallowCompare.js"],e.react)}(this,((e,t)=>{return r={965:(e,t,r)=>{"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,i,l=[],a=!0,c=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;a=!1}else for(;!(a=(n=u.call(r)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{if(!a&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(c)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.useStableState=void 0;var u=r(156),i=r(244),l=r(125),a=r(682),c=r(156),s=r(156);t.useStableState=function(e){var t=(0,i.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,r=t?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,u.useRef)({builder:null,cleanup:t,dependencies:r}),f=(0,i.isFunction)(e)?e:function(){return e},p=n((0,c.useState)((function(){return{value:f()}})),2),d=p[0],v=p[1],b=(0,l.isNil)(o.current.builder),y=(0,l.isNil)(r)||!(0,a.shallowCompare)(o.current.dependencies,r);!b&&y&&(d.value=f()),o.current.dependencies=r,o.current.builder=f,o.current.cleanup=t;var h=(0,s.useCallback)((function(){v({value:o.current.builder()})}),[]);return(0,u.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(d.value)}}),[]),[d,h]},t.default=t.useStableState},244:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e||e instanceof Function}})(),e})()},125:function(e){e.exports=(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0}),t.isNil=void 0,t.isNil=function(e){return null==e}})(),e})()},682:t=>{"use strict";t.exports=e},156:e=>{"use strict";e.exports=t}},n={},function e(t){var o=n[t];if(void 0!==o)return o.exports;var u=n[t]={exports:{}};return r[t].call(u.exports,u,u.exports,e),u.exports}(965);var r,n}));
1
+ !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./shallowCompare.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("react")):"function"==typeof define&&define.amd?define(["./shallowCompare.js","json-storage-formatter/isFunction","json-storage-formatter/isNil","react"],r):"object"==typeof exports?exports["react-hooks-global-states"]=r(require("./shallowCompare.js"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("react")):e["react-hooks-global-states"]=r(e["./shallowCompare.js"],e["json-storage-formatter/isFunction"],e["json-storage-formatter/isNil"],e.react)}(this,((e,r,t,n)=>(()=>{"use strict";var o={965:(e,r,t)=>{function n(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,u,a,i=[],s=!0,l=!1;try{if(u=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;s=!1}else for(;!(s=(n=u.call(t)).done)&&(i.push(n.value),i.length!==r);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=t.return&&(a=t.return(),Object(a)!==a))return}finally{if(l)throw o}}return i}}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return o(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return o(e,r)}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}Object.defineProperty(r,"__esModule",{value:!0}),r.useStableState=void 0;var u=t(156),a=t(122),i=t(538),s=t(682),l=t(156),c=t(156);r.useStableState=function(e){var r=(0,a.isFunction)(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:void 0,t=r?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],o=(0,u.useRef)({builder:null,cleanup:r,dependencies:t}),f=(0,a.isFunction)(e)?e:function(){return e},p=n((0,l.useState)((function(){return{value:f()}})),2),d=p[0],m=p[1],v=(0,i.isNil)(o.current.builder),b=(0,i.isNil)(t)||!(0,s.shallowCompare)(o.current.dependencies,t);!v&&b&&(d.value=f()),o.current.dependencies=t,o.current.builder=f,o.current.cleanup=r;var y=(0,c.useCallback)((function(){m({value:o.current.builder()})}),[]);return(0,u.useEffect)((function(){return function(){o.current.cleanup&&o.current.cleanup(d.value)}}),[]),[d,y]},r.default=r.useStableState},682:r=>{r.exports=e},122:e=>{e.exports=r},538:e=>{e.exports=t},156:e=>{e.exports=n}},u={};var a=function e(r){var t=u[r];if(void 0!==t)return t.exports;var n=u[r]={exports:{}};return o[r](n,n.exports,e),n.exports}(965);return a})()));
package/webpack.config.js CHANGED
@@ -22,6 +22,20 @@ module.exports = {
22
22
  },
23
23
  externals: {
24
24
  react: 'react',
25
+ 'json-storage-formatter': 'json-storage-formatter',
26
+ 'json-storage-formatter/clone': 'json-storage-formatter/clone',
27
+ 'json-storage-formatter/isNil': 'json-storage-formatter/isNil',
28
+ 'json-storage-formatter/isNumber': 'json-storage-formatter/isNumber',
29
+ 'json-storage-formatter/isBoolean': 'json-storage-formatter/isBoolean',
30
+ 'json-storage-formatter/isString': 'json-storage-formatter/isString',
31
+ 'json-storage-formatter/isDate': 'json-storage-formatter/isDate',
32
+ 'json-storage-formatter/isRegex': 'json-storage-formatter/isRegex',
33
+ 'json-storage-formatter/isFunction': 'json-storage-formatter/isFunction',
34
+ 'json-storage-formatter/isPrimitive': 'json-storage-formatter/isPrimitive',
35
+ 'json-storage-formatter/types': 'json-storage-formatter/types',
36
+ 'json-storage-formatter/formatFromStore': 'json-storage-formatter/formatFromStore',
37
+ 'json-storage-formatter/formatToStore': 'json-storage-formatter/formatToStore',
38
+
25
39
  './createContext': './createContext.js',
26
40
  './GlobalStore': './GlobalStore.js',
27
41
  './GlobalStoreAbstract': './GlobalStoreAbstract.js',
@@ -48,12 +62,6 @@ module.exports = {
48
62
  },
49
63
  resolve: {
50
64
  extensions: ['.ts', '.js'],
51
- alias: {
52
- 'react-hooks-global-states': path.resolve(
53
- __dirname,
54
- 'node_modules/react-hooks-global-states/package.json'
55
- ),
56
- },
57
65
  },
58
66
  module: {
59
67
  rules: [