react-hooks-global-states 11.0.0-beta.4 → 12.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GlobalStore.d.ts +17 -17
- package/GlobalStore.js +1 -125
- package/GlobalStoreAbstract.d.ts +6 -6
- package/GlobalStoreAbstract.js +1 -41
- package/bundle.js +1 -56
- package/createContext.d.ts +285 -44
- package/createContext.js +1 -70
- package/createGlobalState.d.ts +24 -7
- package/createGlobalState.js +1 -47
- package/index.d.ts +2 -2
- package/isRecord.js +1 -44
- package/package.json +1 -1
- package/shallowCompare.js +1 -53
- package/throwWrongKeyOnActionCollectionConfig.js +1 -16
- package/types.d.ts +204 -27
- package/types.js +1 -4
- package/uniqueId.js +1 -16
- package/webpack.config.js +2 -5
package/GlobalStore.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ActionCollectionConfig, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, StateHook, BaseMetadata, StateChanges, StoreTools, ObservableFragment,
|
|
1
|
+
import type { ActionCollectionConfig, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, StateHook, BaseMetadata, StateChanges, StoreTools, ObservableFragment, UnsubscribeCallback, AnyFunction, ReadonlyHook, ReadonlyStateApi } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* The GlobalStore class is the main class of the library and it is used to create a GlobalStore instances
|
|
4
4
|
* */
|
|
5
|
-
export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig
|
|
5
|
+
export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> {
|
|
6
6
|
protected _name: string;
|
|
7
7
|
actionsConfig: ActionsConfig | null;
|
|
8
|
-
callbacks: GlobalStoreCallbacks<State, Metadata> | null;
|
|
8
|
+
callbacks: GlobalStoreCallbacks<State, PublicStateMutator, Metadata> | null;
|
|
9
9
|
metadata: Metadata;
|
|
10
10
|
/**
|
|
11
11
|
* @description If the actionsConfig is defined, this will be a map of actions that can be used to modify or interact with the state
|
|
@@ -14,7 +14,7 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
|
|
|
14
14
|
/**
|
|
15
15
|
* @description The main hook that will be used to interact with the global state
|
|
16
16
|
*/
|
|
17
|
-
use: StateHook<State,
|
|
17
|
+
use: StateHook<State, PublicStateMutator, Metadata>;
|
|
18
18
|
/**
|
|
19
19
|
* @description
|
|
20
20
|
* Access to the store api that will be passed to the actions and callbacks
|
|
@@ -25,14 +25,14 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
|
|
|
25
25
|
constructor(state: State);
|
|
26
26
|
constructor(state: State, args: {
|
|
27
27
|
metadata?: Metadata;
|
|
28
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
28
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
29
29
|
actions?: ActionsConfig;
|
|
30
30
|
name?: string;
|
|
31
31
|
});
|
|
32
|
-
protected onInit?: (args: StoreTools<State, Metadata>) => void;
|
|
33
|
-
protected onStateChanged?: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
34
|
-
protected onSubscribed?: (args: StoreTools<State, Metadata>, subscription: SubscriberParameters) => void;
|
|
35
|
-
protected computePreventStateChange?: (parameters: StoreTools<State, Metadata> & StateChanges<State>) => boolean;
|
|
32
|
+
protected onInit?: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
33
|
+
protected onStateChanged?: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
34
|
+
protected onSubscribed?: (args: StoreTools<State, PublicStateMutator, Metadata>, subscription: SubscriberParameters) => void;
|
|
35
|
+
protected computePreventStateChange?: (parameters: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => boolean;
|
|
36
36
|
/**
|
|
37
37
|
* @description
|
|
38
38
|
* Initializes the global store, setting up the main hook and actions map if applicable,
|
|
@@ -80,7 +80,7 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
|
|
|
80
80
|
* get the parameters object to pass to the callback functions:
|
|
81
81
|
* onInit, onStateChanged, onSubscribed, computePreventStateChange
|
|
82
82
|
* */
|
|
83
|
-
getConfigCallbackParam: () => StoreTools<State, Metadata>;
|
|
83
|
+
getConfigCallbackParam: () => StoreTools<State, PublicStateMutator, Metadata>;
|
|
84
84
|
protected subscribeCallback: (subscription: SubscriberParameters) => () => void;
|
|
85
85
|
protected partialUpdateSubscription: (subscription: SubscriberParameters, values: Partial<SubscriberParameters>) => void;
|
|
86
86
|
protected executeOnSubscribed: (subscription: SubscriberParameters) => void;
|
|
@@ -88,7 +88,7 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
|
|
|
88
88
|
* Returns a custom hook that allows to handle a global state
|
|
89
89
|
* @returns {[State, StateMutator, Metadata]} - The state, the state setter or the actions map, the metadata
|
|
90
90
|
* */
|
|
91
|
-
getMainHook: () => StateHook<State,
|
|
91
|
+
getMainHook: () => StateHook<State, PublicStateMutator, Metadata>;
|
|
92
92
|
protected computeSelectedState: ({ subscription, currentDependencies, }: {
|
|
93
93
|
subscription: SubscriberParameters;
|
|
94
94
|
currentDependencies: unknown[] | undefined;
|
|
@@ -119,20 +119,20 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsCo
|
|
|
119
119
|
protected removeSubscriptions: () => void;
|
|
120
120
|
dispose: () => void;
|
|
121
121
|
}
|
|
122
|
-
declare function createObservable<RootState, PublicStateMutator, Metadata, Selected
|
|
122
|
+
export declare function createObservable<RootState, PublicStateMutator, Metadata extends BaseMetadata, Selected>(this: Pick<ReadonlyStateApi<RootState, PublicStateMutator, Metadata>, 'getState' | 'subscribe'>, selector: (state: RootState) => Selected, options?: {
|
|
123
123
|
isEqual?: (current: Selected, next: Selected) => boolean;
|
|
124
|
-
isEqualRoot?: (current:
|
|
124
|
+
isEqualRoot?: (current: RootState, next: RootState) => boolean;
|
|
125
125
|
name?: string;
|
|
126
|
-
}): ObservableFragment<Selected,
|
|
126
|
+
}): ObservableFragment<Selected, PublicStateMutator, Metadata>;
|
|
127
127
|
/**
|
|
128
128
|
* @description
|
|
129
129
|
* Creates a derived hook bound to a selected fragment of the root state.
|
|
130
130
|
* The derived hook re-renders only when the selected value changes and
|
|
131
131
|
* exposes the same API as the parent state hook.
|
|
132
132
|
*/
|
|
133
|
-
declare function createSelectorHook<RootState, PublicStateMutator, Metadata, Selected
|
|
133
|
+
export declare function createSelectorHook<RootState, PublicStateMutator, Metadata extends BaseMetadata, Selected>(this: Pick<ReadonlyStateApi<RootState, PublicStateMutator, Metadata>, 'getState' | 'subscribe'>, selector: (state: RootState) => Selected, options?: {
|
|
134
134
|
isEqual?: (current: Selected, next: Selected) => boolean;
|
|
135
|
-
isEqualRoot?: (current:
|
|
135
|
+
isEqualRoot?: (current: RootState, next: RootState) => boolean;
|
|
136
136
|
name?: string;
|
|
137
|
-
}):
|
|
137
|
+
}): ReadonlyHook<Selected, PublicStateMutator, Metadata>;
|
|
138
138
|
export default GlobalStore;
|
package/GlobalStore.js
CHANGED
|
@@ -1,125 +1 @@
|
|
|
1
|
-
var t,e;t=this,e=(t,e,r,n,i,o,a)=>/******/(()=>{
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var s={
|
|
4
|
-
/***/78:
|
|
5
|
-
/***/e=>{e.exports=t;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/155:
|
|
8
|
-
/***/t=>{t.exports=e;
|
|
9
|
-
/***/},
|
|
10
|
-
/***/361:
|
|
11
|
-
/***/t=>{t.exports=r;
|
|
12
|
-
/***/},
|
|
13
|
-
/***/487:
|
|
14
|
-
/***/t=>{t.exports=n;
|
|
15
|
-
/***/},
|
|
16
|
-
/***/506:
|
|
17
|
-
/***/t=>{t.exports=i;
|
|
18
|
-
/***/},
|
|
19
|
-
/***/673:
|
|
20
|
-
/***/t=>{t.exports=o;
|
|
21
|
-
/***/},
|
|
22
|
-
/***/773:
|
|
23
|
-
/***/t=>{t.exports=a;
|
|
24
|
-
/***/},
|
|
25
|
-
/***/811:
|
|
26
|
-
/***/(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=globalThis;r.isDevToolsPresent=Boolean(r.REACT_GLOBAL_STATE_HOOK_DEBUG),e.default=r}
|
|
27
|
-
/***/
|
|
28
|
-
/******/},u={};
|
|
29
|
-
/************************************************************************/
|
|
30
|
-
/******/
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/
|
|
34
|
-
/******/function c(t){
|
|
35
|
-
/******/
|
|
36
|
-
/******/var e=u[t];
|
|
37
|
-
/******/if(void 0!==e)
|
|
38
|
-
/******/return e.exports;
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/var r=u[t]={
|
|
42
|
-
/******/
|
|
43
|
-
/******/
|
|
44
|
-
/******/exports:{}
|
|
45
|
-
/******/};
|
|
46
|
-
/******/
|
|
47
|
-
/******/
|
|
48
|
-
/******/
|
|
49
|
-
/******/
|
|
50
|
-
/******/
|
|
51
|
-
/******/return s[t](r,r.exports,c),r.exports;
|
|
52
|
-
/******/}
|
|
53
|
-
/******/
|
|
54
|
-
/************************************************************************/var l={};
|
|
55
|
-
/******/return(()=>{var t=l;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(){i=function(){return r};var t,r={},n=Object.prototype,o=n.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),s=new A(n||[]);return a(o,"_invoke",{value:M(t,r,s)}),o}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var b="suspendedStart",v="suspendedYield",p="executing",g="completed",y={};function m(){}function S(){}function w(){}var j={};f(j,u,(function(){return this}));var O=Object.getPrototypeOf,k=O&&O(O(P([])));k&&k!==n&&o.call(k,u)&&(j=k);var x=w.prototype=m.prototype=Object.create(j);function C(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,r){function n(i,a,s,u){var c=d(t[i],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&o.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):r.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var i;a(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,i){n(t,e,r,i)}))}return i=i?i.then(o,o):o()}})}function M(e,r,n){var i=b;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===g){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=L(s,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===b)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var c=d(e,r,n);if("normal"===c.type){if(i=n.done?g:v,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=g,n.method="throw",n.arg=c.arg)}}}function L(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,L(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var o=d(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function P(r){if(r||""===r){var n=r[u];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,a=function e(){for(;++i<r.length;)if(o.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,a(x,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:S,configurable:!0}),S.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(x),t},r.awrap=function(t){return{__await:t}},C(E.prototype),f(E.prototype,c,(function(){return this})),r.AsyncIterator=E,r.async=function(t,e,n,i,o){void 0===o&&(o=Promise);var a=new E(h(t,e,n,i),o);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(x),f(x,l,"Generator"),f(x,u,(function(){return this})),f(x,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=P,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(q),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),c=o.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;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,y):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),y},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),q(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;q(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function o(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var a,s=c(155),u=c(506),f=c(773),h=c(487),d=c(673),b=c(361),v=c(78),p=(a=c(811))&&a.__esModule?a:{default:a},g=function(){return t=function t(e){var n,a,c=this,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.actionsConfig=null,this.callbacks=null,
|
|
56
|
-
/**
|
|
57
|
-
* @description If the actionsConfig is defined, this will be a map of actions that can be used to modify or interact with the state
|
|
58
|
-
* */
|
|
59
|
-
this.actions=null,this.subscribers=new Set,
|
|
60
|
-
/**
|
|
61
|
-
* @description
|
|
62
|
-
* Initializes the global store, setting up the main hook and actions map if applicable,
|
|
63
|
-
*/
|
|
64
|
-
this.initialize=function(){return t=c,e=void 0,r=i().mark((function t(){var e,r,n,o,a;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),this.use=this.getMainHook(),this.configurationCallbackParam=this.getConfigCallbackParam(),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},a=o.onInit,n||a){t.next=8;break}return t.abrupt("return");case 8:null==n||n(this.configurationCallbackParam),(0,f.isNil)(a)||null==a||a(this.configurationCallbackParam);case 10:case"end":return t.stop()}}),t,this)})),new(e||(e=Promise))((function(n,i){function o(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?n(t.value):(r=t.value,r instanceof e?r:new e((function(t){t(r)}))).then(o,a)}s((r=r.apply(t,[])).next())}));var t,e,r},
|
|
65
|
-
/**
|
|
66
|
-
* set the state for a single subscriber
|
|
67
|
-
* validate if the state should be updated by comparing the previous state and the new state
|
|
68
|
-
*/
|
|
69
|
-
this.executeSetStateForSubscriber=function(t,e){var r,n,i,o=t.selector,a=t.callback,s=t.currentState,u=t.getConfig,l=null!==(r=null==u?void 0:u())&&void 0!==r?r:{};if(!e.forceUpdate&&(null!==(n=null==l?void 0:l.isEqualRoot)&&void 0!==n?n:function(t,e){return t===e})(e.currentState,e.newState))return{didUpdate:!1};var f=o?o(e.newState):e.newState;return!e.forceUpdate&&(null!==(i=null==l?void 0:l.isEqual)&&void 0!==i?i:function(t,e){return t===e})(s,f)?{didUpdate:!1}:(c.partialUpdateSubscription(t,{currentState:f}),a({state:f},{identifier:e.identifier}),{didUpdate:!0})},
|
|
70
|
-
/**
|
|
71
|
-
* set the state and update all the subscribers
|
|
72
|
-
* @param {State} newState - The new state to set
|
|
73
|
-
* @param {object} options - The options for setting the state
|
|
74
|
-
* @param {boolean} [options.forceUpdate] - Whether to force the update even if the state is the same
|
|
75
|
-
* @param {string} [options.identifier] - An optional identifier for the state change
|
|
76
|
-
* */
|
|
77
|
-
this.setSubscribersState=function(t,e){var n=e.forceUpdate,i=e.identifier,o=c.state;if(n||o!==t){c.state=t;var a,s={forceUpdate:n,newState:t,currentState:o,identifier:i},u=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=r(t))){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw o}}}}(c.subscribers.values());try{for(u.s();!(a=u.n()).done;){var l=a.value;c.executeSetStateForSubscriber(l,s)}}catch(t){u.e(t)}finally{u.f()}}},
|
|
78
|
-
/**
|
|
79
|
-
* Set the value of the metadata property, this is no reactive and will not trigger a re-render
|
|
80
|
-
* @param {MetadataSetter<Metadata>} setter - The setter function or the value to set
|
|
81
|
-
* */
|
|
82
|
-
this.setMetadata=function(t){var e=(0,u.isFunction)(t)?t(c.metadata):t;c.metadata=e},
|
|
83
|
-
/**
|
|
84
|
-
* Returns the metadata [non-reactive additional information associated with the global state]
|
|
85
|
-
*/
|
|
86
|
-
this.getMetadata=function(){return c.metadata},
|
|
87
|
-
/**
|
|
88
|
-
* Get the current value of the state
|
|
89
|
-
*/
|
|
90
|
-
this.getState=function(){return c.state},
|
|
91
|
-
/**
|
|
92
|
-
* get the parameters object to pass to the callback functions:
|
|
93
|
-
* onInit, onStateChanged, onSubscribed, computePreventStateChange
|
|
94
|
-
* */
|
|
95
|
-
this.getConfigCallbackParam=function(){var t=c.setMetadata,e=c.getMetadata,r=c.getState,n=c.subscribe,i=c.actions;return{setMetadata:t,getMetadata:e,getState:r,subscribe:n,setState:c.setState,actions:i}},this.subscribeCallback=function(t){return c.executeOnSubscribed(t),c.subscribers.add(t),function(){c.subscribers.delete(t)}},this.partialUpdateSubscription=function(t,e){(0,h.isRecord)(t)&&Object.assign(t,e)},this.executeOnSubscribed=function(t){var e,r=c.onSubscribed,n=null===(e=c.callbacks)||void 0===e?void 0:e.onSubscribed;(r||n)&&(null==r||r(c.configurationCallbackParam,t),null==n||n(c.configurationCallbackParam,t))},
|
|
96
|
-
/**
|
|
97
|
-
* Returns a custom hook that allows to handle a global state
|
|
98
|
-
* @returns {[State, StateMutator, Metadata]} - The state, the state setter or the actions map, the metadata
|
|
99
|
-
* */
|
|
100
|
-
this.getMainHook=function(){var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=(0,d.isArray)(e)?{dependencies:e}:null!=e?e:{},n=(0,s.useRef)({selector:t,config:r}),i=n.current.config.dependencies;n.current.selector=t,n.current.config=r;var o=(0,s.useMemo)((function(){var t=function(t){var e=n.current.selector;return(0,u.isFunction)(e)?e(t):t},e={currentState:t(c.state),selector:t,getConfig:function(){return n.current.config},callback:function(){throw new Error("Callback not set")}},r=function(){return e.currentState};return{subscribe:function(t){return e.callback=t,c.subscribeCallback(e)},getSnapshot:r,getServerSnapshot:r,subscription:e}}),[]),a=o.subscribe,l=o.getSnapshot,f=o.getServerSnapshot,h=o.subscription;return(0,s.useSyncExternalStore)(a,l,f),[c.computeSelectedState({subscription:h,currentDependencies:i}),c.getStateOrchestrator(),c.metadata]},e={setMetadata:c.setMetadata,getMetadata:c.getMetadata,actions:c.actions,setState:c.actions?null:c.setState.bind(c),getState:c.getState.bind(c),subscribe:c.subscribe.bind(c),dispose:c.dispose.bind(c),createSelectorHook:c.createSelectorHook.bind(c),createObservable:c.createObservable.bind(c)};return Object.assign(t,e),t},this.computeSelectedState=function(t){var e,r=t.subscription,n=t.currentDependencies;if(!r.selector)return r.currentState;var i=(null!==(e=r.getConfig())&&void 0!==e?e:{}).dependencies;return n===i||(null==n?void 0:n.length)===(null==i?void 0:i.length)&&(0,d.shallowCompare)(n,i)||c.partialUpdateSubscription(r,{currentState:r.selector(c.state)}),r.currentState},this.createSelectorHook=m,this.createObservable=y,
|
|
101
|
-
/**
|
|
102
|
-
* Returns the state setter or the actions map
|
|
103
|
-
* @returns {StateMutator} - The state setter or the actions map
|
|
104
|
-
* */
|
|
105
|
-
this.getStateOrchestrator=function(){return c.actions?c.actions:c.setState},
|
|
106
|
-
/**
|
|
107
|
-
* This is the only setState function that should be exposed outside the class
|
|
108
|
-
* This is responsible for defining whenever or not the state change should be allowed or prevented
|
|
109
|
-
* the function also execute the functions:
|
|
110
|
-
* - onStateChanged (if defined) - this function is executed after the state change
|
|
111
|
-
* - 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
|
|
112
|
-
*/
|
|
113
|
-
this.setState=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.forceUpdate,o=n.identifier,a=c.state,s=(0,u.isFunction)(t)?t(a):t;if(i||c.state!==s){var l=c.setMetadata,f=c.getMetadata,h=c.getState,d=c.actions,b={setMetadata:l,getMetadata:f,setState:c.setSubscribersState,getState:h,actions:d,previousState:a,state:s,identifier:o},v=c.computePreventStateChange,p=null===(e=c.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||p)&&((null==v?void 0:v(b))||(null==p?void 0:p(b))))return;c.setSubscribersState(s,{forceUpdate:i,identifier:o});var g=c.onStateChanged,y=null===(r=c.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(b),null==y||y(b))}},
|
|
114
|
-
/**
|
|
115
|
-
* This creates a map of actions that can be used to modify or interact with the state
|
|
116
|
-
* @returns {ActionCollectionResult<State, Metadata, StateMutator>} - The actions map result of the configuration object passed to the constructor
|
|
117
|
-
* */
|
|
118
|
-
this.getStoreActionsMap=function(){if(!(0,h.isRecord)(c.actionsConfig))return null;var t=c.actionsConfig,e=c.setMetadata,r=c.setState,n=c.getState,i=c.getMetadata,a=Object.keys(t).reduce((function(s,u){var c,l,f;return Object.assign(s,(c={},f=function(){for(var o=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=o.apply(a,c);return"function"!=typeof f&&(0,b.throwWrongKeyOnActionCollectionConfig)(u),f.call(a,{setState:r,getState:n,setMetadata:e,getMetadata:i,actions:a})},(l=o(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),s}),{});return a},this.removeSubscriptions=function(){c.subscribers.clear()},this.dispose=function(){c.removeSubscriptions(),c._name="",c.actionsConfig=null,c.callbacks=null,c.metadata={},c.actions=null,c.state=Object.create(null)};var g=l.metadata,S=l.callbacks,w=l.actions,j=l.name;if(this.state=e,this._name=null!=j?j:(0,v.uniqueId)("gs:"),this.metadata=null!=g?g:{},this.callbacks=null!=S?S:null,this.actionsConfig=null!=w?w:null,p.default.isDevToolsPresent){var O=null!==(n=(new Error).stack)&&void 0!==n?n:"";null===(a=p.default.REACT_GLOBAL_STATE_HOOK_DEBUG)||void 0===a||a.call(p.default,this,l,O)}this.constructor!==t||this.initialize()},e=[{key:"subscribe",value:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var i,o=r[0],a=r[1],s=r[2],c=(0,u.isFunction)(a),l=c?o:void 0,f=c?a:o,h=null!==(i=c?s:a)&&void 0!==i?i:void 0,d=l?l(this.state):this.state;(null==h?void 0:h.skipFirst)||f(d);var b={selector:l,getConfig:function(){return h},currentState:d,callback:function(t){var e=t.state;return f(e)}};return this.subscribeCallback(b),function(){t.subscribers.delete(b)}}}],e&&function(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,o(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function y(t,e){var r=null==e?void 0:e.name,n=null==e?void 0:e.isEqualRoot,i=null==e?void 0:e.isEqual,o=this.getState(),a=(null!=t?t:function(t){return t})(o),s=new g(a,{name:null!=r?r:(0,v.uniqueId)("sh:")}),u=this.subscribe((function(e){if(!(null!=n?n:Object.is)(o,e)){o=e;var r=t(e);(null!=i?i:Object.is)(a,r)||(a=r,s.setState(r))}}),{skipFirst:!0}),c=this.actions?null:this.setState,l=s.subscribe.bind(s),f={setMetadata:this.setMetadata,getMetadata:this.getMetadata,actions:this.actions,setState:c,getState:s.getState.bind(s),subscribe:s.subscribe.bind(s),createSelectorHook:m.bind(l),createObservable:y.bind(l),dispose:function(){u(),s.dispose()}};return Object.assign(l,f),l}
|
|
119
|
-
/**
|
|
120
|
-
* @description
|
|
121
|
-
* Creates a derived hook bound to a selected fragment of the root state.
|
|
122
|
-
* The derived hook re-renders only when the selected value changes and
|
|
123
|
-
* exposes the same API as the parent state hook.
|
|
124
|
-
*/function m(t,e){var n,i=this,o=null==e?void 0:e.name,a=null==e?void 0:e.isEqualRoot,s=null==e?void 0:e.isEqual,u=this.getState(),c=(null!=t?t:function(t){return t})(u),l=new g(c,{name:null!=o?o:(0,v.uniqueId)("sh:")}),f=this.subscribe((function(e){if(!(null!=a?a:Object.is)(u,e)){u=e;var r=t(e);(null!=s?s:Object.is)(c,r)||(c=r,l.setState(r))}}),{skipFirst:!0}),h=null!==(n=this.actions)&&void 0!==n?n:this.setState,d=this.actions?null:this.setState,b=function(){return[(t=l.use.apply(l,arguments),function(t){if(Array.isArray(t))return t}(t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,i,o,a=[],s=!0,u=!1;try{for(i=(e=e.call(t)).next;!(s=(r=i.call(e)).done)&&(a.push(r.value),1!==a.length);s=!0);}catch(t){u=!0,n=t}finally{try{if(!s&&null!=e.return&&(o=e.return(),Object(o)!==o))return}finally{if(u)throw n}}return a}}(t)||r(t,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],h,i.getMetadata()];var t},p={setMetadata:this.setMetadata,getMetadata:this.getMetadata,actions:this.actions,setState:d,getState:function(){return l.getState()},subscribe:l.subscribe.bind(l),createSelectorHook:m.bind(b),createObservable:y.bind(b),dispose:function(){f(),l.dispose()}};return Object.assign(b,p),b}t.GlobalStore=g,t.default=g})(),l;
|
|
125
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./uniqueId.js"),require("react"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("json-storage-formatter/isFunction"),require("./shallowCompare.js"),require("json-storage-formatter/isNil")):"function"==typeof define&&define.amd?define(["./uniqueId.js","react","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","json-storage-formatter/isFunction","./shallowCompare.js","json-storage-formatter/isNil"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./uniqueId.js"),require("react"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("json-storage-formatter/isFunction"),require("./shallowCompare.js"),require("json-storage-formatter/isNil")):t["react-hooks-global-states"]=e(t["./uniqueId.js"],t.react,t["./throwWrongKeyOnActionCollectionConfig.js"],t["./isRecord.js"],t["json-storage-formatter/isFunction"],t["./shallowCompare.js"],t["json-storage-formatter/isNil"]);
|
|
1
|
+
var t,e;t=this,e=(t,e,r,n,o,i,a)=>(()=>{"use strict";var u={78:e=>{e.exports=t},155:t=>{t.exports=e},361:t=>{t.exports=r},487:t=>{t.exports=n},506:t=>{t.exports=o},673:t=>{t.exports=i},773:t=>{t.exports=a},811:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=globalThis;r.isDevToolsPresent=Boolean(r.REACT_GLOBAL_STATE_HOOK_DEBUG),e.default=r}},s={};function c(t){var e=s[t];if(void 0!==e)return e.exports;var r=s[t]={exports:{}};return u[t](r,r.exports,c),r.exports}var l={};return(()=>{var t=l;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(t,e){if(t){if("string"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function o(){o=function(){return r};var t,r={},n=Object.prototype,i=n.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},s=u.iterator||"@@iterator",c=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),u=new A(n||[]);return a(i,"_invoke",{value:L(t,r,u)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var b="suspendedStart",v="suspendedYield",p="executing",g="completed",y={};function m(){}function S(){}function w(){}var j={};f(j,s,(function(){return this}));var O=Object.getPrototypeOf,k=O&&O(O(P([])));k&&k!==n&&i.call(k,s)&&(j=k);var x=w.prototype=m.prototype=Object.create(j);function C(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,r){function n(o,a,u,s){var c=d(t[o],t,a);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==e(f)&&i.call(f,"__await")?r.resolve(f.__await).then((function(t){n("next",t,u,s)}),(function(t){n("throw",t,u,s)})):r.resolve(f).then((function(t){l.value=t,u(l)}),(function(t){return n("throw",t,u,s)}))}s(c.arg)}var o;a(this,"_invoke",{value:function(t,e){function i(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(i,i):i()}})}function L(e,r,n){var o=b;return function(i,a){if(o===p)throw Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var s=_(u,n);if(s){if(s===y)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===b)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=p;var c=d(e,r,n);if("normal"===c.type){if(o=n.done?g:v,c.arg===y)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(o=g,n.method="throw",n.arg=c.arg)}}}function _(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,_(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var i=d(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,y;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function q(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(q,this),this.reset(!0)}function P(r){if(r||""===r){var n=r[s];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,a=function e(){for(;++o<r.length;)if(i.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return a.next=a}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,a(x,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:S,configurable:!0}),S.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===S||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(x),t},r.awrap=function(t){return{__await:t}},C(E.prototype),f(E.prototype,c,(function(){return this})),r.AsyncIterator=E,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new E(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(x),f(x,l,"Generator"),f(x,s,(function(){return this})),f(x,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=P,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(M),!e)for(var r in this)"t"===r.charAt(0)&&i.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return u.type="throw",u.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,y):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),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;M(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function i(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0,t.createObservable=y,t.createSelectorHook=m;var a,u=c(155),s=c(506),f=c(773),h=c(487),d=c(673),b=c(361),v=c(78),p=(a=c(811))&&a.__esModule?a:{default:a},g=function(){return t=function t(e){var n,a,c=this,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Set,this.initialize=function(){return t=c,e=void 0,r=o().mark((function t(){var e,r,n,i,a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Object.keys(null!==(e=this.actionsConfig)&&void 0!==e?e:{}).length>0&&(this.actions=this.getStoreActionsMap()),this.use=this.getMainHook(),this.configurationCallbackParam=this.getConfigCallbackParam(),n=this.onInit,i=null!==(r=this.callbacks)&&void 0!==r?r:{},a=i.onInit,n||a){t.next=8;break}return t.abrupt("return");case 8:null==n||n(this.configurationCallbackParam),(0,f.isNil)(a)||null==a||a(this.configurationCallbackParam);case 10:case"end":return t.stop()}}),t,this)})),new(e||(e=Promise))((function(n,o){function i(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var r;t.done?n(t.value):(r=t.value,r instanceof e?r:new e((function(t){t(r)}))).then(i,a)}u((r=r.apply(t,[])).next())}));var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r,n,o,i=t.selector,a=t.callback,u=t.currentState,s=t.getConfig,l=null!==(r=null==s?void 0:s())&&void 0!==r?r:{};if(!e.forceUpdate&&(null!==(n=null==l?void 0:l.isEqualRoot)&&void 0!==n?n:function(t,e){return t===e})(e.currentState,e.newState))return{didUpdate:!1};var f=i?i(e.newState):e.newState;return!e.forceUpdate&&(null!==(o=null==l?void 0:l.isEqual)&&void 0!==o?o:function(t,e){return t===e})(u,f)?{didUpdate:!1}:(c.partialUpdateSubscription(t,{currentState:f}),a({state:f},{identifier:e.identifier}),{didUpdate:!0})},this.setSubscribersState=function(t,e){var n=e.forceUpdate,o=e.identifier,i=c.state;if(n||i!==t){c.state=t;var a,u={forceUpdate:n,newState:t,currentState:i,identifier:o},s=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=r(t))){e&&(t=e);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(u)throw i}}}}(c.subscribers.values());try{for(s.s();!(a=s.n()).done;){var l=a.value;c.executeSetStateForSubscriber(l,u)}}catch(t){s.e(t)}finally{s.f()}}},this.setMetadata=function(t){var e=(0,s.isFunction)(t)?t(c.metadata):t;c.metadata=e},this.getMetadata=function(){return c.metadata},this.getState=function(){return c.state},this.getConfigCallbackParam=function(){var t=c.setMetadata,e=c.getMetadata,r=c.getState,n=c.subscribe,o=c.actions;return{setMetadata:t,getMetadata:e,getState:r,subscribe:n,setState:c.setState,actions:o}},this.subscribeCallback=function(t){return c.executeOnSubscribed(t),c.subscribers.add(t),function(){c.subscribers.delete(t)}},this.partialUpdateSubscription=function(t,e){(0,h.isRecord)(t)&&Object.assign(t,e)},this.executeOnSubscribed=function(t){var e,r=c.onSubscribed,n=null===(e=c.callbacks)||void 0===e?void 0:e.onSubscribed;(r||n)&&(null==r||r(c.configurationCallbackParam,t),null==n||n(c.configurationCallbackParam,t))},this.getMainHook=function(){var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=(0,d.isArray)(e)?{dependencies:e}:null!=e?e:{},n=(0,u.useRef)({selector:t,config:r}),o=n.current.config.dependencies;n.current.selector=t,n.current.config=r;var i=(0,u.useMemo)((function(){var t=function(t){var e=n.current.selector;return(0,s.isFunction)(e)?e(t):t},e={currentState:t(c.state),selector:t,getConfig:function(){return n.current.config},callback:function(){throw new Error("Callback not set")}},r=function(){return e.currentState};return{subscribe:function(t){return e.callback=t,c.subscribeCallback(e)},getSnapshot:r,getServerSnapshot:r,subscription:e}}),[]),a=i.subscribe,l=i.getSnapshot,f=i.getServerSnapshot,h=i.subscription;return(0,u.useSyncExternalStore)(a,l,f),[c.computeSelectedState({subscription:h,currentDependencies:o}),c.getStateOrchestrator(),c.metadata]},e=c.setMetadata,r=c.getMetadata,n=c.actions,o=c.actions?null:c.setState.bind(c),i=c,a={actions:n,createObservable:c.createObservable.bind(i),createSelectorHook:c.createSelectorHook.bind(i),dispose:c.dispose.bind(c),getMetadata:r,getState:c.getState.bind(c),setMetadata:e,setState:o,subscribe:c.subscribe.bind(c),use:t,select:function(){return t.apply(void 0,arguments)[0]}};return Object.assign(t,a),t},this.computeSelectedState=function(t){var e,r=t.subscription,n=t.currentDependencies;if(!r.selector)return r.currentState;var o=(null!==(e=r.getConfig())&&void 0!==e?e:{}).dependencies;return n===o||(null==n?void 0:n.length)===(null==o?void 0:o.length)&&(0,d.shallowCompare)(n,o)||c.partialUpdateSubscription(r,{currentState:r.selector(c.state)}),r.currentState},this.createSelectorHook=m,this.createObservable=y,this.getStateOrchestrator=function(){return c.actions?c.actions:c.setState},this.setState=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,a=c.state,u=(0,s.isFunction)(t)?t(a):t;if(o||c.state!==u){var l=c.setMetadata,f=c.getMetadata,h=c.getState,d=c.actions,b={setMetadata:l,getMetadata:f,setState:c.setSubscribersState,getState:h,actions:d,previousState:a,state:u,identifier:i},v=c.computePreventStateChange,p=null===(e=c.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||p)&&((null==v?void 0:v(b))||(null==p?void 0:p(b))))return;c.setSubscribersState(u,{forceUpdate:o,identifier:i});var g=c.onStateChanged,y=null===(r=c.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(b),null==y||y(b))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(c.actionsConfig))return null;var t=c.actionsConfig,e=c.setMetadata,r=c.setState,n=c.getState,o=c.getMetadata,a=Object.keys(t).reduce((function(u,s){var c,l,f;return Object.assign(u,(c={},f=function(){for(var i=t[s],u=arguments.length,c=new Array(u),l=0;l<u;l++)c[l]=arguments[l];var f=i.apply(a,c);return"function"!=typeof f&&(0,b.throwWrongKeyOnActionCollectionConfig)(s),f.call(a,{setState:r,getState:n,setMetadata:e,getMetadata:o,actions:a})},(l=i(l=s))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),u}),{});return a},this.removeSubscriptions=function(){c.subscribers.clear()},this.dispose=function(){c.removeSubscriptions(),c._name="",c.actionsConfig=null,c.callbacks=null,c.metadata={},c.actions=null,c.state=Object.create(null)};var g=l.metadata,S=l.callbacks,w=l.actions,j=l.name;if(this.state=e,this._name=null!=j?j:(0,v.uniqueId)("gs:"),this.metadata=null!=g?g:{},this.callbacks=null!=S?S:null,this.actionsConfig=null!=w?w:null,p.default.isDevToolsPresent){var O=null!==(n=(new Error).stack)&&void 0!==n?n:"";null===(a=p.default.REACT_GLOBAL_STATE_HOOK_DEBUG)||void 0===a||a.call(p.default,this,l,O)}this.constructor!==t||this.initialize()},e=[{key:"subscribe",value:function(){for(var t=this,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var o,i=r[0],a=r[1],u=r[2],c=(0,s.isFunction)(a),l=c?i:void 0,f=c?a:i,h=null!==(o=c?u:a)&&void 0!==o?o:void 0,d=l?l(this.state):this.state;(null==h?void 0:h.skipFirst)||f(d);var b={selector:l,getConfig:function(){return h},currentState:d,callback:function(t){var e=t.state;return f(e)}};return this.subscribeCallback(b),function(){t.subscribers.delete(b)}}}],e&&function(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,i(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function y(t,e){var r=null==e?void 0:e.name,n=null==e?void 0:e.isEqualRoot,o=null==e?void 0:e.isEqual,i=this.getState(),a=(null!=t?t:function(t){return t})(i),u=new g(a,{name:null!=r?r:(0,v.uniqueId)("sh:")}),s=this.subscribe((function(e){if(!(null!=n?n:Object.is)(i,e)){i=e;var r=t(e);(null!=o?o:Object.is)(a,r)||(a=r,u.setState(r))}}),{skipFirst:!0}),c=u.subscribe.bind(u),l={getState:u.getState.bind(u),subscribe:u.subscribe.bind(u),createSelectorHook:m.bind(c),createObservable:y.bind(c),dispose:function(){s(),u.dispose()}};return Object.assign(c,l),c}function m(t,e){var n=null==e?void 0:e.name,o=null==e?void 0:e.isEqualRoot,i=null==e?void 0:e.isEqual,a=this.getState(),u=(null!=t?t:function(t){return t})(a),s=new g(u,{name:null!=n?n:(0,v.uniqueId)("sh:")}),c=this.subscribe((function(e){if(!(null!=o?o:Object.is)(a,e)){a=e;var r=t(e);(null!=i?i:Object.is)(u,r)||(u=r,s.setState(r))}}),{skipFirst:!0}),l=function(){return(t=s.use.apply(s,arguments),function(t){if(Array.isArray(t))return t}(t)||function(t){var e=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=e){var r,n,o,i,a=[],u=!0,s=!1;try{for(o=(e=e.call(t)).next;!(u=(r=o.call(e)).done)&&(a.push(r.value),1!==a.length);u=!0);}catch(t){s=!0,n=t}finally{try{if(!u&&null!=e.return&&(i=e.return(),Object(i)!==i))return}finally{if(s)throw n}}return a}}(t)||r(t,1)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];var t},f={getState:function(){return s.getState()},subscribe:s.subscribe.bind(s),createSelectorHook:m.bind(l),createObservable:y.bind(l),dispose:function(){c(),s.dispose()}};return Object.assign(l,f),l}t.GlobalStore=g,t.default=g})(),l})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./uniqueId.js"),require("react"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("json-storage-formatter/isFunction"),require("./shallowCompare.js"),require("json-storage-formatter/isNil")):"function"==typeof define&&define.amd?define(["./uniqueId.js","react","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","json-storage-formatter/isFunction","./shallowCompare.js","json-storage-formatter/isNil"],e):"object"==typeof exports?exports["react-hooks-global-states"]=e(require("./uniqueId.js"),require("react"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("json-storage-formatter/isFunction"),require("./shallowCompare.js"),require("json-storage-formatter/isNil")):t["react-hooks-global-states"]=e(t["./uniqueId.js"],t.react,t["./throwWrongKeyOnActionCollectionConfig.js"],t["./isRecord.js"],t["json-storage-formatter/isFunction"],t["./shallowCompare.js"],t["json-storage-formatter/isNil"]);
|
package/GlobalStoreAbstract.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionCollectionConfig, StoreTools, BaseMetadata, StateChanges } from './types';
|
|
1
|
+
import type { ActionCollectionConfig, StoreTools, BaseMetadata, StateChanges, ActionCollectionResult } from './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<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | unknown
|
|
10
|
-
protected onInit: (args: StoreTools<State, Metadata>) => void;
|
|
11
|
-
protected onStateChanged: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
12
|
-
protected abstract onInitialize: (args: StoreTools<State, Metadata>) => void;
|
|
13
|
-
protected abstract onChange: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
9
|
+
export declare abstract class GlobalStoreAbstract<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> extends GlobalStore<State, Metadata, ActionsConfig, PublicStateMutator> {
|
|
10
|
+
protected onInit: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
11
|
+
protected onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
12
|
+
protected abstract onInitialize: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
13
|
+
protected abstract onChange: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
14
14
|
}
|
|
15
15
|
export default GlobalStoreAbstract;
|
package/GlobalStoreAbstract.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
var t;t=t
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var e={
|
|
4
|
-
/***/778:
|
|
5
|
-
/***/e=>{e.exports=t;
|
|
6
|
-
/***/
|
|
7
|
-
/******/}},o={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(t){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var n=o[t];
|
|
16
|
-
/******/if(void 0!==n)
|
|
17
|
-
/******/return n.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var i=o[t]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return e[t](i,i.exports,r),i.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var n={};
|
|
34
|
-
/******/return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(o=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var u=function(t){function r(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(t,r,n){return r=i(r),function(t,o){if(o&&("object"==e(o)||"function"==typeof o))return o;if(void 0!==o)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,o()?Reflect.construct(r,n||[],i(t).constructor):r.apply(t,n))}(this,r,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(r,t),n=r,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(r(778).GlobalStore);
|
|
35
|
-
/**
|
|
36
|
-
* @description
|
|
37
|
-
* Use this class to extends the capabilities of the GlobalStore.
|
|
38
|
-
* by implementing the abstract methods onInitialize and onChange.
|
|
39
|
-
* You can use this class to create a store with async storage.
|
|
40
|
-
*/t.GlobalStoreAbstract=u,t.default=u})(),n;
|
|
41
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js")):this["react-hooks-global-states"]=t(this["./GlobalStore.js"]);
|
|
1
|
+
var t;t=t=>(()=>{"use strict";var e={778:e=>{e.exports=t}},o={};function r(t){var n=o[t];if(void 0!==n)return n.exports;var i=o[t]={exports:{}};return e[t](i,i.exports,r),i.exports}var n={};return(()=>{var t=n;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(o=function(){return!!t})()}function i(t){return i=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},i(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStoreAbstract=void 0;var u=function(t){function r(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),(t=function(t,r,n){return r=i(r),function(t,o){if(o&&("object"==e(o)||"function"==typeof o))return o;if(void 0!==o)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,o()?Reflect.construct(r,n||[],i(t).constructor):r.apply(t,n))}(this,r,arguments)).onInit=function(e){t.onInitialize(e)},t.onStateChanged=function(e){t.onChange(e)},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(r,t),n=r,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(r(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),n})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./GlobalStore.js")):this["react-hooks-global-states"]=t(this["./GlobalStore.js"]);
|
package/bundle.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
var e,r;e=this,r=(e,r,t,o,n,a,l,s)
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var i={
|
|
4
|
-
/***/78:
|
|
5
|
-
/***/r=>{r.exports=e;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/361:
|
|
8
|
-
/***/e=>{e.exports=r;
|
|
9
|
-
/***/},
|
|
10
|
-
/***/487:
|
|
11
|
-
/***/e=>{e.exports=t;
|
|
12
|
-
/***/},
|
|
13
|
-
/***/623:
|
|
14
|
-
/***/e=>{e.exports=o;
|
|
15
|
-
/***/},
|
|
16
|
-
/***/670:
|
|
17
|
-
/***/e=>{e.exports=n;
|
|
18
|
-
/***/},
|
|
19
|
-
/***/673:
|
|
20
|
-
/***/e=>{e.exports=a;
|
|
21
|
-
/***/},
|
|
22
|
-
/***/778:
|
|
23
|
-
/***/e=>{e.exports=l;
|
|
24
|
-
/***/},
|
|
25
|
-
/***/804:
|
|
26
|
-
/***/e=>{e.exports=s;
|
|
27
|
-
/***/
|
|
28
|
-
/******/}},c={};
|
|
29
|
-
/************************************************************************/
|
|
30
|
-
/******/
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/
|
|
34
|
-
/******/function u(e){
|
|
35
|
-
/******/
|
|
36
|
-
/******/var r=c[e];
|
|
37
|
-
/******/if(void 0!==r)
|
|
38
|
-
/******/return r.exports;
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/var t=c[e]={
|
|
42
|
-
/******/
|
|
43
|
-
/******/
|
|
44
|
-
/******/exports:{}
|
|
45
|
-
/******/};
|
|
46
|
-
/******/
|
|
47
|
-
/******/
|
|
48
|
-
/******/
|
|
49
|
-
/******/
|
|
50
|
-
/******/
|
|
51
|
-
/******/return i[e](t,t.exports,u),t.exports;
|
|
52
|
-
/******/}
|
|
53
|
-
/******/
|
|
54
|
-
/************************************************************************/var b={};
|
|
55
|
-
/******/return(()=>{var e=b;Object.defineProperty(e,"__esModule",{value:!0}),e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=void 0;var r=u(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return r.GlobalStore}});var t=u(804);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return t.GlobalStoreAbstract}});var o=u(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return o.createGlobalState}});var n=u(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return n.shallowCompare}});var a=u(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return a.uniqueId}});var l=u(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return l.throwWrongKeyOnActionCollectionConfig}});var s=u(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return s.isRecord}});var i=u(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return i.createContext}})})(),b;
|
|
56
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js","./GlobalStoreAbstract.js"],r):"object"==typeof exports?exports["react-hooks-global-states"]=r(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js")):e["react-hooks-global-states"]=r(e["./uniqueId.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"]);
|
|
1
|
+
var e,r;e=this,r=(e,r,t,o,n,a,l,s)=>(()=>{"use strict";var i={78:r=>{r.exports=e},361:e=>{e.exports=r},487:e=>{e.exports=t},623:e=>{e.exports=o},670:e=>{e.exports=n},673:e=>{e.exports=a},778:e=>{e.exports=l},804:e=>{e.exports=s}},c={};function u(e){var r=c[e];if(void 0!==r)return r.exports;var t=c[e]={exports:{}};return i[e](t,t.exports,u),t.exports}var b={};return(()=>{var e=b;Object.defineProperty(e,"__esModule",{value:!0}),e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=void 0;var r=u(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return r.GlobalStore}});var t=u(804);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return t.GlobalStoreAbstract}});var o=u(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return o.createGlobalState}});var n=u(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return n.shallowCompare}});var a=u(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return a.uniqueId}});var l=u(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return l.throwWrongKeyOnActionCollectionConfig}});var s=u(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return s.isRecord}});var i=u(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return i.createContext}})})(),b})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js","./GlobalStoreAbstract.js"],r):"object"==typeof exports?exports["react-hooks-global-states"]=r(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js")):e["react-hooks-global-states"]=r(e["./uniqueId.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"]);
|