react-native-global-state-hooks 14.0.0 → 15.0.1
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 +13 -8
- package/GlobalStore.js +1 -1
- package/asyncStorageWrapper.d.ts +2 -2
- package/asyncStorageWrapper.js +1 -1
- package/bundle.js +1 -1
- package/createGlobalState.d.ts +9 -9
- package/index.d.ts +3 -5
- package/isPromise.d.ts +2 -0
- package/package.json +10 -19
- package/tryCatch.d.ts +19 -0
- package/types.d.ts +134 -51
- package/webpack.config.js +0 -2
- package/getAsyncStorageItem.d.ts +0 -8
- package/getAsyncStorageItem.js +0 -1
- package/setAsyncStorageItem.d.ts +0 -3
- package/setAsyncStorageItem.js +0 -1
package/GlobalStore.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import type { ActionCollectionConfig, GlobalStoreCallbacks, StateChanges, StoreTools } from "react-hooks-global-states/types";
|
|
2
|
-
import type { ActionCollectionResult, AsyncStorageConfig,
|
|
2
|
+
import type { ActionCollectionResult, AsyncStorageConfig, BaseMetadata, AsyncMetadata, AnyFunction } from "./types";
|
|
3
3
|
import { GlobalStoreAbstract } from "react-hooks-global-states/GlobalStoreAbstract";
|
|
4
4
|
/**
|
|
5
5
|
* React Native Global Store with Async Storage support
|
|
6
6
|
*/
|
|
7
|
-
export declare class GlobalStore<State, Metadata extends
|
|
8
|
-
asyncStorage: AsyncStorageConfig | null;
|
|
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> {
|
|
8
|
+
asyncStorage: AsyncStorageConfig<State> | null;
|
|
9
9
|
constructor(state: State);
|
|
10
10
|
constructor(state: State, args: {
|
|
11
11
|
metadata?: Metadata;
|
|
12
12
|
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator extends AnyFunction ? null : PublicStateMutator, Metadata>;
|
|
13
13
|
actions?: ActionsConfig;
|
|
14
14
|
name?: string;
|
|
15
|
-
asyncStorage?: AsyncStorageConfig
|
|
15
|
+
asyncStorage?: AsyncStorageConfig<State>;
|
|
16
16
|
});
|
|
17
|
-
getMetadata: () =>
|
|
18
|
-
|
|
19
|
-
protected _onInitialize: ({
|
|
20
|
-
|
|
17
|
+
getMetadata: () => AsyncMetadata<Metadata>;
|
|
18
|
+
protected isPersistStorageAvailable: () => boolean;
|
|
19
|
+
protected _onInitialize: ({ getState, }: StoreTools<State, PublicStateMutator, Metadata>) => Promise<void>;
|
|
20
|
+
private trySetStorageItem;
|
|
21
|
+
private updateStateWithValidation;
|
|
22
|
+
protected _onChange: ({ state, }: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => Promise<void>;
|
|
21
23
|
/**
|
|
22
24
|
* We set it to null so the instances of the GlobalStoreAbstract can override it.
|
|
23
25
|
*/
|
|
@@ -29,5 +31,8 @@ export declare class GlobalStore<State, Metadata extends AsyncMetadata, ActionsC
|
|
|
29
31
|
*/
|
|
30
32
|
protected onInit: (parameters: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
31
33
|
protected onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
34
|
+
private getStorageItem;
|
|
35
|
+
private setStorageItem;
|
|
36
|
+
private handleStorageError;
|
|
32
37
|
}
|
|
33
38
|
export default GlobalStore;
|
package/GlobalStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e;t=this,e=(t,e,r,n,o,i,a)=>(()=>{var u={38:e=>{"use strict";e.exports=t},155:t=>{"use strict";t.exports=e},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,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}function o(t,e){if(t){if("string"==typeof t)return i(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)?i(t,e):void 0}}function i(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 a(t){return a="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},a(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 u=r(955),c=r(38),s=r(773),l=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,l.isRecord)(t)&&(0,l.isRecord)(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=a(t),n=a(e);return r!==n||(0,s.isNil)(t)||(0,s.isNil)(e)||(0,u.isPrimitive)(t)&&(0,u.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(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,i,a=n(t);try{for(a.s();!(r=a.n()).done;){var u=function(t){if(Array.isArray(t))return t}(i=r.value)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,i,a=[],u=!0,c=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(a.push(r.value),2!==a.length);u=!0);}catch(t){c=!0,n=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(c)throw n}}return a}}(i)||o(i,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.")}(),c=u[0];if(u[1]!==e.get(c))return!1}}catch(t){a.e(t)}finally{a.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 i=r.value;if(!e.has(i))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,i=r;o<i.length;o++){var a=i[o];if(t[a]!==e[a])return!1}return!0},e.default=e.shallowCompare}},i={};return function t(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return o[e](n,n.exports,t),n.exports}(973)})(),t.exports=n(r(38),r(947),r(773),r(955))},316:function(t,e,r){var n;n=(t,e,r,n,o,i,a)=>(()=>{"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=i},773:t=>{t.exports=a},811:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=globalThis;r.isDevToolsPresent=Boolean(r.REACT_GLOBAL_STATE_HOOK_DEBUG),e.default=r}},c={};function s(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return u[t](r,r.exports,s),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,i=n.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",s=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 p(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),u=new q(n||[]);return a(i,"_invoke",{value:k(t,r,u)}),i}function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var d="suspendedStart",v="suspendedYield",b="executing",h="completed",g={};function m(){}function S(){}function w(){}var j={};f(j,c,function(){return this});var O=Object.getPrototypeOf,x=O&&O(O(I([])));x&&x!==n&&i.call(x,c)&&(j=x);var E=w.prototype=m.prototype=Object.create(j);function _(t){["next","throw","return"].forEach(function(e){f(t,e,function(t){return this._invoke(e,t)})})}function A(t,r){function n(o,a,u,c){var s=y(t[o],t,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then(function(t){n("next",t,u,c)},function(t){n("throw",t,u,c)}):r.resolve(f).then(function(t){l.value=t,u(l)},function(t){return n("throw",t,u,c)})}c(s.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r(function(r,o){n(t,e,r,o)})}return o=o?o.then(i,i):i()}})}function k(e,r,n){var o=d;return function(i,a){if(o===b)throw Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var c=P(u,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var s=y(e,r,n);if("normal"===s.type){if(o=n.done?h:v,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=h,n.method="throw",n.arg=s.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 i=y(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function C(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 M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function q(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function I(r){if(r||""===r){var n=r[c];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,a(E,"constructor",{value:w,configurable:!0}),a(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(E),t},r.awrap=function(t){return{__await:t}},_(A.prototype),f(A.prototype,s,function(){return this}),r.AsyncIterator=A,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new A(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},_(E),f(E,l,"Generator"),f(E,c,function(){return this}),f(E,"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,q.prototype={constructor:q,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(M),!e)for(var r in this)"t"===r.charAt(0)&&i.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 a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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&&i.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):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),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),M(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;M(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 i(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+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0,t.createObservable=g,t.createSelectorHook=m;var a,u=s(155),c=s(506),f=s(773),p=s(487),y=s(673),d=s(361),v=s(78),b=(a=s(811))&&a.__esModule?a:{default:a},h=function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e){var n,a,s=this,l=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=s,e=void 0,r=o().mark(function t(){var e,r,n,i,a,u,c;return o().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.getStoreActionsMap(),n=r.actions,i=r.storeTools,this.actions=n,this.storeTools=i,this.use=this.getMainHook(),a=this.onInit,u=null!==(e=this.callbacks)&&void 0!==e?e:{},c=u.onInit,a||c){t.next=8;break}return t.abrupt("return");case 8:null==a||a(i),(0,f.isNil)(c)||null==c||c(i);case 10:case"end":return t.stop()}},t,this)}),new(e||(e=Promise))(function(n,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function a(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(i,a)}u((r=r.apply(t,[])).next())});var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r,n,o,i=t.selector,a=t.callback,u=t.currentState,c=t.getConfig,l=null!==(r=null==c?void 0:c())&&void 0!==r?r:{};if(!e.forceUpdate&&(null!==(n=null==l?void 0:l.isEqualRoot)&&void 0!==n?n:function(t,e){return t===e})(e.currentState,e.newState))return{didUpdate:!1};var f=i?i(e.newState):e.newState;return!e.forceUpdate&&(null!==(o=null==l?void 0:l.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,f)?{didUpdate:!1}:(s.partialUpdateSubscription(t,{currentState:f}),a({state:f},{identifier:e.identifier}),{didUpdate:!0})},this.setSubscribersState=function(t,e){var n=e.forceUpdate,o=e.identifier,i=s.state;if(n||i!==t){s.state=t;var a,u={forceUpdate:n,newState:t,currentState:i,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 i,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw i}}}}(s.subscribers.values());try{for(c.s();!(a=c.n()).done;){var l=a.value;s.executeSetStateForSubscriber(l,u)}}catch(t){c.e(t)}finally{c.f()}}},this.setMetadata=function(t){var e=(0,c.isFunction)(t)?t(s.metadata):t;s.metadata=e},this.getMetadata=function(){return s.metadata},this.getState=function(){return s.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],i=e[1],a=e[2],u=(0,c.isFunction)(i),l=u?o:void 0,f=u?i:o,p=null!==(n=u?a:i)&&void 0!==n?n:void 0,y=l?l(s.state):s.state;(null==p?void 0:p.skipFirst)||f(y);var d={selector:l,getConfig:function(){return p},currentState:y,callback:function(t){var e=t.state;return f(e)}};return s.subscribeCallback(d),function(){s.subscribers.delete(d)}},this.subscribeCallback=function(t){return s.executeOnSubscribed(t),s.subscribers.add(t),function(){s.subscribers.delete(t)}},this.partialUpdateSubscription=function(t,e){(0,p.isRecord)(t)&&Object.assign(t,e)},this.executeOnSubscribed=function(t){var e,r=s.onSubscribed,n=null===(e=s.callbacks)||void 0===e?void 0:e.onSubscribed;(r||n)&&(null==r||r(s.storeTools,t),null==n||n(s.storeTools,t))},this.getMainHook=function(){var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=(0,y.isArray)(e)?{dependencies:e}:null!=e?e:{},n=(0,u.useRef)({selector:t,config:r}),o=n.current.config.dependencies;n.current.selector=t,n.current.config=r;var i=(0,u.useMemo)(function(){var t=function(t){var e=n.current.selector;return(0,c.isFunction)(e)?e(t):t},e={currentState:t(s.state),selector:t,getConfig:function(){return n.current.config},callback:function(){throw new Error("Callback not set")}},r=function(){return e.currentState};return{subscribe:function(t){return e.callback=t,s.subscribeCallback(e)},getSnapshot:r,getServerSnapshot:r,subscription:e}},[]),a=i.subscribe,l=i.getSnapshot,f=i.getServerSnapshot,p=i.subscription;return(0,u.useSyncExternalStore)(a,l,f),[s.computeSelectedState({subscription:p,currentDependencies:o}),s.getStateOrchestrator(),s.metadata]},e=s.setMetadata,r=s.getMetadata,n=s.actions,o=s.actions?null:s.setState.bind(s),i=s,a={actions:n,createObservable:s.createObservable.bind(i),createSelectorHook:s.createSelectorHook.bind(i),dispose:s.dispose.bind(s),getMetadata:r,getState:s.getState.bind(s),setMetadata:e,setState:o,subscribe:s.subscribe.bind(s),use:t,select:function(){return t.apply(void 0,arguments)[0]}};return Object.assign(t,a),t},this.computeSelectedState=function(t){var e,r=t.subscription,n=t.currentDependencies;if(!r.selector)return r.currentState;var o=(null!==(e=r.getConfig())&&void 0!==e?e:{}).dependencies;return n===o||(null==n?void 0:n.length)===(null==o?void 0:o.length)&&(0,y.shallowCompare)(n,o)||s.partialUpdateSubscription(r,{currentState:r.selector(s.state)}),r.currentState},this.createSelectorHook=m,this.createObservable=g,this.getStateOrchestrator=function(){return s.actions?s.actions:s.setState},this.setState=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,a=s.state,u=(0,c.isFunction)(t)?t(a):t;if(o||s.state!==u){var l=s.setMetadata,f=s.getMetadata,p=s.getState,y=s.actions,d={setMetadata:l,getMetadata:f,setState:s.setSubscribersState,getState:p,actions:y,previousState:a,state:u,identifier:i},v=s.computePreventStateChange,b=null===(e=s.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||b)&&((null==v?void 0:v(d))||(null==b?void 0:b(d))))return;s.setSubscribersState(u,{forceUpdate:o,identifier:i});var h=s.onStateChanged,g=null===(r=s.callbacks)||void 0===r?void 0:r.onStateChanged;(h||g)&&(null==h||h(d),null==g||g(d))}},this.getStoreActionsMap=function(){var t=s.actionsConfig,e=s.getMetadata,r=s.getState,n={setMetadata:s.setMetadata,getMetadata:e,getState:r,setState:s.setState,subscribe:s.subscribe,actions:null};if(!(0,p.isRecord)(t))return{actions:null,storeTools:n};var o={};n.actions=o;for(var a=Object.keys(t),u=function(){var e,r,a,u=l[c];Object.assign(o,(e={},a=function(){for(var e=t[u],r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var c=e.apply(o,i);return"function"!=typeof c&&(0,d.throwWrongKeyOnActionCollectionConfig)(u),c.call(o,n)},(r=i(r=u))in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e))},c=0,l=a;c<l.length;c++)u();return{actions:o,storeTools:n}},this.removeSubscriptions=function(){s.subscribers.clear()},this.dispose=function(){s.removeSubscriptions(),s._name="",s.actionsConfig=null,s.callbacks=null,s.metadata={},s.actions=null,s.state=Object.create(null)};var h=l.metadata,S=l.callbacks,w=l.actions,j=l.name;if(this.state=e,this._name=null!=j?j:(0,v.uniqueId)("gs:"),this.metadata=null!=h?h:{},this.callbacks=null!=S?S:null,this.actionsConfig=null!=w?w:null,b.default.isDevToolsPresent){var O=null!==(n=(new Error).stack)&&void 0!==n?n:"";null===(a=b.default.REACT_GLOBAL_STATE_HOOK_DEBUG)||void 0===a||a.call(b.default,this,l,O)}this.constructor!==t||this.initialize()});function g(t,e){var r=null==e?void 0:e.name,n=null==e?void 0:e.isEqualRoot,o=null==e?void 0:e.isEqual,i=this.getState(),a=(null!=t?t:function(t){return t})(i),u=new h(a,{name:null!=r?r:(0,v.uniqueId)("sh:")}),c=this.subscribe(function(e){if(!(null!=n?n:Object.is)(i,e)){i=e;var r=t(e);(null!=o?o:Object.is)(a,r)||(a=r,u.setState(r))}},{skipFirst:!0}),s=u.subscribe.bind(u),l={getState:u.getState.bind(u),subscribe:u.subscribe.bind(u),createSelectorHook:m.bind(s),createObservable:g.bind(s),dispose:function(){c(),u.dispose()}};return Object.assign(s,l),s}function m(t,e){var n=null==e?void 0:e.name,o=null==e?void 0:e.isEqualRoot,i=null==e?void 0:e.isEqual,a=this.getState(),u=(null!=t?t:function(t){return t})(a),c=new h(u,{name:null!=n?n:(0,v.uniqueId)("sh:")}),s=this.subscribe(function(e){if(!(null!=o?o:Object.is)(a,e)){a=e;var r=t(e);(null!=i?i:Object.is)(u,r)||(u=r,c.setState(r))}},{skipFirst:!0}),l=function(){return(t=c.use.apply(c,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,i,a=[],u=!0,c=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(a.push(r.value),1!==a.length);u=!0);}catch(t){c=!0,n=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(c)throw n}}return a}}(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 c.getState()},subscribe:c.subscribe.bind(c),createSelectorHook:m.bind(l),createObservable:g.bind(l),dispose:function(){s(),c.dispose()}};return Object.assign(l,f),l}t.GlobalStore=h,t.default=h})(),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 i=r[t]={exports:{}};return e[t](i,i.exports,n),i.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 i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(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=i(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||[],i(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&&a(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))},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()},506:t=>{"use strict";t.exports=r},512:t=>{"use strict";t.exports=n},773:t=>{"use strict";t.exports=o},868: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=r(773);e.isRecord=function(t){return!(0,o.isNil)(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 i=r[n]={exports:{}};return e[n](i,i.exports,t),i.exports}(35)})(),t.exports=n(r(773))},955:t=>{"use strict";t.exports=a}},c={};function s(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return u[t].call(r.exports,r,r.exports,s),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(){var t,e,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.toStringTag||"@@toStringTag";function u(r,o,i,a){var u=o&&o.prototype instanceof s?o:s,l=Object.create(u.prototype);return n(l,"_invoke",function(r,n,o){var i,a,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,a=0,u=t,p.n=r,c}};function y(r,n){for(a=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],y=p.p,d=i[2];r>3?(o=d===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(a=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,a=0))}if(o||r>1)return c;throw f=!0,n}return function(o,l,d){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&y(l,d),a=l,u=d;(e=a<2?t:u)||!f;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(s=2,i){if(a||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==c)break}catch(e){i=t,a=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,i,a),!0),l}var c={};function s(){}function l(){}function f(){}e=Object.getPrototypeOf;var p=[][i]?e(e([][i]())):(n(e={},i,function(){return this}),e),y=f.prototype=s.prototype=Object.create(p);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,n(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t}return l.prototype=f,n(y,"constructor",f),n(f,"constructor",l),l.displayName="GeneratorFunction",n(f,a,"GeneratorFunction"),n(y),n(y,a,"Generator"),n(y,i,function(){return this}),n(y,"toString",function(){return"[object Generator]"}),(r=function(){return{w:u,m:d}})()}function n(t,e,r,o){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}n=function(t,e,r,o){if(e)i?i(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r;else{var a=function(e,r){n(t,e,function(t){return this._invoke(e,r,t)})};a("next",0),a("throw",1),a("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 i(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(i=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var c=s(318),f=s(512),p=s(868),y=function(t){function e(t){var n,u,c,s,l,y=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),c=this,l=[t,y],s=a(s=e),(n=o(c,i()?Reflect.construct(s,l||[],a(c).constructor):s.apply(c,l))).asyncStorage=null,n.getMetadata=function(){var t,e;return(null===(t=n.asyncStorage)||void 0===t?void 0:t.key)?Object.assign({isAsyncStorageReady:!1,asyncStorageKey:n.asyncStorage.key},null!==(e=n.metadata)&&void 0!==e?e:{}):n.metadata},n._onInitialize=function(t){return o=n,i=[t],u=function(t){var n=this,o=t.setState,i=t.getState,a=t.setMetadata;return r().m(function t(){var u;return r().w(function(t){for(;;)switch(t.n){case 0:if(e.isAsyncStorageAvailable(n.asyncStorage)){t.n=1;break}return t.a(2);case 1:return a(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1})}),t.n=2,(0,f.getAsyncStorageItem)(n.asyncStorage);case 2:u=t.v,a(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!0})}),null===u&&(u=i(),(0,p.setAsyncStorageItem)(u,n.asyncStorage)),o(u,{forceUpdate:!0});case 3:return t.a(2)}},t)})()},new((a=void 0)||(a=Promise))(function(t,e){function r(t){try{c(u.next(t))}catch(t){e(t)}}function n(t){try{c(u.throw(t))}catch(t){e(t)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof a?o:new a(function(t){t(o)})).then(r,n)}c((u=u.apply(o,i||[])).next())});var o,i,a,u},n._onChange=function(t){var r=t.getState;e.isAsyncStorageAvailable(n.asyncStorage)&&(0,p.setAsyncStorageItem)(r(),n.asyncStorage)},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.asyncStorage=null!==(u=y.asyncStorage)&&void 0!==u?u:null,n.setMetadata(function(t){var e,r;return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1,asyncStorageKey:null!==(r=null===(e=n.asyncStorage)||void 0===e?void 0:e.key)&&void 0!==r?r: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}(c.GlobalStoreAbstract);t.GlobalStore=y,y.isAsyncStorageAvailable=function(t){return Boolean(null==t?void 0:t.key)},t.default=y})(),l})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("json-storage-formatter/isDate"),require("react"),require("json-storage-formatter/isFunction"),require("./getAsyncStorageItem.js"),require("json-storage-formatter/isNil"),require("./setAsyncStorageItem.js"),require("json-storage-formatter/isPrimitive")):"function"==typeof define&&define.amd?define(["json-storage-formatter/isDate","react","json-storage-formatter/isFunction","./getAsyncStorageItem.js","json-storage-formatter/isNil","./setAsyncStorageItem.js","json-storage-formatter/isPrimitive"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("json-storage-formatter/isDate"),require("react"),require("json-storage-formatter/isFunction"),require("./getAsyncStorageItem.js"),require("json-storage-formatter/isNil"),require("./setAsyncStorageItem.js"),require("json-storage-formatter/isPrimitive")):t["react-native-global-state-hooks"]=e(t["json-storage-formatter/isDate"],t.react,t["json-storage-formatter/isFunction"],t["./getAsyncStorageItem.js"],t["json-storage-formatter/isNil"],t["./setAsyncStorageItem.js"],t["json-storage-formatter/isPrimitive"]);
|
|
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"]);
|
package/asyncStorageWrapper.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type AsyncStorageManager = {
|
|
|
7
7
|
* @param key storage key
|
|
8
8
|
* @returns stored value or null if not found
|
|
9
9
|
*/
|
|
10
|
-
getItem:
|
|
10
|
+
getItem: (key: string) => Promise<string | null>;
|
|
11
11
|
/**
|
|
12
12
|
* Set item in storage
|
|
13
13
|
* @param key storage key
|
|
@@ -20,7 +20,7 @@ export type AsyncStorageManager = {
|
|
|
20
20
|
* It tries to use @react-native-async-storage/async-storage by default
|
|
21
21
|
* If not available, you can add your own async storage manager using the addAsyncStorageManager method
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
declare const asyncStorageWrapper: AsyncStorageManager & {
|
|
24
24
|
addAsyncStorageManager: (callback: () => Promise<AsyncStorageManager>) => Promise<void>;
|
|
25
25
|
};
|
|
26
26
|
export default asyncStorageWrapper;
|
package/asyncStorageWrapper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e;e=e=>(()=>{"use strict";var t={463:t=>{t.exports=e},
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={463:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}var o={};return(()=>{var e=o;function t(){var e,r,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",c=o.toStringTag||"@@toStringTag";function i(t,o,a,c){var i=o&&o.prototype instanceof f?o:f,s=Object.create(i.prototype);return n(s,"_invoke",function(t,n,o){var a,c,i,f=0,s=o||[],v=!1,l={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,c=0,i=e,l.n=n,u}};function d(t,n){for(c=t,i=n,r=0;!v&&f&&!o&&r<s.length;r++){var o,a=s[r],d=l.p,p=a[2];t>3?(o=p===n)&&(i=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=t<2&&d<a[1])?(c=0,l.v=n,l.n=a[1]):d<p&&(o=t<3||a[0]>n||n>p)&&(a[4]=t,a[5]=n,l.n=p,c=0))}if(o||t>1)return u;throw v=!0,n}return function(o,s,p){if(f>1)throw TypeError("Generator is already running");for(v&&1===s&&d(s,p),c=s,i=p;(r=c<2?e:i)||!v;){a||(c?c<3?(c>1&&(l.n=-1),d(c,i)):l.n=i:l.v=i);try{if(f=2,a){if(c||(o="next"),r=a[o]){if(!(r=r.call(a,i)))throw TypeError("iterator result is not an object");if(!r.done)return r;i=r.value,c<2&&(c=0)}else 1===c&&(r=a.return)&&r.call(a),c<2&&(i=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((r=(v=l.n<0)?i:t.call(n,l))!==u)break}catch(t){a=e,c=1,i=t}finally{f=1}}return{value:r,done:v}}}(t,a,c),!0),s}var u={};function f(){}function s(){}function v(){}r=Object.getPrototypeOf;var l=[][a]?r(r([][a]())):(n(r={},a,function(){return this}),r),d=v.prototype=f.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,n(e,c,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=v,n(d,"constructor",v),n(v,"constructor",s),s.displayName="GeneratorFunction",n(v,c,"GeneratorFunction"),n(d),n(d,c,"Generator"),n(d,a,function(){return this}),n(d,"toString",function(){return"[object Generator]"}),(t=function(){return{w:i,m:p}})()}function n(e,t,r,o){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}n=function(e,t,r,o){if(t)a?a(e,t,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[t]=r;else{var c=function(t,r){n(e,t,function(e){return this._invoke(t,r,e)})};c("next",0),c("throw",1),c("return",2)}},n(e,t,r,o)}var a,c=Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},i=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},u=(a=function(e){return a=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},a(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=a(e),r=0;r<n.length;r++)"default"!==n[r]&&c(t,e,n[r]);return i(t,e),t}),f=function(e,t,n,r){return new(n||(n=Promise))(function(o,a){function c(e){try{u(r.next(e))}catch(e){a(e)}}function i(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(c,i)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});var s=function(){var e,n="pending",o=null;f(void 0,void 0,void 0,t().m(function a(){var c,i,f,s,v;return t().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,c=Promise.resolve().then(function(){return u(r(463))}),e=c,t.n=1,c;case 1:i=t.v,f=i.default,s=f.getItem,v=f.setItem,s.bind(f),v.bind(f),o={getItem:s,setItem:v},n="resolved",t.n=3;break;case 2:t.p=2,t.v,n="rejected";case 3:return t.p=3,e=null,t.f(3);case 4:return t.a(2)}},a,null,[[0,2,3,4]])}));var a=function(){throw new Error("[AsyncStorageManager Not Found] \n\n Please install the react-native-async-storage/async-storage to be use as the default async storage manager or\n add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.")},c=function(){return f(void 0,void 0,void 0,t().m(function r(){return t().w(function(t){for(;;)switch(t.n){case 0:if("pending"!==n||!e){t.n=1;break}return t.a(2,e);case 1:if("rejected"!==n){t.n=2;break}return t.a(2,e.catch(function(e){throw e}));case 2:return o||a(),t.a(2,o)}},r)}))};return{getItem:function(e){return f(void 0,void 0,void 0,t().m(function n(){return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,c();case 1:return t.a(2,o.getItem(e))}},n)}))},setItem:function(e,n){return f(void 0,void 0,void 0,t().m(function r(){return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,c();case 1:return t.a(2,o.setItem(e,n))}},r)}))},addAsyncStorageManager:function(r){return f(void 0,void 0,void 0,t().m(function a(){var c,i;return t().w(function(t){for(;;)switch(t.n){case 0:if(t.p=0,"pending"!==n||!e){t.n=1;break}return t.n=1,e.catch(function(){});case 1:return n="pending",c=r(),e=c,t.n=2,c;case 2:o=t.v,n="resolved",t.n=4;break;case 3:throw t.p=3,i=t.v,e=null,n="rejected",i;case 4:return t.a(2)}},a,null,[[0,3]])}))}}}();e.default=s})(),o})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@react-native-async-storage/async-storage")):"function"==typeof define&&define.amd?define(["@react-native-async-storage/async-storage"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("@react-native-async-storage/async-storage")):this["react-native-global-state-hooks"]=e(this["@react-native-async-storage/async-storage"]);
|
package/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,r;e=this,r=(e,r,t,o,n,a,
|
|
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"]);
|
package/createGlobalState.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StateHook, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks } from "react-hooks-global-states/types";
|
|
2
|
-
import { AsyncStorageConfig,
|
|
2
|
+
import { AsyncStorageConfig, BaseMetadata, AsyncMetadata } from "./types";
|
|
3
3
|
import React from "react";
|
|
4
|
-
export type { InferActionsType } from "react-hooks-global-states/createGlobalState";
|
|
5
|
-
|
|
4
|
+
export type { InferActionsType, InferStateApi } 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
|
|
@@ -22,7 +22,7 @@ export interface CreateGlobalState {
|
|
|
22
22
|
* );
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
|
-
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>,
|
|
25
|
+
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>, BaseMetadata>;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a global state hook that you can use across your application
|
|
28
28
|
* @param state initial state value
|
|
@@ -73,13 +73,13 @@ export interface CreateGlobalState {
|
|
|
73
73
|
* }
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
|
-
<State, Metadata extends
|
|
76
|
+
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
77
77
|
name?: string;
|
|
78
78
|
metadata?: Metadata;
|
|
79
79
|
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
80
80
|
actions?: ActionsConfig;
|
|
81
|
-
asyncStorage?: AsyncStorageConfig
|
|
82
|
-
}): StateHook<State, PublicStateMutator,
|
|
81
|
+
asyncStorage?: AsyncStorageConfig<State>;
|
|
82
|
+
}): StateHook<State, PublicStateMutator, AsyncMetadata<Metadata>>;
|
|
83
83
|
/**
|
|
84
84
|
* Creates a global state hook that you can use across your application
|
|
85
85
|
* @param state initial state value
|
|
@@ -130,12 +130,12 @@ export interface CreateGlobalState {
|
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
133
|
-
<State, Metadata extends
|
|
133
|
+
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>, PublicStateMutator = ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
134
134
|
name?: string;
|
|
135
135
|
metadata?: Metadata;
|
|
136
136
|
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
137
137
|
actions: ActionsConfig;
|
|
138
|
-
asyncStorage?: AsyncStorageConfig
|
|
138
|
+
asyncStorage?: AsyncStorageConfig<State>;
|
|
139
139
|
}): StateHook<State, PublicStateMutator, Metadata>;
|
|
140
140
|
}
|
|
141
141
|
/**
|
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* By handling the same structure as the original library,
|
|
3
3
|
* We can add the specific overrides for web while keeping the modularity of the library.
|
|
4
4
|
*/
|
|
5
|
-
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback,
|
|
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
7
|
export { uniqueId } from "./uniqueId";
|
|
8
8
|
export { throwWrongKeyOnActionCollectionConfig } from "./throwWrongKeyOnActionCollectionConfig";
|
|
@@ -10,7 +10,5 @@ export { isRecord } from "./isRecord";
|
|
|
10
10
|
export { type ContextProvider, type ContextHook, type InferContextApi, createContext } from "./createContext";
|
|
11
11
|
export type { AsyncStorageConfig } from "./types";
|
|
12
12
|
export { GlobalStore } from "./GlobalStore";
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export { setAsyncStorageItem } from "./setAsyncStorageItem";
|
|
16
|
-
export { asyncStorageWrapper, type AsyncStorageManager } from "./asyncStorageWrapper";
|
|
13
|
+
export { createGlobalState, type InferActionsType, type InferStateApi } from "./createGlobalState";
|
|
14
|
+
export { default as asyncStorageWrapper, type AsyncStorageManager } from "./asyncStorageWrapper";
|
package/isPromise.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-global-state-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.1",
|
|
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",
|
|
@@ -26,16 +26,6 @@
|
|
|
26
26
|
"require": "./createGlobalState.js",
|
|
27
27
|
"types": "./createGlobalState.d.ts"
|
|
28
28
|
},
|
|
29
|
-
"./getAsyncStorageItem": {
|
|
30
|
-
"import": "./getAsyncStorageItem.js",
|
|
31
|
-
"require": "./getAsyncStorageItem.js",
|
|
32
|
-
"types": "./getAsyncStorageItem.d.ts"
|
|
33
|
-
},
|
|
34
|
-
"./setAsyncStorageItem": {
|
|
35
|
-
"import": "./setAsyncStorageItem.js",
|
|
36
|
-
"require": "./setAsyncStorageItem.js",
|
|
37
|
-
"types": "./setAsyncStorageItem.d.ts"
|
|
38
|
-
},
|
|
39
29
|
"./GlobalStore": {
|
|
40
30
|
"import": "./GlobalStore.js",
|
|
41
31
|
"require": "./GlobalStore.js",
|
|
@@ -63,17 +53,18 @@
|
|
|
63
53
|
],
|
|
64
54
|
"scripts": {
|
|
65
55
|
"format": "prettier --write . --log-level silent && yarn lint:fix",
|
|
56
|
+
"test": "yarn build && yarn jest",
|
|
66
57
|
"test:debug:no-watch": "node --inspect-brk node_modules/.bin/jest --no-watchman --runInBand",
|
|
67
58
|
"test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
|
|
68
|
-
"test:quick": "
|
|
69
|
-
"test:coverage": "
|
|
59
|
+
"test:quick": "yarn test --no-coverage --maxWorkers=4 -c --no-watchman -u",
|
|
60
|
+
"test:coverage": "yarn test --maxWorkers=4 -c --colors --no-watchman --verbose --coverage",
|
|
70
61
|
"build": "yarn ts-check && yarn clean && webpack --config webpack.config.js",
|
|
71
62
|
"prepare": "yarn format && npm run build && yarn test:quick",
|
|
72
63
|
"version": "npm run format && yarn build && yarn jest && git add -A",
|
|
73
64
|
"postversion": "git push && git push --tags",
|
|
74
|
-
"lint": "eslint
|
|
75
|
-
"lint:fix": "eslint --fix
|
|
76
|
-
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' ! -name 'eslint.config.mts' -exec rm {} +",
|
|
65
|
+
"lint": "eslint . --max-warnings=0",
|
|
66
|
+
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
67
|
+
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' ! -name 'eslint.config.mts' -exec rm {} + && rm -rf coverage",
|
|
77
68
|
"ts-check": "tsc -p tsconfig.json --noEmit"
|
|
78
69
|
},
|
|
79
70
|
"repository": {
|
|
@@ -129,7 +120,7 @@
|
|
|
129
120
|
"jest": "^29.7.0",
|
|
130
121
|
"jest-environment-jsdom": "^29.7.0",
|
|
131
122
|
"jiti": "^2.6.1",
|
|
132
|
-
"json-storage-formatter": "^
|
|
123
|
+
"json-storage-formatter": "^3.0.2",
|
|
133
124
|
"prettier": "^3.6.2",
|
|
134
125
|
"react": "^18.2.0",
|
|
135
126
|
"react-dom": "^18.2.0",
|
|
@@ -145,7 +136,7 @@
|
|
|
145
136
|
},
|
|
146
137
|
"peerDependencies": {
|
|
147
138
|
"@react-native-async-storage/async-storage": ">=1.17.11",
|
|
148
|
-
"json-storage-formatter": "^
|
|
139
|
+
"json-storage-formatter": "^3.0.2",
|
|
149
140
|
"react": ">=18.0.0",
|
|
150
141
|
"react-native": ">=0.69.0"
|
|
151
142
|
},
|
|
@@ -164,6 +155,6 @@
|
|
|
164
155
|
}
|
|
165
156
|
},
|
|
166
157
|
"dependencies": {
|
|
167
|
-
"react-hooks-global-states": "^
|
|
158
|
+
"react-hooks-global-states": "^15.0.3"
|
|
168
159
|
}
|
|
169
160
|
}
|
package/tryCatch.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type TryCatchResult<T extends (...args: any) => any, Fallback extends ReturnType<T> | undefined> = T extends () => Promise<infer R> ? Promise<{
|
|
2
|
+
result: Fallback extends undefined ? R | null : NonNullable<R>;
|
|
3
|
+
error: any;
|
|
4
|
+
}> : {
|
|
5
|
+
result: Fallback extends undefined ? ReturnType<T> | null : NonNullable<ReturnType<T>>;
|
|
6
|
+
error: any;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Lineal try/catch function.
|
|
10
|
+
*
|
|
11
|
+
* If the callback is synchronous, it returns an object: `{ result, error }`.
|
|
12
|
+
* If the callback returns a promise, it returns a promise that resolves to: `{ result, error }`.
|
|
13
|
+
*
|
|
14
|
+
* @template T
|
|
15
|
+
* @param {() => T | Promise<T>} callback - The function to execute.
|
|
16
|
+
* @returns {{ result: T | null, error: any } | Promise<{ result: T | null, error: any }>}
|
|
17
|
+
*/
|
|
18
|
+
declare function tryCatch<T extends () => any, Fallback extends Awaited<ReturnType<T>> | undefined>(callback: T, fallback?: Fallback): TryCatchResult<T, Fallback>;
|
|
19
|
+
export default tryCatch;
|
package/types.d.ts
CHANGED
|
@@ -1,19 +1,97 @@
|
|
|
1
|
-
export type { StateApi, AnyFunction,
|
|
1
|
+
export type { StateApi, AnyFunction, StateChanges, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, } from "react-hooks-global-states/types";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { BaseMetadata as BaseLibraryMetadata,
|
|
3
|
+
import type { BaseMetadata as BaseLibraryMetadata, StateApi, StateChanges, SubscriberParameters, UseHookOptions } from "react-hooks-global-states";
|
|
4
4
|
import { AnyFunction, SubscribeToState } from "react-hooks-global-states/types";
|
|
5
|
-
export type AsyncStorageConfig = {
|
|
6
|
-
key: string | (() => string);
|
|
5
|
+
export type AsyncStorageConfig<State> = {
|
|
7
6
|
/**
|
|
8
|
-
* The
|
|
7
|
+
* @description The key used to store the item in async storage.
|
|
9
8
|
*/
|
|
10
|
-
|
|
9
|
+
key: string;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* @description Validator function to ensure the integrity of the restored state.
|
|
12
|
+
* Receives the restored value and the initial state... If the function returns a value then
|
|
13
|
+
* that value is used as the new state. If it returns `void` (undefined) then the restored state is used
|
|
14
|
+
* and the async storage is updated accordingly.
|
|
15
|
+
*
|
|
16
|
+
* Executes after every initialization from async storage, including after migration.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* validator: ({ restored, initial }) => {
|
|
21
|
+
* if (typeof restored !== 'number') {
|
|
22
|
+
* return initial;
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* return restored;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
13
28
|
*/
|
|
14
|
-
|
|
29
|
+
validator: (args: {
|
|
30
|
+
restored: unknown;
|
|
31
|
+
initial: any;
|
|
32
|
+
}) => any | void;
|
|
33
|
+
/**
|
|
34
|
+
* @description Error callback invoked when an exception occurs during any persistence phase.
|
|
35
|
+
* Use this to log or report issues without throwing.
|
|
36
|
+
*/
|
|
37
|
+
onError?: (error: unknown) => void;
|
|
38
|
+
versioning?: {
|
|
39
|
+
/**
|
|
40
|
+
* @description Current schema version for this item. When the stored version differs,
|
|
41
|
+
* the `migrator` function is invoked to upgrade the stored value.
|
|
42
|
+
* @default -1
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* {
|
|
46
|
+
* key: 'counter',
|
|
47
|
+
* version: 1
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
version: string | number;
|
|
52
|
+
/**
|
|
53
|
+
* @description Called when a stored value is found with a different version.
|
|
54
|
+
* Receives the raw stored value and must return the upgraded `State`.
|
|
55
|
+
* If and error is thrown during migration, the `onError` callback is invoked
|
|
56
|
+
* and the state falls back to the initial value.
|
|
57
|
+
*/
|
|
58
|
+
migrator: (args: {
|
|
59
|
+
legacy: unknown;
|
|
60
|
+
initial: any;
|
|
61
|
+
}) => any;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* @description High level overrides of the async storage synchronization
|
|
65
|
+
* Use it if you want to have full control of how the state is stored/retrieved.
|
|
66
|
+
*
|
|
67
|
+
* This disables versioning, migration
|
|
68
|
+
*/
|
|
69
|
+
adapter?: {
|
|
70
|
+
/**
|
|
71
|
+
* @description Custom setter for the stored value associated with `key`.
|
|
72
|
+
*/
|
|
73
|
+
setItem: (key: string, value: State) => Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* @description Custom getter for the stored value associated with `key`.
|
|
76
|
+
* Should return the previously stored value (parsed/decoded to `State`) for that key.
|
|
77
|
+
*/
|
|
78
|
+
getItem: (key: string) => Promise<State | null>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* @description Structure of the item stored in async storage
|
|
83
|
+
*/
|
|
84
|
+
export type ItemEnvelope<T> = {
|
|
85
|
+
/**
|
|
86
|
+
* @description Actual stored state
|
|
87
|
+
*/
|
|
88
|
+
s: T;
|
|
89
|
+
/**
|
|
90
|
+
* @description Version of the stored state
|
|
91
|
+
*/
|
|
92
|
+
v?: string | number;
|
|
15
93
|
};
|
|
16
|
-
export type
|
|
94
|
+
export type BaseMetadata = BaseLibraryMetadata & {
|
|
17
95
|
isAsyncStorageReady?: boolean;
|
|
18
96
|
asyncStorageKey?: string | null;
|
|
19
97
|
};
|
|
@@ -21,44 +99,26 @@ export type AsyncMetadata = BaseLibraryMetadata & {
|
|
|
21
99
|
* The base metadata for async storage always carries the information about the async storage state and
|
|
22
100
|
* the key used to store the state in async storage.
|
|
23
101
|
*/
|
|
24
|
-
export type
|
|
25
|
-
export
|
|
26
|
-
/**
|
|
27
|
-
* @description
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]>;
|
|
38
|
-
/***
|
|
39
|
-
* @description Creates a new hooks that returns the result of the selector passed as a parameter
|
|
40
|
-
* Your can create selector hooks of other selectors hooks and extract as many derived states as or fragments of the state as you want
|
|
41
|
-
* The selector hook will be evaluated only if the result of the selector changes and the equality function returns false
|
|
42
|
-
* you can customize the equality function by passing the isEqualRoot and isEqual parameters
|
|
43
|
-
*/
|
|
44
|
-
createSelectorHook: <Derivate>(this: StateHook<State, StateMutator, Metadata>, selector: (state: State) => Derivate, args?: Omit<UseHookOptions<Derivate, State>, "dependencies"> & {
|
|
45
|
-
name?: string;
|
|
46
|
-
}) => StateHook<Derivate, StateMutator, Metadata>;
|
|
47
|
-
createObservable: <Fragment>(this: StateHook<State, StateMutator, Metadata>, mainSelector: (state: State) => Fragment, args?: {
|
|
48
|
-
isEqual?: (current: Fragment, next: Fragment) => boolean;
|
|
49
|
-
isEqualRoot?: (current: State, next: State) => boolean;
|
|
50
|
-
name?: string;
|
|
51
|
-
}) => ObservableFragment<Fragment, StateMutator, Metadata>;
|
|
52
|
-
};
|
|
53
|
-
export interface StateHook<State, StateMutator, Metadata extends AsyncMetadata> extends HookExtensions<State, StateMutator, Metadata> {
|
|
54
|
-
(): Readonly<[state: State, stateMutator: StateMutator, metadata: Metadata]> & HookExtensions<State, StateMutator, Metadata>;
|
|
55
|
-
<Derivate>(selector: (state: State) => Derivate, config?: UseHookOptions<Derivate, State>): Readonly<[state: Derivate, stateMutator: StateMutator, metadata: Metadata]> & HookExtensions<Derivate, StateMutator, Metadata>;
|
|
102
|
+
export type AsyncMetadata<T> = (keyof T extends never ? {} : T) & BaseMetadata;
|
|
103
|
+
export interface StateHook<State, StateMutator, Metadata extends BaseMetadata> extends StateApi<State, StateMutator, Metadata> {
|
|
104
|
+
/**
|
|
105
|
+
* @description React hook that provides access to the state, state mutator, and metadata.
|
|
106
|
+
*/
|
|
107
|
+
(): Readonly<[state: State, stateMutator: StateMutator, metadata: Metadata]>;
|
|
108
|
+
/**
|
|
109
|
+
* @description React hook that provides a derived state based on the provided selector function.
|
|
110
|
+
*/
|
|
111
|
+
<Derivate>(selector: (state: State) => Derivate, dependencies?: unknown[]): Readonly<[state: Derivate, stateMutator: StateMutator, metadata: Metadata]>;
|
|
112
|
+
/**
|
|
113
|
+
* @description React hook that provides a derived state based on the provided selector function and configuration.
|
|
114
|
+
*/
|
|
115
|
+
<Derivate>(selector: (state: State) => Derivate, config?: UseHookOptions<Derivate, State>): Readonly<[state: Derivate, stateMutator: StateMutator, metadata: Metadata]>;
|
|
56
116
|
}
|
|
57
|
-
export type MetadataSetter<Metadata extends
|
|
117
|
+
export type MetadataSetter<Metadata extends BaseMetadata> = (setter: Metadata | ((metadata: Metadata) => Metadata)) => void;
|
|
58
118
|
/**
|
|
59
119
|
* API for the actions of the global states
|
|
60
120
|
**/
|
|
61
|
-
export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction<State>>, Metadata extends
|
|
121
|
+
export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction<State>>, Metadata extends BaseMetadata = BaseMetadata> = {
|
|
62
122
|
/**
|
|
63
123
|
* The actions available for the global state
|
|
64
124
|
*/
|
|
@@ -99,20 +159,43 @@ export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction
|
|
|
99
159
|
/**
|
|
100
160
|
* contract for the storeActionsConfig configuration
|
|
101
161
|
*/
|
|
102
|
-
export interface ActionCollectionConfig<State, Metadata extends
|
|
162
|
+
export interface ActionCollectionConfig<State, Metadata extends BaseMetadata, ThisAPI = Record<string, (...parameters: any[]) => unknown>> {
|
|
103
163
|
readonly [key: string]: {
|
|
104
164
|
(this: ThisAPI, ...parameters: any[]): (this: ThisAPI, storeTools: StoreTools<State, Record<string, (...parameters: any[]) => unknown | void>, Metadata>) => unknown | void;
|
|
105
165
|
};
|
|
106
166
|
}
|
|
107
|
-
|
|
167
|
+
/**
|
|
168
|
+
* @description Resulting type of the action collection configuration
|
|
169
|
+
*/
|
|
170
|
+
export type ActionCollectionResult<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>> = {
|
|
108
171
|
[key in keyof ActionsConfig]: {
|
|
109
172
|
(...params: Parameters<ActionsConfig[key]>): ReturnType<ReturnType<ActionsConfig[key]>>;
|
|
110
173
|
};
|
|
111
174
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Callbacks for the global store lifecycle events
|
|
177
|
+
*/
|
|
178
|
+
export type GlobalStoreCallbacks<State, StateMutator, Metadata extends BaseMetadata> = {
|
|
179
|
+
/**
|
|
180
|
+
* @description Called when the store is initialized
|
|
181
|
+
*/
|
|
182
|
+
onInit?: (args: StoreTools<State, StateMutator, Metadata>) => void;
|
|
183
|
+
/**
|
|
184
|
+
* @description Called when the state has changed
|
|
185
|
+
*/
|
|
186
|
+
onStateChanged?: (args: StoreTools<State, StateMutator, Metadata> & StateChanges<State>) => void;
|
|
187
|
+
/**
|
|
188
|
+
* @description Called when a new subscription is created
|
|
189
|
+
*/
|
|
190
|
+
onSubscribed?: (args: StoreTools<State, StateMutator, Metadata>, subscription: SubscriberParameters) => void;
|
|
191
|
+
/**
|
|
192
|
+
* @description Called to determine whether to prevent a state change
|
|
193
|
+
*/
|
|
194
|
+
computePreventStateChange?: (args: StoreTools<State, StateMutator, Metadata> & StateChanges<State>) => boolean;
|
|
195
|
+
/**
|
|
196
|
+
* @description Called when the store is unmounted, only applicable in context stores
|
|
197
|
+
*/
|
|
198
|
+
onUnMount?: (store: StoreTools<State, StateMutator, Metadata>) => void;
|
|
117
199
|
};
|
|
118
|
-
export type MetadataGetter<Metadata extends
|
|
200
|
+
export type MetadataGetter<Metadata extends BaseMetadata> = () => Metadata;
|
|
201
|
+
export type ObservableFragment<State, StateMutator, Metadata extends BaseMetadata> = SubscribeToState<State> & Pick<StateApi<State, StateMutator, Metadata>, "getState" | "subscribe" | "createSelectorHook" | "createObservable" | "dispose" | "subscribers">;
|
package/webpack.config.js
CHANGED
|
@@ -16,8 +16,6 @@ const individualEntries = {
|
|
|
16
16
|
|
|
17
17
|
// extras
|
|
18
18
|
asyncStorageWrapper: "./src/asyncStorageWrapper.ts",
|
|
19
|
-
getAsyncStorageItem: "./src/getAsyncStorageItem.ts",
|
|
20
|
-
setAsyncStorageItem: "./src/setAsyncStorageItem.ts",
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
const generateExternalEntryMappings = () => {
|
package/getAsyncStorageItem.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AsyncStorageConfig } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Gets an item from async storage
|
|
4
|
-
* @param args AsyncStorageConfig configuration
|
|
5
|
-
* @returns The stored value or null if not found
|
|
6
|
-
*/
|
|
7
|
-
export declare const getAsyncStorageItem: <TState>(args: AsyncStorageConfig) => Promise<TState>;
|
|
8
|
-
export default getAsyncStorageItem;
|
package/getAsyncStorageItem.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t,r;t=this,r=(t,r)=>(()=>{"use strict";var e={114:r=>{r.exports=t},330:t=>{t.exports=r},494:(t,r,e)=>{function o(){var t,r,e="function"==typeof Symbol?Symbol:{},a=e.iterator||"@@iterator",c=e.toStringTag||"@@toStringTag";function i(e,o,a,c){var i=o&&o.prototype instanceof f?o:f,s=Object.create(i.prototype);return n(s,"_invoke",function(e,o,n){var a,c,i,f=0,s=n||[],p=!1,y={p:0,n:0,v:t,a:l,f:l.bind(t,4),d:function(r,e){return a=r,c=0,i=t,y.n=e,u}};function l(e,o){for(c=e,i=o,r=0;!p&&f&&!n&&r<s.length;r++){var n,a=s[r],l=y.p,v=a[2];e>3?(n=v===o)&&(i=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=t):a[0]<=l&&((n=e<2&&l<a[1])?(c=0,y.v=o,y.n=a[1]):l<v&&(n=e<3||a[0]>o||o>v)&&(a[4]=e,a[5]=o,y.n=v,c=0))}if(n||e>1)return u;throw p=!0,o}return function(n,s,v){if(f>1)throw TypeError("Generator is already running");for(p&&1===s&&l(s,v),c=s,i=v;(r=c<2?t:i)||!p;){a||(c?c<3?(c>1&&(y.n=-1),l(c,i)):y.n=i:y.v=i);try{if(f=2,a){if(c||(n="next"),r=a[n]){if(!(r=r.call(a,i)))throw TypeError("iterator result is not an object");if(!r.done)return r;i=r.value,c<2&&(c=0)}else 1===c&&(r=a.return)&&r.call(a),c<2&&(i=TypeError("The iterator does not provide a '"+n+"' method"),c=1);a=t}else if((r=(p=y.n<0)?i:e.call(o,y))!==u)break}catch(r){a=t,c=1,i=r}finally{f=1}}return{value:r,done:p}}}(e,a,c),!0),s}var u={};function f(){}function s(){}function p(){}r=Object.getPrototypeOf;var y=[][a]?r(r([][a]())):(n(r={},a,function(){return this}),r),l=p.prototype=f.prototype=Object.create(y);function v(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,n(t,c,"GeneratorFunction")),t.prototype=Object.create(l),t}return s.prototype=p,n(l,"constructor",p),n(p,"constructor",s),s.displayName="GeneratorFunction",n(p,c,"GeneratorFunction"),n(l),n(l,c,"Generator"),n(l,a,function(){return this}),n(l,"toString",function(){return"[object Generator]"}),(o=function(){return{w:i,m:v}})()}function n(t,r,e,o){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}n=function(t,r,e,o){if(r)a?a(t,r,{value:e,enumerable:!o,configurable:!o,writable:!o}):t[r]=e;else{var c=function(r,e){n(t,r,function(t){return this._invoke(r,e,t)})};c("next",0),c("throw",1),c("return",2)}},n(t,r,e,o)}Object.defineProperty(r,"__esModule",{value:!0}),r.getAsyncStorageItem=void 0;var a=e(114),c=e(330);r.getAsyncStorageItem=function(t){return r=void 0,e=o().m(function r(){var e,n,i,u,f;return o().w(function(r){for(;;)switch(r.n){case 0:if(e=t.key){r.n=1;break}return r.a(2,null);case 1:return n=function(){return"function"==typeof e?e():e}(),r.n=2,a.asyncStorageWrapper.getItem(n);case 2:if(null!==(i=r.v)){r.n=3;break}return r.a(2,null);case 3:return u=function(){return t.decrypt||t.encrypt?"function"==typeof t.decrypt?t.decrypt(i):atob(i):i}(),f=(0,c.formatFromStore)(u,{jsonParse:!0}),r.a(2,f)}},r)}),new(r||(r=Promise))(function(t,o){function n(t){try{c(e.next(t))}catch(t){o(t)}}function a(t){try{c(e.throw(t))}catch(t){o(t)}}function c(e){var o;e.done?t(e.value):(o=e.value,o instanceof r?o:new r(function(t){t(o)})).then(n,a)}c((e=e.apply(void 0,[])).next())});var r,e},r.default=r.getAsyncStorageItem}},o={};return function t(r){var n=o[r];if(void 0!==n)return n.exports;var a=o[r]={exports:{}};return e[r](a,a.exports,t),a.exports}(494)})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatFromStore")):"function"==typeof define&&define.amd?define(["./asyncStorageWrapper.js","json-storage-formatter/formatFromStore"],r):"object"==typeof exports?exports["react-native-global-state-hooks"]=r(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatFromStore")):t["react-native-global-state-hooks"]=r(t["./asyncStorageWrapper.js"],t["json-storage-formatter/formatFromStore"]);
|
package/setAsyncStorageItem.d.ts
DELETED
package/setAsyncStorageItem.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e,t;e=this,t=(e,t)=>(()=>{"use strict";var r={114:t=>{t.exports=e},306:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setAsyncStorageItem=void 0;var o=r(413),a=r(114);t.setAsyncStorageItem=function(e,t){var r=t.key;if(r){var s="function"==typeof r?r():r,n=(0,o.formatToStore)(e,{stringify:!0,excludeTypes:["function"]}),p=t.encrypt?"function"==typeof t.encrypt?t.encrypt(n):btoa(n):n;a.asyncStorageWrapper.setItem(s,p)}},t.default=t.setAsyncStorageItem},413:e=>{e.exports=t}},o={};return function e(t){var a=o[t];if(void 0!==a)return a.exports;var s=o[t]={exports:{}};return r[t](s,s.exports,e),s.exports}(306)})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatToStore")):"function"==typeof define&&define.amd?define(["./asyncStorageWrapper.js","json-storage-formatter/formatToStore"],t):"object"==typeof exports?exports["react-native-global-state-hooks"]=t(require("./asyncStorageWrapper.js"),require("json-storage-formatter/formatToStore")):e["react-native-global-state-hooks"]=t(e["./asyncStorageWrapper.js"],e["json-storage-formatter/formatToStore"]);
|