react-hooks-global-states 2.4.1 → 3.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/README.md +50 -51
- package/lib/bundle.js +1 -1
- package/lib/src/GlobalStore.context.d.ts +16 -3
- package/lib/src/GlobalStore.d.ts +45 -149
- package/lib/src/GlobalStore.functionHooks.d.ts +105 -8
- package/lib/src/GlobalStore.types.d.ts +52 -239
- package/lib/src/GlobalStoreAbstract.d.ts +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -238,9 +238,15 @@ const initialState = {
|
|
|
238
238
|
|
|
239
239
|
type State = typeof initialState;
|
|
240
240
|
|
|
241
|
-
export const useContacts = createGlobalState(
|
|
241
|
+
export const useContacts = createGlobalState(
|
|
242
|
+
initialState,
|
|
243
|
+
{
|
|
244
|
+
onInit: async ({ setState }: StoreTools<State>) => {
|
|
245
|
+
// fetch contacts
|
|
246
|
+
},
|
|
247
|
+
},
|
|
242
248
|
// this are the actions available for this state
|
|
243
|
-
|
|
249
|
+
{
|
|
244
250
|
setFilter(filter: string) {
|
|
245
251
|
return ({ setState }: StoreTools<State>) => {
|
|
246
252
|
setState((state) => ({
|
|
@@ -249,11 +255,8 @@ export const useContacts = createGlobalState(initialState, {
|
|
|
249
255
|
}));
|
|
250
256
|
};
|
|
251
257
|
},
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// fetch contacts
|
|
255
|
-
},
|
|
256
|
-
});
|
|
258
|
+
}
|
|
259
|
+
);
|
|
257
260
|
```
|
|
258
261
|
|
|
259
262
|
That's it! In this updated version, the **useContacts** hook will no longer return [**state**, **stateMutator:Setter<State>**] but instead will return [**state**, **stateMutator:ActionCollectionResult<State>**]. This change will provide a more intuitive and convenient way to access and interact with the state and its associated actions.
|
|
@@ -319,31 +322,29 @@ Here's an example of adding multiple actions to the state and utilizing one acti
|
|
|
319
322
|
```ts
|
|
320
323
|
import { createGlobalState } from 'react-hooks-global-states';
|
|
321
324
|
|
|
322
|
-
export const useCount = createGlobalState(0, {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
},
|
|
325
|
+
export const useCount = createGlobalState(0, () => ({
|
|
326
|
+
log: (currentValue: string) => {
|
|
327
|
+
return ({ getState }: StoreTools<number>): void => {
|
|
328
|
+
console.log(`Current Value: ${getState()}`);
|
|
329
|
+
};
|
|
330
|
+
},
|
|
329
331
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
increase(value: number = 1) {
|
|
333
|
+
return ({ getState, setState, actions }: StoreTools<number>) => {
|
|
334
|
+
setState((count) => count + value);
|
|
333
335
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
actions.log(message);
|
|
337
|
+
};
|
|
338
|
+
},
|
|
337
339
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
decrease(value: number = 1) {
|
|
341
|
+
return ({ getState, setState, actions }: StoreTools<number>) => {
|
|
342
|
+
setState((count) => count - value);
|
|
341
343
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
});
|
|
344
|
+
actions.log(message);
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
}));
|
|
347
348
|
```
|
|
348
349
|
|
|
349
350
|
Notice that the **StoreTools** will contain a reference to the generated actions API. From there, you'll be able to access all actions from inside another one... the **StoreTools** is generic and allow your to set an interface for getting the typing on the actions.
|
|
@@ -427,29 +428,27 @@ const initialState: CounterState = {
|
|
|
427
428
|
count: 0,
|
|
428
429
|
};
|
|
429
430
|
|
|
430
|
-
export const [useCounterContext, CounterProvider] = createStatefulContext(initialState, {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
} as const,
|
|
449
|
-
});
|
|
431
|
+
export const [useCounterContext, CounterProvider] = createStatefulContext(initialState, () => ({
|
|
432
|
+
increase: (value: number = 1) => {
|
|
433
|
+
return ({ setState }: StoreTools<CounterState>) => {
|
|
434
|
+
setState((state) => ({
|
|
435
|
+
...state,
|
|
436
|
+
count: state.count + value,
|
|
437
|
+
}));
|
|
438
|
+
};
|
|
439
|
+
},
|
|
440
|
+
decrease: (value: number = 1) => {
|
|
441
|
+
return ({ setState }: StoreTools<CounterState>) => {
|
|
442
|
+
setState((state) => ({
|
|
443
|
+
...state,
|
|
444
|
+
count: state.count - value,
|
|
445
|
+
}));
|
|
446
|
+
};
|
|
447
|
+
},
|
|
448
|
+
}));
|
|
450
449
|
```
|
|
451
450
|
|
|
452
|
-
And just like with regular global hooks, now instead of a setState function, the hook will return the collection of actions
|
|
451
|
+
And just like with regular global hooks, now instead of a setState function, the hook will return the collection of actions
|
|
453
452
|
|
|
454
453
|
```tsx
|
|
455
454
|
const MyComponent = () => {
|
|
@@ -808,7 +807,7 @@ onSubscribed?: (parameters: StateConfigCallbackParam<TState, TMetadata, TActions
|
|
|
808
807
|
computePreventStateChange?: (parameters: StateChangesParam<TState, TMetadata, TActions>) => boolean;
|
|
809
808
|
```
|
|
810
809
|
|
|
811
|
-
You can pass this callbacks
|
|
810
|
+
You can pass this callbacks on the config objects when building a **createGlobalState**
|
|
812
811
|
|
|
813
812
|
```ts
|
|
814
813
|
const useData = createGlobalState(
|
|
@@ -916,7 +915,7 @@ const storage = new GlobalStore(0, {
|
|
|
916
915
|
},
|
|
917
916
|
});
|
|
918
917
|
|
|
919
|
-
const [getState, _, getMetadata] = storage.
|
|
918
|
+
const [getState, _, getMetadata] = storage.stateControls();
|
|
920
919
|
const useState = storage.getHook();
|
|
921
920
|
```
|
|
922
921
|
|
package/lib/bundle.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see bundle.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>{return e={852:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.combineRetrieverAsynchronously=e.combineAsyncGetters=e.combineRetrieverEmitterAsynchronously=e.combineAsyncGettersEmitter=void 0;var i=r(608),a=r(156),u=r(774);e.combineAsyncGettersEmitter=function(t){for(var e,r,n,o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];var l=a,s=new Map(l.map((function(t,e){return[e,t()]}))),f=t.selector(Array.from(s.values())),p=void 0!==(null===(e=null==t?void 0:t.config)||void 0===e?void 0:e.isEqual)?null===(r=null==t?void 0:t.config)||void 0===r?void 0:r.isEqual:i.shallowCompare,v=new Set,d=(0,i.debounce)((function(){var e=t.selector(Array.from(s.values()));(null==p?void 0:p(f,e))||(f=e,v.forEach((function(t){return t()})))}),null===(n=null==t?void 0:t.config)||void 0===n?void 0:n.delay),y=l.map((function(t,e){return t((function(t){t((function(t){s.set(e,t),d()}))}))})),b=function(t,e,r){var n,o,a="function"==typeof e,u=a?t:null,c=a?e:t,l=a?r:e,s=Object.assign({delay:0,isEqual:i.shallowCompare},null!=l?l:{}),p=null!==(n=null==u?void 0:u(f))&&void 0!==n?n:f;s.skipFirst||c(p);var d=(0,i.debounce)((function(){var t,e,r=null!==(t=null==u?void 0:u(f))&&void 0!==t?t:f;(null===(e=s.isEqual)||void 0===e?void 0:e.call(s,p,r))||(p=r,c(r))}),null!==(o=s.delay)&&void 0!==o?o:0);return v.add(d),function(){v.delete(d)}};return[b,function(t){if(!t)return f;var e=[];return t((function(){e.push(b.apply(void 0,arguments))})),e.length||(0,u.throwNoSubscribersWereAdded)(),function(){e.forEach((function(t){t(),v.delete(t)}))}},function(){y.forEach((function(t){return t()}))}]},e.combineRetrieverEmitterAsynchronously=e.combineAsyncGettersEmitter,e.combineAsyncGetters=function(t){for(var r=arguments.length,o=new Array(r>1?r-1:0),u=1;u<r;u++)o[u-1]=arguments[u];var c=n(e.combineAsyncGettersEmitter.apply(void 0,[t].concat(o)),3),l=c[0],s=c[1],f=c[2];return[function(t,e){var r=n((0,a.useState)((function(){var e=s();return t?t(e):e})),2),o=r[0],u=r[1];return(0,a.useEffect)((function(){var r,n=Object.assign({delay:0,isEqual:i.shallowCompare},null!=e?e:{}),o=void 0!==n.isEqual?n.isEqual:i.shallowCompare,a=l((function(e){return t?t(e):e}),(0,i.debounce)((function(e){var r=t?t(e):e;(null==o?void 0:o(e,r))||u(r)}),null!==(r=n.delay)&&void 0!==r?r:0));return function(){a()}}),[]),[o,null,null]},s,f]},e.combineRetrieverAsynchronously=e.combineAsyncGetters},113:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createStatefulContext=void 0;var n,o=r(853),i=r(684),a=(n=r(156))&&n.__esModule?n:{default:n};e.createStatefulContext=function(t,e){var r=a.default.createContext(null);return[function(){return a.default.useContext(r)},function(n){var u=n.children,c=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["children"]),l=(0,o.createGlobalStateWithDecoupledFuncs)(function(){if(c.initialValue){if("function"==typeof c.initialValue)return c.initialValue((0,i.clone)(t));var e=Array.isArray(c.initialValue),r=c.initialValue instanceof Map,n=c.initialValue instanceof Set;return(0,i.isPrimitive)(c.initialValue)||(0,i.isDate)(c.initialValue)||e||r||n?c.initialValue:Object.assign(Object.assign({},t),c.initialValue)}return(0,i.clone)(t)}(),e);return a.default.createElement(r.Provider,{value:l},u)}]}},853:(t,e,r)=>{"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var o=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};Object.defineProperty(e,"__esModule",{value:!0}),e.createDerivateEmitter=e.createDerivate=e.createCustomGlobalStateWithDecoupledFuncs=e.createGlobalState=e.createGlobalStateWithDecoupledFuncs=void 0;var i=r(774);e.createGlobalStateWithDecoupledFuncs=function(t){var e,r,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=a.actions,c=o(a,["actions"]),l=new i.GlobalStore(t,c,u).getHook(),s=(e=l.stateControls(),r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(e,r)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());return[l,s[0],s[1]]},e.createGlobalState=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.actions,n=o(e,["actions"]);return new i.GlobalStore(t,n,r).getHook()},e.createCustomGlobalStateWithDecoupledFuncs=function(t){var r=t.onInitialize,n=t.onChange;return function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:null},a=i.config,u=i.onInit,c=i.onStateChanged,l=o(i,["config","onInit","onStateChanged"]);return(0,e.createGlobalStateWithDecoupledFuncs)(t,Object.assign({onInit:function(t){r(t,a),null==u||u(t)},onStateChanged:function(t){n(t,a),null==c||c(t)}},l))}},e.createDerivate=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.createSelectorHook(e,r)},e.createDerivateEmitter=function(t,r){var n=t._father_emitter;if(n){var o=function(t){var e=n.selector(t);return r(e)},i=(0,e.createDerivateEmitter)(n.getter,o);return i._father_emitter={getter:n.getter,selector:o},i}var a=function(e,n){var o="function"==typeof n,i=o?e:null,a=o?n:e,u=o?arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}:n;return t((function(t){t((function(t){var e,n=r(t);return null!==(e=null==i?void 0:i(n))&&void 0!==e?e:n}),a,u)}))};return a._father_emitter={getter:t,selector:r},a}},774:(t,e,r)=>{"use strict";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)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new _(n||[]);return o(a,"_invoke",{value:j(t,r,u)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var v={};function d(){}function y(){}function b(){}var h={};s(h,u,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(k([])));m&&m!==e&&r.call(m,u)&&(h=m);var S=b.prototype=d.prototype=Object.create(h);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function i(o,a,u,c){var l=p(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,c)}),(function(t){i("throw",t,u,c)})):e.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return i("throw",t,u,c)}))}c(l.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function j(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===v)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=p(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===v)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=p(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,v;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,v):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,v)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function k(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:P}}function P(){return{value:void 0,done:!0}}return y.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:y,configurable:!0}),y.displayName=s(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},w(O.prototype),s(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(S),s(S,l,"Generator"),s(S,u,(function(){return this})),s(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):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),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},t}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===n(e)?e:String(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=e.throwNoSubscribersWereAdded=void 0;var l=r(608),s=r(156);e.throwNoSubscribersWereAdded=function(){throw new Error("No new subscribers were added, please make sure to add at least one subscriber with the subscribe method")};var f=function(){function t(r){var n=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.actionsConfig=u,this.subscribers=new Map,this.actions=null,this.config={metadata:null},this.onInit=null,this.onStateChanged=null,this.onSubscribed=null,this.computePreventStateChange=null,this.initialize=function(){return t=n,e=void 0,r=void 0,o=a().mark((function t(){var e,r,n;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.actionsConfig&&(this.actions=this.getStoreActionsMap()),e=this.onInit,r=this.config.onInit,e||r){t.next=5;break}return t.abrupt("return");case 5:n=this.getConfigCallbackParam(),null==e||e(n),null==r||r(n);case 8:case"end":return t.stop()}}),t,this)})),new(r||(r=Promise))((function(n,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function u(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}c((o=o.apply(t,e||[])).next())}));var t,e,r,o},this.setState=function(t){var e=t.state,r=t.forceUpdate,o=t.identifier,i=n.stateWrapper.state;n.stateWrapper={state:e};for(var a=function(t){var n,a,u=t.selector,c=t.callback,l=t.currentState,s=t.config;if(r||!(null!==(n=null==s?void 0:s.isEqualRoot)&&void 0!==n?n:function(t,e){return Object.is(t,e)})(i,e)){var f=u?u(e):e;!r&&(null!==(a=null==s?void 0:s.isEqual)&&void 0!==a?a:function(t,e){return Object.is(t,e)})(l,f)||c({state:f,identifier:o})}},u=Array.from(n.subscribers.values()),c=0;c<u.length;c++)a(u[c])},this.setMetadata=function(t){var e,r,o="function"==typeof t?t(null!==(e=n.config.metadata)&&void 0!==e?e:null):t;n.config=Object.assign(Object.assign({},null!==(r=n.config)&&void 0!==r?r:{}),{metadata:o})},this.getMetadata=function(){var t;return null!==(t=n.config.metadata)&&void 0!==t?t:null},this.createChangesSubscriber=function(t){var e=t.callback,r=t.selector,o=t.config,i=r?r(n.stateWrapper.state):n.stateWrapper.state,a={state:i};return(null==o?void 0:o.skipFirst)||e(i),{stateWrapper:a,subscriptionCallback:function(t){var r=t.state;a.state=r,e(r)}}},this.getState=function(t){if(!t)return n.stateWrapper.state;var r=[];return t((function(t,e,o){var i="function"==typeof e,a=i?t:null,u=i?e:t,c=i?o:e,s=n.createChangesSubscriber({selector:a,callback:u,config:c}),f=s.subscriptionCallback,p=s.stateWrapper,v=(0,l.uniqueId)();n.addNewSubscriber(v,{selector:a,config:c,stateWrapper:p,callback:f}),r.push(v)})),r.length||(0,e.throwNoSubscribersWereAdded)(),function(){for(var t=0;t<r.length;t++){var e=r[t];n.subscribers.delete(e)}}},this.getConfigCallbackParam=function(){var t=n.setMetadata,e=n.getMetadata,r=n.getState,o=n.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:n.setStateWrapper,actions:o}},this.addNewSubscriber=function(t,e){n.subscribers.set(t,{subscriptionId:t,currentState:e.stateWrapper.state,selector:e.selector,config:e.config,callback:e.callback}),Object.assign(e.callback,{__global_state_subscription_id__:t})},this.updateSubscriptionIfExists=function(t,e){if(n.subscribers.has(t)){var r=n.subscribers.get(t);r.currentState=e.stateWrapper.state,r.selector=e.selector,r.config=e.config,r.callback=e.callback}},this.executeOnSubscribed=function(){var t=n.onSubscribed,e=n.config.onSubscribed;if(t||e){var r=n.getConfigCallbackParam();null==t||t(r),null==e||e(r)}},this.getHook=function(){var t=function(t){var e,r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=(0,s.useRef)(null),u=function(){return t?{state:t(n.stateWrapper.state)}:{state:n.stateWrapper.state}},c=o((0,s.useState)(u),2),f=c[0],p=c[1];(0,s.useEffect)((function(){return null===a.current&&(a.current=(0,l.uniqueId)()),function(){n.subscribers.delete(a.current)}}),[]);var v=n.subscribers.get(a.current),d=(null!==(e=null==v?void 0:v.config)&&void 0!==e?e:{dependencies:i.dependencies}).dependencies;return n.updateSubscriptionIfExists(a.current,{stateWrapper:f,selector:t,config:i,callback:p}),(0,s.useEffect)((function(){var e=a.current;null!==e&&!n.subscribers.has(e)&&(n.addNewSubscriber(e,{stateWrapper:f,selector:t,config:i,callback:p}),n.executeOnSubscribed())}),[f]),[function(){if(!t||!a.current)return f.state;var e=i.dependencies;if(d===e)return f.state;if((null==d?void 0:d.length)===(null==e?void 0:e.length)&&(0,l.shallowCompare)(d,e))return f.state;var r=u();return n.updateSubscriptionIfExists(a.current,{stateWrapper:r,selector:t,config:i,callback:p}),f.state=r.state,r.state}(),n.getStateOrchestrator(),null!==(r=n.config.metadata)&&void 0!==r?r:null]};return t.stateControls=n.stateControls,t.createSelectorHook=n.createSelectorHook,t},this.createSelectorHook=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.isEqualRoot,a=r.isEqual,u=new Map,c=n,f=o(c.stateControls(),3),p=f[0],v=f[1],d=f[2],y=p(),b=(null!=t?t:function(t){return t})(p());p((function(e){e((function(e){if(!(null!=i?i:Object.is)(y,e)){y=e;var r=t(e);(null!=a?a:Object.is)(b,r)||(b=r,u.forEach((function(t){t.callback({state:b})})))}}),{skipFirst:!0})}));var h=function(t,e){u.set(t,{subscriptionId:t,currentState:e.stateWrapper.state,selector:e.selector,config:e.config,callback:e.callback}),Object.assign(e.callback,{__global_state_subscription_id__:t})},g=function(t,e){if(u.has(t)){var r=u.get(t);r.currentState=e.stateWrapper.state,r.selector=e.selector,r.config=e.config,r.callback=e.callback}},m=function(t){if(!t)return b;var r=[];return t((function(t,e,n){var o="function"==typeof e,i=o?t:null,a=o?n:e,u=function(t){var e=t.callback,r=t.selector,n=t.config,o=(null!=r?r:function(t){return t})(b),i={state:o};return(null==n?void 0:n.skipFirst)||e(o),{stateWrapper:i,subscriptionCallback:function(t){var r=t.state;i.state=r,e(r)}}}({selector:i,callback:o?e:t,config:a}),c=u.subscriptionCallback,s=u.stateWrapper,f=(0,l.uniqueId)();h(f,{selector:i,config:a,stateWrapper:s,callback:c}),r.push(f)})),r.length||(0,e.throwNoSubscribersWereAdded)(),function(){for(var t=0;t<r.length;t++){var e=r[t];u.delete(e)}}},S=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.isEqualRoot,i=r.isEqual,a=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(r,["isEqualRoot","isEqual"]),c=function(){return t?{state:t(b)}:{state:b}},f=(0,s.useRef)(null),p=o((0,s.useState)(c),2),y=p[0],S=p[1];(0,s.useEffect)((function(){null===f.current&&(f.current=(0,l.uniqueId)());var e=m((function(e){var r=b;e((function(e){var o=u.get(f.current);if(!(null!=n?n:Object.is)(r,e)){r=e;var a=(null!=t?t:function(t){return t})(b);(null!=i?i:Object.is)(a,o.currentState)||(o.currentState=a,S({state:a}))}}),{skipFirst:!0})}));return function(){e(),u.delete(f.current)}}),[]);var w=u.get(f.current),O=(null!==(e=null==w?void 0:w.config)&&void 0!==e?e:{dependencies:a.dependencies}).dependencies;return g(f.current,{stateWrapper:y,selector:t,config:a,callback:S}),(0,s.useEffect)((function(){var e=f.current;null!==e&&!u.has(e)&&h(e,{stateWrapper:y,selector:t,config:a,callback:S})}),[y]),[function(){if(!t||f.current)return y.state;var e=a.dependencies;if(O===e)return y.state;if((null==O?void 0:O.length)===(null==e?void 0:e.length)&&(0,l.shallowCompare)(O,e))return y.state;var r=c();return g(f.current,{stateWrapper:r,selector:t,config:a,callback:S}),y.state=r.state,r.state}(),v,d]};return S.stateControls=function(){return[m,v,d]},S.createSelectorHook=n.createSelectorHook.bind(S),Object.assign(S,{_parent:c,_subscribers:u}),S},this.stateControls=function(){var t=n.getStateOrchestrator(),e=n.getMetadata;return[n.getState,t,e]},this.getHookDecoupled=function(){return n.stateControls()},this.getStateOrchestrator=function(){return n.actions?n.actions:n.setStateWrapper},this.hasStateCallbacks=function(){var t=n.computePreventStateChange,e=n.onStateChanged,r=n.config,o=r.computePreventStateChange,i=r.onStateChanged;return!!(t||o||e||i)},this.setStateWrapper=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.forceUpdate,o=e.identifier,i="function"==typeof t,a=n.stateWrapper.state,u=i?t(a):t;if(r||!Object.is(n.stateWrapper.state,u)){var c=n.setMetadata,l=n.getMetadata,s=n.getState,f=n.actions,p={setMetadata:c,getMetadata:l,setState:n.setState,getState:s,actions:f,previousState:a,state:u,identifier:o},v=n.computePreventStateChange,d=n.config.computePreventStateChange;if((v||d)&&((null==v?void 0:v(p))||(null==d?void 0:d(p))))return;n.setState({forceUpdate:r,identifier:o,state:u});var y=n.onStateChanged,b=n.config.onStateChanged;(y||b)&&(null==y||y(p),null==b||b(p))}},this.getStoreActionsMap=function(){if(!n.actionsConfig)return null;var t=n.actionsConfig,e=n.setMetadata,r=n.setStateWrapper,o=n.getState,i=n.getMetadata,a=Object.keys(t).reduce((function(n,u){var l,s,f;return Object.assign(n,(l={},f=function(){for(var n=t[u],c=arguments.length,l=new Array(c),s=0;s<c;s++)l[s]=arguments[s];var f=n.apply(a,l);return"function"!=typeof f&&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"))}(u),f.call(a,{setState:r,getState:o,setMetadata:e,getMetadata:i,actions:a})},(s=c(s=u))in l?Object.defineProperty(l,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):l[s]=f,l)),n}),{});return a},this.stateWrapper={state:r},this.config=Object.assign({metadata:null},null!=i?i:{}),(null===globalThis||void 0===globalThis?void 0:globalThis.REACT_GLOBAL_STATE_HOOK_DEBUG)&&globalThis.REACT_GLOBAL_STATE_HOOK_DEBUG(this,r,i,u),this.constructor!==t||this.initialize()}var r,n;return r=t,(n=[{key:"state",get:function(){return this.stateWrapper.state}}])&&u(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),t}();e.GlobalStore=f},530:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},608:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);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,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 i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="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},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=e.debounce=e.shallowCompare=void 0;var c=r(684);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,c.isNil)(t)||(0,c.isNil)(e)||(0,c.isPrimitive)(t)&&(0,c.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,l=e;if(a.length!==l.length)return!1;for(var s=0;s<a.length;s++)if(a[s]!==l[s])return!1}if(t instanceof Map){var f=t,p=e;if(f.size!==p.size)return!1;var v,d=o(f);try{for(d.s();!(v=d.n()).done;){var y=n(v.value,2),b=y[0];if(y[1]!==p.get(b))return!1}}catch(t){d.e(t)}finally{d.f()}}if(t instanceof Set){var h=t,g=e;if(h.size!==g.size)return!1;var m,S=o(h);try{for(S.s();!(m=S.n()).done;){var w=m.value;if(!g.has(w))return!1}}catch(t){S.e(t)}finally{S.f()}}var O=Object.keys(t),j=Object.keys(e);if(O.length!==j.length)return!1;for(var E=0,A=O;E<A.length;E++){var x=A[E];if(t[x]!==e[x])return!1}return!0},e.debounce=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];e&&clearTimeout(e),e=setTimeout((function(){t.apply(void 0,o)}),r)}},e.uniqueId=function(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},195:(t,e,r)=>{"use strict";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)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStoreAbstract=void 0;var a=function(t){!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&&o(t,e)}(c,t);var e,r,a,u=(r=c,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=i(r);if(a){var o=i(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)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)}(this,t)});function c(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(e=u.call(this,t,r,n)).onInit=function(t){e.onInitialize(t)},e.onStateChanged=function(t){e.onChange(t)},e}return e=c,Object.defineProperty(e,"prototype",{writable:!1}),e}(r(774).GlobalStore);e.GlobalStoreAbstract=a},991:(t,e,r)=>{"use strict";var n=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]},o=function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(684),e),o(r(530),e),o(r(774),e),o(r(195),e),o(r(853),e),o(r(608),e),o(r(852),e),o(r(113),e)},684:function(t){t.exports=(()=>{"use strict";var t={991:(t,e,r)=>{var n=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]};Object.defineProperty(e,"__esModule",{value:!0}),function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)}(r(729),e)},729:(t,e)=>{function r(t){return r="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},r(t)}function n(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.formatToStore=e.formatFromStore=e.isPrimitive=e.isFunction=e.isRegex=e.isDate=e.isString=e.isBoolean=e.isNumber=e.isNil=e.clone=void 0,e.clone=function(t){var r,a=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).shallow;if((0,e.isPrimitive)(t)||(0,e.isDate)(t))return t;if(Array.isArray(t))return a?function(t){if(Array.isArray(t))return i(t)}(r=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||o(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}():t.map((function(t){return(0,e.clone)(t)}));if(t instanceof Map){var u=Array.from(t.entries());return a?new Map(u):new Map(u.map((function(t){return(0,e.clone)(t)})))}if(t instanceof Set){var c=Array.from(t.values());return a?new Set(c):new Set(c.map((function(t){return(0,e.clone)(t)})))}return t instanceof RegExp?new RegExp(t.toString()):(0,e.isFunction)(t)?a?t:Object.create(t):a?Object.assign({},t):t instanceof Error?new Error(t.message):Object.keys(t).reduce((function(r,o){var i=t[o];return Object.assign(Object.assign({},r),n({},o,(0,e.clone)(i)))}),{})},e.isNil=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isBoolean=function(t){return"boolean"==typeof t},e.isString=function(t){return"string"==typeof t},e.isDate=function(t){return t instanceof Date},e.isRegex=function(t){return t instanceof RegExp},e.isFunction=function(t){return"function"==typeof t||t instanceof Function},e.isPrimitive=function(t){return(0,e.isNil)(t)||(0,e.isNumber)(t)||(0,e.isBoolean)(t)||(0,e.isString)(t)||"symbol"===r(t)},e.formatFromStore=function(t){return function(t){var r,i;if((0,e.isPrimitive)(t))return t;if("date"===(null==t?void 0:t.$t))return new Date(t.$v);if("map"===(null==t?void 0:t.$t)){var a=(null!==(r=t.$v)&&void 0!==r?r:[]).map((function(t){var r,n=(2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{for(i=(r=r.call(t)).next,0;!(c=(n=i.call(r)).done)&&(u.push(n.value),2!==u.length);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r)||o(r,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.")}()),i=n[0],a=n[1];return[i,(0,e.formatFromStore)(a)]}));return new Map(a)}if("set"===(null==t?void 0:t.$t)){var u=null!==(i=t.$v)&&void 0!==i?i:[].map((function(t){return(0,e.formatFromStore)(t)}));return new Set(u)}return"regex"===(null==t?void 0:t.$t)?new RegExp(t.$v):"error"===(null==t?void 0:t.$t)?new Error(t.$v):Array.isArray(t)?t.map((function(t){return(0,e.formatFromStore)(t)})):"function"===(null==t?void 0:t.$t)?Function("(".concat(t.$v,")(...arguments)")):Object.keys(t).reduce((function(r,o){var i=t[o];return Object.assign(Object.assign({},r),n({},o,(0,e.formatFromStore)(i)))}),{})}((arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).jsonParse?JSON.parse(t):(0,e.clone)(t))},e.formatToStore=function(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stringify:!1},i=o.stringify,a=o.validator,u=o.excludeTypes,c=o.excludeKeys,l=new Set(null!=u?u:[]),s=new Set(null!=c?c:[]),f=l.size||s.size,p=null!=a?a:function(t){var e=t.key,n=t.value;if(!f)return!0;var o=s.has(e),i=l.has(r(n));return!o&&!i},v=function t(r){if((0,e.isPrimitive)(r))return r;if(Array.isArray(r))return r.map((function(e){return t(e)}));if(r instanceof Map)return{$t:"map",$v:Array.from(r.entries()).map((function(e){return t(e)}))};if(r instanceof Set)return{$t:"set",$v:Array.from(r.values()).map((function(e){return t(e)}))};if((0,e.isDate)(r))return{$t:"date",$v:r.toISOString()};if((0,e.isRegex)(r))return{$t:"regex",$v:r.toString()};if((0,e.isFunction)(r)){var o;try{o={$t:"function",$v:r.toString()}}catch(t){o={$t:"error",$v:"Error: Could not serialize function"}}return o}return r instanceof Error?{$t:"error",$v:r.message}:Object.keys(r).reduce((function(e,o){var i=r[o],a=t(i);return p({obj:r,key:o,value:a})?Object.assign(Object.assign({},e),n({},o,t(i))):e}),{})}((0,e.clone)(t));return i?JSON.stringify(v):v}}},e={};return function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(991)})()},156:e=>{"use strict";e.exports=t}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(991);var e,r}));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("react")):t["react-hooks-global-states"]=e(t.react)}(this,(t=>{return e={852:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.combineRetrieverAsynchronously=e.combineAsyncGetters=e.combineRetrieverEmitterAsynchronously=e.combineAsyncGettersEmitter=void 0;var i=r(608),a=r(156),u=r(774);e.combineAsyncGettersEmitter=function(t){for(var e,r,n,o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];var l=a,s=new Map(l.map((function(t,e){return[e,t()]}))),f=t.selector(Array.from(s.values())),v=void 0!==(null===(e=null==t?void 0:t.config)||void 0===e?void 0:e.isEqual)?null===(r=null==t?void 0:t.config)||void 0===r?void 0:r.isEqual:i.shallowCompare,p=new Set,d=(0,i.debounce)((function(){var e=t.selector(Array.from(s.values()));(null==v?void 0:v(f,e))||(f=e,p.forEach((function(t){return t()})))}),null===(n=null==t?void 0:t.config)||void 0===n?void 0:n.delay),y=l.map((function(t,e){return t((function(t){t((function(t){s.set(e,t),d()}))}))})),b=function(t,e,r){var n,o,a="function"==typeof e,u=a?t:null,c=a?e:t,l=a?r:e,s=Object.assign({delay:0,isEqual:i.shallowCompare},null!=l?l:{}),v=null!==(n=null==u?void 0:u(f))&&void 0!==n?n:f;s.skipFirst||c(v);var d=(0,i.debounce)((function(){var t,e,r=null!==(t=null==u?void 0:u(f))&&void 0!==t?t:f;(null===(e=s.isEqual)||void 0===e?void 0:e.call(s,v,r))||(v=r,c(r))}),null!==(o=s.delay)&&void 0!==o?o:0);return p.add(d),function(){p.delete(d)}};return[b,function(t){if(!t)return f;var e=[];return t((function(){e.push(b.apply(void 0,arguments))})),e.length||(0,u.throwNoSubscribersWereAdded)(),function(){e.forEach((function(t){t(),p.delete(t)}))}},function(){y.forEach((function(t){return t()}))}]},e.combineRetrieverEmitterAsynchronously=e.combineAsyncGettersEmitter,e.combineAsyncGetters=function(t){for(var r=arguments.length,o=new Array(r>1?r-1:0),u=1;u<r;u++)o[u-1]=arguments[u];var c=n(e.combineAsyncGettersEmitter.apply(void 0,[t].concat(o)),3),l=c[0],s=c[1],f=c[2];return[function(t,e){var r=n((0,a.useState)((function(){var e=s();return t?t(e):e})),2),o=r[0],u=r[1];return(0,a.useEffect)((function(){var r,n=Object.assign({delay:0,isEqual:i.shallowCompare},null!=e?e:{}),o=void 0!==n.isEqual?n.isEqual:i.shallowCompare,a=l((function(e){return t?t(e):e}),(0,i.debounce)((function(e){var r=t?t(e):e;(null==o?void 0:o(e,r))||u(r)}),null!==(r=n.delay)&&void 0!==r?r:0));return function(){a()}}),[]),[o,null,null]},s,f]},e.combineRetrieverAsynchronously=e.combineAsyncGetters},113:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createStatefulContext=void 0;var n,o=r(853),i=r(684),a=(n=r(156))&&n.__esModule?n:{default:n};e.createStatefulContext=function(t,e){var r=a.default.createContext(null);return[function(){return a.default.useContext(r)},function(n){var u=n.children,c=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["children"]),l=(0,o.createGlobalState)(function(){if(c.initialValue){if("function"==typeof c.initialValue)return c.initialValue((0,i.clone)(t));var e=Array.isArray(c.initialValue),r=c.initialValue instanceof Map,n=c.initialValue instanceof Set;return(0,i.isPrimitive)(c.initialValue)||(0,i.isDate)(c.initialValue)||e||r||n?c.initialValue:Object.assign(Object.assign({},t),c.initialValue)}return t}(),e);return a.default.createElement(r.Provider,{value:l},u)}]}},853:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createDerivateEmitter=e.createDerivate=e.createCustomGlobalStateWithDecoupledFuncs=e.createCustomGlobalState=e.createGlobalState=void 0;var n=r(774);e.createGlobalState=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];var i="function"==typeof r[0],a=function(){var t;if(i){var e=r[0];return{config:r[1],actions:e()}}var n=r[0];return{config:n,actions:null!==(t=r[1])&&void 0!==t?t:null==n?void 0:n.actions}}(),u=a.config,c=a.actions;return new n.GlobalStore(t,u,c).getHook()},e.createCustomGlobalState=function(t){var r=t.onInitialize,n=t.onChange;return function(t,o){var i=null!=o?o:{},a=(i.actions,i.config),u=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(i,["actions","config"]);return(0,e.createGlobalState)(t,Object.assign({onInit:function(t){var e;r(t,a),null===(e=null==u?void 0:u.onInit)||void 0===e||e.call(u,t)},onStateChanged:function(t){var e;n(t,a),null===(e=null==u?void 0:u.onStateChanged)||void 0===e||e.call(u,t)}},u))}},e.createCustomGlobalStateWithDecoupledFuncs=e.createCustomGlobalState,e.createDerivate=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.createSelectorHook(e,r)},e.createDerivateEmitter=function(t,r){var n=t._father_emitter;if(n){var o=function(t){var e=n.selector(t);return r(e)},i=(0,e.createDerivateEmitter)(n.getter,o);return i._father_emitter={getter:n.getter,selector:o},i}var a=function(e,n){var o="function"==typeof n,i=o?e:null,a=o?n:e,u=o?arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}:n;return t((function(t){t((function(t){var e,n=r(t);return null!==(e=null==i?void 0:i(n))&&void 0!==e?e:n}),a,u)}))};return a._father_emitter={getter:t,selector:r},a}},774:(t,e,r)=>{"use strict";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)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(){a=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),u=new P(n||[]);return o(a,"_invoke",{value:j(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}}}t.wrap=f;var p={};function d(){}function y(){}function b(){}var h={};s(h,u,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(k([])));m&&m!==e&&r.call(m,u)&&(h=m);var S=b.prototype=d.prototype=Object.create(h);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function i(o,a,u,c){var l=v(t[o],t,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){i("next",t,u,c)}),(function(t){i("throw",t,u,c)})):e.resolve(f).then((function(t){s.value=t,u(s)}),(function(t){return i("throw",t,u,c)}))}c(l.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function j(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=v(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=v(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function k(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return y.prototype=b,o(S,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:y,configurable:!0}),y.displayName=s(b,l,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,l,"GeneratorFunction")),t.prototype=Object.create(S),t},t.awrap=function(t){return{__await:t}},w(O.prototype),s(O.prototype,c,(function(){return this})),t.AsyncIterator=O,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new O(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(S),s(S,l,"Generator"),s(S,u,(function(){return this})),s(S,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=k,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):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),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;x(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function u(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,"string");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===n(e)?e:String(e)}Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStore=e.throwNoSubscribersWereAdded=void 0;var l=r(608),s=r(156);e.throwNoSubscribersWereAdded=function(){throw new Error("No new subscribers were added, please make sure to add at least one subscriber with the subscribe method")};var f=function(){function t(r,n){var i=this,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.actionsConfig=u,this.subscribers=new Map,this.actions=null,this.config={metadata:null},this.initialize=function(){return t=i,e=void 0,r=void 0,n=a().mark((function t(){var e,r,n;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.actionsConfig&&(this.actions=this.getStoreActionsMap()),e=this.onInit,r=this.config.onInit,e||r){t.next=5;break}return t.abrupt("return");case 5:n=this.getConfigCallbackParam(),null==e||e(n),null==r||r(n);case 8:case"end":return t.stop()}}),t,this)})),new(r||(r=Promise))((function(o,i){function a(t){try{c(n.next(t))}catch(t){i(t)}}function u(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}c((n=n.apply(t,e||[])).next())}));var t,e,r,n},this.setState=function(t){var e=t.state,r=t.forceUpdate,n=t.identifier,o=i.stateWrapper.state;i.stateWrapper={state:e};for(var a=function(t){var i,a,u=t.selector,c=t.callback,l=t.currentState,s=t.config;if(r||!(null!==(i=null==s?void 0:s.isEqualRoot)&&void 0!==i?i:function(t,e){return Object.is(t,e)})(o,e)){var f=u?u(e):e;!r&&(null!==(a=null==s?void 0:s.isEqual)&&void 0!==a?a:function(t,e){return Object.is(t,e)})(l,f)||c({state:f,identifier:n})}},u=Array.from(i.subscribers.values()),c=0;c<u.length;c++)a(u[c])},this.setMetadata=function(t){var e,r,n="function"==typeof t?t(null!==(e=i.config.metadata)&&void 0!==e?e:null):t;i.config=Object.assign(Object.assign({},null!==(r=i.config)&&void 0!==r?r:{}),{metadata:n})},this.getMetadata=function(){var t;return null!==(t=i.config.metadata)&&void 0!==t?t:null},this.createChangesSubscriber=function(t){var e=t.callback,r=t.selector,n=t.config,o=r?r(i.stateWrapper.state):i.stateWrapper.state,a={state:o};return(null==n?void 0:n.skipFirst)||e(o),{stateWrapper:a,subscriptionCallback:function(t){var r=t.state;a.state=r,e(r)}}},this.getState=function(t){if(!t)return i.stateWrapper.state;var r=[];return t((function(t,e,n){var o="function"==typeof e,a=o?t:null,u=o?e:t,c=o?n:e,s=i.createChangesSubscriber({selector:a,callback:u,config:c}),f=s.subscriptionCallback,v=s.stateWrapper,p=(0,l.uniqueId)();i.addNewSubscriber(p,{subscriptionId:p,selector:a,config:c,currentState:v.state,callback:f}),r.push(p)})),r.length||(0,e.throwNoSubscribersWereAdded)(),function(){for(var t=0;t<r.length;t++){var e=r[t];i.subscribers.delete(e)}}},this.getConfigCallbackParam=function(){var t=i.setMetadata,e=i.getMetadata,r=i.getState,n=i.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:i.setStateWrapper,actions:n}},this.addNewSubscriber=function(t,e){i.subscribers.set(t,e)},this.updateSubscriptionIfExists=function(t,e){i.subscribers.has(t)&&Object.assign(i.subscribers.get(t),e)},this.executeOnSubscribed=function(){var t=i.onSubscribed,e=i.config.onSubscribed;if(t||e){var r=i.getConfigCallbackParam();null==t||t(r),null==e||e(r)}},this.getHook=function(){var t=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=function(){return t?{state:t(i.stateWrapper.state)}:{state:i.stateWrapper.state}},u=o((0,s.useState)(a),2),c=u[0],f=u[1],v=(0,s.useRef)(null);(0,s.useEffect)((function(){if(null===v.current){var e=(0,l.uniqueId)();v.current=e,i.addNewSubscriber(e,{subscriptionId:e,currentState:c.state,selector:t,config:n,callback:f}),i.executeOnSubscribed()}var r=v.current;return i.updateSubscriptionIfExists(r,{subscriptionId:r,currentState:c.state,selector:t,config:n,callback:f}),function(){i.subscribers.delete(v.current)}}),[]);var p=v.current,d=i.subscribers.get(p),y=(null!==(e=null==d?void 0:d.config)&&void 0!==e?e:{dependencies:n.dependencies}).dependencies;return i.updateSubscriptionIfExists(p,{subscriptionId:p,currentState:c.state,selector:t,config:n,callback:f}),[function(){if(!t||!p)return c.state;var e=n.dependencies;if(y===e)return c.state;if((null==y?void 0:y.length)===(null==e?void 0:e.length)&&(0,l.shallowCompare)(y,e))return c.state;var r=a();return i.updateSubscriptionIfExists(p,{subscriptionId:p,currentState:r.state,selector:t,config:n,callback:f}),c.state=r.state,r.state}(),i.getStateOrchestrator(),null!==(r=i.config.metadata)&&void 0!==r?r:null]};return t.stateControls=i.stateControls,t.createSelectorHook=i.createSelectorHook,t},this.createSelectorHook=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.isEqualRoot,a=r.isEqual,u=new Map,c=o(i.stateControls(),3),f=c[0],v=c[1],p=c[2],d=f(),y=(null!=t?t:function(t){return t})(f());f((function(e){e((function(e){if(!(null!=n?n:Object.is)(d,e)){d=e;var r=t(e);(null!=a?a:Object.is)(y,r)||(y=r,u.forEach((function(t){t.callback({state:y})})))}}),{skipFirst:!0})}));var b=function(t,e){u.set(t,e)},h=function(t,e){u.has(t)&&Object.assign(u.get(t),e)},g=function(t){if(!t)return y;var r=[];return t((function(t,e,n){var o="function"==typeof e,i=o?t:null,a=o?n:e,u=function(t){var e=t.callback,r=t.selector,n=t.config,o=(null!=r?r:function(t){return t})(y),i={state:o};return(null==n?void 0:n.skipFirst)||e(o),{stateWrapper:i,subscriptionCallback:function(t){var r=t.state;i.state=r,e(r)}}}({selector:i,callback:o?e:t,config:a}),c=u.subscriptionCallback,s=u.stateWrapper,f=(0,l.uniqueId)();b(f,{subscriptionId:f,selector:i,config:a,currentState:s.state,callback:c}),r.push(f)})),r.length||(0,e.throwNoSubscribersWereAdded)(),function(){for(var t=0;t<r.length;t++){var e=r[t];u.delete(e)}}},m=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(r.isEqualRoot,r.isEqual,function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(r,["isEqualRoot","isEqual"])),a=function(){return t?{state:t(y)}:{state:y}},c=o((0,s.useState)(a),2),f=c[0],d=c[1],m=(0,s.useRef)(null);(0,s.useEffect)((function(){if(null===m.current){var e=(0,l.uniqueId)();m.current=e,b(e,{subscriptionId:e,currentState:f.state,selector:t,config:n,callback:d})}var r=m.current;i.updateSubscriptionIfExists(r,{subscriptionId:r,currentState:f.state,selector:t,config:n,callback:d});var o=g((function(t){var e=y;t((function(t){var r,n,o,i,a=u.get(m.current);if(!(null!==(n=null===(r=a.config)||void 0===r?void 0:r.isEqualRoot)&&void 0!==n?n:Object.is)(e,t)){e=t;var c=(null!==(o=a.selector)&&void 0!==o?o:function(t){return t})(y);(null!==(i=null==a?void 0:a.config.isEqual)&&void 0!==i?i:Object.is)(c,a.currentState)||(a.currentState=c,a.callback({state:c}))}}))}));return function(){o(),u.delete(m.current)}}),[]);var S=m.current,w=u.get(S),O=(null!==(e=null==w?void 0:w.config)&&void 0!==e?e:{dependencies:n.dependencies}).dependencies;return h(S,{subscriptionId:S,currentState:f.state,selector:t,config:n,callback:d}),[function(){if(!t||!S)return f.state;var e=n.dependencies;if(O===e)return f.state;if((null==O?void 0:O.length)===(null==e?void 0:e.length)&&(0,l.shallowCompare)(O,e))return f.state;var r=a();return h(S,{subscriptionId:S,currentState:r.state,selector:t,config:n,callback:d}),f.state=r.state,r.state}(),v,p]};return m.stateControls=function(){return[g,v,p]},m.createSelectorHook=i.createSelectorHook.bind(m),Object.assign(m,{subscribers:u}),m},this.stateControls=function(){var t=i.getStateOrchestrator(),e=i.getMetadata;return[i.getState,t,e]},this.getStateOrchestrator=function(){return i.actions?i.actions:i.setStateWrapper},this.hasStateCallbacks=function(){var t=i.computePreventStateChange,e=i.onStateChanged,r=i.config,n=r.computePreventStateChange,o=r.onStateChanged;return!!(t||n||e||o)},this.setStateWrapper=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.forceUpdate,n=e.identifier,o="function"==typeof t,a=i.stateWrapper.state,u=o?t(a):t;if(r||!Object.is(i.stateWrapper.state,u)){var c=i.setMetadata,l=i.getMetadata,s=i.getState,f=i.actions,v={setMetadata:c,getMetadata:l,setState:i.setState,getState:s,actions:f,previousState:a,state:u,identifier:n},p=i.computePreventStateChange,d=i.config.computePreventStateChange;if((p||d)&&((null==p?void 0:p(v))||(null==d?void 0:d(v))))return;i.setState({forceUpdate:r,identifier:n,state:u});var y=i.onStateChanged,b=i.config.onStateChanged;(y||b)&&(null==y||y(v),null==b||b(v))}},this.getStoreActionsMap=function(){if(!i.actionsConfig)return null;var t=i.actionsConfig,e=i.setMetadata,r=i.setStateWrapper,n=i.getState,o=i.getMetadata,a=Object.keys(t).reduce((function(i,u){var l,s,f;return Object.assign(i,(l={},f=function(){for(var i=t[u],c=arguments.length,l=new Array(c),s=0;s<c;s++)l[s]=arguments[s];var f=i.apply(a,l);return"function"!=typeof f&&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"))}(u),f.call(a,{setState:r,getState:n,setMetadata:e,getMetadata:o,actions:a})},(s=c(s=u))in l?Object.defineProperty(l,s,{value:f,enumerable:!0,configurable:!0,writable:!0}):l[s]=f,l)),i}),{});return a},this.stateWrapper={state:r},this.config=Object.assign({metadata:null},null!=n?n:{}),(null===globalThis||void 0===globalThis?void 0:globalThis.REACT_GLOBAL_STATE_HOOK_DEBUG)&&globalThis.REACT_GLOBAL_STATE_HOOK_DEBUG(this,r,n,u),this.constructor!==t||this.initialize()}var r,n;return r=t,(n=[{key:"state",get:function(){return this.stateWrapper.state}}])&&u(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),t}();e.GlobalStore=f},530:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0})},608:(t,e,r)=>{"use strict";function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);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,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 i(t,e){if(t){if("string"==typeof t)return a(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t){return u="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},u(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.uniqueId=e.debounce=e.shallowCompare=void 0;var c=r(684);e.shallowCompare=function(t,e){if(t===e)return!0;var r=u(t),i=u(e);if(r!==i)return!1;if((0,c.isNil)(t)||(0,c.isNil)(e)||(0,c.isPrimitive)(t)&&(0,c.isPrimitive)(e)||(0,c.isDate)(t)&&(0,c.isDate)(e)||"function"===r&&"function"===i)return t===e;if(Array.isArray(t)){var a=t,l=e;if(a.length!==l.length)return!1;for(var s=0;s<a.length;s++)if(a[s]!==l[s])return!1}if(t instanceof Map){var f=t,v=e;if(f.size!==v.size)return!1;var p,d=o(f);try{for(d.s();!(p=d.n()).done;){var y=n(p.value,2),b=y[0];if(y[1]!==v.get(b))return!1}}catch(t){d.e(t)}finally{d.f()}}if(t instanceof Set){var h=t,g=e;if(h.size!==g.size)return!1;var m,S=o(h);try{for(S.s();!(m=S.n()).done;){var w=m.value;if(!g.has(w))return!1}}catch(t){S.e(t)}finally{S.f()}}var O=Object.keys(t),j=Object.keys(e);if(O.length!==j.length)return!1;for(var E=0,A=O;E<A.length;E++){var x=A[E];if(t[x]!==e[x])return!1}return!0},e.debounce=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];e&&clearTimeout(e),e=setTimeout((function(){t.apply(void 0,o)}),r)}},e.uniqueId=function(){return Date.now().toString(36)+Math.random().toString(36).substr(2,5)}},195:(t,e,r)=>{"use strict";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)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.GlobalStoreAbstract=void 0;var a=function(t){!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&&o(t,e)}(c,t);var e,r,a,u=(r=c,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=i(r);if(a){var o=i(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(e)||"function"==typeof e))return e;if(void 0!==e)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)}(this,t)});function c(t,e,r){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,c),(n=u.call(this,t,e,r)).onInit=function(t){n.onInitialize(t)},n.onStateChanged=function(t){n.onChange(t)},n}return e=c,Object.defineProperty(e,"prototype",{writable:!1}),e}(r(774).GlobalStore);e.GlobalStoreAbstract=a},991:(t,e,r)=>{"use strict";var n=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]},o=function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(684),e),o(r(530),e),o(r(774),e),o(r(195),e),o(r(853),e),o(r(608),e),o(r(852),e),o(r(113),e)},684:function(t){t.exports=(()=>{"use strict";var t={991:(t,e,r)=>{var n=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]};Object.defineProperty(e,"__esModule",{value:!0}),function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)}(r(729),e)},729:(t,e)=>{function r(t){return r="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},r(t)}function n(t,e,n){return(e=function(t){var e=function(t,e){if("object"!==r(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,"string");if("object"!==r(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===r(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){if(t){if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}Object.defineProperty(e,"__esModule",{value:!0}),e.formatToStore=e.formatFromStore=e.isPrimitive=e.isFunction=e.isRegex=e.isDate=e.isString=e.isBoolean=e.isNumber=e.isNil=e.clone=void 0,e.clone=function(t){var r,a=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).shallow;if((0,e.isPrimitive)(t)||(0,e.isDate)(t))return t;if(Array.isArray(t))return a?function(t){if(Array.isArray(t))return i(t)}(r=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||o(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}():t.map((function(t){return(0,e.clone)(t)}));if(t instanceof Map){var u=Array.from(t.entries());return a?new Map(u):new Map(u.map((function(t){return(0,e.clone)(t)})))}if(t instanceof Set){var c=Array.from(t.values());return a?new Set(c):new Set(c.map((function(t){return(0,e.clone)(t)})))}return t instanceof RegExp?new RegExp(t.toString()):(0,e.isFunction)(t)?a?t:Object.create(t):a?Object.assign({},t):t instanceof Error?new Error(t.message):Object.keys(t).reduce((function(r,o){var i=t[o];return Object.assign(Object.assign({},r),n({},o,(0,e.clone)(i)))}),{})},e.isNil=function(t){return null==t},e.isNumber=function(t){return"number"==typeof t},e.isBoolean=function(t){return"boolean"==typeof t},e.isString=function(t){return"string"==typeof t},e.isDate=function(t){return t instanceof Date},e.isRegex=function(t){return t instanceof RegExp},e.isFunction=function(t){return"function"==typeof t||t instanceof Function},e.isPrimitive=function(t){return(0,e.isNil)(t)||(0,e.isNumber)(t)||(0,e.isBoolean)(t)||(0,e.isString)(t)||"symbol"===r(t)},e.formatFromStore=function(t){return function(t){var r,i;if((0,e.isPrimitive)(t))return t;if("date"===(null==t?void 0:t.$t))return new Date(t.$v);if("map"===(null==t?void 0:t.$t)){var a=(null!==(r=t.$v)&&void 0!==r?r:[]).map((function(t){var r,n=(2,function(t){if(Array.isArray(t))return t}(r=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,u=[],c=!0,l=!1;try{for(i=(r=r.call(t)).next,0;!(c=(n=i.call(r)).done)&&(u.push(n.value),2!==u.length);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(r)||o(r,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.")}()),i=n[0],a=n[1];return[i,(0,e.formatFromStore)(a)]}));return new Map(a)}if("set"===(null==t?void 0:t.$t)){var u=null!==(i=t.$v)&&void 0!==i?i:[].map((function(t){return(0,e.formatFromStore)(t)}));return new Set(u)}return"regex"===(null==t?void 0:t.$t)?new RegExp(t.$v):"error"===(null==t?void 0:t.$t)?new Error(t.$v):Array.isArray(t)?t.map((function(t){return(0,e.formatFromStore)(t)})):"function"===(null==t?void 0:t.$t)?Function("(".concat(t.$v,")(...arguments)")):Object.keys(t).reduce((function(r,o){var i=t[o];return Object.assign(Object.assign({},r),n({},o,(0,e.formatFromStore)(i)))}),{})}((arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).jsonParse?JSON.parse(t):(0,e.clone)(t))},e.formatToStore=function(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{stringify:!1},i=o.stringify,a=o.validator,u=o.excludeTypes,c=o.excludeKeys,l=new Set(null!=u?u:[]),s=new Set(null!=c?c:[]),f=l.size||s.size,v=null!=a?a:function(t){var e=t.key,n=t.value;if(!f)return!0;var o=s.has(e),i=l.has(r(n));return!o&&!i},p=function t(r){if((0,e.isPrimitive)(r))return r;if(Array.isArray(r))return r.map((function(e){return t(e)}));if(r instanceof Map)return{$t:"map",$v:Array.from(r.entries()).map((function(e){return t(e)}))};if(r instanceof Set)return{$t:"set",$v:Array.from(r.values()).map((function(e){return t(e)}))};if((0,e.isDate)(r))return{$t:"date",$v:r.toISOString()};if((0,e.isRegex)(r))return{$t:"regex",$v:r.toString()};if((0,e.isFunction)(r)){var o;try{o={$t:"function",$v:r.toString()}}catch(t){o={$t:"error",$v:"Error: Could not serialize function"}}return o}return r instanceof Error?{$t:"error",$v:r.message}:Object.keys(r).reduce((function(e,o){var i=r[o],a=t(i);return v({obj:r,key:o,value:a})?Object.assign(Object.assign({},e),n({},o,t(i))):e}),{})}((0,e.clone)(t));return i?JSON.stringify(p):p}}},e={};return function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}(991)})()},156:e=>{"use strict";e.exports=t}},r={},function t(n){var o=r[n];if(void 0!==o)return o.exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.exports}(991);var e,r}));
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { ActionCollectionConfig,
|
|
1
|
+
import { ActionCollectionConfig, StateHook, StateSetter, ActionCollectionResult, StateGetter, StateChanges, StoreTools } from './GlobalStore.types';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare const createStatefulContext: <
|
|
4
|
-
|
|
3
|
+
export declare const createStatefulContext: <State, Metadata = null, ActionsConfig extends {} | ActionCollectionConfig<State, Metadata> = null>(initialValue: State, parameters?: Readonly<{
|
|
4
|
+
/**
|
|
5
|
+
* Non reactive data of the store
|
|
6
|
+
* */
|
|
7
|
+
metadata?: Metadata;
|
|
8
|
+
/**
|
|
9
|
+
* actions configuration for restricting the manipulation of the state
|
|
10
|
+
*/
|
|
11
|
+
actions?: ActionsConfig;
|
|
12
|
+
onInit?: (storeAPI: StoreTools<State, Metadata>) => void;
|
|
13
|
+
onStateChanged?: (storeAPI: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
14
|
+
onSubscribed?: (storeAPI: StoreTools<State, Metadata>) => void;
|
|
15
|
+
computePreventStateChange?: (storeAPI: StoreTools<State, Metadata>) => boolean;
|
|
16
|
+
}>) => readonly [() => [hook: StateHook<State, ActionsConfig extends null ? StateSetter<State> : ActionCollectionResult<State, Metadata, ActionsConfig>, Metadata>, stateRetriever: StateGetter<State>, stateMutator: ActionsConfig extends null ? StateSetter<State> : ActionCollectionResult<State, Metadata, ActionsConfig>], React.FC<React.PropsWithChildren<{
|
|
17
|
+
initialValue?: Partial<State>;
|
|
5
18
|
}>>];
|
package/lib/src/GlobalStore.d.ts
CHANGED
|
@@ -1,138 +1,65 @@
|
|
|
1
|
-
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult,
|
|
1
|
+
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, MetadataGetter, StateHook, BaseMetadata, StateChanges } from './GlobalStore.types';
|
|
2
2
|
export declare const throwNoSubscribersWereAdded: () => never;
|
|
3
3
|
/**
|
|
4
4
|
* The GlobalStore class is the main class of the library and it is used to create a GlobalStore instances
|
|
5
|
-
* @template {TState} TState - The type of the state object
|
|
6
|
-
* @template {TMetadata} TMetadata - The type of the metadata object (optional) (default: null) no reactive information set to share with the subscribers
|
|
7
|
-
* @template {TStateMutator} TStateMutator - The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
8
5
|
* */
|
|
9
|
-
export declare class GlobalStore<
|
|
10
|
-
|
|
6
|
+
export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {} = null, StoreAPI = {
|
|
7
|
+
setMetadata: MetadataSetter<Metadata>;
|
|
8
|
+
setState: StateSetter<State>;
|
|
9
|
+
getState: StateGetter<State>;
|
|
10
|
+
getMetadata: () => Metadata;
|
|
11
|
+
actions: any;
|
|
12
|
+
}, PublicStateMutator = ActionsConfig extends null ? StateSetter<State> : ActionCollectionResult<State, Metadata, ActionsConfig>> {
|
|
13
|
+
protected actionsConfig: ActionsConfig;
|
|
11
14
|
/**
|
|
12
15
|
* list of all the subscribers setState functions
|
|
13
|
-
* @template {
|
|
16
|
+
* @template {State} TState - The type of the state object
|
|
14
17
|
* */
|
|
15
18
|
subscribers: Map<string, SubscriberParameters>;
|
|
16
19
|
/**
|
|
17
20
|
* Actions of the store
|
|
18
21
|
*/
|
|
19
|
-
actions?: ActionCollectionResult<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
* @template {TMetadata} TMetadata - The type of the metadata object (optional) (default: null) no reactive information set to share with the subscribers
|
|
24
|
-
* @template {TStateMutator} TStateMutator - The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
25
|
-
* @property {GlobalStoreConfig<TState, TMetadata, TStateMutator>} config.metadata - The metadata to pass to the callbacks (optional) (default: null)
|
|
26
|
-
* @property {GlobalStoreConfig<TState, TMetadata, TStateMutator>} config.onInit - The callback to execute when the store is initialized (optional) (default: null)
|
|
27
|
-
* @property {GlobalStoreConfig<TState, TMetadata, TStateMutator>} config.onStateChanged - The callback to execute when the state is changed (optional) (default: null)
|
|
28
|
-
* @property {GlobalStoreConfig<TState, TMetadata, TStateMutator>} config.onSubscribed - The callback to execute when a component is subscribed to the store (optional) (default: null)
|
|
29
|
-
* @property {GlobalStoreConfig<TState, TMetadata, TStateMutator>} config.computePreventStateChange - The callback to execute when the state is changed to compute if the state change should be prevented (optional) (default: null)
|
|
22
|
+
actions?: ActionsConfig extends null ? null : ActionCollectionResult<State, Metadata, ActionsConfig>;
|
|
23
|
+
protected config: GlobalStoreConfig<State, Metadata>;
|
|
24
|
+
/**
|
|
25
|
+
* execute when the store is initialized
|
|
30
26
|
*/
|
|
31
|
-
protected
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @param {Dispatch<SetStateAction<TState>>} parameters.setState - The setState function to update the state
|
|
39
|
-
* @param {() => TState} parameters.getState - The getState function to get the state
|
|
40
|
-
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
41
|
-
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
42
|
-
* */
|
|
43
|
-
protected onInit?: GlobalStoreConfig<TState, TMetadata, TStateMutator>['onInit'];
|
|
44
|
-
/**
|
|
45
|
-
* execute every time the state is changed
|
|
46
|
-
* @template {TState} TState - The type of the state object
|
|
47
|
-
* @template {TMetadata} TMetadata - The type of the metadata object (optional) (default: null) no reactive information set to share with the subscribers
|
|
48
|
-
* @template {TStateMutator} TStateMutator - The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
49
|
-
* @param {StateConfigCallbackParam<TState, TMetadata, TStateMutator>} parameters - The parameters object brings the following properties: setState, getState, setMetadata, getMetadata
|
|
50
|
-
* @param {Dispatch<SetStateAction<TState>>} parameters.setState - The setState function to update the state
|
|
51
|
-
* @param {() => TState} parameters.getState - The getState function to get the state
|
|
52
|
-
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
53
|
-
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
54
|
-
* */
|
|
55
|
-
protected onStateChanged?: GlobalStoreConfig<TState, TMetadata, TStateMutator>['onStateChanged'];
|
|
56
|
-
/**
|
|
57
|
-
* Execute each time a new component gets subscribed to the store
|
|
58
|
-
* @template {TState} TState - The type of the state object
|
|
59
|
-
* @template {TMetadata} TMetadata - The type of the metadata object (optional) (default: null) no reactive information set to share with the subscribers
|
|
60
|
-
* @template {TStateMutator} TStateMutator - The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
61
|
-
* @param {StateConfigCallbackParam<TState, TMetadata, TStateMutator>} parameters - The parameters object brings the following properties: setState, getState, setMetadata, getMetadata
|
|
62
|
-
* @param {Dispatch<SetStateAction<TState>>} parameters.setState - The setState function to update the state
|
|
63
|
-
* @param {() => TState} parameters.getState - The getState function to get the state
|
|
64
|
-
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
65
|
-
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
66
|
-
* */
|
|
67
|
-
protected onSubscribed?: GlobalStoreConfig<TState, TMetadata, TStateMutator>['onSubscribed'];
|
|
68
|
-
/**
|
|
69
|
-
* Execute every time a state change is triggered and before the state is updated, it allows to prevent the state change by returning true
|
|
70
|
-
* @template {TState} TState - The type of the state object
|
|
71
|
-
* @template {TMetadata} TMetadata - The type of the metadata object (optional) (default: null) no reactive information set to share with the subscribers
|
|
72
|
-
* @template {TStateMutator} TStateMutator - The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
73
|
-
* @param {StateConfigCallbackParam<TState, TMetadata, TStateMutator>} parameters - The parameters object brings the following properties: setState, getState, setMetadata, getMetadata
|
|
74
|
-
* @param {Dispatch<SetStateAction<TState>>} parameters.setState - The setState function to update the state
|
|
75
|
-
* @param {() => TState} parameters.getState - The getState function to get the state
|
|
76
|
-
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
77
|
-
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
78
|
-
* @returns {boolean} - true to prevent the state change, false to allow the state change
|
|
79
|
-
* */
|
|
80
|
-
protected computePreventStateChange?: GlobalStoreConfig<TState, TMetadata, TStateMutator>['computePreventStateChange'];
|
|
27
|
+
protected onInit?: (args: StoreAPI) => void;
|
|
28
|
+
protected onStateChanged?: (args: StoreAPI & StateChanges<State>) => void;
|
|
29
|
+
protected onSubscribed?: (args: StoreAPI) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Every time a state change is triggered and before the state is updated, it allows to prevent the state change by returning true
|
|
32
|
+
*/
|
|
33
|
+
protected computePreventStateChange?: (parameters: StoreAPI & StateChanges<State>) => boolean;
|
|
81
34
|
/**
|
|
82
35
|
* We use a wrapper in order to be able to force the state update when necessary even with primitive types
|
|
83
36
|
*/
|
|
84
37
|
protected stateWrapper: {
|
|
85
|
-
state:
|
|
38
|
+
state: State;
|
|
86
39
|
};
|
|
87
40
|
/**
|
|
88
41
|
* @deprecated direct modifications of the state could end up in unexpected behaviors
|
|
89
42
|
*/
|
|
90
|
-
protected get state():
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* */
|
|
95
|
-
constructor(state: TState);
|
|
96
|
-
/**
|
|
97
|
-
* Create a new global store with custom action
|
|
98
|
-
* The metadata object could be null if not needed
|
|
99
|
-
* The setter Object is used to define the actions that will be used to manipulate the state
|
|
100
|
-
* @param {TState} state - The initial state
|
|
101
|
-
* @param {TStateMutator} actionsConfig - The actions configuration object (optional) (default: null) if not null the store manipulation will be done through the actions
|
|
102
|
-
* */
|
|
103
|
-
constructor(state: TState, config: GlobalStoreConfig<TState, TMetadata, TStateMutator>);
|
|
104
|
-
/**
|
|
105
|
-
* Create a new global store with custom action
|
|
106
|
-
* The metadata object could be null if not needed
|
|
107
|
-
* The setter Object is used to define the actions that will be used to manipulate the state
|
|
108
|
-
* The config object is used to define the callbacks that will be executed during the store lifecycle
|
|
109
|
-
* The lifecycle callbacks are: onInit, onStateChanged, onSubscribed and computePreventStateChange
|
|
110
|
-
* @param {TState} state - The initial state
|
|
111
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config - The configuration object (optional) (default: { metadata: null })
|
|
112
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config.metadata - The metadata object (optional) (default: null) if not null the metadata object will be reactive
|
|
113
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config.onInit - The callback to execute when the store is initialized (optional) (default: null)
|
|
114
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config.onStateChanged - The callback to execute when the state is changed (optional) (default: null)
|
|
115
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config.onSubscribed - The callback to execute when a new component gets subscribed to the store (optional) (default: null)
|
|
116
|
-
* @param {GlobalStoreConfig<TState, TMetadata>} config.computePreventStateChange - The callback to execute every time a state change is triggered and before the state is updated, it allows to prevent the state change by returning true (optional) (default: null)
|
|
117
|
-
* @param {TStateMutator} actionsConfig - The actions configuration object (optional) (default: null) if not null the store manipulation will be done through the actions
|
|
118
|
-
* */
|
|
119
|
-
constructor(state: TState, config: GlobalStoreConfig<TState, TMetadata, TStateMutator>, actionsConfig: TStateMutator);
|
|
43
|
+
protected get state(): State;
|
|
44
|
+
constructor(state: State);
|
|
45
|
+
constructor(state: State, config: GlobalStoreConfig<State, Metadata>);
|
|
46
|
+
constructor(state: State, config: GlobalStoreConfig<State, Metadata>, actionsConfig: ActionsConfig);
|
|
120
47
|
protected initialize: () => Promise<void>;
|
|
121
48
|
/**
|
|
122
49
|
* set the state and update all the subscribers
|
|
123
|
-
* @param {StateSetter<
|
|
50
|
+
* @param {StateSetter<State>} setter - The setter function or the value to set
|
|
124
51
|
* */
|
|
125
52
|
protected setState: ({ state: newRootState, forceUpdate, identifier, }: {
|
|
126
|
-
state:
|
|
53
|
+
state: State;
|
|
127
54
|
forceUpdate: boolean;
|
|
128
55
|
identifier?: string;
|
|
129
56
|
}) => void;
|
|
130
57
|
/**
|
|
131
58
|
* Set the value of the metadata property, this is no reactive and will not trigger a re-render
|
|
132
|
-
* @param {MetadataSetter<
|
|
59
|
+
* @param {MetadataSetter<Metadata>} setter - The setter function or the value to set
|
|
133
60
|
* */
|
|
134
|
-
protected setMetadata: MetadataSetter<
|
|
135
|
-
protected getMetadata: () =>
|
|
61
|
+
protected setMetadata: MetadataSetter<Metadata>;
|
|
62
|
+
protected getMetadata: () => Metadata;
|
|
136
63
|
protected createChangesSubscriber: ({ callback, selector, config, }: {
|
|
137
64
|
selector?: SelectorCallback<unknown, unknown>;
|
|
138
65
|
callback: SubscribeCallback<unknown>;
|
|
@@ -143,65 +70,34 @@ export declare class GlobalStore<TState, TMetadata = null, TStateMutator extends
|
|
|
143
70
|
};
|
|
144
71
|
subscriptionCallback: SubscriptionCallback;
|
|
145
72
|
};
|
|
146
|
-
|
|
147
|
-
* Return current state of the store
|
|
148
|
-
* Optionally you can use this method to subscribe a callback to the store changes
|
|
149
|
-
* @param {UseHookConfig<TState, TDerivate>} config - The configuration object (optional) (default: { selector: null, subscriptionCallback: null, config: null })
|
|
150
|
-
* @param {TSelector} config.selector - The selector function to derive the state (optional) (default: null)
|
|
151
|
-
* @param {TSubscriptionCallback} config.subscriptionCallback - The callback to execute every time the state is changed
|
|
152
|
-
* @param {UseHookConfig<TState, TDerivate>} config.config - The configuration for the callback (optional) (default: null)
|
|
153
|
-
* @param {UseHookConfig<TState, TDerivate>} config.config.isEqual - The compare function to check if the state is changed (optional) (default: shallowCompare)
|
|
154
|
-
* @returns The state of the store, optionally if you provide a subscriptionCallback it this method will return the unsubscribe function
|
|
155
|
-
*/
|
|
156
|
-
protected getState: StateGetter<TState>;
|
|
73
|
+
protected getState: StateGetter<State>;
|
|
157
74
|
/**
|
|
158
75
|
* get the parameters object to pass to the callback functions (onInit, onStateChanged, onSubscribed, computePreventStateChange)
|
|
159
|
-
* this parameters object brings the following properties: setState, getState, setMetadata, getMetadata
|
|
160
|
-
* this parameter object allows to update the state, get the state, update the metadata, get the metadata
|
|
161
|
-
* @returns {StateConfigCallbackParam<TState, TMetadata>} - The parameters object
|
|
162
76
|
* */
|
|
163
|
-
protected getConfigCallbackParam: () =>
|
|
164
|
-
protected addNewSubscriber: (subscriptionId: string,
|
|
165
|
-
|
|
166
|
-
selector: SelectorCallback<any, any>;
|
|
167
|
-
config: UseHookConfig<any> | SubscribeCallbackConfig<any>;
|
|
168
|
-
stateWrapper: {
|
|
169
|
-
state: unknown;
|
|
170
|
-
};
|
|
171
|
-
}) => void;
|
|
172
|
-
protected updateSubscriptionIfExists: (subscriptionId: string, args: {
|
|
173
|
-
callback: SubscriptionCallback;
|
|
174
|
-
selector: SelectorCallback<any, any>;
|
|
175
|
-
config: UseHookConfig<any> | SubscribeCallbackConfig<any>;
|
|
176
|
-
stateWrapper: {
|
|
177
|
-
state: unknown;
|
|
178
|
-
};
|
|
179
|
-
}) => void;
|
|
77
|
+
protected getConfigCallbackParam: () => StoreAPI;
|
|
78
|
+
protected addNewSubscriber: (subscriptionId: string, item: SubscriberParameters) => void;
|
|
79
|
+
protected updateSubscriptionIfExists: (subscriptionId: string, item: SubscriberParameters) => void;
|
|
180
80
|
protected executeOnSubscribed: () => void;
|
|
181
81
|
/**
|
|
182
82
|
* Returns a custom hook that allows to handle a global state
|
|
183
|
-
* @returns {[
|
|
83
|
+
* @returns {[State, StateMutator, Metadata]} - The state, the state setter or the actions map, the metadata
|
|
184
84
|
* */
|
|
185
|
-
getHook: () => StateHook<
|
|
85
|
+
getHook: () => StateHook<State, PublicStateMutator, Metadata>;
|
|
186
86
|
/**
|
|
187
87
|
* @description
|
|
188
88
|
* Use this function to create a custom global hook which contains a fragment of the state of another hook
|
|
189
89
|
*/
|
|
190
|
-
createSelectorHook: <RootState, StateMutator,
|
|
90
|
+
createSelectorHook: <RootState, StateMutator, Metadata_1 extends BaseMetadata, RootSelectorResult, RootDerivate = RootSelectorResult extends never ? RootState : RootSelectorResult>(mainSelector?: (state: RootState) => RootSelectorResult, { isEqualRoot: mainIsEqualRoot, isEqual: mainIsEqualFun, }?: Omit<UseHookConfig<RootDerivate, RootState>, "dependencies">) => StateHook<RootDerivate, StateMutator, Metadata_1>;
|
|
191
91
|
/**
|
|
192
92
|
* Returns an array with the a function to get the state, the state setter or the actions map, and a function to get the metadata
|
|
193
|
-
* @returns {[() =>
|
|
93
|
+
* @returns {[() => State, StateMutator, () => Metadata]} - The state getter, the state setter or the actions map, the metadata getter
|
|
194
94
|
* */
|
|
195
|
-
stateControls: () => [StateGetter<
|
|
196
|
-
/**
|
|
197
|
-
* @deprecated use the stateControls method instead
|
|
198
|
-
*/
|
|
199
|
-
getHookDecoupled: () => [StateGetter<TState>, keyof TStateMutator extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TStateMutator>, MetadataGetter<TMetadata>];
|
|
95
|
+
stateControls: () => [StateGetter<State>, PublicStateMutator, MetadataGetter<Metadata>];
|
|
200
96
|
/**
|
|
201
97
|
* Returns the state setter or the actions map
|
|
202
|
-
* @returns {
|
|
98
|
+
* @returns {StateMutator} - The state setter or the actions map
|
|
203
99
|
* */
|
|
204
|
-
protected getStateOrchestrator: () =>
|
|
100
|
+
protected getStateOrchestrator: () => PublicStateMutator;
|
|
205
101
|
/**
|
|
206
102
|
* Calculate whenever or not we should compute the callback parameters on the state change
|
|
207
103
|
* @returns {boolean} - True if we should compute the callback parameters on the state change
|
|
@@ -213,10 +109,10 @@ export declare class GlobalStore<TState, TMetadata = null, TStateMutator extends
|
|
|
213
109
|
* - onStateChanged (if defined) - this function is executed after the state change
|
|
214
110
|
* - computePreventStateChange (if defined) - this function is executed before the state change and it should return a boolean value that will be used to determine if the state change should be prevented or not
|
|
215
111
|
*/
|
|
216
|
-
protected setStateWrapper: StateSetter<
|
|
112
|
+
protected setStateWrapper: StateSetter<State>;
|
|
217
113
|
/**
|
|
218
114
|
* This creates a map of actions that can be used to modify or interact with the state
|
|
219
|
-
* @returns {ActionCollectionResult<
|
|
115
|
+
* @returns {ActionCollectionResult<State, Metadata, StateMutator>} - The actions map result of the configuration object passed to the constructor
|
|
220
116
|
* */
|
|
221
|
-
protected getStoreActionsMap: () => ActionCollectionResult<
|
|
117
|
+
protected getStoreActionsMap: () => ActionCollectionResult<State, Metadata, ActionsConfig>;
|
|
222
118
|
}
|
|
@@ -1,20 +1,117 @@
|
|
|
1
|
-
import { ActionCollectionConfig, StateSetter, ActionCollectionResult, UseHookConfig,
|
|
2
|
-
/**
|
|
3
|
-
* Creates a global state with the given state and config.
|
|
4
|
-
* @returns {} [HOOK, DECOUPLED_RETRIEVER, DECOUPLED_MUTATOR] this is an array with the hook, the decoupled getState function and the decoupled setter of the state
|
|
5
|
-
*/
|
|
6
|
-
export declare const createGlobalStateWithDecoupledFuncs: <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, TMetadata> = null>(state: TState, { actions, ...config }?: createStateConfig<TState, TMetadata, TActions>) => [hook: StateHook<TState, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TActions>, TMetadata>, stateRetriever: StateGetter<TState>, stateMutator: keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TActions>];
|
|
1
|
+
import { ActionCollectionConfig, StateSetter, ActionCollectionResult, UseHookConfig, UnsubscribeCallback, StateHook, StateGetter, CustomGlobalHookBuilderParams, SelectorCallback, SubscribeToEmitter, StateChanges, BaseMetadata, MetadataSetter, StoreTools } from './GlobalStore.types';
|
|
7
2
|
/**
|
|
8
3
|
* Creates a global hook that can be used to access the state and actions across the application
|
|
9
4
|
* @returns {} - () => [TState, Setter, TMetadata] the hook that can be used to access the state and the setter of the state
|
|
10
5
|
*/
|
|
11
|
-
export declare const createGlobalState:
|
|
6
|
+
export declare const createGlobalState: {
|
|
7
|
+
<State>(state: State): StateHook<State, StateSetter<State>, BaseMetadata>;
|
|
8
|
+
<State_1, Metadata extends BaseMetadata, ActionsConfig extends {} | ActionCollectionConfig<State_1, Metadata> = null, StoreAPI = {
|
|
9
|
+
setMetadata: MetadataSetter<Metadata>;
|
|
10
|
+
setState: StateSetter<State_1>;
|
|
11
|
+
getState: StateGetter<State_1>;
|
|
12
|
+
getMetadata: () => Metadata;
|
|
13
|
+
actions: ActionsConfig extends null ? null : Record<string, (...args: any[]) => void>;
|
|
14
|
+
}>(state: State_1, config: Readonly<{
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated We needed to move the actions parameter as a third argument to fix several issues with the type inference of the actions
|
|
17
|
+
*/
|
|
18
|
+
actions?: ActionsConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Non reactive information about the state
|
|
21
|
+
*/
|
|
22
|
+
metadata?: Metadata;
|
|
23
|
+
/**
|
|
24
|
+
* executes immediately after the store is created
|
|
25
|
+
* */
|
|
26
|
+
onInit?: (args: StoreAPI) => void;
|
|
27
|
+
onStateChanged?: (args: StoreAPI & StateChanges<State_1>) => void;
|
|
28
|
+
onSubscribed?: (args: StoreAPI) => void;
|
|
29
|
+
/**
|
|
30
|
+
* callback function called every time the state is about to change and it allows you to prevent the state change
|
|
31
|
+
*/
|
|
32
|
+
computePreventStateChange?: (args: StoreAPI & StateChanges<State_1>) => boolean;
|
|
33
|
+
}>): StateHook<State_1, ActionsConfig extends null ? StateSetter<State_1> : ActionCollectionResult<State_1, Metadata, ActionsConfig>, Metadata>;
|
|
34
|
+
<State_2, Metadata_1 extends BaseMetadata, ActionsConfig_1 extends ActionCollectionConfig<State_2, Metadata_1>, StoreAPI_1 = {
|
|
35
|
+
setMetadata: MetadataSetter<Metadata_1>;
|
|
36
|
+
setState: StateSetter<State_2>;
|
|
37
|
+
getState: StateGetter<State_2>;
|
|
38
|
+
getMetadata: () => Metadata_1;
|
|
39
|
+
actions: Record<string, (...args: any[]) => void>;
|
|
40
|
+
}>(state: State_2, config: Readonly<{
|
|
41
|
+
/**
|
|
42
|
+
* Non reactive information about the state
|
|
43
|
+
*/
|
|
44
|
+
metadata?: Metadata_1;
|
|
45
|
+
/**
|
|
46
|
+
* executes immediately after the store is created
|
|
47
|
+
* */
|
|
48
|
+
onInit?: (args: StoreAPI_1) => void;
|
|
49
|
+
onStateChanged?: (args: StoreAPI_1 & StateChanges<State_2>) => void;
|
|
50
|
+
onSubscribed?: (args: StoreAPI_1) => void;
|
|
51
|
+
/**
|
|
52
|
+
* callback function called every time the state is about to change and it allows you to prevent the state change
|
|
53
|
+
*/
|
|
54
|
+
computePreventStateChange?: (args: StoreAPI_1 & StateChanges<State_2>) => boolean;
|
|
55
|
+
}>, actions: ActionsConfig_1): StateHook<State_2, ActionCollectionResult<State_2, Metadata_1, ActionsConfig_1>, Metadata_1>;
|
|
56
|
+
<State_3, Metadata_2 extends BaseMetadata, ActionsConfig_2 extends ActionCollectionConfig<State_3, Metadata_2>, StoreAPI_2 = {
|
|
57
|
+
setMetadata: MetadataSetter<Metadata_2>;
|
|
58
|
+
setState: StateSetter<State_3>;
|
|
59
|
+
getState: StateGetter<State_3>;
|
|
60
|
+
getMetadata: () => Metadata_2;
|
|
61
|
+
}>(state: State_3, builder: () => ActionsConfig_2, config?: Readonly<{
|
|
62
|
+
/**
|
|
63
|
+
* Non reactive information about the state
|
|
64
|
+
*/
|
|
65
|
+
metadata?: Metadata_2;
|
|
66
|
+
/**
|
|
67
|
+
* executes immediately after the store is created
|
|
68
|
+
* */
|
|
69
|
+
onInit?: (args: StoreAPI_2) => void;
|
|
70
|
+
onStateChanged?: (args: StoreAPI_2 & StateChanges<State_3>) => void;
|
|
71
|
+
onSubscribed?: (args: StoreAPI_2) => void;
|
|
72
|
+
/**
|
|
73
|
+
* callback function called every time the state is about to change and it allows you to prevent the state change
|
|
74
|
+
*/
|
|
75
|
+
computePreventStateChange?: (args: StoreAPI_2 & StateChanges<State_3>) => boolean;
|
|
76
|
+
}>): StateHook<State_3, ActionCollectionResult<State_3, Metadata_2, ActionsConfig_2>, Metadata_2>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* @description
|
|
80
|
+
* Use this function to create a custom global store.
|
|
81
|
+
* You can use this function to create a store with async storage.
|
|
82
|
+
*/
|
|
83
|
+
export declare const createCustomGlobalState: <InheritMetadata, TCustomConfig>({ onInitialize, onChange, }: CustomGlobalHookBuilderParams<InheritMetadata, TCustomConfig>) => <State, Metadata, ActionsConfig extends Readonly<ActionCollectionConfig<State, Metadata & InheritMetadata>> = null>(state: State, _config?: Readonly<{
|
|
84
|
+
metadata?: Metadata & InheritMetadata;
|
|
85
|
+
readonly actions?: Readonly<ActionsConfig>;
|
|
86
|
+
onInit?: (args: StoreTools<State, Metadata & InheritMetadata>) => void;
|
|
87
|
+
onStateChanged?: (args: StoreTools<State, Metadata & InheritMetadata> & StateChanges<State>) => void;
|
|
88
|
+
onSubscribed?: (parameters: StoreTools<State, Metadata & InheritMetadata>) => void;
|
|
89
|
+
computePreventStateChange?: (args: StoreTools<State, Metadata & InheritMetadata> & StateChanges<State>) => boolean;
|
|
90
|
+
/**
|
|
91
|
+
* @description
|
|
92
|
+
* Type of the configuration object that the custom hook will require or accept
|
|
93
|
+
*/
|
|
94
|
+
config?: TCustomConfig;
|
|
95
|
+
}>) => StateHook<State, ActionsConfig extends null ? StateSetter<State> : ActionCollectionResult<State, Metadata & InheritMetadata, ActionsConfig>, Metadata & InheritMetadata>;
|
|
12
96
|
/**
|
|
13
97
|
* @description
|
|
14
98
|
* Use this function to create a custom global store.
|
|
15
99
|
* You can use this function to create a store with async storage.
|
|
100
|
+
* @deprecated
|
|
16
101
|
*/
|
|
17
|
-
export declare const createCustomGlobalStateWithDecoupledFuncs: <
|
|
102
|
+
export declare const createCustomGlobalStateWithDecoupledFuncs: <InheritMetadata, TCustomConfig>({ onInitialize, onChange, }: CustomGlobalHookBuilderParams<InheritMetadata, TCustomConfig>) => <State, Metadata, ActionsConfig extends Readonly<ActionCollectionConfig<State, Metadata & InheritMetadata>> = null>(state: State, _config?: Readonly<{
|
|
103
|
+
metadata?: Metadata & InheritMetadata;
|
|
104
|
+
readonly actions?: Readonly<ActionsConfig>;
|
|
105
|
+
onInit?: (args: StoreTools<State, Metadata & InheritMetadata>) => void;
|
|
106
|
+
onStateChanged?: (args: StoreTools<State, Metadata & InheritMetadata> & StateChanges<State>) => void;
|
|
107
|
+
onSubscribed?: (parameters: StoreTools<State, Metadata & InheritMetadata>) => void;
|
|
108
|
+
computePreventStateChange?: (args: StoreTools<State, Metadata & InheritMetadata> & StateChanges<State>) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* @description
|
|
111
|
+
* Type of the configuration object that the custom hook will require or accept
|
|
112
|
+
*/
|
|
113
|
+
config?: TCustomConfig;
|
|
114
|
+
}>) => StateHook<State, ActionsConfig extends null ? StateSetter<State> : ActionCollectionResult<State, Metadata & InheritMetadata, ActionsConfig>, Metadata & InheritMetadata>;
|
|
18
115
|
/**
|
|
19
116
|
* @description
|
|
20
117
|
* Use this function to create a custom global hook which contains a fragment of the state of another hook
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @param {StateSetter<TState>} setter - set the state
|
|
3
|
-
* @returns {void} result - void
|
|
4
|
-
*/
|
|
5
|
-
export type StateSetter<TState> = (
|
|
6
|
-
/**
|
|
7
|
-
* @param {StateSetter<TState>} setter - set the state
|
|
8
|
-
* @param {{ forceUpdate?: boolean }} options - Options to be passed to the setter
|
|
9
|
-
* @param {{ forceUpdate?: boolean }} options.forceUpdate - Force the re-render of the subscribers even if the state is the same
|
|
10
|
-
* @returns {void} result - void
|
|
11
|
-
* */
|
|
12
|
-
setter: TState | ((state: TState) => TState),
|
|
1
|
+
export type StateSetter<State> = (setter: State | ((state: State) => State),
|
|
13
2
|
/**
|
|
14
3
|
* This parameter indicate whether we should force the re-render of the subscribers even if the state is the same,
|
|
15
4
|
* Do
|
|
@@ -26,12 +15,7 @@ setter: TState | ((state: TState) => TState),
|
|
|
26
15
|
*/
|
|
27
16
|
forceUpdate?: boolean;
|
|
28
17
|
}) => void;
|
|
29
|
-
|
|
30
|
-
* @description
|
|
31
|
-
* The hook to use the global state
|
|
32
|
-
* @returns {[State, StateSetter<State>, TMetadata]} result - the state, the setter and the metadata
|
|
33
|
-
*/
|
|
34
|
-
export type StateHook<State, StateMutator, TMetadata> = (<Derivate = State>(selector?: (state: State) => Derivate, config?: UseHookConfig<Derivate, State>) => Readonly<[state: Derivate, stateMutator: StateMutator, metadata: TMetadata]>) & {
|
|
18
|
+
export type StateHook<State, StateMutator, Metadata extends BaseMetadata> = (<Derivate = State>(selector?: (state: State) => Derivate, config?: UseHookConfig<Derivate, State>) => Readonly<[state: Derivate, stateMutator: StateMutator, metadata: Metadata]>) & {
|
|
35
19
|
/**
|
|
36
20
|
* @description Return the state controls of the hook
|
|
37
21
|
* This selectors includes:
|
|
@@ -40,9 +24,9 @@ export type StateHook<State, StateMutator, TMetadata> = (<Derivate = State>(sele
|
|
|
40
24
|
* - metadataRetriever: a function to get the metadata of the global state
|
|
41
25
|
*/
|
|
42
26
|
stateControls: () => Readonly<[
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
retriever: StateGetter<State>,
|
|
28
|
+
mutator: StateMutator,
|
|
29
|
+
metadata: MetadataGetter<Metadata>
|
|
46
30
|
]>;
|
|
47
31
|
/***
|
|
48
32
|
* @description Creates a new hooks that returns the result of the selector passed as a parameter
|
|
@@ -50,197 +34,57 @@ export type StateHook<State, StateMutator, TMetadata> = (<Derivate = State>(sele
|
|
|
50
34
|
* The selector hook will be evaluated only if the result of the selector changes and the equality function returns false
|
|
51
35
|
* you can customize the equality function by passing the isEqualRoot and isEqual parameters
|
|
52
36
|
*/
|
|
53
|
-
createSelectorHook: <RootState, StateMutator, Metadata, RootSelectorResult, RootDerivate = RootSelectorResult extends never ? RootState : RootSelectorResult>(this: StateHook<RootState, StateMutator, Metadata>, mainSelector?: (state: RootState) => RootSelectorResult, { isEqualRoot, isEqual }?: Omit<UseHookConfig<RootDerivate, RootState>, 'dependencies'>) => StateHook<RootDerivate, StateMutator, Metadata>;
|
|
37
|
+
createSelectorHook: <RootState, StateMutator, Metadata extends BaseMetadata, RootSelectorResult, RootDerivate = RootSelectorResult extends never ? RootState : RootSelectorResult>(this: StateHook<RootState, StateMutator, Metadata>, mainSelector?: (state: RootState) => RootSelectorResult, { isEqualRoot, isEqual }?: Omit<UseHookConfig<RootDerivate, RootState>, 'dependencies'>) => StateHook<RootDerivate, StateMutator, Metadata>;
|
|
54
38
|
State: State;
|
|
55
39
|
StateMutator: StateMutator;
|
|
56
|
-
Metadata:
|
|
40
|
+
Metadata: Metadata;
|
|
57
41
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param {TMetadata} setter - set the metadata
|
|
65
|
-
* @returns {void} result - void
|
|
66
|
-
*/
|
|
67
|
-
export type MetadataSetter<TMetadata> = (
|
|
68
|
-
/**
|
|
69
|
-
* @param {TMetadata} setter - set the metadata
|
|
70
|
-
* @returns {void} result - void
|
|
71
|
-
* */
|
|
72
|
-
setter: TMetadata | ((metadata: TMetadata) => TMetadata)) => void;
|
|
73
|
-
/**
|
|
74
|
-
* Parameters of the onStateChanged callback function
|
|
75
|
-
* @param {TState} state - the new state
|
|
76
|
-
* @param {TState} previousState - the previous state
|
|
77
|
-
**/
|
|
78
|
-
export type StateChanges<TState> = {
|
|
79
|
-
/**
|
|
80
|
-
* The new state
|
|
81
|
-
* */
|
|
82
|
-
state: TState;
|
|
83
|
-
/**
|
|
84
|
-
* The previous state
|
|
85
|
-
* */
|
|
86
|
-
previousState?: TState;
|
|
42
|
+
export type MetadataSetter<Metadata extends BaseMetadata> = (setter: Metadata | ((metadata: Metadata) => Metadata)) => void;
|
|
43
|
+
export type StateChanges<State> = {
|
|
44
|
+
state: State;
|
|
45
|
+
previousState?: State;
|
|
46
|
+
identifier?: string;
|
|
87
47
|
};
|
|
88
48
|
/**
|
|
89
|
-
*
|
|
90
|
-
* @template {TState} TState - The state type
|
|
91
|
-
* @template {TMetadata} TMetadata - The metadata type
|
|
92
|
-
* @property {StateSetter<TState>} setMetadata - Set the metadata
|
|
93
|
-
* @property {StateSetter<TState>} setState - Set the state
|
|
94
|
-
* @property {() => TState} getState - Get the state
|
|
95
|
-
* @property {() => TMetadata} getMetadata - Get the metadata
|
|
96
|
-
* @property {ActionCollectionResult<TState, TMetadata>} actions - The actions collection if any
|
|
49
|
+
* API for the actions of the global states
|
|
97
50
|
**/
|
|
98
|
-
export type StoreTools<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
setMetadata: MetadataSetter<TMetadata>;
|
|
105
|
-
/**
|
|
106
|
-
* Set the state
|
|
107
|
-
* @param {TState} setter - The state or a function that will receive the state and return the new state
|
|
108
|
-
* @param {{ forceUpdate?: boolean }} options - Options
|
|
109
|
-
* @returns {void} result - void
|
|
110
|
-
* */
|
|
111
|
-
setState: StateSetter<TState>;
|
|
112
|
-
/**
|
|
113
|
-
* Get the state
|
|
114
|
-
* @returns {TState} result - The state
|
|
115
|
-
* */
|
|
116
|
-
getState: StateGetter<TState>;
|
|
117
|
-
/**
|
|
118
|
-
* Get the metadata
|
|
119
|
-
* @returns {TMetadata} result - The metadata
|
|
120
|
-
* */
|
|
121
|
-
getMetadata: () => TMetadata;
|
|
122
|
-
/**
|
|
123
|
-
* Actions of the hook
|
|
124
|
-
*/
|
|
125
|
-
actions: TActions;
|
|
51
|
+
export type StoreTools<State, Metadata extends BaseMetadata = BaseMetadata, Actions = Record<string, (...args: any[]) => void>> = {
|
|
52
|
+
setMetadata: MetadataSetter<Metadata>;
|
|
53
|
+
setState: StateSetter<State>;
|
|
54
|
+
getState: StateGetter<State>;
|
|
55
|
+
getMetadata: () => Metadata;
|
|
56
|
+
actions: Actions;
|
|
126
57
|
};
|
|
127
58
|
/**
|
|
128
|
-
*
|
|
129
|
-
* @template {TState} TState - The state type
|
|
130
|
-
* @template {TMetadata} TMetadata - The metadata type
|
|
131
|
-
* @property {string} key - The action name
|
|
132
|
-
* @property {(...parameters: unknown[]) => (storeTools: { setMetadata: MetadataSetter<TMetadata>; setState: StateSetter<TState>; getState: () => TState; getMetadata: () => TMetadata; }) => unknown | void} value - The action function
|
|
133
|
-
* @returns {ActionCollectionConfig<TState, TMetadata>} result - The action collection configuration
|
|
59
|
+
* contract for the storeActionsConfig configuration
|
|
134
60
|
*/
|
|
135
|
-
export interface ActionCollectionConfig<
|
|
136
|
-
[key: string]: (...parameters: any[]) => (storeTools: any) => unknown | void;
|
|
61
|
+
export interface ActionCollectionConfig<State, Metadata extends BaseMetadata> {
|
|
62
|
+
readonly [key: string]: (...parameters: any[]) => (storeTools: StoreTools<State, Metadata, Record<string, (...parameters: any[]) => unknown | void>>) => unknown | void;
|
|
137
63
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
* if you pass an storeActionsConfig configuration, the hook will return an object with the actions
|
|
141
|
-
* whatever data manipulation of the state should be executed through the custom actions with as access to the state and metadata
|
|
142
|
-
* @template {TState} TState - The state type
|
|
143
|
-
* @template {TMetadata} TMetadata - The metadata type
|
|
144
|
-
* @template {TStateMutator} TStateMutator - The storeActionsConfig type (optional) - if you pass an storeActionsConfig the hook will return an object with the actions
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
*
|
|
148
|
-
* const store = new GlobalStore(0, {
|
|
149
|
-
* increment: () => ({ setState }) => {
|
|
150
|
-
* setState((state) => state + 1);
|
|
151
|
-
* },
|
|
152
|
-
* decrement: () => ({ setState }) => {
|
|
153
|
-
* setState((state) => state - 1);
|
|
154
|
-
* },
|
|
155
|
-
* });
|
|
156
|
-
*
|
|
157
|
-
* const [state, actions] = store.getHook();
|
|
158
|
-
*
|
|
159
|
-
* actions.increment();
|
|
160
|
-
* actions.decrement();
|
|
161
|
-
*
|
|
162
|
-
* console.log(state); // 0
|
|
163
|
-
*/
|
|
164
|
-
export type ActionCollectionResult<TState, TMetadata, TStateMutator extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = TStateMutator extends ActionCollectionConfig<TState, TMetadata> ? {
|
|
165
|
-
[key in keyof TStateMutator]: (...params: Parameters<TStateMutator[key]>) => ReturnType<ReturnType<TStateMutator[key]>>;
|
|
166
|
-
} : null;
|
|
167
|
-
/**
|
|
168
|
-
* Common parameters of the store configuration callback functions
|
|
169
|
-
* @param {StateSetter<TState>} setState - add a new value to the state
|
|
170
|
-
* @param {() => TState} getState - get the current state
|
|
171
|
-
* @param {MetadataSetter<TMetadata>} setMetadata - add a new value to the metadata
|
|
172
|
-
* @param {() => TMetadata} getMetadata - get the current metadata
|
|
173
|
-
* @param {ActionCollectionResult<TState, ActionCollectionConfig<TState, TMetadata>> | null} actions - the actions object returned by the hook when you pass an storeActionsConfig configuration otherwise null
|
|
174
|
-
* @template {TState} TState - The state type
|
|
175
|
-
* @template {TMetadata} TMetadata - The metadata type
|
|
176
|
-
* @template {TStateMutator} TStateMutator - The storeActionsConfig type (optional) - if you pass an storeActionsConfig the hook will return an object with the actions
|
|
177
|
-
* @template {ActionCollectionResult<TState, TStateMutator>} TStateMutator - the result of the API (optional) - if you don't pass an API as a parameter, you can pass null
|
|
178
|
-
* */
|
|
179
|
-
export type StateConfigCallbackParam<TState = any, TMetadata = null, TStateMutator extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = {
|
|
180
|
-
actions: ActionCollectionResult<TState, TMetadata, TStateMutator>;
|
|
181
|
-
} & StoreTools<TState, TMetadata>;
|
|
182
|
-
/**
|
|
183
|
-
* Parameters of the onStateChanged callback function
|
|
184
|
-
* @template {TState} TState - The state type
|
|
185
|
-
* @template {TMetadata} TMetadata - The metadata type
|
|
186
|
-
* @template {TStateMutator} TStateMutator - The storeActionsConfig type (optional) - if you pass an storeActionsConfig the hook will return an object with the actions
|
|
187
|
-
*/
|
|
188
|
-
export type StateChangesParam<TState = any, TMetadata = null, TStateMutator extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = StateConfigCallbackParam<TState, TMetadata, TStateMutator> & StateChanges<TState> & {
|
|
189
|
-
identifier?: string;
|
|
64
|
+
export type ActionCollectionResult<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>> = {
|
|
65
|
+
[key in keyof ActionsConfig]: (...params: Parameters<ActionsConfig[key]>) => ReturnType<ReturnType<ActionsConfig[key]>>;
|
|
190
66
|
};
|
|
191
|
-
|
|
192
|
-
* Configuration of the store (optional) - if you don't need to use the store configuration you don't need to pass this parameter
|
|
193
|
-
* @param {StateConfigCallbackParam<TState, TMetadata> => void} onInit - callback function called when the store is initialized
|
|
194
|
-
* @param {StateConfigCallbackParam<TState, TMetadata> => void} onSubscribed - callback function called every time a component is subscribed to the store
|
|
195
|
-
* @param {StateChangesParam<TState, TMetadata> => boolean} computePreventStateChange - callback function called every time the state is changed and it allows you to prevent the state change
|
|
196
|
-
* @param {StateChangesParam<TState, TMetadata> => void} onStateChanged - callback function called every time the state is changed
|
|
197
|
-
* @template TState - the type of the state
|
|
198
|
-
* @template TMetadata - the type of the metadata (optional) - if you don't pass an metadata as a parameter, you can pass null
|
|
199
|
-
* @template {ActionCollectionConfig<TState,TMetadata> | null} TStateMutator - the configuration of the API (optional) - if you don't pass an API as a parameter, you can pass null
|
|
200
|
-
* */
|
|
201
|
-
export type GlobalStoreConfig<TState, TMetadata, TStateMutator extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = {
|
|
67
|
+
export type GlobalStoreConfig<State, Metadata extends BaseMetadata> = {
|
|
202
68
|
/**
|
|
203
|
-
*
|
|
69
|
+
* non reactive information that you want to store in the store
|
|
204
70
|
* */
|
|
205
|
-
metadata?:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
* @param {StateChangesParam<TState, TMetadata> => void} onStateChanged - callback function called every time the state is changed
|
|
213
|
-
* @returns {void} result - void
|
|
214
|
-
*/
|
|
215
|
-
onStateChanged?: (parameters: StateChangesParam<TState, TMetadata, TStateMutator>) => void;
|
|
216
|
-
/**
|
|
217
|
-
* @param {StateConfigCallbackParam<TState, TMetadata> => void} onSubscribed - callback function called every time a component is subscribed to the store
|
|
218
|
-
* @returns {void} result - void
|
|
219
|
-
*/
|
|
220
|
-
onSubscribed?: (parameters: StateConfigCallbackParam<TState, TMetadata, TStateMutator>) => void;
|
|
221
|
-
/**
|
|
222
|
-
* @param {StateChangesParam<TState, TMetadata> => boolean} computePreventStateChange - callback function called every time the state is about to change and it allows you to prevent the state change
|
|
223
|
-
* @returns {boolean} result - true if you want to prevent the state change, false otherwise
|
|
224
|
-
*/
|
|
225
|
-
computePreventStateChange?: (parameters: StateChangesParam<TState, TMetadata, TStateMutator>) => boolean;
|
|
226
|
-
} | null;
|
|
227
|
-
export type UseHookConfig<TState, TRoot = any> = {
|
|
71
|
+
metadata?: Metadata;
|
|
72
|
+
onInit?: (args: StoreTools<State, Metadata>) => void;
|
|
73
|
+
onStateChanged?: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
74
|
+
onSubscribed?: (args: StoreTools<State, Metadata>) => void;
|
|
75
|
+
computePreventStateChange?: (args: StoreTools<State, Metadata> & StateChanges<State>) => boolean;
|
|
76
|
+
};
|
|
77
|
+
export type UseHookConfig<State, TRoot = any> = {
|
|
228
78
|
/**
|
|
229
79
|
* The callback to execute when the state is changed to check if the same really changed
|
|
230
80
|
* If the function is not provided the derived state will perform a shallow comparison
|
|
231
81
|
*/
|
|
232
|
-
isEqual?: (current:
|
|
82
|
+
isEqual?: (current: State, next: State) => boolean;
|
|
233
83
|
isEqualRoot?: (current: TRoot, next: TRoot) => boolean;
|
|
234
84
|
dependencies?: unknown[];
|
|
235
85
|
};
|
|
236
|
-
/**
|
|
237
|
-
* Callback function to unsubscribe from the store
|
|
238
|
-
*/
|
|
239
86
|
export type UnsubscribeCallback = () => void;
|
|
240
|
-
|
|
241
|
-
* Configuration of the subscribe callbacks
|
|
242
|
-
*/
|
|
243
|
-
export type SubscribeCallbackConfig<TState> = UseHookConfig<TState> & {
|
|
87
|
+
export type SubscribeCallbackConfig<State> = UseHookConfig<State> & {
|
|
244
88
|
/**
|
|
245
89
|
* By default the callback is executed immediately after the subscription
|
|
246
90
|
*/
|
|
@@ -249,75 +93,44 @@ export type SubscribeCallbackConfig<TState> = UseHookConfig<TState> & {
|
|
|
249
93
|
/**
|
|
250
94
|
* Callback function to subscribe to the store changes
|
|
251
95
|
*/
|
|
252
|
-
export type SubscribeCallback<
|
|
96
|
+
export type SubscribeCallback<State> = (state: State) => void;
|
|
253
97
|
/**
|
|
254
98
|
* Callback function to subscribe to the store changes from a getter
|
|
255
99
|
*/
|
|
256
|
-
export type SubscriberCallback<
|
|
100
|
+
export type SubscriberCallback<State> = (subscribe: SubscribeToEmitter<State>) => void;
|
|
257
101
|
/**
|
|
258
102
|
* Callback function to get the current state of the store or to subscribe to the store changes
|
|
259
|
-
* @template
|
|
260
|
-
* @param {SubscriberCallback<
|
|
103
|
+
* @template State - the type of the state
|
|
104
|
+
* @param {SubscriberCallback<State> | null} callback - the callback function to subscribe to the store changes (optional)
|
|
261
105
|
* use the methods subscribe and subscribeSelect to subscribe to the store changes
|
|
262
106
|
* if you don't pass a callback function the hook will return the current state of the store
|
|
263
|
-
* @returns {UnsubscribeCallback |
|
|
107
|
+
* @returns {UnsubscribeCallback | State} result - the state or the unsubscribe callback if you pass a callback function
|
|
264
108
|
*/
|
|
265
|
-
export type StateGetter<
|
|
109
|
+
export type StateGetter<State> = <Subscription extends Subscribe | false = false>(
|
|
266
110
|
/**
|
|
267
|
-
* @param {SubscriberCallback<
|
|
111
|
+
* @param {SubscriberCallback<State> | null} callback - the callback function to subscribe to the store changes (optional)
|
|
268
112
|
* use the methods subscribe and subscribeSelect to subscribe to the store changes
|
|
269
113
|
*/
|
|
270
|
-
callback?: Subscription extends Subscribe ? SubscriberCallback<
|
|
271
|
-
export type
|
|
114
|
+
callback?: Subscription extends Subscribe ? SubscriberCallback<State> : null) => Subscription extends Subscribe ? UnsubscribeCallback : State;
|
|
115
|
+
export type BaseMetadata = {
|
|
116
|
+
name?: string;
|
|
117
|
+
} & Record<string, any>;
|
|
118
|
+
export type MetadataGetter<Metadata extends BaseMetadata> = () => Metadata;
|
|
272
119
|
/**
|
|
273
120
|
* Constant value type to indicate that the getter is a subscription
|
|
274
121
|
*/
|
|
275
122
|
export type Subscribe = true;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
export type createStateConfig<TState, TMetadata, TActions extends ActionCollectionConfig<TState, TMetadata> | null = null> = {
|
|
280
|
-
/**
|
|
281
|
-
* @description
|
|
282
|
-
* The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
283
|
-
*/
|
|
284
|
-
actions?: TActions;
|
|
285
|
-
} & GlobalStoreConfig<TState, TMetadata, TActions>;
|
|
286
|
-
export type CustomGlobalHookBuilderParams<TInheritMetadata = null, TCustomConfig = {}> = {
|
|
287
|
-
/**
|
|
288
|
-
* @description
|
|
289
|
-
* This function is called when the state is initialized.
|
|
290
|
-
*/
|
|
291
|
-
onInitialize: ({ setState, setMetadata, getMetadata, getState, actions, }: StateConfigCallbackParam<any, TInheritMetadata>, config: TCustomConfig) => void;
|
|
292
|
-
/**
|
|
293
|
-
* @description
|
|
294
|
-
* This function is called when the state is changed.
|
|
295
|
-
*/
|
|
296
|
-
onChange: ({ setState, setMetadata, getMetadata, getState, actions }: StateChangesParam<any, TInheritMetadata>, config: TCustomConfig) => void;
|
|
123
|
+
export type CustomGlobalHookBuilderParams<TInheritMetadata extends BaseMetadata, TCustomConfig> = {
|
|
124
|
+
onInitialize: (args: StoreTools<any, TInheritMetadata>, config: TCustomConfig) => void;
|
|
125
|
+
onChange: (args: StoreTools<any, TInheritMetadata> & StateChanges<any>, config: TCustomConfig) => void;
|
|
297
126
|
};
|
|
298
|
-
|
|
299
|
-
* @description
|
|
300
|
-
* Configuration of the custom global hook
|
|
301
|
-
*/
|
|
302
|
-
export type CustomGlobalHookParams<TCustomConfig, TState, TMetadata, TActions extends ActionCollectionConfig<TState, TMetadata> | null> = {
|
|
303
|
-
/**
|
|
304
|
-
* @description
|
|
305
|
-
* Type of the configuration object that the custom hook will require or accept
|
|
306
|
-
*/
|
|
307
|
-
config?: TCustomConfig;
|
|
308
|
-
/**
|
|
309
|
-
* @description
|
|
310
|
-
* The type of the actionsConfig object (optional) (default: null) if a configuration is passed, the hook will return an object with the actions then all the store manipulation will be done through the actions
|
|
311
|
-
*/
|
|
312
|
-
actions?: TActions;
|
|
313
|
-
} & GlobalStoreConfig<TState, TMetadata, TActions>;
|
|
314
|
-
export type SelectorCallback<TState, TDerivate> = (state: TState) => TDerivate;
|
|
127
|
+
export type SelectorCallback<State, TDerivate> = (state: State) => TDerivate;
|
|
315
128
|
/**
|
|
316
129
|
* @description
|
|
317
130
|
* Function to subscribe to the store changes
|
|
318
131
|
* @returns {UnsubscribeCallback} result - Function to unsubscribe from the store
|
|
319
132
|
*/
|
|
320
|
-
export type SubscribeToEmitter<
|
|
133
|
+
export type SubscribeToEmitter<State> = <TParam1 extends SubscribeCallback<State> | SelectorCallback<State, unknown>, TResult = ReturnType<TParam1>, TConfig = TResult extends void | null | undefined | never ? SubscribeCallbackConfig<State> : SubscribeCallbackConfig<TResult>, TParam2 extends SubscribeCallbackConfig<State> | SubscribeCallback<TResult> = TResult extends void | null | undefined | never ? TConfig : SubscribeCallback<TResult>, TParam3 = TResult extends void | null | undefined | never ? never : TConfig>(
|
|
321
134
|
/**
|
|
322
135
|
* @description
|
|
323
136
|
* The callback function to subscribe to the store changes or a selector function to derive the state
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ActionCollectionConfig, GlobalStoreConfig, StoreTools, BaseMetadata, StateChanges } from './GlobalStore.types';
|
|
2
2
|
import { GlobalStore } from './GlobalStore';
|
|
3
3
|
/**
|
|
4
4
|
* @description
|
|
@@ -6,10 +6,10 @@ import { GlobalStore } from './GlobalStore';
|
|
|
6
6
|
* by implementing the abstract methods onInitialize and onChange.
|
|
7
7
|
* You can use this class to create a store with async storage.
|
|
8
8
|
*/
|
|
9
|
-
export declare abstract class GlobalStoreAbstract<
|
|
10
|
-
constructor(state:
|
|
11
|
-
protected onInit: (
|
|
12
|
-
protected onStateChanged: (
|
|
13
|
-
protected abstract onInitialize: (
|
|
14
|
-
protected abstract onChange: (
|
|
9
|
+
export declare abstract class GlobalStoreAbstract<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {} = null> extends GlobalStore<State, Metadata, ActionsConfig> {
|
|
10
|
+
constructor(state: State, config: GlobalStoreConfig<State, Metadata>, actionsConfig: ActionsConfig);
|
|
11
|
+
protected onInit: (args: StoreTools<State, Metadata>) => void;
|
|
12
|
+
protected onStateChanged: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
13
|
+
protected abstract onInitialize: (args: StoreTools<State, Metadata>) => void;
|
|
14
|
+
protected abstract onChange: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
15
15
|
}
|
package/package.json
CHANGED