react-global-state-hooks 11.0.0 → 12.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 +9 -9
- package/GlobalStore.js +1 -50
- package/GlobalStoreAbstract.d.ts +6 -6
- package/GlobalStoreAbstract.js +1 -35
- package/bundle.js +1 -62
- package/createContext.d.ts +1 -1
- package/createContext.js +1 -35
- package/createGlobalState.d.ts +8 -8
- package/createGlobalState.js +1 -49
- package/getLocalStorageItem.js +1 -43
- package/index.d.ts +2 -2
- package/isRecord.js +1 -35
- package/package.json +2 -2
- package/setLocalStorageItem.js +1 -43
- package/shallowCompare.js +1 -35
- package/throwWrongKeyOnActionCollectionConfig.js +1 -35
- package/types.d.ts +1 -1
- package/types.js +1 -4
- package/uniqueId.js +1 -35
- package/webpack.config.js +2 -5
package/GlobalStore.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { ActionCollectionConfig, BaseMetadata, GlobalStoreCallbacks, StateChanges, StoreTools } from 'react-hooks-global-states/types';
|
|
1
|
+
import type { ActionCollectionConfig, ActionCollectionResult, AnyFunction, BaseMetadata, GlobalStoreCallbacks, StateChanges, StoreTools } from 'react-hooks-global-states/types';
|
|
2
2
|
import { GlobalStoreAbstract } from 'react-hooks-global-states/GlobalStoreAbstract';
|
|
3
3
|
import { LocalStorageConfig } from './types';
|
|
4
|
-
export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown
|
|
4
|
+
export declare class GlobalStore<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | undefined | unknown, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> extends GlobalStoreAbstract<State, Metadata, ActionsConfig> {
|
|
5
5
|
protected localStorage: LocalStorageConfig | null;
|
|
6
6
|
constructor(state: State);
|
|
7
7
|
constructor(state: State, args: {
|
|
8
8
|
metadata?: Metadata;
|
|
9
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
9
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator extends AnyFunction ? null : PublicStateMutator, Metadata>;
|
|
10
10
|
actions?: ActionsConfig;
|
|
11
11
|
name?: string;
|
|
12
12
|
localStorage?: LocalStorageConfig;
|
|
13
13
|
});
|
|
14
14
|
protected isLocalStorageAvailable: (config: LocalStorageConfig | null) => config is LocalStorageConfig;
|
|
15
|
-
protected _onInitialize: ({ setState, getState }: StoreTools<State, Metadata>) => void;
|
|
16
|
-
protected _onChange: ({ getState }: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
15
|
+
protected _onInitialize: ({ setState, getState, }: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
16
|
+
protected _onChange: ({ getState, }: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
17
17
|
/**
|
|
18
18
|
* We set it to null so the instances of the GlobalStoreAbstract can override it.
|
|
19
19
|
*/
|
|
20
|
-
protected onInitialize: (args: StoreTools<State, Metadata>) => void;
|
|
21
|
-
protected onChange: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
20
|
+
protected onInitialize: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
21
|
+
protected onChange: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
22
22
|
/**
|
|
23
23
|
* Instead of calling onInitialize and onChange directly, we call the _onInitialize and _onChange
|
|
24
24
|
* This allows the concat the logic of the GlobalStore with the logic of the extension class.
|
|
25
25
|
*/
|
|
26
|
-
protected onInit: (parameters: StoreTools<State, Metadata>) => void;
|
|
27
|
-
protected onStateChanged: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
26
|
+
protected onInit: (parameters: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
27
|
+
protected onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
28
28
|
}
|
|
29
29
|
export default GlobalStore;
|
package/GlobalStore.js
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
var t,e;t=this,e=(t,e,o)
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var r={
|
|
4
|
-
/***/266:
|
|
5
|
-
/***/e=>{e.exports=t;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/683:
|
|
8
|
-
/***/t=>{t.exports=e;
|
|
9
|
-
/***/},
|
|
10
|
-
/***/959:
|
|
11
|
-
/***/t=>{t.exports=o;
|
|
12
|
-
/***/}
|
|
13
|
-
/******/},a={};
|
|
14
|
-
/************************************************************************/
|
|
15
|
-
/******/
|
|
16
|
-
/******/
|
|
17
|
-
/******/
|
|
18
|
-
/******/
|
|
19
|
-
/******/function n(t){
|
|
20
|
-
/******/
|
|
21
|
-
/******/var e=a[t];
|
|
22
|
-
/******/if(void 0!==e)
|
|
23
|
-
/******/return e.exports;
|
|
24
|
-
/******/
|
|
25
|
-
/******/
|
|
26
|
-
/******/var o=a[t]={
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/exports:{}
|
|
30
|
-
/******/};
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/
|
|
34
|
-
/******/
|
|
35
|
-
/******/
|
|
36
|
-
/******/return r[t](o,o.exports,n),o.exports;
|
|
37
|
-
/******/}
|
|
38
|
-
/******/
|
|
39
|
-
/************************************************************************/var l={};
|
|
40
|
-
/******/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 o(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)}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function 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.GlobalStore=void 0;var i=n(266),u=n(959),s=n(683),f=function(t){function e(t){var n,l,c,i,f,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),c=this,f=[t,b],i=a(i=e),(n=o(c,r()?Reflect.construct(i,f||[],a(c).constructor):i.apply(c,f))).localStorage=null,n.isLocalStorageAvailable=function(t){return Boolean((null==t?void 0:t.key)&&(null===globalThis||void 0===globalThis?void 0:globalThis.localStorage))},n._onInitialize=function(t){var e=t.setState,o=t.getState;if(n.isLocalStorageAvailable(n.localStorage)){var r=(0,u.getLocalStorageItem)(n.localStorage);if(null===r){var a=o();return(0,s.setLocalStorageItem)(a,n.localStorage)}e(r)}},n._onChange=function(t){var e=t.getState;n.isLocalStorageAvailable(n.localStorage)&&(0,s.setLocalStorageItem)(e(),n.localStorage)},
|
|
41
|
-
/**
|
|
42
|
-
* We set it to null so the instances of the GlobalStoreAbstract can override it.
|
|
43
|
-
*/
|
|
44
|
-
n.onInitialize=null,n.onChange=null,
|
|
45
|
-
/**
|
|
46
|
-
* Instead of calling onInitialize and onChange directly, we call the _onInitialize and _onChange
|
|
47
|
-
* This allows the concat the logic of the GlobalStore with the logic of the extension class.
|
|
48
|
-
*/
|
|
49
|
-
n.onInit=function(t){var e;null===(e=n._onInitialize)||void 0===e||e.call(n,t)},n.onStateChanged=function(t){var e;null===(e=n._onChange)||void 0===e||e.call(n,t)},n.localStorage=null!==(l=b.localStorage)&&void 0!==l?l:null,n.constructor!==e?o(n):(n.initialize(),n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(i.GlobalStoreAbstract);t.GlobalStore=f,t.default=f})(),l;
|
|
50
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./setLocalStorageItem.js"),require("./getLocalStorageItem.js")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/GlobalStoreAbstract","./setLocalStorageItem.js","./getLocalStorageItem.js"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./setLocalStorageItem.js"),require("./getLocalStorageItem.js")):t["react-global-state-hooks"]=e(t["react-hooks-global-states/GlobalStoreAbstract"],t["./setLocalStorageItem.js"],t["./getLocalStorageItem.js"]);
|
|
1
|
+
var t,e;t=this,e=(t,e,o)=>(()=>{"use strict";var r={266:e=>{e.exports=t},683:t=>{t.exports=e},959:t=>{t.exports=o}},a={};function n(t){var e=a[t];if(void 0!==e)return e.exports;var o=a[t]={exports:{}};return r[t](o,o.exports,n),o.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 o(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)}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(r=function(){return!!t})()}function a(t){return a=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},a(t)}function 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.GlobalStore=void 0;var i=n(266),u=n(959),s=n(683),f=function(t){function e(t){var n,l,c,i,f,b=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{metadata:{}};return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),c=this,f=[t,b],i=a(i=e),(n=o(c,r()?Reflect.construct(i,f||[],a(c).constructor):i.apply(c,f))).localStorage=null,n.isLocalStorageAvailable=function(t){return Boolean((null==t?void 0:t.key)&&(null===globalThis||void 0===globalThis?void 0:globalThis.localStorage))},n._onInitialize=function(t){var e=t.setState,o=t.getState;if(n.isLocalStorageAvailable(n.localStorage)){var r=(0,u.getLocalStorageItem)(n.localStorage);if(null===r){var a=o();return(0,s.setLocalStorageItem)(a,n.localStorage)}e(r)}},n._onChange=function(t){var e=t.getState;n.isLocalStorageAvailable(n.localStorage)&&(0,s.setLocalStorageItem)(e(),n.localStorage)},n.onInitialize=null,n.onChange=null,n.onInit=function(t){var e;null===(e=n._onInitialize)||void 0===e||e.call(n,t)},n.onStateChanged=function(t){var e;null===(e=n._onChange)||void 0===e||e.call(n,t)},n.localStorage=null!==(l=b.localStorage)&&void 0!==l?l:null,n.constructor!==e?o(n):(n.initialize(),n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(i.GlobalStoreAbstract);t.GlobalStore=f,t.default=f})(),l})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./setLocalStorageItem.js"),require("./getLocalStorageItem.js")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/GlobalStoreAbstract","./setLocalStorageItem.js","./getLocalStorageItem.js"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/GlobalStoreAbstract"),require("./setLocalStorageItem.js"),require("./getLocalStorageItem.js")):t["react-global-state-hooks"]=e(t["react-hooks-global-states/GlobalStoreAbstract"],t["./setLocalStorageItem.js"],t["./getLocalStorageItem.js"]);
|
package/GlobalStoreAbstract.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActionCollectionConfig, BaseMetadata, StateChanges, StoreTools } from 'react-hooks-global-states/types';
|
|
1
|
+
import { ActionCollectionConfig, ActionCollectionResult, BaseMetadata, StateChanges, StoreTools } from 'react-hooks-global-states/types';
|
|
2
2
|
import { GlobalStore } from './GlobalStore';
|
|
3
|
-
export declare abstract class GlobalStoreAbstract<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> |
|
|
4
|
-
protected onInit: (args: StoreTools<State, Metadata>) => void;
|
|
5
|
-
onStateChanged: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
6
|
-
protected abstract onInitialize: (args: StoreTools<State, Metadata>) => void;
|
|
7
|
-
protected abstract onChange: (args: StoreTools<State, Metadata> & StateChanges<State>) => void;
|
|
3
|
+
export declare abstract class GlobalStoreAbstract<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>> extends GlobalStore<State, Metadata, ActionsConfig> {
|
|
4
|
+
protected onInit: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
5
|
+
onStateChanged: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
6
|
+
protected abstract onInitialize: (args: StoreTools<State, PublicStateMutator, Metadata>) => void;
|
|
7
|
+
protected abstract onChange: (args: StoreTools<State, PublicStateMutator, Metadata> & StateChanges<State>) => void;
|
|
8
8
|
}
|
|
9
9
|
export default GlobalStoreAbstract;
|
package/GlobalStoreAbstract.js
CHANGED
|
@@ -1,35 +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){var o;t._onInitialize(e),null===(o=t.onInitialize)||void 0===o||o.call(t,e)},t.onStateChanged=function(e){var o;t._onInitialize(e),null===(o=t.onChange)||void 0===o||o.call(t,e)},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(r,t),n=r,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(r(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),n;
|
|
35
|
-
/******/})(),"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-global-state-hooks"]=t(require("./GlobalStore.js")):this["react-global-state-hooks"]=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){var o;t._onInitialize(e),null===(o=t.onInitialize)||void 0===o||o.call(t,e)},t.onStateChanged=function(e){var o;t._onInitialize(e),null===(o=t.onChange)||void 0===o||o.call(t,e)},t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(r,t),n=r,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(r(778).GlobalStore);t.GlobalStoreAbstract=u,t.default=u})(),n})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("./GlobalStore.js")):this["react-global-state-hooks"]=t(this["./GlobalStore.js"]);
|
package/bundle.js
CHANGED
|
@@ -1,62 +1 @@
|
|
|
1
|
-
var e,t;e=this,t=(e,t,r,o,a,n,l,s,i,c)
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var u={
|
|
4
|
-
/***/78:
|
|
5
|
-
/***/t=>{t.exports=e;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/361:
|
|
8
|
-
/***/e=>{e.exports=t;
|
|
9
|
-
/***/},
|
|
10
|
-
/***/487:
|
|
11
|
-
/***/e=>{e.exports=r;
|
|
12
|
-
/***/},
|
|
13
|
-
/***/623:
|
|
14
|
-
/***/e=>{e.exports=o;
|
|
15
|
-
/***/},
|
|
16
|
-
/***/670:
|
|
17
|
-
/***/e=>{e.exports=a;
|
|
18
|
-
/***/},
|
|
19
|
-
/***/673:
|
|
20
|
-
/***/e=>{e.exports=n;
|
|
21
|
-
/***/},
|
|
22
|
-
/***/683:
|
|
23
|
-
/***/e=>{e.exports=l;
|
|
24
|
-
/***/},
|
|
25
|
-
/***/778:
|
|
26
|
-
/***/e=>{e.exports=s;
|
|
27
|
-
/***/},
|
|
28
|
-
/***/804:
|
|
29
|
-
/***/e=>{e.exports=i;
|
|
30
|
-
/***/},
|
|
31
|
-
/***/959:
|
|
32
|
-
/***/e=>{e.exports=c;
|
|
33
|
-
/***/}
|
|
34
|
-
/******/},b={};
|
|
35
|
-
/************************************************************************/
|
|
36
|
-
/******/
|
|
37
|
-
/******/
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/function j(e){
|
|
41
|
-
/******/
|
|
42
|
-
/******/var t=b[e];
|
|
43
|
-
/******/if(void 0!==t)
|
|
44
|
-
/******/return t.exports;
|
|
45
|
-
/******/
|
|
46
|
-
/******/
|
|
47
|
-
/******/var r=b[e]={
|
|
48
|
-
/******/
|
|
49
|
-
/******/
|
|
50
|
-
/******/exports:{}
|
|
51
|
-
/******/};
|
|
52
|
-
/******/
|
|
53
|
-
/******/
|
|
54
|
-
/******/
|
|
55
|
-
/******/
|
|
56
|
-
/******/
|
|
57
|
-
/******/return u[e](r,r.exports,j),r.exports;
|
|
58
|
-
/******/}
|
|
59
|
-
/******/
|
|
60
|
-
/************************************************************************/var g={};
|
|
61
|
-
/******/return(()=>{var e=g;Object.defineProperty(e,"__esModule",{value:!0}),e.setLocalStorageItem=e.getLocalStorageItem=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var t=j(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return t.shallowCompare}});var r=j(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return r.uniqueId}});var o=j(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}});var a=j(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return a.isRecord}});var n=j(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return n.createContext}});var l=j(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return l.GlobalStore}});var s=j(804);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return s.GlobalStoreAbstract}});var i=j(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return i.createGlobalState}});var c=j(959);Object.defineProperty(e,"getLocalStorageItem",{enumerable:!0,get:function(){return c.getLocalStorageItem}});var u=j(683);Object.defineProperty(e,"setLocalStorageItem",{enumerable:!0,get:function(){return u.setLocalStorageItem}})})(),g;
|
|
62
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./setLocalStorageItem.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./getLocalStorageItem.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./setLocalStorageItem.js","./GlobalStore.js","./GlobalStoreAbstract.js","./getLocalStorageItem.js"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./setLocalStorageItem.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./getLocalStorageItem.js")):e["react-global-state-hooks"]=t(e["./uniqueId.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./setLocalStorageItem.js"],e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"],e["./getLocalStorageItem.js"]);
|
|
1
|
+
var e,t;e=this,t=(e,t,r,o,a,n,l,s,i,c)=>(()=>{"use strict";var u={78:t=>{t.exports=e},361:e=>{e.exports=t},487:e=>{e.exports=r},623:e=>{e.exports=o},670:e=>{e.exports=a},673:e=>{e.exports=n},683:e=>{e.exports=l},778:e=>{e.exports=s},804:e=>{e.exports=i},959:e=>{e.exports=c}},b={};function j(e){var t=b[e];if(void 0!==t)return t.exports;var r=b[e]={exports:{}};return u[e](r,r.exports,j),r.exports}var g={};return(()=>{var e=g;Object.defineProperty(e,"__esModule",{value:!0}),e.setLocalStorageItem=e.getLocalStorageItem=e.createGlobalState=e.GlobalStoreAbstract=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var t=j(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return t.shallowCompare}});var r=j(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return r.uniqueId}});var o=j(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}});var a=j(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return a.isRecord}});var n=j(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return n.createContext}});var l=j(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return l.GlobalStore}});var s=j(804);Object.defineProperty(e,"GlobalStoreAbstract",{enumerable:!0,get:function(){return s.GlobalStoreAbstract}});var i=j(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return i.createGlobalState}});var c=j(959);Object.defineProperty(e,"getLocalStorageItem",{enumerable:!0,get:function(){return c.getLocalStorageItem}});var u=j(683);Object.defineProperty(e,"setLocalStorageItem",{enumerable:!0,get:function(){return u.setLocalStorageItem}})})(),g})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./setLocalStorageItem.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./getLocalStorageItem.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./setLocalStorageItem.js","./GlobalStore.js","./GlobalStoreAbstract.js","./getLocalStorageItem.js"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("./uniqueId.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./setLocalStorageItem.js"),require("./GlobalStore.js"),require("./GlobalStoreAbstract.js"),require("./getLocalStorageItem.js")):e["react-global-state-hooks"]=t(e["./uniqueId.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./setLocalStorageItem.js"],e["./GlobalStore.js"],e["./GlobalStoreAbstract.js"],e["./getLocalStorageItem.js"]);
|
package/createContext.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type
|
|
1
|
+
export { type ContextProvider, type ContextHook, type InferContextApi, createContext, default, } from 'react-hooks-global-states/createContext';
|
package/createContext.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var t={
|
|
4
|
-
/***/407:
|
|
5
|
-
/***/t=>{t.exports=e;
|
|
6
|
-
/***/}
|
|
7
|
-
/******/},o={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(e){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var a=o[e];
|
|
16
|
-
/******/if(void 0!==a)
|
|
17
|
-
/******/return a.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var s=o[e]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return t[e](s,s.exports,r),s.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var a={};
|
|
34
|
-
/******/return(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.createContext=void 0;var t=r(407);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return t.createContext}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),a;
|
|
35
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/createContext")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/createContext"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/createContext")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/createContext"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={407:t=>{t.exports=e}},o={};function r(e){var a=o[e];if(void 0!==a)return a.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,r),s.exports}var a={};return(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.createContext=void 0;var t=r(407);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return t.createContext}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),a})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/createContext")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/createContext"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/createContext")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/createContext"]);
|
package/createGlobalState.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type React from 'react';
|
|
|
2
2
|
import { StateHook, BaseMetadata, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks } from 'react-hooks-global-states/types';
|
|
3
3
|
export type { InferActionsType } from 'react-hooks-global-states/createGlobalState';
|
|
4
4
|
import { LocalStorageConfig } from './types';
|
|
5
|
-
|
|
5
|
+
interface CreateGlobalState {
|
|
6
6
|
/**
|
|
7
7
|
* Creates a global state hook.
|
|
8
8
|
* @param state initial state value
|
|
@@ -22,7 +22,7 @@ export interface CreateGlobalState {
|
|
|
22
22
|
* );
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
|
-
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>,
|
|
25
|
+
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>, BaseMetadata>;
|
|
26
26
|
/**
|
|
27
27
|
* Creates a global state hook that you can use across your application
|
|
28
28
|
* @param state initial state value
|
|
@@ -73,13 +73,13 @@ export interface CreateGlobalState {
|
|
|
73
73
|
* }
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
|
-
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig
|
|
76
|
+
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata> | null | {}, PublicStateMutator = keyof ActionsConfig extends never | undefined ? React.Dispatch<React.SetStateAction<State>> : ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
77
77
|
name?: string;
|
|
78
78
|
metadata?: Metadata;
|
|
79
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
79
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
80
80
|
actions?: ActionsConfig;
|
|
81
81
|
localStorage?: LocalStorageConfig;
|
|
82
|
-
}): StateHook<State,
|
|
82
|
+
}): StateHook<State, PublicStateMutator, Metadata>;
|
|
83
83
|
/**
|
|
84
84
|
* Creates a global state hook that you can use across your application
|
|
85
85
|
* @param state initial state value
|
|
@@ -130,13 +130,13 @@ export interface CreateGlobalState {
|
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
133
|
-
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>,
|
|
133
|
+
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>, PublicStateMutator = ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
134
134
|
name?: string;
|
|
135
135
|
metadata?: Metadata;
|
|
136
|
-
callbacks?: GlobalStoreCallbacks<State, Metadata>;
|
|
136
|
+
callbacks?: GlobalStoreCallbacks<State, PublicStateMutator, Metadata>;
|
|
137
137
|
actions: ActionsConfig;
|
|
138
138
|
localStorage?: LocalStorageConfig;
|
|
139
|
-
}): StateHook<State,
|
|
139
|
+
}): StateHook<State, PublicStateMutator, Metadata>;
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* Creates a global state hook.
|
package/createGlobalState.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var t={
|
|
4
|
-
/***/778:
|
|
5
|
-
/***/t=>{t.exports=e;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/840:
|
|
8
|
-
/***/(e,t,o)=>{function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(n=function(){return!!e})()}Object.defineProperty(t,"__esModule",{value:!0}),t.createGlobalState=void 0;var a=o(778);
|
|
9
|
-
/**
|
|
10
|
-
* Creates a global state hook.
|
|
11
|
-
* @param state - The initial state value.
|
|
12
|
-
* @param args - Optional configuration arguments.
|
|
13
|
-
* @returns A state hook for managing the global state, the hook also embeds the state api methods.
|
|
14
|
-
*/t.createGlobalState=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return function(e,t,o){if(n())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,t);var l=new(e.bind.apply(e,a));return o&&r(l,o.prototype),l}(a.GlobalStore,t).use},t.default=t.createGlobalState}
|
|
15
|
-
/******/},o={};
|
|
16
|
-
/************************************************************************/
|
|
17
|
-
/******/
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/return function e(r){
|
|
24
|
-
/******/
|
|
25
|
-
/******/var n=o[r];
|
|
26
|
-
/******/if(void 0!==n)
|
|
27
|
-
/******/return n.exports;
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/var a=o[r]={
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/exports:{}
|
|
34
|
-
/******/};
|
|
35
|
-
/******/
|
|
36
|
-
/******/
|
|
37
|
-
/******/
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/return t[r](a,a.exports,e),a.exports;
|
|
41
|
-
/******/}
|
|
42
|
-
/******/
|
|
43
|
-
/************************************************************************/
|
|
44
|
-
/******/
|
|
45
|
-
/******/
|
|
46
|
-
/******/
|
|
47
|
-
/******/
|
|
48
|
-
/******/(840);
|
|
49
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("./GlobalStore.js")):this["react-global-state-hooks"]=e(this["./GlobalStore.js"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={778:t=>{t.exports=e},840:(e,t,o)=>{function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}function n(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(n=function(){return!!e})()}Object.defineProperty(t,"__esModule",{value:!0}),t.createGlobalState=void 0;var a=o(778);t.createGlobalState=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return function(e,t,o){if(n())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,t);var l=new(e.bind.apply(e,a));return o&&r(l,o.prototype),l}(a.GlobalStore,t).use},t.default=t.createGlobalState}},o={};return function e(r){var n=o[r];if(void 0!==n)return n.exports;var a=o[r]={exports:{}};return t[r](a,a.exports,e),a.exports}(840)})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./GlobalStore.js"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("./GlobalStore.js")):this["react-global-state-hooks"]=e(this["./GlobalStore.js"]);
|
package/getLocalStorageItem.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
var t;t=t
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var e={
|
|
4
|
-
/***/330:
|
|
5
|
-
/***/e=>{e.exports=t;
|
|
6
|
-
/***/},
|
|
7
|
-
/***/527:
|
|
8
|
-
/***/(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalStorageItem=void 0;var o=r(330);e.getLocalStorageItem=function(t){var e=t.key;if(!e)return null;var r="function"==typeof e?e():e,a=localStorage.getItem(r);if(null===a)return null;var n=t.decrypt||t.encrypt?"function"==typeof t.decrypt?t.decrypt(a):atob(a):a;return(0,o.formatFromStore)(n,{jsonParse:!0})},e.default=e.getLocalStorageItem}
|
|
9
|
-
/******/},r={};
|
|
10
|
-
/************************************************************************/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/
|
|
14
|
-
/******/
|
|
15
|
-
/******/
|
|
16
|
-
/******/
|
|
17
|
-
/******/return function t(o){
|
|
18
|
-
/******/
|
|
19
|
-
/******/var a=r[o];
|
|
20
|
-
/******/if(void 0!==a)
|
|
21
|
-
/******/return a.exports;
|
|
22
|
-
/******/
|
|
23
|
-
/******/
|
|
24
|
-
/******/var n=r[o]={
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/exports:{}
|
|
28
|
-
/******/};
|
|
29
|
-
/******/
|
|
30
|
-
/******/
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/
|
|
34
|
-
/******/return e[o](n,n.exports,t),n.exports;
|
|
35
|
-
/******/}
|
|
36
|
-
/******/
|
|
37
|
-
/************************************************************************/
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/
|
|
42
|
-
/******/(527);
|
|
43
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/formatFromStore")):"function"==typeof define&&define.amd?define(["json-storage-formatter/formatFromStore"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("json-storage-formatter/formatFromStore")):this["react-global-state-hooks"]=t(this["json-storage-formatter/formatFromStore"]);
|
|
1
|
+
var t;t=t=>(()=>{"use strict";var e={330:e=>{e.exports=t},527:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalStorageItem=void 0;var o=r(330);e.getLocalStorageItem=function(t){var e=t.key;if(!e)return null;var r="function"==typeof e?e():e,a=localStorage.getItem(r);if(null===a)return null;var n=t.decrypt||t.encrypt?"function"==typeof t.decrypt?t.decrypt(a):atob(a):a;return(0,o.formatFromStore)(n,{jsonParse:!0})},e.default=e.getLocalStorageItem}},r={};return function t(o){var a=r[o];if(void 0!==a)return a.exports;var n=r[o]={exports:{}};return e[o](n,n.exports,t),n.exports}(527)})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/formatFromStore")):"function"==typeof define&&define.amd?define(["json-storage-formatter/formatFromStore"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("json-storage-formatter/formatFromStore")):this["react-global-state-hooks"]=t(this["json-storage-formatter/formatFromStore"]);
|
package/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* By handling the same structure as the original library,
|
|
3
3
|
* We can add the specific overrides for web while keeping the modularity of the library.
|
|
4
4
|
*/
|
|
5
|
-
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks,
|
|
5
|
+
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, BaseMetadata, MetadataGetter, SelectorCallback, SubscriberParameters, SubscriptionCallback, StateHook, ActionCollectionConfig, } from './types';
|
|
6
6
|
export { shallowCompare } from './shallowCompare';
|
|
7
7
|
export { uniqueId } from './uniqueId';
|
|
8
8
|
export { throwWrongKeyOnActionCollectionConfig } from './throwWrongKeyOnActionCollectionConfig';
|
|
9
9
|
export { isRecord } from './isRecord';
|
|
10
|
-
export { type
|
|
10
|
+
export { type ContextProvider, type ContextHook, type InferContextApi, createContext } from './createContext';
|
|
11
11
|
export { type LocalStorageConfig } from './types';
|
|
12
12
|
export { GlobalStore } from './GlobalStore';
|
|
13
13
|
export { GlobalStoreAbstract } from './GlobalStoreAbstract';
|
package/isRecord.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var t={
|
|
4
|
-
/***/93:
|
|
5
|
-
/***/t=>{t.exports=e;
|
|
6
|
-
/***/}
|
|
7
|
-
/******/},o={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(e){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var s=o[e];
|
|
16
|
-
/******/if(void 0!==s)
|
|
17
|
-
/******/return s.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var a=o[e]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return t[e](a,a.exports,r),a.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var s={};
|
|
34
|
-
/******/return(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.isRecord=void 0;var t=r(93);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return t.isRecord}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),s;
|
|
35
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/isRecord")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/isRecord"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/isRecord")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/isRecord"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={93:t=>{t.exports=e}},o={};function r(e){var s=o[e];if(void 0!==s)return s.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}var s={};return(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.isRecord=void 0;var t=r(93);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return t.isRecord}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),s})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/isRecord")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/isRecord"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/isRecord")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/isRecord"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-global-state-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "This is a package to easily handling global-state across your react components No-redux, No-context.",
|
|
5
5
|
"main": "./bundle.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -148,6 +148,6 @@
|
|
|
148
148
|
"react": ">=18.0.0"
|
|
149
149
|
},
|
|
150
150
|
"dependencies": {
|
|
151
|
-
"react-hooks-global-states": "^
|
|
151
|
+
"react-hooks-global-states": "^12.0.0"
|
|
152
152
|
}
|
|
153
153
|
}
|
package/setLocalStorageItem.js
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
var t;t=t
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var e={
|
|
4
|
-
/***/339:
|
|
5
|
-
/***/(t,e,o)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setLocalStorageItem=void 0;var r=o(413);e.setLocalStorageItem=function(t,e){var o=e.key;if(o){var a="function"==typeof o?o():o,s=(0,r.formatToStore)(t,{stringify:!0,excludeTypes:["function"]}),f=e.encrypt?"function"==typeof e.encrypt?e.encrypt(s):btoa(s):s;localStorage.setItem(a,f)}},e.default=e.setLocalStorageItem},
|
|
6
|
-
/***/413:
|
|
7
|
-
/***/e=>{e.exports=t;
|
|
8
|
-
/***/}
|
|
9
|
-
/******/},o={};
|
|
10
|
-
/************************************************************************/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/
|
|
14
|
-
/******/
|
|
15
|
-
/******/
|
|
16
|
-
/******/
|
|
17
|
-
/******/return function t(r){
|
|
18
|
-
/******/
|
|
19
|
-
/******/var a=o[r];
|
|
20
|
-
/******/if(void 0!==a)
|
|
21
|
-
/******/return a.exports;
|
|
22
|
-
/******/
|
|
23
|
-
/******/
|
|
24
|
-
/******/var s=o[r]={
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/exports:{}
|
|
28
|
-
/******/};
|
|
29
|
-
/******/
|
|
30
|
-
/******/
|
|
31
|
-
/******/
|
|
32
|
-
/******/
|
|
33
|
-
/******/
|
|
34
|
-
/******/return e[r](s,s.exports,t),s.exports;
|
|
35
|
-
/******/}
|
|
36
|
-
/******/
|
|
37
|
-
/************************************************************************/
|
|
38
|
-
/******/
|
|
39
|
-
/******/
|
|
40
|
-
/******/
|
|
41
|
-
/******/
|
|
42
|
-
/******/(339);
|
|
43
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/formatToStore")):"function"==typeof define&&define.amd?define(["json-storage-formatter/formatToStore"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("json-storage-formatter/formatToStore")):this["react-global-state-hooks"]=t(this["json-storage-formatter/formatToStore"]);
|
|
1
|
+
var t;t=t=>(()=>{"use strict";var e={339:(t,e,o)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setLocalStorageItem=void 0;var r=o(413);e.setLocalStorageItem=function(t,e){var o=e.key;if(o){var a="function"==typeof o?o():o,s=(0,r.formatToStore)(t,{stringify:!0,excludeTypes:["function"]}),f=e.encrypt?"function"==typeof e.encrypt?e.encrypt(s):btoa(s):s;localStorage.setItem(a,f)}},e.default=e.setLocalStorageItem},413:e=>{e.exports=t}},o={};return function t(r){var a=o[r];if(void 0!==a)return a.exports;var s=o[r]={exports:{}};return e[r](s,s.exports,t),s.exports}(339)})(),"object"==typeof exports&&"object"==typeof module?module.exports=t(require("json-storage-formatter/formatToStore")):"function"==typeof define&&define.amd?define(["json-storage-formatter/formatToStore"],t):"object"==typeof exports?exports["react-global-state-hooks"]=t(require("json-storage-formatter/formatToStore")):this["react-global-state-hooks"]=t(this["json-storage-formatter/formatToStore"]);
|
package/shallowCompare.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var o={
|
|
4
|
-
/***/859:
|
|
5
|
-
/***/o=>{o.exports=e;
|
|
6
|
-
/***/}
|
|
7
|
-
/******/},t={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(e){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var a=t[e];
|
|
16
|
-
/******/if(void 0!==a)
|
|
17
|
-
/******/return a.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var s=t[e]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return o[e](s,s.exports,r),s.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var a={};
|
|
34
|
-
/******/return(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.shallowCompare=void 0;var o=r(859);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return o.shallowCompare}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=o,e&&e.__esModule?e:{default:e}).default;var e}})})(),a;
|
|
35
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/shallowCompare")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/shallowCompare"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/shallowCompare")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/shallowCompare"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var o={859:o=>{o.exports=e}},t={};function r(e){var a=t[e];if(void 0!==a)return a.exports;var s=t[e]={exports:{}};return o[e](s,s.exports,r),s.exports}var a={};return(()=>{var e=a;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.shallowCompare=void 0;var o=r(859);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return o.shallowCompare}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=o,e&&e.__esModule?e:{default:e}).default;var e}})})(),a})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/shallowCompare")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/shallowCompare"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/shallowCompare")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/shallowCompare"]);
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var o={
|
|
4
|
-
/***/637:
|
|
5
|
-
/***/o=>{o.exports=e;
|
|
6
|
-
/***/}
|
|
7
|
-
/******/},t={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(e){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var n=t[e];
|
|
16
|
-
/******/if(void 0!==n)
|
|
17
|
-
/******/return n.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var i=t[e]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return o[e](i,i.exports,r),i.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var n={};
|
|
34
|
-
/******/return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.throwWrongKeyOnActionCollectionConfig=void 0;var o=r(637);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=o,e&&e.__esModule?e:{default:e}).default;var e}})})(),n;
|
|
35
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var o={637:o=>{o.exports=e}},t={};function r(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.throwWrongKeyOnActionCollectionConfig=void 0;var o=r(637);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return o.throwWrongKeyOnActionCollectionConfig}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=o,e&&e.__esModule?e:{default:e}).default;var e}})})(),n})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"]);
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks,
|
|
1
|
+
export type { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, BaseMetadata, MetadataGetter, SelectorCallback, SubscriberParameters, SubscriptionCallback, StateHook, ActionCollectionConfig, } from 'react-hooks-global-states/types';
|
|
2
2
|
export type LocalStorageConfig = {
|
|
3
3
|
key: string | (() => string);
|
|
4
4
|
/**
|
package/types.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
var e;e=()
|
|
2
|
-
/******/"use strict";var e={};
|
|
3
|
-
/******/return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0})})(),e;
|
|
4
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["react-global-state-hooks"]=e():this["react-global-state-hooks"]=e();
|
|
1
|
+
var e;e=()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0})})(),e})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["react-global-state-hooks"]=e():this["react-global-state-hooks"]=e();
|
package/uniqueId.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var e;e=e
|
|
2
|
-
/******/"use strict";
|
|
3
|
-
/******/var t={
|
|
4
|
-
/***/366:
|
|
5
|
-
/***/t=>{t.exports=e;
|
|
6
|
-
/***/}
|
|
7
|
-
/******/},o={};
|
|
8
|
-
/************************************************************************/
|
|
9
|
-
/******/
|
|
10
|
-
/******/
|
|
11
|
-
/******/
|
|
12
|
-
/******/
|
|
13
|
-
/******/function r(e){
|
|
14
|
-
/******/
|
|
15
|
-
/******/var u=o[e];
|
|
16
|
-
/******/if(void 0!==u)
|
|
17
|
-
/******/return u.exports;
|
|
18
|
-
/******/
|
|
19
|
-
/******/
|
|
20
|
-
/******/var a=o[e]={
|
|
21
|
-
/******/
|
|
22
|
-
/******/
|
|
23
|
-
/******/exports:{}
|
|
24
|
-
/******/};
|
|
25
|
-
/******/
|
|
26
|
-
/******/
|
|
27
|
-
/******/
|
|
28
|
-
/******/
|
|
29
|
-
/******/
|
|
30
|
-
/******/return t[e](a,a.exports,r),a.exports;
|
|
31
|
-
/******/}
|
|
32
|
-
/******/
|
|
33
|
-
/************************************************************************/var u={};
|
|
34
|
-
/******/return(()=>{var e=u;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.uniqueId=void 0;var t=r(366);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return t.uniqueId}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),u;
|
|
35
|
-
/******/})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/uniqueId")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/uniqueId"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/uniqueId")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/uniqueId"]);
|
|
1
|
+
var e;e=e=>(()=>{"use strict";var t={366:t=>{t.exports=e}},o={};function r(e){var u=o[e];if(void 0!==u)return u.exports;var a=o[e]={exports:{}};return t[e](a,a.exports,r),a.exports}var u={};return(()=>{var e=u;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.uniqueId=void 0;var t=r(366);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return t.uniqueId}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return(e=t,e&&e.__esModule?e:{default:e}).default;var e}})})(),u})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react-hooks-global-states/uniqueId")):"function"==typeof define&&define.amd?define(["react-hooks-global-states/uniqueId"],e):"object"==typeof exports?exports["react-global-state-hooks"]=e(require("react-hooks-global-states/uniqueId")):this["react-global-state-hooks"]=e(this["react-hooks-global-states/uniqueId"]);
|
package/webpack.config.js
CHANGED
|
@@ -121,11 +121,8 @@ module.exports = {
|
|
|
121
121
|
toplevel: true,
|
|
122
122
|
properties: false,
|
|
123
123
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
comments: (_node, comment) => {
|
|
127
|
-
return comment.type === 'comment2' && comment.value.startsWith('*');
|
|
128
|
-
},
|
|
124
|
+
format: {
|
|
125
|
+
comments: false,
|
|
129
126
|
},
|
|
130
127
|
},
|
|
131
128
|
}),
|