react-native-global-state-hooks 15.0.2 → 16.0.3-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GlobalStore.cjs +5 -0
- package/GlobalStore.d.ts +3 -3
- package/GlobalStore.js +5 -1
- package/GlobalStore.mjs +5 -0
- package/README.md +1209 -202
- package/actions.cjs +1 -0
- package/actions.d.ts +1 -0
- package/actions.js +1 -0
- package/actions.mjs +1 -0
- package/asyncStorageWrapper.cjs +4 -0
- package/asyncStorageWrapper.js +4 -1
- package/asyncStorageWrapper.mjs +4 -0
- package/bundle.cjs +1 -0
- package/bundle.js +1 -1
- package/bundle.mjs +1 -0
- package/createContext.cjs +1 -0
- package/createContext.js +1 -1
- package/createContext.mjs +1 -0
- package/createGlobalState.cjs +1 -0
- package/createGlobalState.d.ts +8 -8
- package/createGlobalState.js +1 -1
- package/createGlobalState.mjs +1 -0
- package/index.d.ts +11 -10
- package/isPromise.cjs +1 -0
- package/isPromise.js +1 -0
- package/isPromise.mjs +1 -0
- package/isRecord.cjs +1 -0
- package/isRecord.js +1 -1
- package/isRecord.mjs +1 -0
- package/package.json +48 -90
- package/shallowCompare.cjs +1 -0
- package/shallowCompare.js +1 -1
- package/shallowCompare.mjs +1 -0
- package/throwWrongKeyOnActionCollectionConfig.cjs +1 -0
- package/throwWrongKeyOnActionCollectionConfig.js +1 -1
- package/throwWrongKeyOnActionCollectionConfig.mjs +1 -0
- package/tryCatch.cjs +1 -0
- package/tryCatch.js +1 -0
- package/tryCatch.mjs +1 -0
- package/types.cjs +1 -0
- package/types.d.ts +15 -4
- package/types.js +1 -1
- package/types.mjs +0 -0
- package/uniqueId.cjs +1 -0
- package/uniqueId.d.ts +1 -1
- package/uniqueId.js +1 -1
- package/uniqueId.mjs +1 -0
- package/webpack.config.js +0 -132
package/actions.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.create;var f=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var s=(o,t)=>{for(var a in t)f(o,a,{get:t[a],enumerable:!0})},d=(o,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of m(t))!p.call(o,e)&&e!==a&&f(o,e,{get:()=>t[e],enumerable:!(c=l(t,e))||c.enumerable});return o};var u=(o,t,a)=>(a=o!=null?i(n(o)):{},d(t||!o||!o.__esModule?f(a,"default",{value:o,enumerable:!0}):a,o)),x=o=>d(f({},"__esModule",{value:!0}),o);var b={};s(b,{actions:()=>r.actions,default:()=>r.default});module.exports=x(b);var r=u(require("react-hooks-global-states/actions"));
|
package/actions.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { actions, default } from "react-hooks-global-states/actions";
|
package/actions.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.create;var f=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var s=(o,t)=>{for(var a in t)f(o,a,{get:t[a],enumerable:!0})},d=(o,t,a,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of m(t))!p.call(o,e)&&e!==a&&f(o,e,{get:()=>t[e],enumerable:!(c=l(t,e))||c.enumerable});return o};var u=(o,t,a)=>(a=o!=null?i(n(o)):{},d(t||!o||!o.__esModule?f(a,"default",{value:o,enumerable:!0}):a,o)),x=o=>d(f({},"__esModule",{value:!0}),o);var b={};s(b,{actions:()=>r.actions,default:()=>r.default});module.exports=x(b);var r=u(require("react-hooks-global-states/actions"));
|
package/actions.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{actions as a,default as e}from"react-hooks-global-states/actions";export{a as actions,e as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";var y=Object.create;var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var S=(e,a)=>{for(var t in a)g(e,t,{get:a[t],enumerable:!0})},d=(e,a,t,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of u(a))!M.call(e,s)&&s!==t&&g(e,s,{get:()=>a[s],enumerable:!(o=m(a,s))||o.enumerable});return e};var w=(e,a,t)=>(t=e!=null?y(p(e)):{},d(a||!e||!e.__esModule?g(t,"default",{value:e,enumerable:!0}):t,e)),A=e=>d(g({},"__esModule",{value:!0}),e);var v={};S(v,{default:()=>f});module.exports=A(v);var h=(()=>{let e="pending",a=null,t=null;(async()=>{try{let r=import("@react-native-async-storage/async-storage");a=r;let{default:n}=await r,{getItem:c,setItem:l}=n;c.bind(n),l.bind(n),t={getItem:c,setItem:l},e="resolved"}catch(r){process.env.NODE_ENV==="development"&&console.warn(r),e="rejected"}finally{a=null}})();let o=()=>{throw new Error(`[AsyncStorageManager Not Found]
|
|
2
|
+
|
|
3
|
+
Please install the react-native-async-storage/async-storage to be use as the default async storage manager or
|
|
4
|
+
add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.`)},s=async r=>{try{e==="pending"&&a&&await a.catch(()=>{}),e="pending";let n=r();a=n,t=await n,e="resolved"}catch(n){throw a=null,e="rejected",n}},i=async()=>(e==="pending"&&a&&await a,e==="rejected"&&a&&await a.catch(r=>{throw r}),t||o());return{getItem:async r=>(await i()).getItem(r),setItem:async(r,n)=>(await i()).setItem(r,n),addAsyncStorageManager:s}})(),f=h;
|
package/asyncStorageWrapper.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var y=Object.create;var g=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var S=(e,a)=>{for(var t in a)g(e,t,{get:a[t],enumerable:!0})},d=(e,a,t,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let s of u(a))!M.call(e,s)&&s!==t&&g(e,s,{get:()=>a[s],enumerable:!(o=m(a,s))||o.enumerable});return e};var w=(e,a,t)=>(t=e!=null?y(p(e)):{},d(a||!e||!e.__esModule?g(t,"default",{value:e,enumerable:!0}):t,e)),A=e=>d(g({},"__esModule",{value:!0}),e);var v={};S(v,{default:()=>f});module.exports=A(v);var h=(()=>{let e="pending",a=null,t=null;(async()=>{try{let r=import("@react-native-async-storage/async-storage");a=r;let{default:n}=await r,{getItem:c,setItem:l}=n;c.bind(n),l.bind(n),t={getItem:c,setItem:l},e="resolved"}catch(r){process.env.NODE_ENV==="development"&&console.warn(r),e="rejected"}finally{a=null}})();let o=()=>{throw new Error(`[AsyncStorageManager Not Found]
|
|
2
|
+
|
|
3
|
+
Please install the react-native-async-storage/async-storage to be use as the default async storage manager or
|
|
4
|
+
add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.`)},s=async r=>{try{e==="pending"&&a&&await a.catch(()=>{}),e="pending";let n=r();a=n,t=await n,e="resolved"}catch(n){throw a=null,e="rejected",n}},i=async()=>(e==="pending"&&a&&await a,e==="rejected"&&a&&await a.catch(r=>{throw r}),t||o());return{getItem:async r=>(await i()).getItem(r),setItem:async(r,n)=>(await i()).setItem(r,n),addAsyncStorageManager:s}})(),f=h;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var l=(()=>{let r="pending",t=null,n=null;(async()=>{try{let e=import("@react-native-async-storage/async-storage");t=e;let{default:a}=await e,{getItem:s,setItem:g}=a;s.bind(a),g.bind(a),n={getItem:s,setItem:g},r="resolved"}catch(e){process.env.NODE_ENV==="development"&&console.warn(e),r="rejected"}finally{t=null}})();let c=()=>{throw new Error(`[AsyncStorageManager Not Found]
|
|
2
|
+
|
|
3
|
+
Please install the react-native-async-storage/async-storage to be use as the default async storage manager or
|
|
4
|
+
add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.`)},i=async e=>{try{r==="pending"&&t&&await t.catch(()=>{}),r="pending";let a=e();t=a,n=await a,r="resolved"}catch(a){throw t=null,r="rejected",a}},o=async()=>(r==="pending"&&t&&await t,r==="rejected"&&t&&await t.catch(e=>{throw e}),n||c());return{getItem:async e=>(await o()).getItem(e),setItem:async(e,a)=>(await o()).setItem(e,a),addAsyncStorageManager:i}})(),m=l;export{m as default};
|
package/bundle.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of y(t))!k.call(e,a)&&a!==o&&n(e,a,{get:()=>t[a],enumerable:!(r=u(t,a))||r.enumerable});return e};var i=(e,t,o)=>(o=e!=null?d(m(e)):{},l(t||!e||!e.__esModule?n(o,"default",{value:e,enumerable:!0}):o,e)),I=e=>l(n({},"__esModule",{value:!0}),e);var R={};g(R,{GlobalStore:()=>S.default,actions:()=>b.actions,asyncStorageWrapper:()=>A.default,createContext:()=>x.createContext,createGlobalState:()=>f.createGlobalState,isRecord:()=>p.isRecord,shallowCompare:()=>c.shallowCompare,throwWrongKeyOnActionCollectionConfig:()=>C.throwWrongKeyOnActionCollectionConfig,uniqueId:()=>s.uniqueId});module.exports=I(R);var c=require("./shallowCompare.cjs"),s=require("./uniqueId.cjs"),C=require("./throwWrongKeyOnActionCollectionConfig.cjs"),p=require("./isRecord.cjs"),b=require("./actions.cjs"),x=require("./createContext.cjs"),S=i(require("./GlobalStore.cjs")),f=require("./createGlobalState.cjs"),A=i(require("./asyncStorageWrapper.cjs"));
|
package/bundle.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var d=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},l=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of y(t))!k.call(e,a)&&a!==o&&n(e,a,{get:()=>t[a],enumerable:!(r=u(t,a))||r.enumerable});return e};var i=(e,t,o)=>(o=e!=null?d(m(e)):{},l(t||!e||!e.__esModule?n(o,"default",{value:e,enumerable:!0}):o,e)),I=e=>l(n({},"__esModule",{value:!0}),e);var R={};g(R,{GlobalStore:()=>S.default,actions:()=>b.actions,asyncStorageWrapper:()=>A.default,createContext:()=>x.createContext,createGlobalState:()=>f.createGlobalState,isRecord:()=>p.isRecord,shallowCompare:()=>c.shallowCompare,throwWrongKeyOnActionCollectionConfig:()=>C.throwWrongKeyOnActionCollectionConfig,uniqueId:()=>s.uniqueId});module.exports=I(R);var c=require("./shallowCompare.js"),s=require("./uniqueId.js"),C=require("./throwWrongKeyOnActionCollectionConfig.js"),p=require("./isRecord.js"),b=require("./actions.js"),x=require("./createContext.js"),S=i(require("./GlobalStore.js")),f=require("./createGlobalState.js"),A=i(require("./asyncStorageWrapper.js"));
|
package/bundle.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowCompare as o}from"./shallowCompare.mjs";import{uniqueId as n}from"./uniqueId.mjs";import{throwWrongKeyOnActionCollectionConfig as l}from"./throwWrongKeyOnActionCollectionConfig.mjs";import{isRecord as c}from"./isRecord.mjs";import{actions as C}from"./actions.mjs";import{createContext as b}from"./createContext.mjs";import{default as S}from"./GlobalStore.mjs";import{createGlobalState as A}from"./createGlobalState.mjs";import{default as u}from"./asyncStorageWrapper.mjs";export{S as GlobalStore,C as actions,u as asyncStorageWrapper,b as createContext,A as createGlobalState,c as isRecord,o as shallowCompare,l as throwWrongKeyOnActionCollectionConfig,n as uniqueId};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var f=Object.create;var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)n(t,o,{get:e[o],enumerable:!0})},C=(t,e,o,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!i.call(t,r)&&r!==o&&n(t,r,{get:()=>e[r],enumerable:!(x=y(e,r))||x.enumerable});return t};var k=(t,e,o)=>(o=t!=null?f(d(t)):{},C(e||!t||!t.__esModule?n(o,"default",{value:t,enumerable:!0}):o,t)),l=t=>C(n({},"__esModule",{value:!0}),t);var m={};c(m,{createContext:()=>p.createContext,default:()=>p.default});module.exports=l(m);var p=k(require("react-hooks-global-states/createContext"));
|
package/createContext.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var f=Object.create;var n=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var c=(t,e)=>{for(var o in e)n(t,o,{get:e[o],enumerable:!0})},C=(t,e,o,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!i.call(t,r)&&r!==o&&n(t,r,{get:()=>e[r],enumerable:!(x=y(e,r))||x.enumerable});return t};var k=(t,e,o)=>(o=t!=null?f(d(t)):{},C(e||!t||!t.__esModule?n(o,"default",{value:t,enumerable:!0}):o,t)),l=t=>C(n({},"__esModule",{value:!0}),t);var m={};c(m,{createContext:()=>p.createContext,default:()=>p.default});module.exports=l(m);var p=k(require("react-hooks-global-states/createContext"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as o,default as r}from"react-hooks-global-states/createContext";export{o as createContext,r as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var A=(t,a)=>{for(var o in a)n(t,o,{get:a[o],enumerable:!0})},d=(t,a,o,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of S(a))!r.call(t,e)&&e!==o&&n(t,e,{get:()=>a[e],enumerable:!(c=i(a,e))||c.enumerable});return t};var f=t=>d(n({},"__esModule",{value:!0}),t);var g={};A(g,{createGlobalState:()=>s,default:()=>C});module.exports=f(g);var l=require("./GlobalStore.cjs"),s=(...t)=>new l.GlobalStore(...t).use,C=s;
|
package/createGlobalState.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StateHook, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks } from "react-hooks-global-states/types";
|
|
1
|
+
import type { StateHook, ActionCollectionConfig, ActionCollectionResult, GlobalStoreCallbacks, Any, AnyActions } from "react-hooks-global-states/types";
|
|
2
2
|
import { AsyncStorageConfig, BaseMetadata, AsyncMetadata } from "./types";
|
|
3
3
|
import React from "react";
|
|
4
4
|
export type { InferActionsType, InferStateApi, AnyActions, } from "react-hooks-global-states/createGlobalState";
|
|
@@ -22,7 +22,7 @@ interface CreateGlobalState {
|
|
|
22
22
|
* );
|
|
23
23
|
* }
|
|
24
24
|
*/
|
|
25
|
-
<State>(state: State): StateHook<State, React.Dispatch<React.SetStateAction<State>>, BaseMetadata>;
|
|
25
|
+
<State>(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,10 +73,10 @@ 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>>>(state: State, args: {
|
|
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 | (() => State), args: {
|
|
77
77
|
name?: string;
|
|
78
|
-
metadata?: Metadata;
|
|
79
|
-
callbacks?: GlobalStoreCallbacks<
|
|
78
|
+
metadata?: Metadata | (() => Metadata);
|
|
79
|
+
callbacks?: GlobalStoreCallbacks<Any, AnyActions, Any>;
|
|
80
80
|
actions?: ActionsConfig;
|
|
81
81
|
asyncStorage?: AsyncStorageConfig<State>;
|
|
82
82
|
}): StateHook<State, PublicStateMutator, AsyncMetadata<Metadata>>;
|
|
@@ -130,10 +130,10 @@ interface CreateGlobalState {
|
|
|
130
130
|
* }
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
133
|
-
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>, PublicStateMutator = ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State, args: {
|
|
133
|
+
<State, Metadata extends BaseMetadata, ActionsConfig extends ActionCollectionConfig<State, Metadata>, PublicStateMutator = ActionCollectionResult<State, Metadata, NonNullable<ActionsConfig>>>(state: State | (() => State), args: {
|
|
134
134
|
name?: string;
|
|
135
|
-
metadata?: Metadata;
|
|
136
|
-
callbacks?: GlobalStoreCallbacks<
|
|
135
|
+
metadata?: Metadata | (() => Metadata);
|
|
136
|
+
callbacks?: GlobalStoreCallbacks<Any, AnyActions, Any>;
|
|
137
137
|
actions: ActionsConfig;
|
|
138
138
|
asyncStorage?: AsyncStorageConfig<State>;
|
|
139
139
|
}): StateHook<State, PublicStateMutator, Metadata>;
|
package/createGlobalState.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var A=(t,a)=>{for(var o in a)n(t,o,{get:a[o],enumerable:!0})},d=(t,a,o,c)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of S(a))!r.call(t,e)&&e!==o&&n(t,e,{get:()=>a[e],enumerable:!(c=i(a,e))||c.enumerable});return t};var f=t=>d(n({},"__esModule",{value:!0}),t);var g={};A(g,{createGlobalState:()=>s,default:()=>C});module.exports=f(g);var l=require("./GlobalStore.js"),s=(...t)=>new l.GlobalStore(...t).use,C=s;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{GlobalStore as a}from"./GlobalStore.mjs";var e=(...t)=>new a(...t).use,n=e;export{e as createGlobalState,n as default};
|
package/index.d.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
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 {
|
|
6
|
-
export { shallowCompare } from
|
|
7
|
-
export { uniqueId
|
|
8
|
-
export { throwWrongKeyOnActionCollectionConfig } from
|
|
9
|
-
export { isRecord } from
|
|
10
|
-
export {
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
5
|
+
export type { ActionCollectionConfig, ActionCollectionResult, Any, AnyActions, AnyFunction, BaseMetadata, BrandedId, CleanupFunction, ContextActionCollectionConfig, ContextActionCollectionResult, ContextHook, ContextProvider, ContextProviderExtensions, ContextPublicApi, ContextStoreTools, ContextStoreToolsExtensions, CreateContext, CreateGlobalState, GlobalStoreCallbacks, GlobalStoreContextCallbacks, InferAPI, InferActionsType, InferContextApi, InferStateApi, MetadataGetter, MetadataSetter, ObservableFragment, ReadonlyContextHook, ReadonlyContextPublicApi, ReadonlyHook, ReadonlyStateApi, SelectHook, SelectorCallback, StateApi, StateChanges, StateHook, StoreTools, SubscribeCallback, SubscribeCallbackConfig, SubscribeToState, SubscriberParameters, SubscriptionCallback, UniqueId, UnsubscribeCallback, UseHookOptions, } from './types';
|
|
6
|
+
export { shallowCompare } from './shallowCompare';
|
|
7
|
+
export { uniqueId } from './uniqueId';
|
|
8
|
+
export { throwWrongKeyOnActionCollectionConfig } from './throwWrongKeyOnActionCollectionConfig';
|
|
9
|
+
export { isRecord } from './isRecord';
|
|
10
|
+
export { actions } from './actions';
|
|
11
|
+
export { createContext } from './createContext';
|
|
12
|
+
export type { AsyncStorageConfig, AsyncMetadata, ItemEnvelope } from './types';
|
|
13
|
+
export { default as GlobalStore } from './GlobalStore';
|
|
14
|
+
export { createGlobalState } from './createGlobalState';
|
|
15
|
+
export { default as asyncStorageWrapper, type AsyncStorageManager } from './asyncStorageWrapper';
|
package/isPromise.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(n,o)=>{for(var s in o)t(n,s,{get:o[s],enumerable:!0})},k=(n,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of u(o))!a.call(n,e)&&e!==s&&t(n,e,{get:()=>o[e],enumerable:!(i=r(o,e))||i.enumerable});return n};var m=n=>k(t({},"__esModule",{value:!0}),n);var c={};f(c,{default:()=>P});module.exports=m(c);var w=n=>!!(n&&typeof n.then=="function"),P=w;
|
package/isPromise.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(n,o)=>{for(var s in o)t(n,s,{get:o[s],enumerable:!0})},k=(n,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of u(o))!a.call(n,e)&&e!==s&&t(n,e,{get:()=>o[e],enumerable:!(i=r(o,e))||i.enumerable});return n};var m=n=>k(t({},"__esModule",{value:!0}),n);var c={};f(c,{default:()=>P});module.exports=m(c);var w=n=>!!(n&&typeof n.then=="function"),P=w;
|
package/isPromise.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=n=>!!(n&&typeof n.then=="function"),e=o;export{e as default};
|
package/isRecord.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.create;var f=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;var u=(e,o)=>{for(var r in o)f(e,r,{get:o[r],enumerable:!0})},c=(e,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of m(o))!s.call(e,d)&&d!==r&&f(e,d,{get:()=>o[d],enumerable:!(a=l(o,d))||a.enumerable});return e};var x=(e,o,r)=>(r=e!=null?i(p(e)):{},c(o||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>c(f({},"__esModule",{value:!0}),e);var b={};u(b,{default:()=>t.default,isRecord:()=>t.isRecord});module.exports=R(b);var t=x(require("react-hooks-global-states/isRecord"));
|
package/isRecord.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var i=Object.create;var f=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty;var u=(e,o)=>{for(var r in o)f(e,r,{get:o[r],enumerable:!0})},c=(e,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of m(o))!s.call(e,d)&&d!==r&&f(e,d,{get:()=>o[d],enumerable:!(a=l(o,d))||a.enumerable});return e};var x=(e,o,r)=>(r=e!=null?i(p(e)):{},c(o||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e)),R=e=>c(f({},"__esModule",{value:!0}),e);var b={};u(b,{default:()=>t.default,isRecord:()=>t.isRecord});module.exports=R(b);var t=x(require("react-hooks-global-states/isRecord"));
|
package/isRecord.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRecord as r,default as d}from"react-hooks-global-states/isRecord";export{d as default,r as isRecord};
|
package/package.json
CHANGED
|
@@ -1,72 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-global-state-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "16.0.3-beta.0",
|
|
4
4
|
"description": "This is a package to easily handling global-state across your react-native-components No-redux... The library now includes @react-native-async-storage/async-storage to persist your state across sessions... if you want to keep using the old version without async-storage or react-native dependencies just use version 5.0.15 or user react-hooks-global-states instead",
|
|
5
|
-
"main": "./bundle.
|
|
5
|
+
"main": "./bundle.cjs",
|
|
6
|
+
"module": "./bundle.mjs",
|
|
6
7
|
"types": "./index.d.ts",
|
|
7
8
|
"sideEffects": false,
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"types": "./index.d.ts",
|
|
12
|
+
"import": "./bundle.mjs",
|
|
13
|
+
"require": "./bundle.cjs"
|
|
13
14
|
},
|
|
14
15
|
"./asyncStorageWrapper": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"types": "./asyncStorageWrapper.d.ts",
|
|
17
|
+
"import": "./asyncStorageWrapper.mjs",
|
|
18
|
+
"require": "./asyncStorageWrapper.cjs"
|
|
18
19
|
},
|
|
19
20
|
"./createContext": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"types": "./createContext.d.ts",
|
|
22
|
+
"import": "./createContext.mjs",
|
|
23
|
+
"require": "./createContext.cjs"
|
|
23
24
|
},
|
|
24
25
|
"./createGlobalState": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"types": "./createGlobalState.d.ts",
|
|
27
|
+
"import": "./createGlobalState.mjs",
|
|
28
|
+
"require": "./createGlobalState.cjs"
|
|
29
|
+
},
|
|
30
|
+
"./types": {
|
|
31
|
+
"types": "./types.d.ts",
|
|
32
|
+
"import": "./types.mjs",
|
|
33
|
+
"require": "./types.cjs"
|
|
28
34
|
},
|
|
29
35
|
"./GlobalStore": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
36
|
+
"types": "./GlobalStore.d.ts",
|
|
37
|
+
"import": "./GlobalStore.mjs",
|
|
38
|
+
"require": "./GlobalStore.cjs"
|
|
33
39
|
},
|
|
34
40
|
"./isRecord": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
41
|
+
"types": "./isRecord.d.ts",
|
|
42
|
+
"import": "./isRecord.mjs",
|
|
43
|
+
"require": "./isRecord.cjs"
|
|
38
44
|
},
|
|
39
45
|
"./shallowCompare": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
46
|
+
"types": "./shallowCompare.d.ts",
|
|
47
|
+
"import": "./shallowCompare.mjs",
|
|
48
|
+
"require": "./shallowCompare.cjs"
|
|
43
49
|
},
|
|
44
50
|
"./throwWrongKeyOnActionCollectionConfig": {
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
}
|
|
51
|
+
"types": "./throwWrongKeyOnActionCollectionConfig.d.ts",
|
|
52
|
+
"import": "./throwWrongKeyOnActionCollectionConfig.mjs",
|
|
53
|
+
"require": "./throwWrongKeyOnActionCollectionConfig.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./uniqueId": {
|
|
56
|
+
"types": "./uniqueId.d.ts",
|
|
57
|
+
"import": "./uniqueId.mjs",
|
|
58
|
+
"require": "./uniqueId.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./actions": {
|
|
61
|
+
"types": "./actions.d.ts",
|
|
62
|
+
"import": "./actions.mjs",
|
|
63
|
+
"require": "./actions.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./package.json": "./package.json"
|
|
49
66
|
},
|
|
50
67
|
"files": [
|
|
51
68
|
"*.js",
|
|
69
|
+
"*.cjs",
|
|
70
|
+
"*.mjs",
|
|
52
71
|
"*.d.ts"
|
|
53
72
|
],
|
|
54
|
-
"scripts": {
|
|
55
|
-
"format": "prettier --write . --log-level silent && yarn lint:fix",
|
|
56
|
-
"test": "yarn build && yarn jest",
|
|
57
|
-
"test:debug:no-watch": "node --inspect-brk node_modules/.bin/jest --no-watchman --runInBand",
|
|
58
|
-
"test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
|
|
59
|
-
"test:quick": "yarn test --no-coverage --maxWorkers=4 -c --no-watchman -u",
|
|
60
|
-
"test:coverage": "yarn test --maxWorkers=4 -c --colors --no-watchman --verbose --coverage",
|
|
61
|
-
"build": "yarn ts-check && yarn clean && webpack --config webpack.config.js",
|
|
62
|
-
"prepare": "yarn format && npm run build && yarn test:quick",
|
|
63
|
-
"version": "npm run format && yarn build && yarn jest && git add -A",
|
|
64
|
-
"postversion": "git push && git push --tags",
|
|
65
|
-
"lint": "eslint . --max-warnings=0",
|
|
66
|
-
"lint:fix": "eslint . --fix --max-warnings=0",
|
|
67
|
-
"clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' ! -name 'eslint.config.mts' -exec rm {} + && rm -rf coverage",
|
|
68
|
-
"ts-check": "tsc -p tsconfig.json --noEmit"
|
|
69
|
-
},
|
|
70
73
|
"repository": {
|
|
71
74
|
"type": "git",
|
|
72
75
|
"url": "git+https://github.com/johnny-quesada-developer/react-native-global-state-hooks.git"
|
|
@@ -89,54 +92,9 @@
|
|
|
89
92
|
"url": "https://github.com/johnny-quesada-developer/react-native-global-state-hooks/issues"
|
|
90
93
|
},
|
|
91
94
|
"homepage": "https://github.com/johnny-quesada-developer/react-native-global-state-hooks#readme",
|
|
92
|
-
"devDependencies": {
|
|
93
|
-
"@babel/core": "^7.21.3",
|
|
94
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
|
|
95
|
-
"@babel/plugin-transform-modules-commonjs": "^7.21.2",
|
|
96
|
-
"@babel/preset-env": "^7.20.2",
|
|
97
|
-
"@babel/preset-react": "^7.18.6",
|
|
98
|
-
"@babel/preset-typescript": "^7.21.0",
|
|
99
|
-
"@eslint/js": "^9.39.1",
|
|
100
|
-
"@react-native-async-storage/async-storage": ">=1.17.11",
|
|
101
|
-
"@testing-library/dom": "^10.4.0",
|
|
102
|
-
"@testing-library/react": "^16.3.0",
|
|
103
|
-
"@types/jest": "^29.5.11",
|
|
104
|
-
"@types/lodash": "^4.14.165",
|
|
105
|
-
"@types/react": "^18.0.38",
|
|
106
|
-
"@types/react-dom": "^18.0.11",
|
|
107
|
-
"@types/react-test-renderer": "^18.0.0",
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^4.9.1",
|
|
109
|
-
"@typescript-eslint/parser": "^4.9.1",
|
|
110
|
-
"babel-loader": "^9.1.2",
|
|
111
|
-
"clean-webpack-plugin": "^4.0.0",
|
|
112
|
-
"easy-cancelable-promise": "^1.0.2",
|
|
113
|
-
"eslint": "^9.39.1",
|
|
114
|
-
"eslint-config-airbnb": "^18.2.1",
|
|
115
|
-
"eslint-plugin-import": "^2.22.1",
|
|
116
|
-
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
117
|
-
"eslint-plugin-react": "^7.37.5",
|
|
118
|
-
"eslint-plugin-react-hooks": "^4.2.0",
|
|
119
|
-
"globals": "^16.5.0",
|
|
120
|
-
"jest": "^29.7.0",
|
|
121
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
122
|
-
"jiti": "^2.6.1",
|
|
123
|
-
"json-storage-formatter": "^3.0.2",
|
|
124
|
-
"prettier": "^3.6.2",
|
|
125
|
-
"react": "^18.2.0",
|
|
126
|
-
"react-dom": "^18.2.0",
|
|
127
|
-
"react-native": ">=0.71.6",
|
|
128
|
-
"react-test-renderer": "^18.2.0",
|
|
129
|
-
"ts-jest": "^29.1.1",
|
|
130
|
-
"ts-loader": "^9.4.2",
|
|
131
|
-
"tslib": "^2.5.0",
|
|
132
|
-
"typescript": "^5.3.3",
|
|
133
|
-
"typescript-eslint": "^8.46.3",
|
|
134
|
-
"webpack": "^5.76.3",
|
|
135
|
-
"webpack-cli": "^5.0.1"
|
|
136
|
-
},
|
|
137
95
|
"peerDependencies": {
|
|
138
96
|
"@react-native-async-storage/async-storage": ">=1.17.11",
|
|
139
|
-
"json-storage-formatter": "^
|
|
97
|
+
"json-storage-formatter": "^4.0.0",
|
|
140
98
|
"react": ">=18.0.0",
|
|
141
99
|
"react-native": ">=0.69.0"
|
|
142
100
|
},
|
|
@@ -155,6 +113,6 @@
|
|
|
155
113
|
}
|
|
156
114
|
},
|
|
157
115
|
"dependencies": {
|
|
158
|
-
"react-hooks-global-states": "^
|
|
116
|
+
"react-hooks-global-states": "^16.0.3"
|
|
159
117
|
}
|
|
160
118
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=Object.create;var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var w=(o,a)=>{for(var e in a)r(o,e,{get:a[e],enumerable:!0})},p=(o,a,e,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of h(a))!u.call(o,l)&&l!==e&&r(o,l,{get:()=>a[l],enumerable:!(m=d(a,l))||m.enumerable});return o};var x=(o,a,e)=>(e=o!=null?t(s(o)):{},p(a||!o||!o.__esModule?r(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>p(r({},"__esModule",{value:!0}),o);var b={};w(b,{default:()=>f.default,shallowCompare:()=>f.shallowCompare});module.exports=C(b);var f=x(require("react-hooks-global-states/shallowCompare"));
|
package/shallowCompare.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var t=Object.create;var r=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var s=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var w=(o,a)=>{for(var e in a)r(o,e,{get:a[e],enumerable:!0})},p=(o,a,e,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of h(a))!u.call(o,l)&&l!==e&&r(o,l,{get:()=>a[l],enumerable:!(m=d(a,l))||m.enumerable});return o};var x=(o,a,e)=>(e=o!=null?t(s(o)):{},p(a||!o||!o.__esModule?r(e,"default",{value:o,enumerable:!0}):e,o)),C=o=>p(r({},"__esModule",{value:!0}),o);var b={};w(b,{default:()=>f.default,shallowCompare:()=>f.shallowCompare});module.exports=C(b);var f=x(require("react-hooks-global-states/shallowCompare"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowCompare as e,default as l}from"react-hooks-global-states/shallowCompare";export{l as default,e as shallowCompare};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var c=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var h=(o,n)=>{for(var t in n)r(o,t,{get:n[t],enumerable:!0})},l=(o,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of C(n))!d.call(o,e)&&e!==t&&r(o,e,{get:()=>n[e],enumerable:!(i=g(n,e))||i.enumerable});return o};var m=(o,n,t)=>(t=o!=null?c(a(o)):{},l(n||!o||!o.__esModule?r(t,"default",{value:o,enumerable:!0}):t,o)),p=o=>l(r({},"__esModule",{value:!0}),o);var u={};h(u,{default:()=>f.default,throwWrongKeyOnActionCollectionConfig:()=>f.throwWrongKeyOnActionCollectionConfig});module.exports=p(u);var f=m(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var c=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var a=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var h=(o,n)=>{for(var t in n)r(o,t,{get:n[t],enumerable:!0})},l=(o,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of C(n))!d.call(o,e)&&e!==t&&r(o,e,{get:()=>n[e],enumerable:!(i=g(n,e))||i.enumerable});return o};var m=(o,n,t)=>(t=o!=null?c(a(o)):{},l(n||!o||!o.__esModule?r(t,"default",{value:o,enumerable:!0}):t,o)),p=o=>l(r({},"__esModule",{value:!0}),o);var u={};h(u,{default:()=>f.default,throwWrongKeyOnActionCollectionConfig:()=>f.throwWrongKeyOnActionCollectionConfig});module.exports=p(u);var f=m(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{throwWrongKeyOnActionCollectionConfig as t,default as e}from"react-hooks-global-states/throwWrongKeyOnActionCollectionConfig";export{e as default,t as throwWrongKeyOnActionCollectionConfig};
|
package/tryCatch.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.create;var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var c=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},s=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of y(e))!i.call(r,u)&&u!==t&&l(r,u,{get:()=>e[u],enumerable:!(n=d(e,u))||n.enumerable});return r};var R=(r,e,t)=>(t=r!=null?T(o(r)):{},s(e||!r||!r.__esModule?l(t,"default",{value:r,enumerable:!0}):t,r)),h=r=>s(l({},"__esModule",{value:!0}),r);var p={};c(p,{default:()=>x});module.exports=h(p);var a=R(require("./isPromise.cjs"));function F(r,e){try{let t=r();return(0,a.default)(t)?t.then(n=>({result:n,error:null})).catch(n=>({result:e!=null?e:null,error:n})):{result:t,error:null}}catch(t){return{result:e!=null?e:null,error:t}}}var x=F;
|
package/tryCatch.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var T=Object.create;var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty;var c=(r,e)=>{for(var t in e)l(r,t,{get:e[t],enumerable:!0})},s=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of y(e))!i.call(r,u)&&u!==t&&l(r,u,{get:()=>e[u],enumerable:!(n=d(e,u))||n.enumerable});return r};var R=(r,e,t)=>(t=r!=null?T(o(r)):{},s(e||!r||!r.__esModule?l(t,"default",{value:r,enumerable:!0}):t,r)),h=r=>s(l({},"__esModule",{value:!0}),r);var p={};c(p,{default:()=>x});module.exports=h(p);var a=R(require("./isPromise.js"));function F(r,e){try{let t=r();return(0,a.default)(t)?t.then(n=>({result:n,error:null})).catch(n=>({result:e!=null?e:null,error:n})):{result:t,error:null}}catch(t){return{result:e!=null?e:null,error:t}}}var x=F;
|
package/tryCatch.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import u from"./isPromise.mjs";function l(n,e){try{let r=n();return u(r)?r.then(t=>({result:t,error:null})).catch(t=>({result:e!=null?e:null,error:t})):{result:r,error:null}}catch(r){return{result:e!=null?e:null,error:r}}}var a=l;export{a as default};
|
package/types.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var S=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of i(t))!d.call(e,a)&&a!==r&&n(e,a,{get:()=>t[a],enumerable:!(o=s(t,a))||o.enumerable});return e};var l=e=>S(n({},"__esModule",{value:!0}),e);var c={};module.exports=l(c);
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type { StateApi, AnyFunction, StateChanges, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, } from "react-hooks-global-states/types";
|
|
1
|
+
export type { StateApi, AnyFunction, StateChanges, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, Any, AnyActions, BrandedId, CleanupFunction, ContextActionCollectionConfig, ContextActionCollectionResult, ContextHook, ContextProvider, ContextProviderExtensions, ContextPublicApi, ContextStoreTools, ContextStoreToolsExtensions, CreateContext, CreateGlobalState, GlobalStoreContextCallbacks, InferAPI, InferActionsType, InferContextApi, InferStateApi, ReadonlyContextHook, ReadonlyContextPublicApi, ReadonlyHook, ReadonlyStateApi, SelectHook, SubscribeToState, UniqueId, } from "react-hooks-global-states/types";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type { BaseMetadata as BaseLibraryMetadata, StateApi, StateChanges, SubscriberParameters, UseHookOptions } from "react-hooks-global-states";
|
|
3
|
+
import type { BaseMetadata as BaseLibraryMetadata, CleanupFunction, StateApi, StateChanges, SubscriberParameters, UseHookOptions } from "react-hooks-global-states";
|
|
4
4
|
import { AnyFunction, SubscribeToState } from "react-hooks-global-states/types";
|
|
5
5
|
export type AsyncStorageConfig<State> = {
|
|
6
6
|
/**
|
|
@@ -124,6 +124,12 @@ export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction
|
|
|
124
124
|
*/
|
|
125
125
|
actions: StateMutator extends AnyFunction ? null : StateMutator;
|
|
126
126
|
/**
|
|
127
|
+
* @description Metadata associated with the global state.
|
|
128
|
+
* Metadata is non-reactive; reading it will not trigger re-renders. To change it use `setMetadata`.
|
|
129
|
+
*/
|
|
130
|
+
readonly metadata: Metadata;
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use the `metadata` property instead, e.g. `const { metadata } = storeTools;`. Metadata is stable, so it is exposed directly.
|
|
127
133
|
* @description Metadata associated with the global state
|
|
128
134
|
*/
|
|
129
135
|
getMetadata: () => Metadata;
|
|
@@ -138,7 +144,12 @@ export type StoreTools<State, StateMutator = React.Dispatch<React.SetStateAction
|
|
|
138
144
|
/**
|
|
139
145
|
* @description Function to set the state value
|
|
140
146
|
*/
|
|
141
|
-
setState: React.
|
|
147
|
+
setState: (setter: React.SetStateAction<State>, args?: {
|
|
148
|
+
/** Force update even if the state value did not change (advanced use only). */
|
|
149
|
+
forceUpdate?: boolean;
|
|
150
|
+
/** Optional identifier visible on the devtools. */
|
|
151
|
+
identifier?: string;
|
|
152
|
+
}) => void;
|
|
142
153
|
/**
|
|
143
154
|
* @description Subscribe to the state changes
|
|
144
155
|
* You can subscribe to the whole state or to a fragment of the state by passing a selector as first parameter,
|
|
@@ -179,7 +190,7 @@ export type GlobalStoreCallbacks<State, StateMutator, Metadata extends BaseMetad
|
|
|
179
190
|
/**
|
|
180
191
|
* @description Called when the store is initialized
|
|
181
192
|
*/
|
|
182
|
-
onInit?: (args: StoreTools<State, StateMutator, Metadata>) => void;
|
|
193
|
+
onInit?: (args: StoreTools<State, StateMutator, Metadata>) => void | Promise<void> | CleanupFunction;
|
|
183
194
|
/**
|
|
184
195
|
* @description Called when the state has changed
|
|
185
196
|
*/
|
package/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var S=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of i(t))!d.call(e,a)&&a!==r&&n(e,a,{get:()=>t[a],enumerable:!(o=s(t,a))||o.enumerable});return e};var l=e=>S(n({},"__esModule",{value:!0}),e);var c={};module.exports=l(c);
|
package/types.mjs
ADDED
|
File without changes
|
package/uniqueId.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.create;var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var o=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var y=(e,d)=>{for(var t in d)n(e,t,{get:d[t],enumerable:!0})},I=(e,d,t,r)=>{if(d&&typeof d=="object"||typeof d=="function")for(let u of i(d))!q.call(e,u)&&u!==t&&n(e,u,{get:()=>d[u],enumerable:!(r=f(d,u))||r.enumerable});return e};var l=(e,d,t)=>(t=e!=null?a(o(e)):{},I(d||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),m=e=>I(n({},"__esModule",{value:!0}),e);var x={};y(x,{default:()=>p.default,uniqueId:()=>p.uniqueId});module.exports=m(x);var p=l(require("react-hooks-global-states/uniqueId"));
|
package/uniqueId.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { uniqueId, BrandedId,
|
|
1
|
+
export { uniqueId, default, type BrandedId, type UniqueId } from "react-hooks-global-states/uniqueId";
|
package/uniqueId.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";var a=Object.create;var n=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var o=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var y=(e,d)=>{for(var t in d)n(e,t,{get:d[t],enumerable:!0})},I=(e,d,t,r)=>{if(d&&typeof d=="object"||typeof d=="function")for(let u of i(d))!q.call(e,u)&&u!==t&&n(e,u,{get:()=>d[u],enumerable:!(r=f(d,u))||r.enumerable});return e};var l=(e,d,t)=>(t=e!=null?a(o(e)):{},I(d||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),m=e=>I(n({},"__esModule",{value:!0}),e);var x={};y(x,{default:()=>p.default,uniqueId:()=>p.uniqueId});module.exports=m(x);var p=l(require("react-hooks-global-states/uniqueId"));
|
package/uniqueId.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{uniqueId as t,default as u}from"react-hooks-global-states/uniqueId";export{u as default,t as uniqueId};
|