react-native-global-state-hooks 15.0.0 → 15.0.2

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.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { ActionCollectionConfig, GlobalStoreCallbacks, StateChanges, StoreTools } from "react-hooks-global-states/types";
1
+ import type { ActionCollectionConfig, GlobalStoreCallbacks, StateChanges } from "react-hooks-global-states/types";
2
2
  import type { ActionCollectionResult, AsyncStorageConfig, BaseMetadata, AsyncMetadata, AnyFunction } from "./types";
3
- import { GlobalStoreAbstract } from "react-hooks-global-states/GlobalStoreAbstract";
3
+ import GlobalStoreBase from "react-hooks-global-states/GlobalStore";
4
4
  /**
5
5
  * React Native Global Store with Async Storage support
6
6
  */
7
- export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> extends GlobalStoreAbstract<State, AsyncMetadata<Metadata>, ActionsConfig> {
7
+ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> extends GlobalStoreBase<State, AsyncMetadata<Metadata>, ActionsConfig> {
8
8
  asyncStorage: AsyncStorageConfig<State> | null;
9
9
  constructor(state: State);
10
10
  constructor(state: State, args: {
@@ -16,21 +16,14 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
16
16
  });
17
17
  getMetadata: () => AsyncMetadata<Metadata>;
18
18
  protected isPersistStorageAvailable: () => boolean;
19
- protected _onInitialize: ({ getState, }: StoreTools<State, PublicStateMutator, Metadata>) => Promise<void>;
20
19
  private trySetStorageItem;
21
20
  private updateStateWithValidation;
22
- protected _onChange: ({ state, }: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => Promise<void>;
23
- /**
24
- * We set it to null so the instances of the GlobalStoreAbstract can override it.
25
- */
26
- protected onInitialize: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
27
- protected onChange: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
28
21
  /**
29
22
  * Instead of calling onInitialize and onChange directly, we call the _onInitialize and _onChange
30
23
  * This allows the concat the logic of the GlobalStore with the logic of the extension class.
31
24
  */
32
- protected onInit: (parameters: StoreTools<State, PublicStateMutator, Metadata>) => void;
33
- protected onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
25
+ protected onInit: () => Promise<void>;
26
+ protected onStateChanged: (changes: StateChanges<State>) => Promise<void>;
34
27
  private getStorageItem;
35
28
  private setStorageItem;
36
29
  private handleStorageError;
package/GlobalStore.js CHANGED
@@ -1 +1 @@
1
- var t,e;t=this,e=(t,e,r,n,o,a,i,u)=>(()=>{var s={38:e=>{"use strict";e.exports=t},70:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n,o=(n=r(313))&&n.__esModule?n:{default:n};e.default=function(t,e){try{var r=t();return(0,o.default)(r)?r.then(function(t){return{result:t,error:null}}).catch(function(t){return{result:null!=e?e:null,error:t}}):{result:r,error:null}}catch(t){return{result:null!=e?e:null,error:t}}}},114:t=>{"use strict";t.exports=e},155:t=>{"use strict";t.exports=r},237:function(t,e,r){var n;n=(t,e,r,n)=>(()=>{"use strict";var o={38:e=>{e.exports=t},487:t=>{t.exports=e},773:t=>{t.exports=r},955:t=>{t.exports=n},973:(t,e,r)=>{function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=o(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}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 i,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw i}}}}function o(t,e){if(t){if("string"==typeof t)return a(t,e);var r={}.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)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(t){return i="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},i(t)}var u=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.isEqualObject=e.isEqualSet=e.isEqualMap=e.isEqualArray=e.canCheckSimpleEquality=e.isSet=e.isMap=e.isArray=e.shallowCompare=void 0;var s=u(r(955)),c=u(r(38)),l=u(r(773)),f=u(r(487));e.shallowCompare=function(t,r){return!(t!==r)||((0,e.canCheckSimpleEquality)(t,r)?t===r:(0,e.isArray)(t)&&(0,e.isArray)(r)?(0,e.isEqualArray)(t,r):(0,e.isMap)(t)&&(0,e.isMap)(r)?(0,e.isEqualMap)(t,r):(0,e.isSet)(t)&&(0,e.isSet)(r)?(0,e.isEqualSet)(t,r):(0,f.default)(t)&&(0,f.default)(r)?(0,e.isEqualObject)(t,r):t===r)},e.isArray=function(t){return Array.isArray(t)},e.isMap=function(t){return t instanceof Map},e.isSet=function(t){return t instanceof Set},e.canCheckSimpleEquality=function(t,e){var r=i(t),n=i(e);return r!==n||(0,l.default)(t)||(0,l.default)(e)||(0,s.default)(t)&&(0,s.default)(e)||(0,c.default)(t)&&(0,c.default)(e)||"function"===r&&"function"===n},e.isEqualArray=function(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r+=1)if(t[r]!==e[r])return!1;return!0},e.isEqualMap=function(t,e){if(t.size!==e.size)return!1;var r,a,i=n(t);try{for(i.s();!(r=i.n()).done;){var u=function(t){if(Array.isArray(t))return t}(a=r.value)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,a,i=[],u=!0,s=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(i.push(r.value),2!==i.length);u=!0);}catch(t){s=!0,n=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(s)throw n}}return i}}(a)||o(a,2)||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.")}(),s=u[0];if(u[1]!==e.get(s))return!1}}catch(t){i.e(t)}finally{i.f()}return!0},e.isEqualSet=function(t,e){if(t.size!==e.size)return!1;var r,o=n(t);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(!e.has(a))return!1}}catch(t){o.e(t)}finally{o.f()}return!0},e.isEqualObject=function(t,e){var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(var o=0,a=r;o<a.length;o++){var i=a[o];if(t[i]!==e[i])return!1}return!0},e.default=e.shallowCompare}},a={};return function t(e){var r=a[e];if(void 0!==r)return r.exports;var n=a[e]={exports:{}};return o[e](n,n.exports,t),n.exports}(973)})(),t.exports=n(r(38),r(947),r(773),r(955))},313:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return Boolean(t&&"function"==typeof t.then)}},316:function(t,e,r){var n;n=(t,e,r,n,o,a,i)=>(()=>{"use strict";var u={78:e=>{e.exports=t},155:t=>{t.exports=e},361:t=>{t.exports=r},487:t=>{t.exports=n},506:t=>{t.exports=o},673:t=>{t.exports=a},773:t=>{t.exports=i},811:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=globalThis;r.isDevToolsPresent=Boolean(r.REACT_GLOBAL_STATE_HOOK_DEBUG),e.default=r}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return u[t](r,r.exports,c),r.exports}var l={};return(()=>{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){if(t){if("string"==typeof t)return n(t,e);var r={}.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)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function o(){o=function(){return r};var t,r={},n=Object.prototype,a=n.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},s=u.iterator||"@@iterator",c=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,a=Object.create(o.prototype),u=new C(n||[]);return i(a,"_invoke",{value:A(t,r,u)}),a}function v(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=d;var p="suspendedStart",h="suspendedYield",y="executing",b="completed",g={};function m(){}function S(){}function w(){}var j={};f(j,s,function(){return this});var O=Object.getPrototypeOf,x=O&&O(O(I([])));x&&x!==n&&a.call(x,s)&&(j=x);var _=w.prototype=m.prototype=Object.create(j);function E(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function k(t,r){function n(o,i,u,s){var c=v(t[o],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&a.call(f,"__await")?r.resolve(f.__await).then(function(t){n("next",t,u,s)},function(t){n("throw",t,u,s)}):r.resolve(f).then(function(t){l.value=t,u(l)},function(t){return n("throw",t,u,s)})}s(c.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r(function(r,o){n(t,e,r,o)})}return o=o?o.then(a,a):a()}})}function A(e,r,n){var o=p;return function(a,i){if(o===y)throw Error("Generator is already running");if(o===b){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var u=n.delegate;if(u){var s=P(u,n);if(s){if(s===g)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=b,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var c=v(e,r,n);if("normal"===c.type){if(o=n.done?b:h,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=b,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=v(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function M(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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(M,this),this.reset(!0)}function I(r){if(r||""===r){var n=r[s];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function e(){for(;++o<r.length;)if(a.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,i(_,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:S,configurable:!0}),S.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(_),t},r.awrap=function(t){return{__await:t}},E(k.prototype),f(k.prototype,c,function(){return this}),r.AsyncIterator=k,r.async=function(t,e,n,o,a){void 0===a&&(a=Promise);var i=new k(d(t,e,n,o),a);return r.isGeneratorFunction(e)?i:i.next().then(function(t){return t.done?t.value:i.next()})},E(_),f(_,l,"Generator"),f(_,s,function(){return this}),f(_,"toString",function(){return"[object Generator]"}),r.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}},r.values=I,C.prototype={constructor:C,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=a.call(i,"catchLoc"),c=a.call(i,"finallyLoc");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(i)},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),g},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),T(r),g}},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;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:I(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},r}function a(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}var i,u=Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},s=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},f=(i=function(t){return i=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},i(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=i(t),n=0;n<r.length;n++)"default"!==r[n]&&u(e,t,r[n]);return s(e,t),e}),d=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0,t.createObservable=j,t.createSelectorHook=O;var v=c(155),p=d(c(506)),h=d(c(773)),y=d(c(487)),b=f(c(673)),g=d(c(361)),m=d(c(78)),S=d(c(811)),w=function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){var n,i,u=this,s=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.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Set,this.initialize=function(){return t=u,e=void 0,r=o().mark(function t(){var e,r,n,a,i,u,s;return o().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.getStoreActionsMap(),n=r.actions,a=r.storeTools,this.actions=n,this.storeTools=a,this.use=this.getMainHook(),i=this.onInit,u=null!==(e=this.callbacks)&&void 0!==e?e:{},s=u.onInit,i||s){t.next=8;break}return t.abrupt("return");case 8:null==i||i(a),(0,h.default)(s)||null==s||s(a);case 10:case"end":return t.stop()}},t,this)}),new(e||(e=Promise))(function(n,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function i(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var r;t.done?n(t.value):(r=t.value,r instanceof e?r:new e(function(t){t(r)})).then(a,i)}u((r=r.apply(t,[])).next())});var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r=t.selector,n=t.onStoreChange,o=t.currentState,a=t.isEqualRoot,i=void 0===a?function(t,e){return t===e}:a,s=t.isEqual,c=void 0===s?function(t,e){return t===e}:s;if(!e.forceUpdate&&i(e.currentState,e.newState))return{didUpdate:!1};var l=r?r(e.newState):e.newState;return!e.forceUpdate&&c(o,l)?{didUpdate:!1}:(u.partialUpdateSubscription(t,{currentState:l}),n({state:l},{identifier:e.identifier}),{didUpdate:!0})},this.setActualStateWithoutValidations=function(t,e){var n=e.forceUpdate,o=e.identifier,a=u.state;if(n||a!==t){u.state=t;var i,s={forceUpdate:n,newState:t,currentState:a,identifier:o},c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=r(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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,i=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){u=!0,a=t},f:function(){try{i||null==e.return||e.return()}finally{if(u)throw a}}}}(u.subscribers.values());try{for(c.s();!(i=c.n()).done;){var l=i.value;u.executeSetStateForSubscriber(l,s)}}catch(t){c.e(t)}finally{c.f()}}},this.setMetadata=function(t){var e=(0,p.default)(t)?t(u.metadata):t;u.metadata=e},this.getMetadata=function(){return u.metadata},this.getState=function(){return u.state},this.subscribe=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];var n,o=e[0],a=e[1],i=e[2],s=(0,p.default)(a),c=s?o:void 0,l=s?a:o,f=null!==(n=s?i:a)&&void 0!==n?n:void 0,d=c?c(u.state):u.state;(null==f?void 0:f.skipFirst)||l(d);var v=Object.assign({selector:c,currentState:d,onStoreChange:function(t){var e=t.state;return l(e)}},f);return u.subscribeCallback(v),function(){u.subscribers.delete(v)}},this.subscribeCallback=function(t){return u.executeOnSubscribed(t),u.subscribers.add(t),function(){u.subscribers.delete(t)}},this.partialUpdateSubscription=function(t,e){Object.assign(t,e)},this.executeOnSubscribed=function(t){var e,r=u.onSubscribed,n=null===(e=u.callbacks)||void 0===e?void 0:e.onSubscribed;(r||n)&&(null==r||r(u.storeTools,t),null==n||n(u.storeTools,t))},this.getMainHook=function(){var t="globalHook:".concat(u._name),e=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];(0,v.useDebugValue)(t);var n=(0,b.isArray)(r)?{dependencies:r}:null!=r?r:{},o=(0,v.useRef)(null),a=function(t){return(0,p.default)(e)?e(t):t};o.current=o.current?o.current:Object.assign({selector:a,currentState:a(u.state),onStoreChange:function(){throw new Error("Callback not set")}},n);var i=o.current.dependencies,s=null==n?void 0:n.dependencies,c=Object.assign(Object.assign({},n),{selector:a,dependencies:s});u.partialUpdateSubscription(o.current,c);var l=(0,v.useMemo)(function(){var t=function(){return o.current.currentState};return{subscribe:function(t){return o.current.onStoreChange=t,u.subscribeCallback(o.current)},getSnapshot:t,getServerSnapshot:t}},[]),f=l.subscribe,d=l.getSnapshot,h=l.getServerSnapshot;return u.reselectIfDependenciesChanged({subscription:o.current,newDependencies:s,currentDependencies:i}),[(0,v.useSyncExternalStore)(f,d,h),u.getStateOrchestrator(),u.metadata]},r=u.setMetadata,n=u.getMetadata,o=u.actions,a=u.actions?null:u.setState.bind(u),i=u,s={actions:o,createObservable:u.createObservable.bind(i),createSelectorHook:u.createSelectorHook.bind(i),dispose:u.dispose.bind(u),getMetadata:n,getState:u.getState.bind(u),setMetadata:r,setState:a,subscribe:u.subscribe.bind(u),subscribers:u.subscribers,use:e,select:function(){return e.apply(void 0,arguments)[0]}};return Object.assign(e,s),e},this.reselectIfDependenciesChanged=function(t){var e=t.subscription,r=t.newDependencies,n=t.currentDependencies;e.selector&&n!==r&&((null==n?void 0:n.length)===(null==r?void 0:r.length)&&(0,b.default)(n,r)||u.partialUpdateSubscription(e,{currentState:e.selector(u.state)}))},this.createSelectorHook=O,this.createObservable=j,this.getStateOrchestrator=function(){return u.actions?u.actions:u.setState},this.setState=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,a=n.identifier,i=u.state,s=(0,p.default)(t)?t(i):t;if(o||u.state!==s){var c=u.setMetadata,l=u.getMetadata,f=u.getState,d=u.actions,v={setMetadata:c,getMetadata:l,setState:u.setActualStateWithoutValidations,getState:f,actions:d,previousState:i,state:s,identifier:a},h=u.computePreventStateChange,y=null===(e=u.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((h||y)&&((null==h?void 0:h(v))||(null==y?void 0:y(v))))return;u.setActualStateWithoutValidations(s,{forceUpdate:o,identifier:a});var b=u.onStateChanged,g=null===(r=u.callbacks)||void 0===r?void 0:r.onStateChanged;null==b||b(v),null==g||g(v)}},this.getStoreActionsMap=function(){var t=u.actionsConfig,e=u.getMetadata,r=u.getState,n={setMetadata:u.setMetadata,getMetadata:e,getState:r,setState:u.setState,subscribe:u.subscribe,actions:null};if(!(0,y.default)(t))return{actions:null,storeTools:n};var o={};n.actions=o;for(var i=Object.keys(t),s=function(){var e,r,i,u=l[c];Object.assign(o,(e={},i=function(){for(var e=t[u],r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];var s=e.apply(o,a);return"function"!=typeof s&&(0,g.default)(u),s.call(o,n)},(r=a(r=u))in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,e))},c=0,l=i;c<l.length;c++)s();return{actions:o,storeTools:n}},this.removeSubscriptions=function(){u.subscribers.clear()},this.dispose=function(){u.removeSubscriptions()};var c=s.metadata,l=s.callbacks,f=s.actions,d=s.name;if(this.state=e,this._name=null!=d?d:(0,m.default)("gs:"),this.metadata=null!=c?c:{},this.callbacks=null!=l?l:null,this.actionsConfig=null!=f?f:null,S.default.isDevToolsPresent){var w=null!==(n=(new Error).stack)&&void 0!==n?n:"";null===(i=S.default.REACT_GLOBAL_STATE_HOOK_DEBUG)||void 0===i||i.call(S.default,this,s,w)}this.constructor!==t||this.initialize()});function j(t,e){var r=null==e?void 0:e.name,n=null==e?void 0:e.isEqualRoot,o=null==e?void 0:e.isEqual,a=this.getState(),i=(null!=t?t:function(t){return t})(a),u=new w(i,{name:null!=r?r:(0,m.default)("sh:")}),s=this.subscribe(function(e){if(!(null!=n?n:Object.is)(a,e)){a=e;var r=t(e);(null!=o?o:Object.is)(i,r)||(i=r,u.setState(r))}},{skipFirst:!0}),c=u.subscribe.bind(u),l={getState:u.getState.bind(u),subscribe:u.subscribe.bind(u),createSelectorHook:O.bind(c),createObservable:j.bind(c),dispose:function(){s(),u.dispose()},subscribers:u.subscribers};return Object.assign(c,l),c}function O(t,e){var n=null==e?void 0:e.name,o=null==e?void 0:e.isEqualRoot,a=null==e?void 0:e.isEqual,i=this.getState(),u=(null!=t?t:function(t){return t})(i),s=new w(u,{name:null!=n?n:(0,m.default)("sh:")}),c=this.subscribe(function(e){if(!(null!=o?o:Object.is)(i,e)){i=e;var r=t(e);(null!=a?a:Object.is)(u,r)||(u=r,s.setState(r))}},{skipFirst:!0}),l=function(){return(t=s.use.apply(s,arguments),function(t){if(Array.isArray(t))return t}(t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,a,i=[],u=!0,s=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(i.push(r.value),1!==i.length);u=!0);}catch(t){s=!0,n=t}finally{try{if(!u&&null!=e.return&&(a=e.return(),Object(a)!==a))return}finally{if(s)throw n}}return i}}(t)||r(t,1)||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.")}())[0];var t},f={getState:function(){return s.getState()},subscribe:s.subscribe.bind(s),createSelectorHook:O.bind(l),createObservable:j.bind(l),dispose:function(){c(),s.dispose()},subscribers:s.subscribers};return Object.assign(l,f),l}t.GlobalStore=w,t.default=w})(),l})(),t.exports=n(r(920),r(155),r(365),r(947),r(506),r(237),r(773))},318:(t,e,r)=>{var n;n=t=>(()=>{"use strict";var e={778:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}var o={};return(()=>{var t=o;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(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var u=function(t){function n(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),(t=function(t,n,o){return n=a(n),function(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,r()?Reflect.construct(n,o||[],a(t).constructor):n.apply(t,o))}(this,n,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(n,t),o=n,Object.defineProperty(o,"prototype",{writable:!1}),o;var o}(n(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),o})(),t.exports=n(r(316))},330:t=>{"use strict";t.exports=n},365:t=>{var e;e=()=>(()=>{"use strict";var t,e={};return t=e,Object.defineProperty(t,"__esModule",{value:!0}),t.throwWrongKeyOnActionCollectionConfig=void 0,t.throwWrongKeyOnActionCollectionConfig=function(t){throw new Error("[WRONG CONFIGURATION!]: Every key inside the storeActionsConfig must be a higher order function that returns a function \n[".concat(t,"]: key is not a valid function, try something like this: \n{\n\n ").concat(t,": (param) => ({ setState, getState, setMetadata, getMetadata, actions }) => {\n\n setState((state) => ({ ...state, ...param }))\n\n }\n\n}\n"))},t.default=t.throwWrongKeyOnActionCollectionConfig,e})(),t.exports=e()},413:t=>{"use strict";t.exports=o},506:t=>{"use strict";t.exports=a},773:t=>{"use strict";t.exports=i},920:t=>{var e;e=()=>(()=>{"use strict";var t,e,r={};return t=r,Object.defineProperty(t,"__esModule",{value:!0}),t.uniqueId=void 0,t.uniqueId=(e=0,function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e===Number.MAX_SAFE_INTEGER&&(e=0),t+Date.now().toString(36)+(e++).toString(36)}),t.default=t.uniqueId,r})(),t.exports=e()},947:(t,e,r)=>{var n;n=t=>(()=>{"use strict";var e={35:(t,e,r)=>{function n(t){return n="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},n(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.isRecord=void 0;var o,a=(o=r(773))&&o.__esModule?o:{default:o};e.isRecord=function(t){return!(0,a.default)(t)&&"object"===n(t)},e.default=e.isRecord},773:e=>{e.exports=t}},r={};return function t(n){var o=r[n];if(void 0!==o)return o.exports;var a=r[n]={exports:{}};return e[n](a,a.exports,t),a.exports}(35)})(),t.exports=n(r(773))},955:t=>{"use strict";t.exports=u}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return s[t].call(r.exports,r,r.exports,l),r.exports}var f={};return(()=>{"use strict";var t=f;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(){var t,e,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.toStringTag||"@@toStringTag";function u(r,o,a,i){var u=o&&o.prototype instanceof c?o:c,l=Object.create(u.prototype);return n(l,"_invoke",function(r,n,o){var a,i,u,c=0,l=o||[],f=!1,d={p:0,n:0,v:t,a:v,f:v.bind(t,4),d:function(e,r){return a=e,i=0,u=t,d.n=r,s}};function v(r,n){for(i=r,u=n,e=0;!f&&c&&!o&&e<l.length;e++){var o,a=l[e],v=d.p,p=a[2];r>3?(o=p===n)&&(u=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=t):a[0]<=v&&((o=r<2&&v<a[1])?(i=0,d.v=n,d.n=a[1]):v<p&&(o=r<3||a[0]>n||n>p)&&(a[4]=r,a[5]=n,d.n=p,i=0))}if(o||r>1)return s;throw f=!0,n}return function(o,l,p){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&v(l,p),i=l,u=p;(e=i<2?t:u)||!f;){a||(i?i<3?(i>1&&(d.n=-1),v(i,u)):d.n=u:d.v=u);try{if(c=2,a){if(i||(o="next"),e=a[o]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,i<2&&(i=0)}else 1===i&&(e=a.return)&&e.call(a),i<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=t}else if((e=(f=d.n<0)?u:r.call(n,d))!==s)break}catch(e){a=t,i=1,u=e}finally{c=1}}return{value:e,done:f}}}(r,a,i),!0),l}var s={};function c(){}function l(){}function f(){}e=Object.getPrototypeOf;var d=[][a]?e(e([][a]())):(n(e={},a,function(){return this}),e),v=f.prototype=c.prototype=Object.create(d);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,n(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t}return l.prototype=f,n(v,"constructor",f),n(f,"constructor",l),l.displayName="GeneratorFunction",n(f,i,"GeneratorFunction"),n(v),n(v,i,"Generator"),n(v,a,function(){return this}),n(v,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:p}})()}function n(t,e,r,o){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}n=function(t,e,r,o){if(e)a?a(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r;else{var i=function(e,r){n(t,e,function(t){return this._invoke(e,r,t)})};i("next",0),i("throw",1),i("return",2)}},n(t,e,r,o)}function o(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function a(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(a=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}var s=function(t,e,r,n){return new(r||(r=Promise))(function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,u)}s((n=n.apply(t,e||[])).next())})},c=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var d=l(318),v=c(l(70)),p=c(l(773)),h=c(l(330)),y=c(l(413)),b=c(l(114)),g=function(t){function e(t){var n,u,c,l,f,d,g,S=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),f=this,g=[t,S],d=i(d=e),(n=o(f,a()?Reflect.construct(d,g||[],i(f).constructor):d.apply(f,g))).asyncStorage=null,n.getMetadata=function(){return n.metadata},n.isPersistStorageAvailable=function(){var t;return Boolean(null===(t=n.asyncStorage)||void 0===t?void 0:t.key)},n._onInitialize=function(t){return s(n,[t],void 0,function(t){var e=this,n=t.getState;return r().m(function t(){var o,a,i,u,c,l,f;return r().w(function(t){for(;;)switch(t.n){case 0:if((o=e.asyncStorage)&&e.isPersistStorageAvailable()){t.n=1;break}return t.a(2);case 1:return e.metadata.isAsyncStorageReady=!1,a=o.versioning,t.n=2,(0,v.default)(function(){return s(e,void 0,void 0,r().m(function t(){var e,n,i,u,s;return r().w(function(t){for(;;)switch(t.n){case 0:if(i=null===(e=o.adapter)||void 0===e?void 0:e.getItem){t.n=1;break}return t.a(2,this.getStorageItem());case 1:return t.n=2,i(o.key);case 2:return u=t.v,s=null!==(n=null==a?void 0:a.version)&&void 0!==n?n:-1,t.a(2,{s:u,v:s})}},t,this)}))});case 2:return i=t.v,u=i.result,c=i.error,t.n=3,(0,v.default)(function(){return s(e,void 0,void 0,r().m(function t(){var e,i,s,l,f,d=this;return r().w(function(t){for(;;)switch(t.n){case 0:if(!c){t.n=2;break}return this.handleStorageError(c),t.n=1,this.updateStateWithValidation(this.getState());case 1:case 3:case 5:case 7:case 9:return t.a(2);case 2:if(u){t.n=4;break}return t.n=3,this.updateStateWithValidation(n());case 4:if(e=u.v===(null==a?void 0:a.version),i=null==a?void 0:a.migrator,!e&&i&&!o.adapter){t.n=6;break}return t.n=5,this.updateStateWithValidation(u.s);case 6:if(s=(0,v.default)(function(){return i({legacy:u.s,initial:d.getState()})}),l=s.result,f=s.error){t.n=8;break}return t.n=7,this.updateStateWithValidation(l);case 8:return this.handleStorageError(f),t.n=9,this.updateStateWithValidation(this.getState())}},t,this)}))});case 3:if(l=t.v,f=l.error,e.metadata.isAsyncStorageReady=!0,f){t.n=4;break}return t.a(2);case 4:e.handleStorageError(f);case 5:return t.a(2)}},t)})()})},n.trySetStorageItem=function(t){return s(n,void 0,void 0,r().m(function e(){var n,o,a,i=this;return r().w(function(e){for(;;)switch(e.n){case 0:if(n=this.asyncStorage){e.n=1;break}return e.a(2);case 1:return e.n=2,(0,v.default)(function(){var e,r=null===(e=n.adapter)||void 0===e?void 0:e.setItem;return r?r(n.key,t):i.setStorageItem(t)});case 2:if(o=e.v,a=o.error){e.n=3;break}return e.a(2);case 3:this.handleStorageError(a);case 4:return e.a(2)}},e,this)}))},n.updateStateWithValidation=function(t){return s(n,void 0,void 0,r().m(function e(){var n,o,a,i,u=this;return r().w(function(e){for(;;)switch(e.n){case 0:if(n=this.asyncStorage){e.n=1;break}return e.a(2);case 1:if(o=(0,v.default)(function(){var e;return null===(e=n.validator)||void 0===e?void 0:e.call(n,{restored:t,initial:u.getState()})}),a=o.result,!(i=o.error)){e.n=3;break}return this.handleStorageError(i),e.n=2,this.trySetStorageItem(this.getState());case 2:case 4:case 6:case 8:return e.a(2);case 3:if(void 0!==a){e.n=7;break}if(void 0!==t){e.n=5;break}return e.n=4,this.trySetStorageItem(this.getState());case 5:return this.setState(t,{forceUpdate:!0}),e.n=6,this.trySetStorageItem(t);case 7:return this.setState(a,{forceUpdate:!0}),e.n=8,this.trySetStorageItem(a)}},e,this)}))},n._onChange=function(t){return s(n,[t],void 0,function(t){var e=this,n=t.state;return r().m(function t(){var o,a,i;return r().w(function(t){for(;;)switch(t.n){case 0:if((o=e.asyncStorage)&&e.isPersistStorageAvailable()){t.n=1;break}return t.a(2);case 1:return t.n=2,(0,v.default)(function(){var t,r=null===(t=o.adapter)||void 0===t?void 0:t.setItem;return r?r(o.key,n):e.setStorageItem(n)});case 2:if(a=t.v,i=a.error){t.n=3;break}return t.a(2);case 3:e.handleStorageError(i);case 4:return t.a(2)}},t)})()})},n.onInitialize=null,n.onChange=null,n.onInit=function(t){var e;null===(e=n._onInitialize)||void 0===e||e.call(n,t)},n.onStateChanged=function(t){var e;null===(e=n._onChange)||void 0===e||e.call(n,t)},n.getStorageItem=function(){return s(n,void 0,void 0,r().m(function t(){var e,n;return r().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,b.default.getItem(this.asyncStorage.key);case 1:return e=t.v,n=(0,p.default)(e)?null:(0,h.default)(e),m(this.asyncStorage.key,n),t.a(2,n)}},t,this)}))},n.setStorageItem=function(t){return s(n,void 0,void 0,r().m(function e(){var n,o,a,i,u;return r().w(function(e){for(;;)if(0===e.n)return i={s:t,v:null!==(a=null===(o=null===(n=this.asyncStorage)||void 0===n?void 0:n.versioning)||void 0===o?void 0:o.version)&&void 0!==a?a:-1},u=(0,y.default)(i),e.a(2,b.default.setItem(this.asyncStorage.key,u))},e,this)}))},n.handleStorageError=function(t){var e;if(null===(e=n.asyncStorage)||void 0===e?void 0:e.onError)return n.asyncStorage.onError(t)},n.asyncStorage=null!==(u=S.asyncStorage)&&void 0!==u?u:null,Object.assign(n.getMetadata(),{isAsyncStorageReady:!1,asyncStorageKey:null!==(l=null===(c=n.asyncStorage)||void 0===c?void 0:c.key)&&void 0!==l?l:null}),n.constructor!==e?o(n):(n.initialize(),n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(d.GlobalStoreAbstract);function m(t,r){if(!((0,p.default)(r)||"object"===e(r)&&"s"in r&&"v"in r))throw new Error('[react-native-global-state-hooks] The value of the key "'.concat(t,'" is not a valid storage envelope.'))}t.GlobalStore=g,t.default=g})(),f})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("json-storage-formatter/isDate"),require("./asyncStorageWrapper.js"),require("react"),require("json-storage-formatter/formatFromStore"),require("json-storage-formatter/formatToStore"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):"function"==typeof define&&define.amd?define(["json-storage-formatter/isDate","./asyncStorageWrapper.js","react","json-storage-formatter/formatFromStore","json-storage-formatter/formatToStore","json-storage-formatter/isFunction","json-storage-formatter/isNil","json-storage-formatter/isPrimitive"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("json-storage-formatter/isDate"),require("./asyncStorageWrapper.js"),require("react"),require("json-storage-formatter/formatFromStore"),require("json-storage-formatter/formatToStore"),require("json-storage-formatter/isFunction"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):t["react-native-global-state-hooks"]=e(t["json-storage-formatter/isDate"],t["./asyncStorageWrapper.js"],t.react,t["json-storage-formatter/formatFromStore"],t["json-storage-formatter/formatToStore"],t["json-storage-formatter/isFunction"],t["json-storage-formatter/isNil"],t["json-storage-formatter/isPrimitive"]);
1
+ var t,e;t=this,e=(t,e,r,o,n)=>(()=>{"use strict";var a={70:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var o,n=(o=r(313))&&o.__esModule?o:{default:o};e.default=function(t,e){try{var r=t();return(0,n.default)(r)?r.then(function(t){return{result:t,error:null}}).catch(function(t){return{result:null!=e?e:null,error:t}}):{result:r,error:null}}catch(t){return{result:null!=e?e:null,error:t}}}},114:e=>{e.exports=t},313:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return Boolean(t&&"function"==typeof t.then)}},330:t=>{t.exports=e},413:t=>{t.exports=r},536:t=>{t.exports=o},773:t=>{t.exports=n}},i={};function u(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return a[t](r,r.exports,u),r.exports}var s={};return(()=>{var t=s;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(){var t,e,n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function u(r,n,a,i){var u=n&&n.prototype instanceof c?n:c,f=Object.create(u.prototype);return o(f,"_invoke",function(r,o,n){var a,i,u,c=0,f=n||[],l=!1,d={p:0,n:0,v:t,a:v,f:v.bind(t,4),d:function(e,r){return a=e,i=0,u=t,d.n=r,s}};function v(r,o){for(i=r,u=o,e=0;!l&&c&&!n&&e<f.length;e++){var n,a=f[e],v=d.p,h=a[2];r>3?(n=h===o)&&(u=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=t):a[0]<=v&&((n=r<2&&v<a[1])?(i=0,d.v=o,d.n=a[1]):v<h&&(n=r<3||a[0]>o||o>h)&&(a[4]=r,a[5]=o,d.n=h,i=0))}if(n||r>1)return s;throw l=!0,o}return function(n,f,h){if(c>1)throw TypeError("Generator is already running");for(l&&1===f&&v(f,h),i=f,u=h;(e=i<2?t:u)||!l;){a||(i?i<3?(i>1&&(d.n=-1),v(i,u)):d.n=u:d.v=u);try{if(c=2,a){if(i||(n="next"),e=a[n]){if(!(e=e.call(a,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,i<2&&(i=0)}else 1===i&&(e=a.return)&&e.call(a),i<2&&(u=TypeError("The iterator does not provide a '"+n+"' method"),i=1);a=t}else if((e=(l=d.n<0)?u:r.call(o,d))!==s)break}catch(e){a=t,i=1,u=e}finally{c=1}}return{value:e,done:l}}}(r,a,i),!0),f}var s={};function c(){}function f(){}function l(){}e=Object.getPrototypeOf;var d=[][a]?e(e([][a]())):(o(e={},a,function(){return this}),e),v=l.prototype=c.prototype=Object.create(d);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,o(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t}return f.prototype=l,o(v,"constructor",l),o(l,"constructor",f),f.displayName="GeneratorFunction",o(l,i,"GeneratorFunction"),o(v),o(v,i,"Generator"),o(v,a,function(){return this}),o(v,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:h}})()}function o(t,e,r,n){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}o=function(t,e,r,n){if(e)a?a(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r;else{var i=function(e,r){o(t,e,function(t){return this._invoke(e,r,t)})};i("next",0),i("throw",1),i("return",2)}},o(t,e,r,n)}function n(t,r){if(r&&("object"==e(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function a(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(a=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}var f=function(t,e,r,o){return new(r||(r=Promise))(function(n,a){function i(t){try{s(o.next(t))}catch(t){a(t)}}function u(t){try{s(o.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(i,u)}s((o=o.apply(t,e||[])).next())})},l=function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var d=l(u(536)),v=l(u(70)),h=l(u(773)),y=l(u(330)),p=l(u(413)),g=l(u(114)),S=function(t){function e(t){var o,u,s,c,l,d,S,m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),l=this,S=[t,m],d=i(d=e),(o=n(l,a()?Reflect.construct(d,S||[],i(l).constructor):d.apply(l,S))).asyncStorage=null,o.getMetadata=function(){return o.metadata},o.isPersistStorageAvailable=function(){var t;return Boolean(null===(t=o.asyncStorage)||void 0===t?void 0:t.key)},o.trySetStorageItem=function(t){return f(o,void 0,void 0,r().m(function e(){var o,n,a,i=this;return r().w(function(e){for(;;)switch(e.n){case 0:if(o=this.asyncStorage){e.n=1;break}return e.a(2);case 1:return e.n=2,(0,v.default)(function(){var e,r=null===(e=o.adapter)||void 0===e?void 0:e.setItem;return r?r(o.key,t):i.setStorageItem(t)});case 2:if(n=e.v,a=n.error){e.n=3;break}return e.a(2);case 3:this.handleStorageError(a);case 4:return e.a(2)}},e,this)}))},o.updateStateWithValidation=function(t){return f(o,void 0,void 0,r().m(function e(){var o,n,a,i,u=this;return r().w(function(e){for(;;)switch(e.n){case 0:if(o=this.asyncStorage){e.n=1;break}return e.a(2);case 1:if(n=(0,v.default)(function(){var e;return null===(e=o.validator)||void 0===e?void 0:e.call(o,{restored:t,initial:u.getState()})}),a=n.result,!(i=n.error)){e.n=3;break}return this.handleStorageError(i),e.n=2,this.trySetStorageItem(this.getState());case 2:case 4:case 6:case 8:return e.a(2);case 3:if(void 0!==a){e.n=7;break}if(void 0!==t){e.n=5;break}return e.n=4,this.trySetStorageItem(this.getState());case 5:return this.setState(t,{forceUpdate:!0}),e.n=6,this.trySetStorageItem(t);case 7:return this.setState(a,{forceUpdate:!0}),e.n=8,this.trySetStorageItem(a)}},e,this)}))},o.onInit=function(){return f(o,void 0,void 0,r().m(function t(){var e,o,n,a,i,u,s,c=this;return r().w(function(t){for(;;)switch(t.n){case 0:if((e=this.asyncStorage)&&this.isPersistStorageAvailable()){t.n=1;break}return t.a(2);case 1:return this.metadata.isAsyncStorageReady=!1,o=e.versioning,t.n=2,(0,v.default)(function(){return f(c,void 0,void 0,r().m(function t(){var n,a,i,u,s;return r().w(function(t){for(;;)switch(t.n){case 0:if(i=null===(n=e.adapter)||void 0===n?void 0:n.getItem){t.n=1;break}return t.a(2,this.getStorageItem());case 1:return t.n=2,i(e.key);case 2:return u=t.v,s=null!==(a=null==o?void 0:o.version)&&void 0!==a?a:-1,t.a(2,{s:u,v:s})}},t,this)}))});case 2:return n=t.v,a=n.result,i=n.error,t.n=3,(0,v.default)(function(){return f(c,void 0,void 0,r().m(function t(){var n,u,s,c,f,l=this;return r().w(function(t){for(;;)switch(t.n){case 0:if(!i){t.n=2;break}return this.handleStorageError(i),t.n=1,this.updateStateWithValidation(this.getState());case 1:case 3:case 5:case 7:case 9:return t.a(2);case 2:if(a){t.n=4;break}return t.n=3,this.updateStateWithValidation(this.getState());case 4:if(n=a.v===(null==o?void 0:o.version),u=null==o?void 0:o.migrator,!n&&u&&!e.adapter){t.n=6;break}return t.n=5,this.updateStateWithValidation(a.s);case 6:if(s=(0,v.default)(function(){return u({legacy:a.s,initial:l.getState()})}),c=s.result,f=s.error){t.n=8;break}return t.n=7,this.updateStateWithValidation(c);case 8:return this.handleStorageError(f),t.n=9,this.updateStateWithValidation(this.getState())}},t,this)}))});case 3:if(u=t.v,s=u.error,this.metadata.isAsyncStorageReady=!0,s){t.n=4;break}return t.a(2);case 4:this.handleStorageError(s);case 5:return t.a(2)}},t,this)}))},o.onStateChanged=function(t){return f(o,void 0,void 0,r().m(function e(){var o,n,a,i=this;return r().w(function(e){for(;;)switch(e.n){case 0:if((o=this.asyncStorage)&&this.isPersistStorageAvailable()){e.n=1;break}return e.a(2);case 1:return e.n=2,(0,v.default)(function(){var e,r=null===(e=o.adapter)||void 0===e?void 0:e.setItem;return r?r(o.key,t.state):i.setStorageItem(t.state)});case 2:if(n=e.v,a=n.error){e.n=3;break}return e.a(2);case 3:this.handleStorageError(a);case 4:return e.a(2)}},e,this)}))},o.getStorageItem=function(){return f(o,void 0,void 0,r().m(function t(){var e,o;return r().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,g.default.getItem(this.asyncStorage.key);case 1:return e=t.v,o=(0,h.default)(e)?null:(0,y.default)(e),b(this.asyncStorage.key,o),t.a(2,o)}},t,this)}))},o.setStorageItem=function(t){return f(o,void 0,void 0,r().m(function e(){var o,n,a,i,u;return r().w(function(e){for(;;)if(0===e.n)return i={s:t,v:null!==(a=null===(n=null===(o=this.asyncStorage)||void 0===o?void 0:o.versioning)||void 0===n?void 0:n.version)&&void 0!==a?a:-1},u=(0,p.default)(i),e.a(2,g.default.setItem(this.asyncStorage.key,u))},e,this)}))},o.handleStorageError=function(t){var e;if(null===(e=o.asyncStorage)||void 0===e?void 0:e.onError)return o.asyncStorage.onError(t)},o.asyncStorage=null!==(u=m.asyncStorage)&&void 0!==u?u:null,Object.assign(o.getMetadata(),{isAsyncStorageReady:!1,asyncStorageKey:null!==(c=null===(s=o.asyncStorage)||void 0===s?void 0:s.key)&&void 0!==c?c:null}),o.constructor!==e?n(o):(o.initialize(),o)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),o=e,Object.defineProperty(o,"prototype",{writable:!1}),o;var o}(d.default);function b(t,r){if(!((0,h.default)(r)||"object"===e(r)&&"s"in r&&"v"in r))throw new Error('[react-native-global-state-hooks] The value of the key "'.concat(t,'" is not a valid storage envelope.'))}t.GlobalStore=S,t.default=S})(),s})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatFromStore"),require("json-storage-formatter/formatToStore"),require("react-hooks-global-states/GlobalStore"),require("json-storage-formatter/isNil")):"function"==typeof define&&define.amd?define(["./asyncStorageWrapper.js","json-storage-formatter/formatFromStore","json-storage-formatter/formatToStore","react-hooks-global-states/GlobalStore","json-storage-formatter/isNil"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatFromStore"),require("json-storage-formatter/formatToStore"),require("react-hooks-global-states/GlobalStore"),require("json-storage-formatter/isNil")):t["react-native-global-state-hooks"]=e(t["./asyncStorageWrapper.js"],t["json-storage-formatter/formatFromStore"],t["json-storage-formatter/formatToStore"],t["react-hooks-global-states/GlobalStore"],t["json-storage-formatter/isNil"]);
package/bundle.js CHANGED
@@ -1 +1 @@
1
- var e,r;e=this,r=(e,r,t,o,n,a,i,s)=>(()=>{"use strict";var l={78:r=>{r.exports=e},114:e=>{e.exports=r},361:e=>{e.exports=t},487:e=>{e.exports=o},623:e=>{e.exports=n},670:e=>{e.exports=a},673:e=>{e.exports=i},778:e=>{e.exports=s}},u={};function c(e){var r=u[e];if(void 0!==r)return r.exports;var t=u[e]={exports:{}};return l[e](t,t.exports,c),t.exports}var p={};return(()=>{var e=p;Object.defineProperty(e,"__esModule",{value:!0}),e.asyncStorageWrapper=e.createGlobalState=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var r=c(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return r.shallowCompare}});var t=c(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return t.uniqueId}});var o=c(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}});var n=c(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return n.isRecord}});var a=c(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return a.createContext}});var i=c(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return i.GlobalStore}});var s=c(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return s.createGlobalState}});var l=c(114);Object.defineProperty(e,"asyncStorageWrapper",{enumerable:!0,get:function(){return(e=l,e&&e.__esModule?e:{default:e}).default;var e}})})(),p})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./asyncStorageWrapper.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js"],r):"object"==typeof exports?exports["react-native-global-state-hooks"]=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):e["react-native-global-state-hooks"]=r(e["./uniqueId.js"],e["./asyncStorageWrapper.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"]);
1
+ var e,r;e=this,r=(e,r,t,o,n,a,i,s)=>(()=>{"use strict";var l={78:r=>{r.exports=e},114:e=>{e.exports=r},361:e=>{e.exports=t},487:e=>{e.exports=o},623:e=>{e.exports=n},670:e=>{e.exports=a},673:e=>{e.exports=i},778:e=>{e.exports=s}},u={};function c(e){var r=u[e];if(void 0!==r)return r.exports;var t=u[e]={exports:{}};return l[e](t,t.exports,c),t.exports}var p={};return(()=>{var e=p,r=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.asyncStorageWrapper=e.createGlobalState=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var t=c(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return t.shallowCompare}});var o=c(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return o.uniqueId}});var n=c(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return n.throwWrongKeyOnActionCollectionConfig}});var a=c(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return a.isRecord}});var i=c(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return i.createContext}});var s=c(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return r(s).default}});var l=c(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return l.createGlobalState}});var u=c(114);Object.defineProperty(e,"asyncStorageWrapper",{enumerable:!0,get:function(){return r(u).default}})})(),p})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./asyncStorageWrapper.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js"],r):"object"==typeof exports?exports["react-native-global-state-hooks"]=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):e["react-native-global-state-hooks"]=r(e["./uniqueId.js"],e["./asyncStorageWrapper.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"]);
@@ -1,8 +1,8 @@
1
1
  import type { StateHook, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks } from "react-hooks-global-states/types";
