react-native-global-state-hooks 11.3.0 → 14.0.0
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 +14 -11
- package/GlobalStore.js +1 -1
- package/README.md +5 -5
- package/asyncStorageWrapper.d.ts +18 -0
- package/bundle.js +1 -1
- package/createContext.d.ts +1 -1
- package/createGlobalState.d.ts +135 -9
- package/createGlobalState.js +1 -1
- package/getAsyncStorageItem.d.ts +5 -0
- package/index.d.ts +2 -6
- package/package.json +18 -26
- package/types.d.ts +64 -29
- package/webpack.config.js +4 -6
- package/GlobalStoreAbstract.d.ts +0 -10
- package/GlobalStoreAbstract.js +0 -1
- package/createCustomGlobalState.d.ts +0 -23
- package/createCustomGlobalState.js +0 -1
- package/generateStackHash.d.ts +0 -1
- package/generateStackHash.js +0 -1
- package/useStableState.d.ts +0 -1
- package/useStableState.js +0 -1
package/GlobalStore.d.ts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import type { ActionCollectionConfig, GlobalStoreCallbacks, StateChanges, StoreTools } from "react-hooks-global-states/types";
|
|
2
|
-
import type { AsyncStorageConfig, BaseMetadata,
|
|
2
|
+
import type { ActionCollectionResult, AsyncStorageConfig, AsyncMetadata, BaseMetadata, AnyFunction } from "./types";
|
|
3
3
|
import { GlobalStoreAbstract } from "react-hooks-global-states/GlobalStoreAbstract";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* React Native Global Store with Async Storage support
|
|
6
|
+
*/
|
|
7
|
+
export declare class GlobalStore<State, Metadata extends AsyncMetadata, 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, BaseMetadata<Metadata>, ActionsConfig> {
|
|
8
|
+
asyncStorage: AsyncStorageConfig | null;
|
|
6
9
|
constructor(state: State);
|
|
7
10
|
constructor(state: State, args: {
|
|
8
11
|
metadata?: Metadata;
|
|
9
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
12
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator extends AnyFunction ? null : PublicStateMutator, Metadata>;
|
|
10
13
|
actions?: ActionsConfig;
|
|
11
14
|
name?: string;
|
|
12
15
|
asyncStorage?: AsyncStorageConfig;
|
|
13
16
|
});
|
|
14
|
-
|
|
17
|
+
getMetadata: () => BaseMetadata<Metadata>;
|
|
15
18
|
static isAsyncStorageAvailable: (config: AsyncStorageConfig | null) => config is AsyncStorageConfig;
|
|
16
|
-
protected _onInitialize: ({ setState, getState, setMetadata, }: StoreTools<State, Metadata>) => Promise<void>;
|
|
17
|
-
protected _onChange: ({ getState }: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
19
|
+
protected _onInitialize: ({ setState, getState, setMetadata, }: StoreTools<State, PublicStateMutator, Metadata>) => Promise<void>;
|
|
20
|
+
protected _onChange: ({ getState, }: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
18
21
|
/**
|
|
19
22
|
* We set it to null so the instances of the GlobalStoreAbstract can override it.
|
|
20
23
|
*/
|
|
21
|
-
protected onInitialize: (args: StoreTools<State,
|
|
22
|
-
protected onChange: (args: StoreTools<State,
|
|
24
|
+
protected onInitialize: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
25
|
+
protected onChange: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
23
26
|
/**
|
|
24
27
|
* Instead of calling onInitialize and onChange directly, we call the _onInitialize and _onChange
|
|
25
28
|
* This allows the concat the logic of the GlobalStore with the logic of the extension class.
|
|
26
29
|
*/
|
|
27
|
-
protected onInit: (parameters: StoreTools<State,
|
|
28
|
-
protected onStateChanged: (args: StoreTools<State,
|
|
30
|
+
protected onInit: (parameters: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
31
|
+
protected onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
29
32
|
}
|
|
30
33
|
export default GlobalStore;
|
package/GlobalStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e;t=this,e=(t,e,n)=>(()=>{"use strict";var r={266:e=>{e.exports=t},512:t=>{t.exports=e},868:t=>{t.exports=n}},o={};function a(t){var e=o[t];if(void 0!==e)return e.exports;var n=o[t]={exports:{}};return r[t](n,n.exports,a),n.exports}var c={};return(()=>{var t=c;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 n(){var t,e,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",c=o.toStringTag||"@@toStringTag";function i(n,o,a,c){var i=o&&o.prototype instanceof s?o:s,l=Object.create(i.prototype);return r(l,"_invoke",function(n,r,o){var a,c,i,s=0,l=o||[],f=!1,y={p:0,n:0,v:t,a:p,f:p.bind(t,4),d:function(e,n){return a=e,c=0,i=t,y.n=n,u}};function p(n,r){for(c=n,i=r,e=0;!f&&s&&!o&&e<l.length;e++){var o,a=l[e],p=y.p,b=a[2];n>3?(o=b===r)&&(i=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=t):a[0]<=p&&((o=n<2&&p<a[1])?(c=0,y.v=r,y.n=a[1]):p<b&&(o=n<3||a[0]>r||r>b)&&(a[4]=n,a[5]=r,y.n=b,c=0))}if(o||n>1)return u;throw f=!0,r}return function(o,l,b){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,b),c=l,i=b;(e=c<2?t:i)||!f;){a||(c?c<3?(c>1&&(y.n=-1),p(c,i)):y.n=i:y.v=i);try{if(s=2,a){if(c||(o="next"),e=a[o]){if(!(e=e.call(a,i)))throw TypeError("iterator result is not an object");if(!e.done)return e;i=e.value,c<2&&(c=0)}else 1===c&&(e=a.return)&&e.call(a),c<2&&(i=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=t}else if((e=(f=y.n<0)?i:n.call(r,y))!==u)break}catch(e){a=t,c=1,i=e}finally{s=1}}return{value:e,done:f}}}(n,a,c),!0),l}var u={};function s(){}function l(){}function f(){}e=Object.getPrototypeOf;var y=[][a]?e(e([][a]())):(r(e={},a,function(){return this}),e),p=f.prototype=s.prototype=Object.create(y);function b(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,r(t,c,"GeneratorFunction")),t.prototype=Object.create(p),t}return l.prototype=f,r(p,"constructor",f),r(f,"constructor",l),l.displayName="GeneratorFunction",r(f,c,"GeneratorFunction"),r(p),r(p,c,"Generator"),r(p,a,function(){return this}),r(p,"toString",function(){return"[object Generator]"}),(n=function(){return{w:i,m:b}})()}function r(t,e,n,o){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}r=function(t,e,n,o){if(e)a?a(t,e,{value:n,enumerable:!o,configurable:!o,writable:!o}):t[e]=n;else{var c=function(e,n){r(t,e,function(t){return this._invoke(e,n,t)})};c("next",0),c("throw",1),c("return",2)}},r(t,e,n,o)}function o(t,n){if(n&&("object"==e(n)||"function"==typeof n))return n;if(void 0!==n)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 u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function s(t,e){return s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},s(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var l=a(266),f=a(512),y=a(868),p=function(t){function e(t){var r,a,c,s,l,p=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,p],s=u(s=e),(r=o(c,i()?Reflect.construct(s,l||[],u(c).constructor):s.apply(c,l))).asyncStorage=null,r.getMetadata=function(){var t,e;return(null===(t=r.asyncStorage)||void 0===t?void 0:t.key)?Object.assign({isAsyncStorageReady:!1,asyncStorageKey:r.asyncStorage.key},null!==(e=r.metadata)&&void 0!==e?e:{}):r.metadata},r._onInitialize=function(t){return o=r,a=[t],i=function(t){var r=this,o=t.setState,a=t.getState,c=t.setMetadata;return n().m(function t(){var i;return n().w(function(t){for(;;)switch(t.n){case 0:if(e.isAsyncStorageAvailable(r.asyncStorage)){t.n=1;break}return t.a(2);case 1:return c(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1})}),t.n=2,(0,f.getAsyncStorageItem)(r.asyncStorage);case 2:i=t.v,c(function(t){return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!0})}),null===i&&(i=a(),(0,y.setAsyncStorageItem)(i,r.asyncStorage)),o(i,{forceUpdate:!0});case 3:return t.a(2)}},t)})()},new((c=void 0)||(c=Promise))(function(t,e){function n(t){try{u(i.next(t))}catch(t){e(t)}}function r(t){try{u(i.throw(t))}catch(t){e(t)}}function u(e){var o;e.done?t(e.value):(o=e.value,o instanceof c?o:new c(function(t){t(o)})).then(n,r)}u((i=i.apply(o,a||[])).next())});var o,a,c,i},r._onChange=function(t){var n=t.getState;e.isAsyncStorageAvailable(r.asyncStorage)&&(0,y.setAsyncStorageItem)(n(),r.asyncStorage)},r.onInitialize=null,r.onChange=null,r.onInit=function(t){var e;null===(e=r._onInitialize)||void 0===e||e.call(r,t)},r.onStateChanged=function(t){var e;null===(e=r._onChange)||void 0===e||e.call(r,t)},r.asyncStorage=null!==(a=p.asyncStorage)&&void 0!==a?a:null,r.setMetadata(function(t){var e,n;return Object.assign(Object.assign({},null!=t?t:{}),{isAsyncStorageReady:!1,asyncStorageKey:null!==(n=null===(e=r.asyncStorage)||void 0===e?void 0:e.key)&&void 0!==n?n:null})}),r.constructor!==e?o(r):(r.initialize(),r)}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&&s(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(l.GlobalStoreAbstract);t.GlobalStore=p,p.isAsyncStorageAvailable=function(t){return Boolean(null==t?void 0:t.key)},t.default=p})(),c})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./getAsyncStorageItem.js"),require("./setAsyncStorageItem.js")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/GlobalStoreAbstract","./getAsyncStorageItem.js","./setAsyncStorageItem.js"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./getAsyncStorageItem.js"),require("./setAsyncStorageItem.js")):t["react-native-global-state-hooks"]=e(t["react-hooks-global-states/GlobalStoreAbstract"],t["./getAsyncStorageItem.js"],t["./setAsyncStorageItem.js"]);
|
|
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"]);
|
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ You can also add **dependencies** to a selector. This is useful when you want to
|
|
|
124
124
|
```tsx
|
|
125
125
|
const [contacts] = useContacts(
|
|
126
126
|
(state) => state.entities.filter((item) => item.name.includes(filter)),
|
|
127
|
-
[filter]
|
|
127
|
+
[filter],
|
|
128
128
|
);
|
|
129
129
|
```
|
|
130
130
|
|
|
@@ -164,7 +164,7 @@ You can still **use dependencies** inside a selector hook:
|
|
|
164
164
|
```tsx
|
|
165
165
|
const [filteredContacts] = useContactsArray(
|
|
166
166
|
(contacts) => contacts.filter((c) => c.name.includes(filter)),
|
|
167
|
-
[filter]
|
|
167
|
+
[filter],
|
|
168
168
|
);
|
|
169
169
|
```
|
|
170
170
|
|
|
@@ -202,7 +202,7 @@ export const useContacts = createGlobalState(
|
|
|
202
202
|
};
|
|
203
203
|
},
|
|
204
204
|
},
|
|
205
|
-
}
|
|
205
|
+
},
|
|
206
206
|
);
|
|
207
207
|
```
|
|
208
208
|
|
|
@@ -241,7 +241,7 @@ const useSelectedContact = createGlobalState(null, {
|
|
|
241
241
|
(state) => state.contacts,
|
|
242
242
|
(contacts) => {
|
|
243
243
|
if (!contacts.has(getState())) setState(null);
|
|
244
|
-
}
|
|
244
|
+
},
|
|
245
245
|
);
|
|
246
246
|
},
|
|
247
247
|
},
|
|
@@ -348,7 +348,7 @@ const useData = createGlobalState(
|
|
|
348
348
|
return state.value === previousState.value;
|
|
349
349
|
},
|
|
350
350
|
},
|
|
351
|
-
}
|
|
351
|
+
},
|
|
352
352
|
);
|
|
353
353
|
```
|
|
354
354
|
|
package/asyncStorageWrapper.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Storage Manager
|
|
3
|
+
*/
|
|
1
4
|
export type AsyncStorageManager = {
|
|
5
|
+
/**
|
|
6
|
+
* Get item from storage
|
|
7
|
+
* @param key storage key
|
|
8
|
+
* @returns stored value or null if not found
|
|
9
|
+
*/
|
|
2
10
|
getItem: <T extends string | null>(key: string) => Promise<T>;
|
|
11
|
+
/**
|
|
12
|
+
* Set item in storage
|
|
13
|
+
* @param key storage key
|
|
14
|
+
* @param value value to store
|
|
15
|
+
*/
|
|
3
16
|
setItem: (key: string, value: string) => Promise<void>;
|
|
4
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Wrapper to manage async storage manager
|
|
20
|
+
* It tries to use @react-native-async-storage/async-storage by default
|
|
21
|
+
* If not available, you can add your own async storage manager using the addAsyncStorageManager method
|
|
22
|
+
*/
|
|
5
23
|
export declare const asyncStorageWrapper: AsyncStorageManager & {
|
|
6
24
|
addAsyncStorageManager: (callback: () => Promise<AsyncStorageManager>) => Promise<void>;
|
|
7
25
|
};
|
package/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,
|
|
1
|
+
var e,r;e=this,r=(e,r,t,o,n,a,s,i,c,l)=>(()=>{"use strict";var u={78:r=>{r.exports=e},114:e=>{e.exports=r},361:e=>{e.exports=t},487:e=>{e.exports=o},512:e=>{e.exports=n},623:e=>{e.exports=a},670:e=>{e.exports=s},673:e=>{e.exports=i},778:e=>{e.exports=c},868:e=>{e.exports=l}},g={};function j(e){var r=g[e];if(void 0!==r)return r.exports;var t=g[e]={exports:{}};return u[e](t,t.exports,j),t.exports}var p={};return(()=>{var e=p;Object.defineProperty(e,"__esModule",{value:!0}),e.asyncStorageWrapper=e.setAsyncStorageItem=e.getAsyncStorageItem=e.createGlobalState=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var r=j(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return r.shallowCompare}});var t=j(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return t.uniqueId}});var o=j(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}});var n=j(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return n.isRecord}});var a=j(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return a.createContext}});var s=j(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return s.GlobalStore}});var i=j(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return i.createGlobalState}});var c=j(512);Object.defineProperty(e,"getAsyncStorageItem",{enumerable:!0,get:function(){return c.getAsyncStorageItem}});var l=j(868);Object.defineProperty(e,"setAsyncStorageItem",{enumerable:!0,get:function(){return l.setAsyncStorageItem}});var u=j(114);Object.defineProperty(e,"asyncStorageWrapper",{enumerable:!0,get:function(){return u.asyncStorageWrapper}})})(),p})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./getAsyncStorageItem.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./setAsyncStorageItem.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./asyncStorageWrapper.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./getAsyncStorageItem.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js","./setAsyncStorageItem.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("./getAsyncStorageItem.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./setAsyncStorageItem.js")):e["react-native-global-state-hooks"]=r(e["./uniqueId.js"],e["./asyncStorageWrapper.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./getAsyncStorageItem.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"],e["./setAsyncStorageItem.js"]);
|
package/createContext.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { type ContextProvider, type ContextHook, type InferContextApi, createContext, default, } from "react-hooks-global-states/createContext";
|
package/createGlobalState.d.ts
CHANGED
|
@@ -1,22 +1,148 @@
|
|
|
1
|
-
import type { StateHook,
|
|
2
|
-
import { AsyncStorageConfig,
|
|
1
|
+
import type { StateHook, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks } from "react-hooks-global-states/types";
|
|
2
|
+
import { AsyncStorageConfig, AsyncMetadata, BaseMetadata } from "./types";
|
|
3
|
+
import React from "react";
|
|
3
4
|
export type { InferActionsType } from "react-hooks-global-states/createGlobalState";
|
|
4
5
|
export interface CreateGlobalState {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates a global state hook.
|
|
8
|
+
* @param state initial state value
|
|
9
|
+
* @returns a state hook for your components
|
|
10
|
+
* @example
|
|
11
|
+
* const useCounter = createGlobalState(0);
|
|
12
|
+
*
|
|
13
|
+
* function Counter() {
|
|
14
|
+
* const [count, setCount] = useCounter();
|
|
15
|
+
* return (
|
|
16
|
+
* <div>
|
|
17
|
+
* <p>Count: {count}</p>
|
|
18
|
+
* <button onClick={() =>
|
|
19
|
+
* setCount(prev => prev + 1)
|
|
20
|
+
* }>Increment</button>
|
|
21
|
+
* </div>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>, AsyncMetadata>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a global state hook that you can use across your application
|
|
28
|
+
* @param state initial state value
|
|
29
|
+
* @param args additional configuration for the global state
|
|
30
|
+
* @param args.name optional name for debugging purposes
|
|
31
|
+
* @param args.metadata optional non-reactive metadata associated with the state
|
|
32
|
+
* @param args.callbacks optional lifecycle callbacks for the global state
|
|
33
|
+
* @param args.actions optional actions to restrict state mutations [if provided `setState` will be nullified]
|
|
34
|
+
* @param args.asyncStorage optional configuration to persist the state in local storage
|
|
35
|
+
* @returns a state hook that you can use in your components
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* const useCounter = createGlobalState(0, {
|
|
40
|
+
* actions: {
|
|
41
|
+
* increase() {
|
|
42
|
+
* return ({ setState }) => {
|
|
43
|
+
* setState((c) => c + 1);
|
|
44
|
+
* };
|
|
45
|
+
* },
|
|
46
|
+
* decrease(amount: number) {
|
|
47
|
+
* return ({ setState }) => {
|
|
48
|
+
* setState((c) => c - amount);
|
|
49
|
+
* };
|
|
50
|
+
* },
|
|
51
|
+
* },
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* function Counter() {
|
|
55
|
+
* const [count, {
|
|
56
|
+
* increase,
|
|
57
|
+
* decrease
|
|
58
|
+
* }] = useCounter();
|
|
59
|
+
*
|
|
60
|
+
* return (
|
|
61
|
+
* <div>
|
|
62
|
+
* <p>Count: {count}</p>
|
|
63
|
+
* <button onClick={increase}>
|
|
64
|
+
* Increment
|
|
65
|
+
* </button>
|
|
66
|
+
* <button onClick={() => {
|
|
67
|
+
* decrease(1);
|
|
68
|
+
* }}>
|
|
69
|
+
* Decrement
|
|
70
|
+
* </button>
|
|
71
|
+
* </div>
|
|
72
|
+
* );
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
<State, Metadata extends AsyncMetadata, 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: {
|
|
7
77
|
name?: string;
|
|
8
78
|
metadata?: Metadata;
|
|
9
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
79
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
10
80
|
actions?: ActionsConfig;
|
|
11
81
|
asyncStorage?: AsyncStorageConfig;
|
|
12
|
-
}): StateHook<State, PublicStateMutator,
|
|
13
|
-
|
|
82
|
+
}): StateHook<State, PublicStateMutator, BaseMetadata<Metadata>>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a global state hook that you can use across your application
|
|
85
|
+
* @param state initial state value
|
|
86
|
+
* @param args additional configuration for the global state
|
|
87
|
+
* @param args.name optional name for debugging purposes
|
|
88
|
+
* @param args.metadata optional non-reactive metadata associated with the state
|
|
89
|
+
* @param args.callbacks optional lifecycle callbacks for the global state
|
|
90
|
+
* @param args.actions optional actions to restrict state mutations [if provided `setState` will be nullified]
|
|
91
|
+
* @param args.asyncStorage optional configuration to persist the state in local storage
|
|
92
|
+
* @returns a state hook that you can use in your components
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const useCounter = createGlobalState(0, {
|
|
97
|
+
* actions: {
|
|
98
|
+
* increase() {
|
|
99
|
+
* return ({ setState }) => {
|
|
100
|
+
* setState((c) => c + 1);
|
|
101
|
+
* };
|
|
102
|
+
* },
|
|
103
|
+
* decrease(amount: number) {
|
|
104
|
+
* return ({ setState }) => {
|
|
105
|
+
* setState((c) => c - amount);
|
|
106
|
+
* };
|
|
107
|
+
* },
|
|
108
|
+
* },
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* function Counter() {
|
|
112
|
+
* const [count, {
|
|
113
|
+
* increase,
|
|
114
|
+
* decrease
|
|
115
|
+
* }] = useCounter();
|
|
116
|
+
*
|
|
117
|
+
* return (
|
|
118
|
+
* <div>
|
|
119
|
+
* <p>Count: {count}</p>
|
|
120
|
+
* <button onClick={increase}>
|
|
121
|
+
* Increment
|
|
122
|
+
* </button>
|
|
123
|
+
* <button onClick={() => {
|
|
124
|
+
* decrease(1);
|
|
125
|
+
* }}>
|
|
126
|
+
* Decrement
|
|
127
|
+
* </button>
|
|
128
|
+
* </div>
|
|
129
|
+
* );
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
<State, Metadata extends AsyncMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>, PublicStateMutator = ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
14
134
|
name?: string;
|
|
15
135
|
metadata?: Metadata;
|
|
16
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
136
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
17
137
|
actions: ActionsConfig;
|
|
18
138
|
asyncStorage?: AsyncStorageConfig;
|
|
19
|
-
}): StateHook<State,
|
|
139
|
+
}): StateHook<State, PublicStateMutator, Metadata>;
|
|
20
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Creates a global state hook.
|
|
143
|
+
* @param state - The initial state value.
|
|
144
|
+
* @param args - Optional configuration arguments.
|
|
145
|
+
* @returns A state hook for managing the global state, the hook also embeds the state api methods.
|
|
146
|
+
*/
|
|
21
147
|
export declare const createGlobalState: CreateGlobalState;
|
|
22
148
|
export default createGlobalState;
|
package/createGlobalState.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e;e=e=>(()=>{"use strict";var t={778:t=>{t.exports=e},840:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createGlobalState=void 0;var
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={778:t=>{t.exports=e},840:(e,t,o)=>{function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(n=function(){return!!e})()}Object.defineProperty(t,"__esModule",{value:!0}),t.createGlobalState=void 0;var a=o(778);t.createGlobalState=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return function(e,t,o){if(n())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,t);var l=new(e.bind.apply(e,a));return o&&r(l,o.prototype),l}(a.GlobalStore,t).use},t.default=t.createGlobalState}},o={};return function e(r){var n=o[r];if(void 0!==n)return n.exports;var a=o[r]={exports:{}};return t[r](a,a.exports,e),a.exports}(840)})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("./GlobalStore.js")):this["react-native-global-state-hooks"]=e(this["./GlobalStore.js"]);
|
package/getAsyncStorageItem.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
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
|
+
*/
|
|
2
7
|
export declare const getAsyncStorageItem: <TState>(args: AsyncStorageConfig) => Promise<TState>;
|
|
3
8
|
export default getAsyncStorageItem;
|
package/index.d.ts
CHANGED
|
@@ -2,19 +2,15 @@
|
|
|
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 {
|
|
5
|
+
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, AsyncMetadata 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";
|
|
9
9
|
export { isRecord } from "./isRecord";
|
|
10
|
-
export {
|
|
11
|
-
export { type Context, type ContextProvider, type ContextHook, type CreateContext, type InferContextType, createContext, } from "./createContext";
|
|
10
|
+
export { type ContextProvider, type ContextHook, type InferContextApi, createContext } from "./createContext";
|
|
12
11
|
export type { AsyncStorageConfig } from "./types";
|
|
13
12
|
export { GlobalStore } from "./GlobalStore";
|
|
14
|
-
export { GlobalStoreAbstract } from "./GlobalStoreAbstract";
|
|
15
13
|
export { type CreateGlobalState, createGlobalState, type InferActionsType } from "./createGlobalState";
|
|
16
|
-
export { createCustomGlobalState, type CustomCreateGlobalState } from "./createCustomGlobalState";
|
|
17
14
|
export { getAsyncStorageItem } from "./getAsyncStorageItem";
|
|
18
15
|
export { setAsyncStorageItem } from "./setAsyncStorageItem";
|
|
19
16
|
export { asyncStorageWrapper, type AsyncStorageManager } from "./asyncStorageWrapper";
|
|
20
|
-
export { generateStackHash } from "./generateStackHash";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-global-state-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
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",
|
|
@@ -21,21 +21,11 @@
|
|
|
21
21
|
"require": "./createContext.js",
|
|
22
22
|
"types": "./createContext.d.ts"
|
|
23
23
|
},
|
|
24
|
-
"./createCustomGlobalState": {
|
|
25
|
-
"import": "./createCustomGlobalState.js",
|
|
26
|
-
"require": "./createCustomGlobalState.js",
|
|
27
|
-
"types": "./createCustomGlobalState.d.ts"
|
|
28
|
-
},
|
|
29
24
|
"./createGlobalState": {
|
|
30
25
|
"import": "./createGlobalState.js",
|
|
31
26
|
"require": "./createGlobalState.js",
|
|
32
27
|
"types": "./createGlobalState.d.ts"
|
|
33
28
|
},
|
|
34
|
-
"./generateStackHash": {
|
|
35
|
-
"import": "./generateStackHash.js",
|
|
36
|
-
"require": "./generateStackHash.js",
|
|
37
|
-
"types": "./generateStackHash.d.ts"
|
|
38
|
-
},
|
|
39
29
|
"./getAsyncStorageItem": {
|
|
40
30
|
"import": "./getAsyncStorageItem.js",
|
|
41
31
|
"require": "./getAsyncStorageItem.js",
|
|
@@ -51,11 +41,6 @@
|
|
|
51
41
|
"require": "./GlobalStore.js",
|
|
52
42
|
"types": "./GlobalStore.d.ts"
|
|
53
43
|
},
|
|
54
|
-
"./GlobalStoreAbstract": {
|
|
55
|
-
"import": "./GlobalStoreAbstract.js",
|
|
56
|
-
"require": "./GlobalStoreAbstract.js",
|
|
57
|
-
"types": "./GlobalStoreAbstract.d.ts"
|
|
58
|
-
},
|
|
59
44
|
"./isRecord": {
|
|
60
45
|
"import": "./isRecord.js",
|
|
61
46
|
"require": "./isRecord.js",
|
|
@@ -77,17 +62,19 @@
|
|
|
77
62
|
"*.d.ts"
|
|
78
63
|
],
|
|
79
64
|
"scripts": {
|
|
65
|
+
"format": "prettier --write . --log-level silent && yarn lint:fix",
|
|
80
66
|
"test:debug:no-watch": "node --inspect-brk node_modules/.bin/jest --no-watchman --runInBand",
|
|
81
67
|
"test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
|
|
82
|
-
"test:quick": "jest --maxWorkers=4 -c --no-watchman -u",
|
|
68
|
+
"test:quick": "jest --no-coverage --maxWorkers=4 -c --no-watchman -u",
|
|
83
69
|
"test:coverage": "jest --maxWorkers=4 -c --colors --no-watchman --verbose --coverage",
|
|
84
|
-
"build": "yarn clean && webpack --config webpack.config.js",
|
|
85
|
-
"prepare": "npm run build",
|
|
86
|
-
"version": "npm run format && git add -A
|
|
70
|
+
"build": "yarn ts-check && yarn clean && webpack --config webpack.config.js",
|
|
71
|
+
"prepare": "yarn format && npm run build && yarn test:quick",
|
|
72
|
+
"version": "npm run format && yarn build && yarn jest && git add -A",
|
|
87
73
|
"postversion": "git push && git push --tags",
|
|
88
74
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --max-warnings=0",
|
|
89
75
|
"lint:fix": "eslint --fix src --ext .js,.jsx,.ts,.tsx --max-warnings=0",
|
|
90
|
-
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' -exec rm {} +"
|
|
76
|
+
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' ! -name 'eslint.config.mts' -exec rm {} +",
|
|
77
|
+
"ts-check": "tsc -p tsconfig.json --noEmit"
|
|
91
78
|
},
|
|
92
79
|
"repository": {
|
|
93
80
|
"type": "git",
|
|
@@ -118,6 +105,7 @@
|
|
|
118
105
|
"@babel/preset-env": "^7.20.2",
|
|
119
106
|
"@babel/preset-react": "^7.18.6",
|
|
120
107
|
"@babel/preset-typescript": "^7.21.0",
|
|
108
|
+
"@eslint/js": "^9.39.1",
|
|
121
109
|
"@react-native-async-storage/async-storage": ">=1.17.11",
|
|
122
110
|
"@testing-library/dom": "^10.4.0",
|
|
123
111
|
"@testing-library/react": "^16.3.0",
|
|
@@ -131,15 +119,18 @@
|
|
|
131
119
|
"babel-loader": "^9.1.2",
|
|
132
120
|
"clean-webpack-plugin": "^4.0.0",
|
|
133
121
|
"easy-cancelable-promise": "^1.0.2",
|
|
134
|
-
"eslint": "^
|
|
122
|
+
"eslint": "^9.39.1",
|
|
135
123
|
"eslint-config-airbnb": "^18.2.1",
|
|
136
124
|
"eslint-plugin-import": "^2.22.1",
|
|
137
125
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
138
|
-
"eslint-plugin-react": "^7.
|
|
126
|
+
"eslint-plugin-react": "^7.37.5",
|
|
139
127
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
128
|
+
"globals": "^16.5.0",
|
|
140
129
|
"jest": "^29.7.0",
|
|
141
130
|
"jest-environment-jsdom": "^29.7.0",
|
|
131
|
+
"jiti": "^2.6.1",
|
|
142
132
|
"json-storage-formatter": "^2.0.9",
|
|
133
|
+
"prettier": "^3.6.2",
|
|
143
134
|
"react": "^18.2.0",
|
|
144
135
|
"react-dom": "^18.2.0",
|
|
145
136
|
"react-native": ">=0.71.6",
|
|
@@ -148,14 +139,15 @@
|
|
|
148
139
|
"ts-loader": "^9.4.2",
|
|
149
140
|
"tslib": "^2.5.0",
|
|
150
141
|
"typescript": "^5.3.3",
|
|
142
|
+
"typescript-eslint": "^8.46.3",
|
|
151
143
|
"webpack": "^5.76.3",
|
|
152
144
|
"webpack-cli": "^5.0.1"
|
|
153
145
|
},
|
|
154
146
|
"peerDependencies": {
|
|
155
147
|
"@react-native-async-storage/async-storage": ">=1.17.11",
|
|
156
148
|
"json-storage-formatter": "^2.0.5",
|
|
157
|
-
"react": ">=
|
|
158
|
-
"react-native": ">=0.
|
|
149
|
+
"react": ">=18.0.0",
|
|
150
|
+
"react-native": ">=0.69.0"
|
|
159
151
|
},
|
|
160
152
|
"peerDependenciesMeta": {
|
|
161
153
|
"react": {
|
|
@@ -172,6 +164,6 @@
|
|
|
172
164
|
}
|
|
173
165
|
},
|
|
174
166
|
"dependencies": {
|
|
175
|
-
"react-hooks-global-states": "^
|
|
167
|
+
"react-hooks-global-states": "^14.0.2"
|
|
176
168
|
}
|
|
177
169
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
import
|
|
1
|
+
export type { StateApi, AnyFunction, ObservableFragment, StateChanges, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, } from "react-hooks-global-states/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { BaseMetadata as BaseLibraryMetadata, ObservableFragment, StateChanges, UseHookOptions } from "react-hooks-global-states";
|
|
4
|
+
import { AnyFunction, SubscribeToState } from "react-hooks-global-states/types";
|
|
3
5
|
export type AsyncStorageConfig = {
|
|
4
6
|
key: string | (() => string);
|
|
5
7
|
/**
|
|
@@ -11,12 +13,16 @@ export type AsyncStorageConfig = {
|
|
|
11
13
|
*/
|
|
12
14
|
decrypt?: boolean | ((value: string) => string);
|
|
13
15
|
};
|
|
14
|
-
export type
|
|
16
|
+
export type AsyncMetadata = BaseLibraryMetadata & {
|
|
15
17
|
isAsyncStorageReady?: boolean;
|
|
16
18
|
asyncStorageKey?: string | null;
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The base metadata for async storage always carries the information about the async storage state and
|
|
22
|
+
* the key used to store the state in async storage.
|
|
23
|
+
*/
|
|
24
|
+
export type BaseMetadata<T> = (keyof T extends never ? {} : T) & AsyncMetadata;
|
|
25
|
+
export type HookExtensions<State, StateMutator, Metadata extends AsyncMetadata> = {
|
|
20
26
|
/**
|
|
21
27
|
* @description Return the state controls of the hook
|
|
22
28
|
* This selectors includes:
|
|
@@ -25,7 +31,7 @@ export type HookExtensions<State, StateMutator, Metadata extends BaseMetadata |
|
|
|
25
31
|
* - metadataRetriever: a function to get the metadata of the global state
|
|
26
32
|
*/
|
|
27
33
|
stateControls: () => Readonly<[
|
|
28
|
-
retriever:
|
|
34
|
+
retriever: () => State,
|
|
29
35
|
mutator: StateMutator,
|
|
30
36
|
metadata: MetadataGetter<Metadata>
|
|
31
37
|
]>;
|
|
@@ -35,49 +41,78 @@ export type HookExtensions<State, StateMutator, Metadata extends BaseMetadata |
|
|
|
35
41
|
* The selector hook will be evaluated only if the result of the selector changes and the equality function returns false
|
|
36
42
|
* you can customize the equality function by passing the isEqualRoot and isEqual parameters
|
|
37
43
|
*/
|
|
38
|
-
createSelectorHook: <Derivate>(this: StateHook<State, StateMutator, Metadata>, selector: (state: State) => Derivate, args?: Omit<
|
|
44
|
+
createSelectorHook: <Derivate>(this: StateHook<State, StateMutator, Metadata>, selector: (state: State) => Derivate, args?: Omit<UseHookOptions<Derivate, State>, "dependencies"> & {
|
|
39
45
|
name?: string;
|
|
40
46
|
}) => StateHook<Derivate, StateMutator, Metadata>;
|
|
41
47
|
createObservable: <Fragment>(this: StateHook<State, StateMutator, Metadata>, mainSelector: (state: State) => Fragment, args?: {
|
|
42
48
|
isEqual?: (current: Fragment, next: Fragment) => boolean;
|
|
43
49
|
isEqualRoot?: (current: State, next: State) => boolean;
|
|
44
50
|
name?: string;
|
|
45
|
-
}) => ObservableFragment<Fragment>;
|
|
51
|
+
}) => ObservableFragment<Fragment, StateMutator, Metadata>;
|
|
46
52
|
};
|
|
47
|
-
export interface StateHook<State, StateMutator, Metadata extends
|
|
53
|
+
export interface StateHook<State, StateMutator, Metadata extends AsyncMetadata> extends HookExtensions<State, StateMutator, Metadata> {
|
|
48
54
|
(): Readonly<[state: State, stateMutator: StateMutator, metadata: Metadata]> & HookExtensions<State, StateMutator, Metadata>;
|
|
49
|
-
<Derivate>(selector: (state: State) => Derivate, config?:
|
|
50
|
-
state: Derivate,
|
|
51
|
-
stateMutator: StateMutator,
|
|
52
|
-
metadata: Metadata
|
|
53
|
-
]> & HookExtensions<Derivate, StateMutator, Metadata>;
|
|
55
|
+
<Derivate>(selector: (state: State) => Derivate, config?: UseHookOptions<Derivate, State>): Readonly<[state: Derivate, stateMutator: StateMutator, metadata: Metadata]> & HookExtensions<Derivate, StateMutator, Metadata>;
|
|
54
56
|
}
|
|
55
|
-
export type MetadataSetter<Metadata extends
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
export type MetadataSetter<Metadata extends AsyncMetadata> = (setter: Metadata | ((metadata: Metadata) => Metadata)) => void;
|
|
58
|
+
/**
|
|
59
|
+
* API for the actions of the global states
|
|
60
|
+
**/
|
|
61
|
+
export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction<State>>, Metadata extends AsyncMetadata = AsyncMetadata> = {
|
|
62
|
+
/**
|
|
63
|
+
* The actions available for the global state
|
|
64
|
+
*/
|
|
65
|
+
actions: StateMutator extends AnyFunction ? null : StateMutator;
|
|
66
|
+
/**
|
|
67
|
+
* @description Metadata associated with the global state
|
|
68
|
+
*/
|
|
60
69
|
getMetadata: () => Metadata;
|
|
61
|
-
|
|
70
|
+
/**
|
|
71
|
+
* @description Current state value
|
|
72
|
+
*/
|
|
73
|
+
getState: () => State;
|
|
74
|
+
/**
|
|
75
|
+
* @description Sets the metadata value
|
|
76
|
+
*/
|
|
77
|
+
setMetadata: MetadataSetter<Metadata>;
|
|
78
|
+
/**
|
|
79
|
+
* @description Function to set the state value
|
|
80
|
+
*/
|
|
81
|
+
setState: React.Dispatch<React.SetStateAction<State>>;
|
|
82
|
+
/**
|
|
83
|
+
* @description Subscribe to the state changes
|
|
84
|
+
* You can subscribe to the whole state or to a fragment of the state by passing a selector as first parameter,
|
|
85
|
+
* this can be used in non react environments to listen to the state changes
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const unsubscribe = storeTools.subscribe((state) => {
|
|
90
|
+
* console.log('State changed:', state);
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* // To unsubscribe later
|
|
94
|
+
* unsubscribe();
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
subscribe: SubscribeToState<State>;
|
|
62
98
|
};
|
|
63
|
-
|
|
99
|
+
/**
|
|
100
|
+
* contract for the storeActionsConfig configuration
|
|
101
|
+
*/
|
|
102
|
+
export interface ActionCollectionConfig<State, Metadata extends AsyncMetadata, ThisAPI = Record<string, (...parameters: any[]) => unknown>> {
|
|
64
103
|
readonly [key: string]: {
|
|
65
|
-
(this: ThisAPI, ...parameters: any[]): (this: ThisAPI, storeTools: StoreTools<State,
|
|
104
|
+
(this: ThisAPI, ...parameters: any[]): (this: ThisAPI, storeTools: StoreTools<State, Record<string, (...parameters: any[]) => unknown | void>, Metadata>) => unknown | void;
|
|
66
105
|
};
|
|
67
106
|
}
|
|
68
|
-
export type ActionCollectionResult<State, Metadata extends
|
|
107
|
+
export type ActionCollectionResult<State, Metadata extends AsyncMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>> = {
|
|
69
108
|
[key in keyof ActionsConfig]: {
|
|
70
109
|
(...params: Parameters<ActionsConfig[key]>): ReturnType<ReturnType<ActionsConfig[key]>>;
|
|
71
110
|
};
|
|
72
111
|
};
|
|
73
|
-
export type GlobalStoreCallbacks<State, Metadata extends
|
|
112
|
+
export type GlobalStoreCallbacks<State, Metadata extends AsyncMetadata> = {
|
|
74
113
|
onInit?: (args: StoreTools<State, Metadata>) => void;
|
|
75
114
|
onStateChanged?: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
76
115
|
onSubscribed?: (args: StoreTools<State, Metadata>) => void;
|
|
77
116
|
computePreventStateChange?: (args: StoreTools<State, Metadata> & StateChanges<State>) => boolean;
|
|
78
117
|
};
|
|
79
|
-
export type MetadataGetter<Metadata extends
|
|
80
|
-
export type CustomGlobalHookBuilderParams<TCustomConfig extends BaseMetadata | unknown, Metadata extends BaseMetadata | unknown> = {
|
|
81
|
-
onInitialize?: (args: StoreTools<unknown, Metadata, unknown>, config: TCustomConfig | undefined) => void;
|
|
82
|
-
onChange?: (args: StoreTools<unknown, Metadata, unknown> & StateChanges<unknown>, config: TCustomConfig | undefined) => void;
|
|
83
|
-
};
|
|
118
|
+
export type MetadataGetter<Metadata extends AsyncMetadata> = () => Metadata;
|
package/webpack.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
1
3
|
const path = require("path");
|
|
2
4
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
3
5
|
|
|
@@ -5,16 +7,12 @@ const individualEntries = {
|
|
|
5
7
|
// inherit from react-global-state-hooks
|
|
6
8
|
createContext: "./src/createContext.ts",
|
|
7
9
|
GlobalStore: "./src/GlobalStore.ts",
|
|
8
|
-
GlobalStoreAbstract: "./src/GlobalStoreAbstract.ts",
|
|
9
|
-
createCustomGlobalState: "./src/createCustomGlobalState.ts",
|
|
10
10
|
createGlobalState: "./src/createGlobalState.ts",
|
|
11
11
|
types: "./src/types.ts",
|
|
12
12
|
isRecord: "./src/isRecord.ts",
|
|
13
13
|
shallowCompare: "./src/shallowCompare.ts",
|
|
14
14
|
throwWrongKeyOnActionCollectionConfig: "./src/throwWrongKeyOnActionCollectionConfig.ts",
|
|
15
15
|
uniqueId: "./src/uniqueId.ts",
|
|
16
|
-
useStableState: "./src/useStableState.ts",
|
|
17
|
-
generateStackHash: "./src/generateStackHash.ts",
|
|
18
16
|
|
|
19
17
|
// extras
|
|
20
18
|
asyncStorageWrapper: "./src/asyncStorageWrapper.ts",
|
|
@@ -22,7 +20,7 @@ const individualEntries = {
|
|
|
22
20
|
setAsyncStorageItem: "./src/setAsyncStorageItem.ts",
|
|
23
21
|
};
|
|
24
22
|
|
|
25
|
-
const
|
|
23
|
+
const generateExternalEntryMappings = () => {
|
|
26
24
|
const keys = Object.keys(individualEntries);
|
|
27
25
|
const fromEntries = keys.reduce((acc, key) => {
|
|
28
26
|
acc[`./${key}`] = `./${key}.js`;
|
|
@@ -68,7 +66,7 @@ module.exports = {
|
|
|
68
66
|
|
|
69
67
|
"react-hooks-global-states": "react-hooks-global-states",
|
|
70
68
|
|
|
71
|
-
...
|
|
69
|
+
...generateExternalEntryMappings(),
|
|
72
70
|
},
|
|
73
71
|
output: {
|
|
74
72
|
path: path.resolve(__dirname),
|
package/GlobalStoreAbstract.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ActionCollectionConfig, StateChanges, StoreTools } from "react-hooks-global-states/types";
|
|
2
|
-
import type { BaseMetadata, StateMeta } from "./types";
|
|
3
|
-
import { GlobalStore } from "./GlobalStore";
|
|
4
|
-
export declare abstract class GlobalStoreAbstract<State, Metadata extends BaseMetadata | unknown, ActionsConfig extends ActionCollectionConfig<State, StateMeta<Metadata>> | unknown> extends GlobalStore<State, Metadata, ActionsConfig> {
|
|
5
|
-
protected onInit: (args: StoreTools<State, StateMeta<Metadata>>) => void;
|
|
6
|
-
protected onStateChanged: (args: StoreTools<State, StateMeta<Metadata>> & StateChanges<State>) => void;
|
|
7
|
-
protected abstract onInitialize: (args: StoreTools<State, StateMeta<Metadata>>) => void;
|
|
8
|
-
protected abstract onChange: (args: StoreTools<State, StateMeta<Metadata>> & StateChanges<State>) => void;
|
|
9
|
-
}
|
|
10
|
-
export default GlobalStoreAbstract;
|
package/GlobalStoreAbstract.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t;t=t=>(()=>{"use strict";var e={778:e=>{e.exports=t}},o={};function r(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return e[t](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;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 o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(o=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var u=function(t){function r(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(t,r,n){return r=i(r),function(t,o){if(o&&("object"==e(o)||"function"==typeof o))return o;if(void 0!==o)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,o()?Reflect.construct(r,n||[],i(t).constructor):r.apply(t,n))}(this,r,arguments)).onInit=function(e){var o;t._onInitialize(e),null===(o=t.onInitialize)||void 0===o||o.call(t,e)},t.onStateChanged=function(e){var o;t._onInitialize(e),null===(o=t.onChange)||void 0===o||o.call(t,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&&c(t,e)}(r,t),n=r,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(r(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),n})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],t):"object"==typeof exports?exports["react-native-global-state-hooks"]=t(require("./GlobalStore.js")):this["react-native-global-state-hooks"]=t(this["./GlobalStore.js"]);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { StateHook, StateSetter, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks, CustomGlobalHookBuilderParams } from "react-hooks-global-states/types";
|
|
2
|
-
import type { AsyncStorageConfig, BaseMetadata } from "./types";
|
|
3
|
-
export interface CustomCreateGlobalState<TCustomConfig extends BaseMetadata | unknown, InheritMetadata extends BaseMetadata | unknown = BaseMetadata> {
|
|
4
|
-
<State>(state: State): StateHook<State, StateSetter<State>, BaseMetadata>;
|
|
5
|
-
<State, Metadata extends BaseMetadata | unknown, ActionsConfig extends ActionCollectionConfig<State, InheritMetadata & Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? StateSetter<State> : ActionCollectionResult<State, InheritMetadata & Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
6
|
-
name?: string;
|
|
7
|
-
metadata?: Metadata;
|
|
8
|
-
callbacks?: GlobalStoreCallbacks<State, InheritMetadata & Metadata>;
|
|
9
|
-
actions?: ActionsConfig;
|
|
10
|
-
config?: TCustomConfig;
|
|
11
|
-
asyncStorage?: AsyncStorageConfig;
|
|
12
|
-
}): StateHook<State, PublicStateMutator, InheritMetadata & Metadata>;
|
|
13
|
-
<State, Metadata extends BaseMetadata | unknown, ActionsConfig extends Readonly<ActionCollectionConfig<State, InheritMetadata & Metadata>>>(state: State, args: {
|
|
14
|
-
name?: string;
|
|
15
|
-
metadata?: Metadata;
|
|
16
|
-
callbacks?: GlobalStoreCallbacks<State, InheritMetadata & Metadata>;
|
|
17
|
-
actions: ActionsConfig;
|
|
18
|
-
config?: TCustomConfig;
|
|
19
|
-
asyncStorage?: AsyncStorageConfig;
|
|
20
|
-
}): StateHook<State, ActionCollectionResult<State, InheritMetadata & Metadata, ActionsConfig>, InheritMetadata & Metadata>;
|
|
21
|
-
}
|
|
22
|
-
export declare const createCustomGlobalState: <TCustomConfig extends BaseMetadata | unknown, InheritMetadata extends BaseMetadata | unknown = BaseMetadata>({ onInitialize, onChange, }: CustomGlobalHookBuilderParams<TCustomConfig, InheritMetadata>) => CustomCreateGlobalState<TCustomConfig, InheritMetadata>;
|
|
23
|
-
export default createCustomGlobalState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;e=e=>(()=>{"use strict";var t={670:t=>{t.exports=e},773:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createCustomGlobalState=void 0;var a=o(670);t.createCustomGlobalState=function(e){var t=e.onInitialize,o=e.onChange;return function(e){var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=l.callbacks,r=function(e,t){var o={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(a=Object.getOwnPropertySymbols(e);l<a.length;l++)t.indexOf(a[l])<0&&Object.prototype.propertyIsEnumerable.call(e,a[l])&&(o[a[l]]=e[a[l]])}return o}(l,["callbacks"]);return(0,a.createGlobalState)(e,Object.assign(Object.assign({},r),{callbacks:Object.assign(Object.assign({},null!=n?n:{}),{onInit:function(e){var o;null==t||t(e,null==r?void 0:r.config),null===(o=null==n?void 0:n.onInit)||void 0===o||o.call(n,e)},onStateChanged:function(e){var t;null==o||o(e,null==r?void 0:r.config),null===(t=null==n?void 0:n.onStateChanged)||void 0===t||t.call(n,e)}})}))}},t.default=t.createCustomGlobalState}},o={};return function e(a){var l=o[a];if(void 0!==l)return l.exports;var n=o[a]={exports:{}};return t[a](n,n.exports,e),n.exports}(773)})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./createGlobalState.js")):"function"==typeof define&&define.amd?define(["./createGlobalState.js"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("./createGlobalState.js")):this["react-native-global-state-hooks"]=e(this["./createGlobalState.js"]);
|
package/generateStackHash.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { generateStackHash, default } from "react-hooks-global-states/generateStackHash";
|
package/generateStackHash.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;e=e=>(()=>{"use strict";var t={225:t=>{t.exports=e}},a={};function r(e){var o=a[e];if(void 0!==o)return o.exports;var s=a[e]={exports:{}};return t[e](s,s.exports,r),s.exports}var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.generateStackHash=void 0;var t=r(225);Object.defineProperty(e,"generateStackHash",{enumerable:!0,get:function(){return t.generateStackHash}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),o})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/generateStackHash")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/generateStackHash"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("react-hooks-global-states/generateStackHash")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/generateStackHash"]);
|
package/useStableState.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useStableState, default } from "react-hooks-global-states/useStableState";
|
package/useStableState.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;e=e=>(()=>{"use strict";var t={525:t=>{t.exports=e}},a={};function o(e){var r=a[e];if(void 0!==r)return r.exports;var s=a[e]={exports:{}};return t[e](s,s.exports,o),s.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.useStableState=void 0;var t=o(525);Object.defineProperty(e,"useStableState",{enumerable:!0,get:function(){return t.useStableState}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),r})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/useStableState")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/useStableState"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("react-hooks-global-states/useStableState")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/useStableState"]);
|