react-hooks-global-states 8.2.5 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GlobalStore.d.ts +7 -18
- package/GlobalStore.js +1 -1
- package/bundle.js +1 -1
- package/index.d.ts +0 -1
- package/package.json +14 -17
- package/shallowCompare.d.ts +8 -0
- package/shallowCompare.js +1 -1
- package/types.d.ts +3 -6
- package/webpack.config.js +0 -1
- package/uniqueSymbol.d.ts +0 -3
- package/uniqueSymbol.js +0 -1
package/GlobalStore.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ActionCollectionConfig, StateSetter, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter,
|
|
2
|
-
import { UniqueSymbol } from './uniqueSymbol';
|
|
1
|
+
import type { ActionCollectionConfig, StateSetter, GlobalStoreCallbacks, ActionCollectionResult, MetadataSetter, StateGetter, SubscriberParameters, MetadataGetter, StateHook, BaseMetadata, StateChanges, StoreTools, ObservableFragment } from './types';
|
|
3
2
|
/**
|
|
4
3
|
* The GlobalStore class is the main class of the library and it is used to create a GlobalStore instances
|
|
5
4
|
* */
|
|
@@ -23,13 +22,13 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata | unknown,
|
|
|
23
22
|
});
|
|
24
23
|
protected onInit?: (args: StoreTools<State, Metadata>) => void;
|
|
25
24
|
protected onStateChanged?: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
26
|
-
protected onSubscribed?: (args: StoreTools<State, Metadata
|
|
25
|
+
protected onSubscribed?: (args: StoreTools<State, Metadata>, subscription: SubscriberParameters) => void;
|
|
27
26
|
protected computePreventStateChange?: (parameters: StoreTools<State, Metadata> & StateChanges<State>) => boolean;
|
|
28
27
|
protected initialize: () => Promise<void>;
|
|
29
28
|
protected executeSetStateForSubscriber: (subscription: SubscriberParameters, args: {
|
|
30
29
|
forceUpdate: boolean | undefined;
|
|
31
30
|
newRootState: State;
|
|
32
|
-
currentRootState: State
|
|
31
|
+
currentRootState: State;
|
|
33
32
|
identifier: string | undefined;
|
|
34
33
|
}) => {
|
|
35
34
|
didUpdate: boolean;
|
|
@@ -57,27 +56,17 @@ export declare class GlobalStore<State, Metadata extends BaseMetadata | unknown,
|
|
|
57
56
|
* */
|
|
58
57
|
getConfigCallbackParam: () => StoreTools<State, Metadata>;
|
|
59
58
|
protected lastSubscriptionId: string | null;
|
|
60
|
-
protected
|
|
61
|
-
isNewSubscription?: boolean;
|
|
62
|
-
};
|
|
59
|
+
protected subscribe: (subscription: SubscriberParameters) => () => void;
|
|
63
60
|
protected partialUpdateSubscription: (subscriptionId: string, values: Partial<SubscriberParameters>) => void;
|
|
64
|
-
protected executeOnSubscribed: () => void;
|
|
61
|
+
protected executeOnSubscribed: (subscription: SubscriberParameters) => void;
|
|
65
62
|
/**
|
|
66
63
|
* Returns a custom hook that allows to handle a global state
|
|
67
64
|
* @returns {[State, StateMutator, Metadata]} - The state, the state setter or the actions map, the metadata
|
|
68
65
|
* */
|
|
69
66
|
getHook: () => StateHook<State, PublicStateMutator, Metadata>;
|
|
70
|
-
protected computeSelectedState: ({
|
|
71
|
-
|
|
72
|
-
subscriptionId: string;
|
|
73
|
-
config: UseHookConfig<unknown, unknown>;
|
|
67
|
+
protected computeSelectedState: ({ subscription, currentDependencies, }: {
|
|
68
|
+
subscription: SubscriberParameters;
|
|
74
69
|
currentDependencies: unknown[] | undefined;
|
|
75
|
-
computeChildState: () => {
|
|
76
|
-
state: unknown;
|
|
77
|
-
};
|
|
78
|
-
stateWrapperRef: {
|
|
79
|
-
state: unknown;
|
|
80
|
-
};
|
|
81
70
|
}) => unknown;
|
|
82
71
|
/**
|
|
83
72
|
* @description
|
package/GlobalStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e;t=this,e=(t,e,r,n,o,i,a,s,u,c)=>(()=>{"use strict";var l={45:e=>{e.exports=t},78:t=>{t.exports=e},155:t=>{t.exports=r},187:t=>{t.exports=n},293:t=>{t.exports=o},361:t=>{t.exports=i},487:t=>{t.exports=a},506:t=>{t.exports=s},673:t=>{t.exports=u},773:t=>{t.exports=c}},f={};function p(t){var e=f[t];if(void 0!==e)return e.exports;var r=f[t]={exports:{}};return l[t](r,r.exports,p),r.exports}var d={};return(()=>{var t=d;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){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,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||n(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 n(t,e){if(t){if("string"==typeof t)return o(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)?o(t,e):void 0}}function o(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 p(t,e,r,n){var o=e&&e.prototype instanceof S?e:S,i=Object.create(o.prototype),s=new q(n||[]);return a(i,"_invoke",{value:x(t,r,s)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=p;var h="suspendedStart",v="suspendedYield",b="executing",g="completed",y={};function S(){}function m(){}function w(){}var O={};f(O,u,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(R([])));E&&E!==n&&o.call(E,u)&&(O=E);var _=w.prototype=S.prototype=Object.create(O);function C(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function k(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,o){n(t,e,r,o)}))}return i=i?i.then(o,o):o()}})}function x(e,r,n){var o=h;return function(i,a){if(o===b)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 s=n.delegate;if(s){var u=T(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(o===h)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;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 T(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,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 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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function q(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(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 m.prototype=w,a(_,"constructor",{value:w,configurable:!0}),a(w,"constructor",{value:m,configurable:!0}),m.displayName=f(w,l,"GeneratorFunction"),r.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(_),t},r.awrap=function(t){return{__await:t}},C(k.prototype),f(k.prototype,c,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(_),f(_,l,"Generator"),f(_,u,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=R,q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!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,o){return s.type="throw",s.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}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),L(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;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function a(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var s=p(155),u=p(506),c=p(773),l=p(187),f=p(487),h=p(673),v=p(361),b=p(78),g=p(293),y=p(45),S=globalThis;!function(){if(!S.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,c.isNil)(S.sessionStorage)){try{if(!S.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}S.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){S.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var m=function(){return t=function t(e){var o,p=this,d=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.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return t=p,e=void 0,r=i().mark((function t(){var e,r,n,o,a,s;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()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},a=o.onInit,n||a){t.next=6;break}return t.abrupt("return");case 6:s=this.getConfigCallbackParam(),null==n||n(s),(0,c.isNil)(a)||null==a||a(s);case 9:case"end":return t.stop()}}),t,this)})),new(e||(e=Promise))((function(n,o){function i(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(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(i,a)}s((r=r.apply(t,[])).next())}));var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r,n,o=t.selector,i=t.callback,a=t.currentState,s=t.config;if(!e.forceUpdate&&(null!==(r=null==s?void 0:s.isEqualRoot)&&void 0!==r?r:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var u=o?o(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(n=null==s?void 0:s.isEqual)&&void 0!==n?n:function(t,e){return t===e})(a,u)?{didUpdate:!1}:(p.partialUpdateSubscription(t.subscriptionId,{currentState:u}),i({state:u},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,i=e.identifier,a=p.stateWrapper.state;if(o||a!==r){p.stateWrapper={state:r};var s,u={forceUpdate:o,newRootState:r,currentRootState:a,identifier:i},c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=n(t))){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},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,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,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw i}}}}(p.subscribers.values());try{for(c.s();!(s=c.n()).done;){var l=s.value;p.executeSetStateForSubscriber(l,u)}}catch(t){c.e(t)}finally{c.f()}}},this.setMetadata=function(t){var e=(0,u.isFunction)(t)?t(p.metadata):t;p.metadata=e},this.getMetadata=function(){return p.metadata},this.getState=function(t,e,r){var n;if(!t)return p.stateWrapper.state;var o=(0,u.isFunction)(e),i=o?t:void 0,a=o?e:t,s=null!==(n=o?r:e)&&void 0!==n?n:void 0,c=i?i(p.stateWrapper.state):p.stateWrapper.state;(null==s?void 0:s.skipFirst)||a(c);var l=(0,b.uniqueId)("gs:");return p.setOrUpdateSubscription({subscriptionId:l,selector:i,config:s,currentState:c,callback:function(t){var e=t.state;return a(e)},isSetStateCallback:!1}),function(){p.subscribers.delete(l)}},this.getConfigCallbackParam=function(){var t=p.setMetadata,e=p.getMetadata,r=p.getState,n=p.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:p.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.setOrUpdateSubscription=function(t){var e=t.subscriptionId;if(!e)return{isNewSubscription:!1};var r=p.subscribers.get(e);return(0,f.isRecord)(r)?(Object.assign(r,t),{isNewSubscription:!1}):(p.executeOnSubscribed(),p.subscribers.set(e,t),p.lastSubscriptionId=e,{isNewSubscription:!0})},this.partialUpdateSubscription=function(t,e){var r=p.subscribers.get(t);(0,f.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(){var t,e=p.onSubscribed,r=null===(t=p.callbacks)||void 0===t?void 0:t.onSubscribed;if(e||r){var n=p.getConfigCallbackParam();null==e||e(n),null==r||r(n)}},this.getHook=function(){var t=function(t){var e,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(p.wasDisposed)throw new Error("The global state was disposed");var i=Array.isArray(o)?{dependencies:o}:null!=o?o:{},a=(0,s.useRef)({subscriptionId:null,tempInitialRootState:p.stateWrapper.state}),u=function(){return t?{state:t(p.stateWrapper.state)}:p.stateWrapper},f=r((0,s.useState)(u),2),d=f[0],h=f[1];(0,s.useEffect)((function(){if(!(0,c.isNil)(a.current)){(0,c.isNil)(a.current.subscriptionId)&&(a.current.subscriptionId=(0,b.uniqueId)("ss:"));var e=a.current.subscriptionId,r={subscriptionId:e,currentState:d.state,selector:t,config:i,callback:h,isSetStateCallback:!0};return p.setOrUpdateSubscription(r).isNewSubscription&&(p.executeSetStateForSubscriber(r,{forceUpdate:!1,newRootState:p.stateWrapper.state,currentRootState:a.current.tempInitialRootState===g.uniqueSymbol?p.stateWrapper.state:a.current.tempInitialRootState,identifier:"on mount state update"}),a.current.tempInitialRootState=g.uniqueSymbol),function(){p.subscribers.delete(e)}}}),[]);var v=(0,l.isString)(null===(e=a.current)||void 0===e?void 0:e.subscriptionId)?a.current.subscriptionId:"",y=p.subscribers.get(v),S=(null!==(n=null==y?void 0:y.config)&&void 0!==n?n:{dependencies:i.dependencies}).dependencies;return p.partialUpdateSubscription(v,{currentState:d.state,selector:t,config:i,callback:h}),[p.computeSelectedState({selector:t,subscriptionId:v,config:i,currentDependencies:S,computeChildState:u,stateWrapperRef:d}),p.getStateOrchestrator(),p.metadata]};return t.stateControls=p.stateControls,t.createSelectorHook=p.createSelectorHook,t.createObservable=p.createObservable,t.removeSubscriptions=p.removeSubscriptions,t.dispose=p.dispose,t},this.computeSelectedState=function(t){var e=t.selector,r=t.subscriptionId,n=t.config,o=t.currentDependencies,i=t.computeChildState,a=t.stateWrapperRef;if(!e||!r)return a.state;var s=n.dependencies;if(o===s)return a.state;if((null==o?void 0:o.length)===(null==s?void 0:s.length)&&(0,h.shallowCompare)(o,s))return a.state;var u=i().state;return p.partialUpdateSubscription(r,{currentState:u}),a.state=u,u},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.isEqualRoot,i=n.isEqual,a=n.name,s=r(p.stateControls(),3),c=s[0],l=s[1],f=s[2],d=c(),h=(null!=e?e:function(t){return t})(d),v=new t(h,{name:null!=a?a:(0,b.uniqueId)("sh:")}),g=r(v.stateControls(),2),y=g[0],S=g[1],m=c((function(t){if(!(null!=o?o:Object.is)(d,t)){d=t;var r=e(t);(null!=i?i:Object.is)(h,r)||(h=r,S(r))}}),{skipFirst:!0}),w=v.getHook(),O=function(t,e){return[r((0,u.isFunction)(t)?w(t,e):w(),1)[0],l,f]};return O.stateControls=function(){return[y,l,f]},O.createSelectorHook=v.createSelectorHook,O.createObservable=p.createObservable.bind(O),O.removeSubscriptions=function(){m(),v.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),v.dispose()},O},this.stateControls=function(){var t=p.getStateOrchestrator(),e=p.getMetadata;return[p.getState,t,e]},this.getStateOrchestrator=function(){return p.actions?p.actions:p.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,a=p.stateWrapper.state,s=(0,u.isFunction)(t)?t(a):t;if(o||p.stateWrapper.state!==s){var c=p.setMetadata,l=p.getMetadata,f=p.getState,d=p.actions,h={setMetadata:c,getMetadata:l,setState:p.setState,getState:f,actions:d,previousState:a,state:s,identifier:i},v=p.computePreventStateChange,b=null===(e=p.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||b)&&((null==v?void 0:v(h))||(null==b?void 0:b(h))))return;p.setState({state:s},{forceUpdate:o,identifier:i});var g=p.onStateChanged,y=null===(r=p.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(h),null==y||y(h))}},this.getStoreActionsMap=function(){if(!(0,f.isRecord)(p.actionsConfig))return null;var t=p.actionsConfig,e=p.setMetadata,r=p.setStateWrapper,n=p.getState,o=p.getMetadata,i=Object.keys(t).reduce((function(s,u){var c,l,f;return Object.assign(s,(c={},f=function(){for(var a=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=a.apply(i,c);return"function"!=typeof f&&(0,v.throwWrongKeyOnActionCollectionConfig)(u),f.call(i,{setState:r,getState:n,setMetadata:e,getMetadata:o,actions:i})},(l=a(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),s}),{});return i},this.removeSubscriptions=function(){p.subscribers.clear()},this.dispose=function(){p.wasDisposed=!0,p.removeSubscriptions(),p._name="",p.actionsConfig=null,p.callbacks=null,p.metadata={},p.actions=null,p.stateWrapper={state:null}};var m=d.metadata,w=d.callbacks,O=d.actions,j=d.name;this.stateWrapper={state:e},this._name=null!=j?j:(0,b.uniqueId)("gs:"),this.metadata=null!=m?m:{},this.callbacks=null!=w?w:null,this.actionsConfig=null!=O?O:null;var E="";if((S.REACT_GLOBAL_STATE_HOOK_DEBUG||S.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(E=(0,y.generateStackHash)(null!==(o=(new Error).stack)&&void 0!==o?o:"")),S.REACT_GLOBAL_STATE_HOOK_DEBUG)S.REACT_GLOBAL_STATE_HOOK_DEBUG(this,d,E);else if(S.REACT_GLOBAL_STATE_TEMP_HOOKS){var _=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,C=void 0!==globalThis.WeakRef?new globalThis.WeakRef(d):d;S.REACT_GLOBAL_STATE_TEMP_HOOKS.set(E,[_,C])}this.constructor!==t||this.initialize()},e=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,o=e.isEqual,i=e.name,a=r(this.stateControls(),1)[0],s=[],c=a(),l=(null!=t?t:function(t){return t})(a()),f=a((function(e){if(!(null!=n?n:Object.is)(c,e)){c=e;var r=t(e);(null!=o?o:Object.is)(l,r)||(l=r,s.forEach((function(t){return t()})))}}),{skipFirst:!0}),p=function(t,e,r){var n;if(!t)return l;var o=(0,u.isFunction)(e),i=o?t:void 0,a=o?e:t,c=null!==(n=o?r:e)&&void 0!==n?n:void 0,f=function(){return a(i?i(l):l)};(null==c?void 0:c.skipFirst)||f();var p=function(){f()};return s.push(p),function(){s.splice(s.indexOf(p),1)}};return p._name=null!=i?i:(0,b.uniqueId)("ob:"),p.createObservable=this.createObservable.bind(p),p.removeSubscriptions=function(){s.forEach((function(t){return t()})),s.length=0,f()},p.stateControls=function(){return[p]},p}}],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,a(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();t.GlobalStore=m,t.default=m})(),d})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./generateStackHash.js"),require("./uniqueId.js"),require("react"),require("json-storage-formatter/isString"),require("./uniqueSymbol.js"),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(["./generateStackHash.js","./uniqueId.js","react","json-storage-formatter/isString","./uniqueSymbol.js","./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("./generateStackHash.js"),require("./uniqueId.js"),require("react"),require("json-storage-formatter/isString"),require("./uniqueSymbol.js"),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["./generateStackHash.js"],t["./uniqueId.js"],t.react,t["json-storage-formatter/isString"],t["./uniqueSymbol.js"],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,s)=>(()=>{"use strict";var u={45:e=>{e.exports=t},78:t=>{t.exports=e},155:t=>{t.exports=r},361:t=>{t.exports=n},487:t=>{t.exports=o},506:t=>{t.exports=i},673:t=>{t.exports=a},773:t=>{t.exports=s}},c={};function l(t){var e=c[t];if(void 0!==e)return e.exports;var r=c[t]={exports:{}};return u[t](r,r.exports,l),r.exports}var f={};return(()=>{var t=f;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(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,s=[],u=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(t,e)||n(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 n(t,e){if(t){if("string"==typeof t)return o(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)?o(t,e):void 0}}function o(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 o=e&&e.prototype instanceof m?e:m,i=Object.create(o.prototype),s=new q(n||[]);return a(i,"_invoke",{value:x(t,r,s)}),i}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=h;var d="suspendedStart",v="suspendedYield",b="executing",g="completed",y={};function m(){}function S(){}function w(){}var O={};f(O,u,(function(){return this}));var E=Object.getPrototypeOf,j=E&&E(E(R([])));j&&j!==n&&o.call(j,u)&&(O=j);var _=w.prototype=m.prototype=Object.create(O);function C(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,r){function n(i,a,s,u){var c=p(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,o){n(t,e,r,o)}))}return i=i?i.then(o,o):o()}})}function x(e,r,n){var o=d;return function(i,a){if(o===b)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 s=n.delegate;if(s){var u=T(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(o===d)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=b;var c=p(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 T(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,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=p(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 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 L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function q(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(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(_,"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(_),t},r.awrap=function(t){return{__await:t}},C(k.prototype),f(k.prototype,c,(function(){return this})),r.AsyncIterator=k,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new k(h(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},C(_),f(_,l,"Generator"),f(_,u,(function(){return this})),f(_,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=R,q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(L),!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,o){return s.type="throw",s.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}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),L(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;L(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function a(t){var r=function(t){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(r)?r:r+""}Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalStore=void 0;var s=l(155),u=l(506),c=l(773),h=l(487),p=l(673),d=l(361),v=l(78),b=l(45),g=globalThis;!function(){if(!g.REACT_GLOBAL_STATE_HOOK_DEBUG&&!(0,c.isNil)(g.sessionStorage)){try{if(!g.sessionStorage.getItem("REACT_GLOBAL_STATE_HOOK_DEBUG"))return}catch(t){return}g.REACT_GLOBAL_STATE_TEMP_HOOKS=new Map,setTimeout((function(){g.REACT_GLOBAL_STATE_TEMP_HOOKS=null}),6e4)}}();var y=function(){return t=function t(e){var o,l=this,f=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.wasDisposed=!1,this.actionsConfig=null,this.callbacks=null,this.actions=null,this.subscribers=new Map,this.initialize=function(){return t=l,e=void 0,r=i().mark((function t(){var e,r,n,o,a,s;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()),n=this.onInit,o=null!==(r=this.callbacks)&&void 0!==r?r:{},a=o.onInit,n||a){t.next=6;break}return t.abrupt("return");case 6:s=this.getConfigCallbackParam(),null==n||n(s),(0,c.isNil)(a)||null==a||a(s);case 9:case"end":return t.stop()}}),t,this)})),new(e||(e=Promise))((function(n,o){function i(t){try{s(r.next(t))}catch(t){o(t)}}function a(t){try{s(r.throw(t))}catch(t){o(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(i,a)}s((r=r.apply(t,[])).next())}));var t,e,r},this.executeSetStateForSubscriber=function(t,e){var r,n,o,i=t.selector,a=t.callback,s=t.currentState,u=t.getConfig,c=null!==(r=null==u?void 0:u())&&void 0!==r?r:{};if(!e.forceUpdate&&(null!==(n=null==c?void 0:c.isEqualRoot)&&void 0!==n?n:function(t,e){return t===e})(e.currentRootState,e.newRootState))return{didUpdate:!1};var f=i?i(e.newRootState):e.newRootState;return!e.forceUpdate&&(null!==(o=null==c?void 0:c.isEqual)&&void 0!==o?o:function(t,e){return t===e})(s,f)?{didUpdate:!1}:(l.partialUpdateSubscription(t.subscriptionId,{currentState:f}),a({state:f},{identifier:e.identifier}),{didUpdate:!0})},this.setState=function(t,e){var r=t.state,o=e.forceUpdate,i=e.identifier,a=l.stateWrapper.state;if(o||a!==r){l.stateWrapper={state:r};var s,u={forceUpdate:o,newRootState:r,currentRootState:a,identifier:i},c=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=n(t))){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},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,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,i=t},f:function(){try{a||null==e.return||e.return()}finally{if(s)throw i}}}}(l.subscribers.values());try{for(c.s();!(s=c.n()).done;){var f=s.value;l.executeSetStateForSubscriber(f,u)}}catch(t){c.e(t)}finally{c.f()}}},this.setMetadata=function(t){var e=(0,u.isFunction)(t)?t(l.metadata):t;l.metadata=e},this.getMetadata=function(){return l.metadata},this.getState=function(t,e,r){var n;if(!t)return l.stateWrapper.state;var o=(0,u.isFunction)(e),i=o?t:void 0,a=o?e:t,s=null!==(n=o?r:e)&&void 0!==n?n:void 0,c=i?i(l.stateWrapper.state):l.stateWrapper.state;(null==s?void 0:s.skipFirst)||a(c);var f=(0,v.uniqueId)("gs:");return l.subscribe({subscriptionId:f,selector:i,getConfig:function(){return s},currentState:c,callback:function(t){var e=t.state;return a(e)}}),function(){l.subscribers.delete(f)}},this.getConfigCallbackParam=function(){var t=l.setMetadata,e=l.getMetadata,r=l.getState,n=l.actions;return{setMetadata:t,getMetadata:e,getState:r,setState:l.setStateWrapper,actions:n}},this.lastSubscriptionId=null,this.subscribe=function(t){var e=t.subscriptionId;return l.executeOnSubscribed(t),l.subscribers.set(e,t),l.lastSubscriptionId=e,function(){l.subscribers.delete(e)}},this.partialUpdateSubscription=function(t,e){var r=l.subscribers.get(t);(0,h.isRecord)(r)&&Object.assign(r,e)},this.executeOnSubscribed=function(t){var e,r=l.onSubscribed,n=null===(e=l.callbacks)||void 0===e?void 0:e.onSubscribed;if(r||n){var o=l.getConfigCallbackParam();null==r||r(o,t),null==n||n(o,t)}},this.getHook=function(){var t=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(l.wasDisposed)throw new Error("The global state was disposed");var r=(0,p.isArray)(e)?{dependencies:e}:null!=e?e:{},n=(0,s.useRef)({selector:t,config:r}),o=n.current.config.dependencies;n.current.selector=t,n.current.config=r;var i=(0,s.useMemo)((function(){var t=function(t){var e=n.current.selector;return(0,u.isFunction)(e)?e(t):t},e={subscriptionId:(0,v.uniqueId)("ss:"),currentState:t(l.stateWrapper.state),selector:t,getConfig:function(){return n.current.config},callback:function(){throw new Error("Callback not set")}};return{subscribe:function(t){return e.callback=t,l.subscribe(e)},getSnapshot:function(){return e.currentState},subscription:e}}),[]),a=i.subscribe,c=i.getSnapshot,f=i.subscription;return(0,s.useSyncExternalStore)(a,c,c),[l.computeSelectedState({subscription:f,currentDependencies:o}),l.getStateOrchestrator(),l.metadata]};return t.stateControls=l.stateControls,t.createSelectorHook=l.createSelectorHook,t.createObservable=l.createObservable,t.removeSubscriptions=l.removeSubscriptions,t.dispose=l.dispose,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,p.shallowCompare)(n,o)||l.partialUpdateSubscription(r.subscriptionId,{currentState:r.selector(l.stateWrapper.state)}),r.currentState},this.createSelectorHook=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.isEqualRoot,i=n.isEqual,a=n.name,s=r(l.stateControls(),3),c=s[0],f=s[1],h=s[2],p=c(),d=(null!=e?e:function(t){return t})(p),b=new t(d,{name:null!=a?a:(0,v.uniqueId)("sh:")}),g=r(b.stateControls(),2),y=g[0],m=g[1],S=c((function(t){if(!(null!=o?o:Object.is)(p,t)){p=t;var r=e(t);(null!=i?i:Object.is)(d,r)||(d=r,m(r))}}),{skipFirst:!0}),w=b.getHook(),O=function(t,e){return[r((0,u.isFunction)(t)?w(t,e):w(),1)[0],f,h]};return O.stateControls=function(){return[y,f,h]},O.createSelectorHook=b.createSelectorHook,O.createObservable=l.createObservable.bind(O),O.removeSubscriptions=function(){S(),b.removeSubscriptions()},O.dispose=function(){O.removeSubscriptions(),b.dispose()},O},this.stateControls=function(){var t=l.getStateOrchestrator(),e=l.getMetadata;return[l.getState,t,e]},this.getStateOrchestrator=function(){return l.actions?l.actions:l.setStateWrapper},this.setStateWrapper=function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.forceUpdate,i=n.identifier,a=l.stateWrapper.state,s=(0,u.isFunction)(t)?t(a):t;if(o||l.stateWrapper.state!==s){var c=l.setMetadata,f=l.getMetadata,h=l.getState,p=l.actions,d={setMetadata:c,getMetadata:f,setState:l.setState,getState:h,actions:p,previousState:a,state:s,identifier:i},v=l.computePreventStateChange,b=null===(e=l.callbacks)||void 0===e?void 0:e.computePreventStateChange;if((v||b)&&((null==v?void 0:v(d))||(null==b?void 0:b(d))))return;l.setState({state:s},{forceUpdate:o,identifier:i});var g=l.onStateChanged,y=null===(r=l.callbacks)||void 0===r?void 0:r.onStateChanged;(g||y)&&(null==g||g(d),null==y||y(d))}},this.getStoreActionsMap=function(){if(!(0,h.isRecord)(l.actionsConfig))return null;var t=l.actionsConfig,e=l.setMetadata,r=l.setStateWrapper,n=l.getState,o=l.getMetadata,i=Object.keys(t).reduce((function(s,u){var c,l,f;return Object.assign(s,(c={},f=function(){for(var a=t[u],s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var f=a.apply(i,c);return"function"!=typeof f&&(0,d.throwWrongKeyOnActionCollectionConfig)(u),f.call(i,{setState:r,getState:n,setMetadata:e,getMetadata:o,actions:i})},(l=a(l=u))in c?Object.defineProperty(c,l,{value:f,enumerable:!0,configurable:!0,writable:!0}):c[l]=f,c)),s}),{});return i},this.removeSubscriptions=function(){l.subscribers.clear()},this.dispose=function(){l.wasDisposed=!0,l.removeSubscriptions(),l._name="",l.actionsConfig=null,l.callbacks=null,l.metadata={},l.actions=null,l.stateWrapper={state:null}};var y=f.metadata,m=f.callbacks,S=f.actions,w=f.name;this.stateWrapper={state:e},this._name=null!=w?w:(0,v.uniqueId)("gs:"),this.metadata=null!=y?y:{},this.callbacks=null!=m?m:null,this.actionsConfig=null!=S?S:null;var O="";if((g.REACT_GLOBAL_STATE_HOOK_DEBUG||g.REACT_GLOBAL_STATE_TEMP_HOOKS)&&(O=(0,b.generateStackHash)(null!==(o=(new Error).stack)&&void 0!==o?o:"")),g.REACT_GLOBAL_STATE_HOOK_DEBUG)g.REACT_GLOBAL_STATE_HOOK_DEBUG(this,f,O);else if(g.REACT_GLOBAL_STATE_TEMP_HOOKS){var E=void 0!==globalThis.WeakRef?new globalThis.WeakRef(this):this,j=void 0!==globalThis.WeakRef?new globalThis.WeakRef(f):f;g.REACT_GLOBAL_STATE_TEMP_HOOKS.set(O,[E,j])}this.constructor!==t||this.initialize()},e=[{key:"createObservable",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.isEqualRoot,o=e.isEqual,i=e.name,a=r(this.stateControls(),1)[0],s=[],c=a(),l=(null!=t?t:function(t){return t})(a()),f=a((function(e){if(!(null!=n?n:Object.is)(c,e)){c=e;var r=t(e);(null!=o?o:Object.is)(l,r)||(l=r,s.forEach((function(t){return t()})))}}),{skipFirst:!0}),h=function(t,e,r){var n;if(!t)return l;var o=(0,u.isFunction)(e),i=o?t:void 0,a=o?e:t,c=null!==(n=o?r:e)&&void 0!==n?n:void 0,f=function(){return a(i?i(l):l)};(null==c?void 0:c.skipFirst)||f();var h=function(){f()};return s.push(h),function(){s.splice(s.indexOf(h),1)}};return h._name=null!=i?i:(0,v.uniqueId)("ob:"),h.createObservable=this.createObservable.bind(h),h.removeSubscriptions=function(){s.forEach((function(t){return t()})),s.length=0,f()},h.stateControls=function(){return[h]},h}}],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,a(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();t.GlobalStore=y,t.default=y})(),f})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./generateStackHash.js"),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(["./generateStackHash.js","./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("./generateStackHash.js"),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["./generateStackHash.js"],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/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=(e,t,r,o,a,n,s,l,u,i,c
|
|
1
|
+
var e,t;e=this,t=(e,t,r,o,a,n,s,l,u,i,c)=>(()=>{"use strict";var b={45:t=>{t.exports=e},78:e=>{e.exports=t},361:e=>{e.exports=r},417:e=>{e.exports=o},487:e=>{e.exports=a},623:e=>{e.exports=n},670:e=>{e.exports=s},673:e=>{e.exports=l},778:e=>{e.exports=u},804:e=>{e.exports=i},923:e=>{e.exports=c}},j={};function S(e){var t=j[e];if(void 0!==t)return t.exports;var r=j[e]={exports:{}};return b[e](r,r.exports,S),r.exports}var p={};return(()=>{var e=p;Object.defineProperty(e,"__esModule",{value:!0}),e.generateStackHash=e.createContext=e.useStableState=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=e.createCustomGlobalState=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=void 0;var t=S(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return t.GlobalStore}});var r=S(804);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return r.GlobalStoreAbstract}});var o=S(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return o.createGlobalState}});var a=S(417);Object.defineProperty(e,"createCustomGlobalState",{enumerable:!0,get:function(){return a.createCustomGlobalState}});var n=S(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return n.shallowCompare}});var s=S(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return s.uniqueId}});var l=S(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return l.throwWrongKeyOnActionCollectionConfig}});var u=S(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return u.isRecord}});var i=S(923);Object.defineProperty(e,"useStableState",{enumerable:!0,get:function(){return i.useStableState}});var c=S(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return c.createContext}});var b=S(45);Object.defineProperty(e,"generateStackHash",{enumerable:!0,get:function(){return b.generateStackHash}})})(),p})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./generateStackHash.js"),require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./createCustomGlobalState.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./useStableState.js")):"function"==typeof define&&define.amd?define(["./generateStackHash.js","./uniqueId.js","./throwWrongKeyOnActionCollectionConfig.js","./createCustomGlobalState.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js","./GlobalStoreAbstract.js","./useStableState.js"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("./generateStackHash.js"),require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./createCustomGlobalState.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./useStableState.js")):e["react-hooks-global-states"]=t(e["./generateStackHash.js"],e["./uniqueId.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./createCustomGlobalState.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"],e["./useStableState.js"]);
|
package/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export { shallowCompare } from './shallowCompare';
|
|
|
7
7
|
export { uniqueId } from './uniqueId';
|
|
8
8
|
export { throwWrongKeyOnActionCollectionConfig } from './throwWrongKeyOnActionCollectionConfig';
|
|
9
9
|
export { isRecord } from './isRecord';
|
|
10
|
-
export { uniqueSymbol, UniqueSymbol } from './uniqueSymbol';
|
|
11
10
|
export { useStableState } from './useStableState';
|
|
12
11
|
export { ContextProviderAPI, ContextProvider, ContextHook, CreateContext, createContext, } from './createContext';
|
|
13
12
|
export { generateStackHash } from './generateStackHash';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hooks-global-states",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "This is a package to easily handling global-state across your react-components using hooks.",
|
|
5
5
|
"main": "./bundle.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -61,11 +61,6 @@
|
|
|
61
61
|
"require": "./uniqueId.js",
|
|
62
62
|
"types": "./uniqueId.d.ts"
|
|
63
63
|
},
|
|
64
|
-
"./uniqueSymbol": {
|
|
65
|
-
"import": "./uniqueSymbol.js",
|
|
66
|
-
"require": "./uniqueSymbol.js",
|
|
67
|
-
"types": "./uniqueSymbol.d.ts"
|
|
68
|
-
},
|
|
69
64
|
"./useStableState": {
|
|
70
65
|
"import": "./useStableState.js",
|
|
71
66
|
"require": "./useStableState.js",
|
|
@@ -123,10 +118,11 @@
|
|
|
123
118
|
"@babel/preset-env": "^7.20.2",
|
|
124
119
|
"@babel/preset-react": "^7.18.6",
|
|
125
120
|
"@babel/preset-typescript": "^7.21.0",
|
|
126
|
-
"@
|
|
127
|
-
"@
|
|
128
|
-
"@types/
|
|
129
|
-
"@types/react
|
|
121
|
+
"@testing-library/dom": "^10.4.0",
|
|
122
|
+
"@testing-library/react": "^16.3.0",
|
|
123
|
+
"@types/jest": "^29.5.11",
|
|
124
|
+
"@types/react": "^18.2.45",
|
|
125
|
+
"@types/react-dom": "^18.2.18",
|
|
130
126
|
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
|
131
127
|
"@typescript-eslint/parser": "^4.9.1",
|
|
132
128
|
"babel-loader": "^9.1.2",
|
|
@@ -138,11 +134,12 @@
|
|
|
138
134
|
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
139
135
|
"eslint-plugin-react": "^7.21.5",
|
|
140
136
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
141
|
-
"jest": "^
|
|
137
|
+
"jest": "^29.7.0",
|
|
138
|
+
"jest-environment-jsdom": "^30.0.4",
|
|
142
139
|
"json-storage-formatter": "^2.0.9",
|
|
143
|
-
"react": "
|
|
144
|
-
"react-
|
|
145
|
-
"ts-jest": "^
|
|
140
|
+
"react": "^18.2.0",
|
|
141
|
+
"react-dom": "^18.2.0",
|
|
142
|
+
"ts-jest": "^29.1.1",
|
|
146
143
|
"ts-loader": "^9.5.1",
|
|
147
144
|
"tslib": "^2.6.2",
|
|
148
145
|
"typescript": "^5.8.2",
|
|
@@ -151,7 +148,8 @@
|
|
|
151
148
|
},
|
|
152
149
|
"peerDependencies": {
|
|
153
150
|
"json-storage-formatter": "^2.0.9",
|
|
154
|
-
"react": "
|
|
151
|
+
"react": "^18.0.0",
|
|
152
|
+
"react-dom": "^18.0.0"
|
|
155
153
|
},
|
|
156
154
|
"peerDependenciesMeta": {
|
|
157
155
|
"react": {
|
|
@@ -160,6 +158,5 @@
|
|
|
160
158
|
"json-storage-formatter": {
|
|
161
159
|
"optional": false
|
|
162
160
|
}
|
|
163
|
-
}
|
|
164
|
-
"dependencies": {}
|
|
161
|
+
}
|
|
165
162
|
}
|
package/shallowCompare.d.ts
CHANGED
|
@@ -2,4 +2,12 @@
|
|
|
2
2
|
* Returns true if the two values are equal.
|
|
3
3
|
*/
|
|
4
4
|
export declare const shallowCompare: <T>(value1: T, value2: T) => boolean;
|
|
5
|
+
export declare const isArray: (value: unknown) => value is unknown[];
|
|
6
|
+
export declare const isMap: (value: unknown) => value is Map<unknown, unknown>;
|
|
7
|
+
export declare const isSet: (value: unknown) => value is Set<unknown>;
|
|
8
|
+
export declare const canCheckSimpleEquality: (value1: unknown, value2: unknown) => boolean;
|
|
9
|
+
export declare const isEqualArray: <T>(array1: T[], array2: T[]) => boolean;
|
|
10
|
+
export declare const isEqualMap: <K, V>(map1: Map<K, V>, map2: Map<K, V>) => boolean;
|
|
11
|
+
export declare const isEqualSet: <T>(set1: Set<T>, set2: Set<T>) => boolean;
|
|
12
|
+
export declare const isEqualObject: <T extends Record<string, unknown>>(value1: T, value2: T) => boolean;
|
|
5
13
|
export default shallowCompare;
|
package/shallowCompare.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r,t;r=this,t=(r,t,e,
|
|
1
|
+
var r,t;r=this,t=(r,t,e,n)=>(()=>{"use strict";var o={38:t=>{t.exports=r},487:r=>{r.exports=t},773:r=>{r.exports=e},955:r=>{r.exports=n},973:(r,t,e)=>{function n(r,t){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=o(r))||t&&r&&"number"==typeof r.length){e&&(r=e);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,u=!1;return{s:function(){e=e.call(r)},n:function(){var r=e.next();return s=r.done,r},e:function(r){u=!0,a=r},f:function(){try{s||null==e.return||e.return()}finally{if(u)throw a}}}}function o(r,t){if(r){if("string"==typeof r)return i(r,t);var e={}.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?i(r,t):void 0}}function i(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function a(r){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},a(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.isEqualObject=t.isEqualSet=t.isEqualMap=t.isEqualArray=t.canCheckSimpleEquality=t.isSet=t.isMap=t.isArray=t.shallowCompare=void 0;var s=e(955),u=e(38),l=e(773),f=e(487);t.shallowCompare=function(r,e){return!(r!==e)||((0,t.canCheckSimpleEquality)(r,e)?r===e:(0,t.isArray)(r)&&(0,t.isArray)(e)?(0,t.isEqualArray)(r,e):(0,t.isMap)(r)&&(0,t.isMap)(e)?(0,t.isEqualMap)(r,e):(0,t.isSet)(r)&&(0,t.isSet)(e)?(0,t.isEqualSet)(r,e):(0,f.isRecord)(r)&&(0,f.isRecord)(e)?(0,t.isEqualObject)(r,e):r===e)},t.isArray=function(r){return Array.isArray(r)},t.isMap=function(r){return r instanceof Map},t.isSet=function(r){return r instanceof Set},t.canCheckSimpleEquality=function(r,t){var e=a(r),n=a(t);return e!==n||(0,l.isNil)(r)||(0,l.isNil)(t)||(0,s.isPrimitive)(r)&&(0,s.isPrimitive)(t)||(0,u.isDate)(r)&&(0,u.isDate)(t)||"function"===e&&"function"===n},t.isEqualArray=function(r,t){if(r.length!==t.length)return!1;for(var e=0;e<r.length;e+=1)if(r[e]!==t[e])return!1;return!0},t.isEqualMap=function(r,t){if(r.size!==t.size)return!1;var e,i,a=n(r);try{for(a.s();!(e=a.n()).done;){var s=function(r){if(Array.isArray(r))return r}(i=e.value)||function(r){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,o,i,a=[],s=!0,u=!1;try{for(o=(t=t.call(r)).next;!(s=(e=o.call(t)).done)&&(a.push(e.value),2!==a.length);s=!0);}catch(r){u=!0,n=r}finally{try{if(!s&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(u)throw n}}return a}}(i)||o(i,2)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=s[0];if(s[1]!==t.get(u))return!1}}catch(r){a.e(r)}finally{a.f()}return!0},t.isEqualSet=function(r,t){if(r.size!==t.size)return!1;var e,o=n(r);try{for(o.s();!(e=o.n()).done;){var i=e.value;if(!t.has(i))return!1}}catch(r){o.e(r)}finally{o.f()}return!0},t.isEqualObject=function(r,t){var e=Object.keys(r),n=Object.keys(t);if(e.length!==n.length)return!1;for(var o=0,i=e;o<i.length;o++){var a=i[o];if(r[a]!==t[a])return!1}return!0},t.default=t.shallowCompare}},i={};return function r(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={exports:{}};return o[t](n,n.exports,r),n.exports}(973)})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/isDate"),require("./isRecord.js"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):"function"==typeof define&&define.amd?define(["json-storage-formatter/isDate","./isRecord.js","json-storage-formatter/isNil","json-storage-formatter/isPrimitive"],t):"object"==typeof exports?exports["react-hooks-global-states"]=t(require("json-storage-formatter/isDate"),require("./isRecord.js"),require("json-storage-formatter/isNil"),require("json-storage-formatter/isPrimitive")):r["react-hooks-global-states"]=t(r["json-storage-formatter/isDate"],r["./isRecord.js"],r["json-storage-formatter/isNil"],r["json-storage-formatter/isPrimitive"]);
|
package/types.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export type ActionCollectionResult<State, Metadata extends BaseMetadata | unknow
|
|
|
94
94
|
export type GlobalStoreCallbacks<State, Metadata extends BaseMetadata | unknown> = {
|
|
95
95
|
onInit?: (args: StoreTools<State, Metadata>) => void;
|
|
96
96
|
onStateChanged?: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
97
|
-
onSubscribed?: (args: StoreTools<State, Metadata
|
|
97
|
+
onSubscribed?: (args: StoreTools<State, Metadata>, subscription: SubscriberParameters) => void;
|
|
98
98
|
computePreventStateChange?: (args: StoreTools<State, Metadata> & StateChanges<State>) => boolean;
|
|
99
99
|
};
|
|
100
100
|
export type UseHookConfig<State, TRoot = any> = {
|
|
@@ -131,12 +131,9 @@ export type SelectorCallback<State, TDerivate> = (state: State) => TDerivate;
|
|
|
131
131
|
export type SubscriberParameters = {
|
|
132
132
|
subscriptionId: string;
|
|
133
133
|
selector: SelectorCallback<unknown, unknown> | undefined;
|
|
134
|
-
|
|
134
|
+
getConfig: () => UseHookConfig<unknown> | SubscribeCallbackConfig<unknown> | undefined;
|
|
135
135
|
currentState: unknown;
|
|
136
|
-
callback: SubscriptionCallback |
|
|
137
|
-
state: unknown;
|
|
138
|
-
}>>;
|
|
139
|
-
isSetStateCallback: boolean;
|
|
136
|
+
callback: SubscriptionCallback | (() => void);
|
|
140
137
|
};
|
|
141
138
|
/**
|
|
142
139
|
* @description
|
package/webpack.config.js
CHANGED
|
@@ -12,7 +12,6 @@ const individualEntries = {
|
|
|
12
12
|
shallowCompare: './src/shallowCompare.ts',
|
|
13
13
|
throwWrongKeyOnActionCollectionConfig: './src/throwWrongKeyOnActionCollectionConfig.ts',
|
|
14
14
|
uniqueId: './src/uniqueId.ts',
|
|
15
|
-
uniqueSymbol: './src/uniqueSymbol.ts',
|
|
16
15
|
useStableState: './src/useStableState.ts',
|
|
17
16
|
generateStackHash: './src/generateStackHash.ts',
|
|
18
17
|
};
|
package/uniqueSymbol.d.ts
DELETED
package/uniqueSymbol.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;e=()=>(()=>{"use strict";var e={};return((e,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.uniqueSymbol=void 0,o.uniqueSymbol=Symbol("unique"),o.default=o.uniqueSymbol})(0,e),e})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["react-hooks-global-states"]=e():this["react-hooks-global-states"]=e();
|