2
2
  import { AsyncStorageConfig, BaseMetadata, AsyncMetadata } from "./types";
3
3
  import React from "react";
4
- export type { InferActionsType } from "react-hooks-global-states/createGlobalState";
5
- export interface CreateGlobalState {
4
+ export type { InferActionsType, InferStateApi, AnyActions, } from "react-hooks-global-states/createGlobalState";
5
+ interface CreateGlobalState {
6
6
  /**
7
7
  * Creates a global state hook.
8
8
  * @param state initial state value
package/index.d.ts CHANGED
@@ -4,11 +4,11 @@
4
4
  */
5
5
  export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, BaseMetadata as BaseMetadata, MetadataGetter, SelectorCallback, SubscriberParameters, SubscriptionCallback, StateHook, ActionCollectionConfig, } from "./types";
6
6
  export { shallowCompare } from "./shallowCompare";
7
- export { uniqueId } from "./uniqueId";
7
+ export { uniqueId, type BrandedId } from "./uniqueId";
8
8
  export { throwWrongKeyOnActionCollectionConfig } from "./throwWrongKeyOnActionCollectionConfig";
9
9
  export { isRecord } from "./isRecord";
10
10
  export { type ContextProvider, type ContextHook, type InferContextApi, createContext } from "./createContext";
11
11
  export type { AsyncStorageConfig } from "./types";
12
- export { GlobalStore } from "./GlobalStore";
13
- export { type CreateGlobalState, createGlobalState, type InferActionsType } from "./createGlobalState";
12
+ export { default as GlobalStore } from "./GlobalStore";
13
+ export { createGlobalState, type InferActionsType, type InferStateApi, type AnyActions, } from "./createGlobalState";
14
14
  export { default as asyncStorageWrapper, type AsyncStorageManager } from "./asyncStorageWrapper";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-global-state-hooks",
3
- "version": "15.0.0",
3
+ "version": "15.0.2",
4
4
  "description": "This is a package to easily handling global-state across your react-native-components No-redux... The library now includes @react-native-async-storage/async-storage to persist your state across sessions... if you want to keep using the old version without async-storage or react-native dependencies just use version 5.0.15 or user react-hooks-global-states instead",
5
5
  "main": "./bundle.js",
6
6
  "types": "./index.d.ts",
@@ -155,6 +155,6 @@
155
155
  }
156
156
  },
157
157
  "dependencies": {
158
- "react-hooks-global-states": "^15.0.2"
158
+ "react-hooks-global-states": "^15.0.8"
159
159
  }
160
160
  }
package/uniqueId.d.ts CHANGED
@@ -1 +1 @@
1
- export { uniqueId, default } from "react-hooks-global-states/uniqueId";
1
+ export { uniqueId, BrandedId, default } from "react-hooks-global-states/uniqueId";