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.
Files changed (48) hide show
  1. package/GlobalStore.cjs +5 -0
  2. package/GlobalStore.d.ts +3 -3
  3. package/GlobalStore.js +5 -1
  4. package/GlobalStore.mjs +5 -0
  5. package/README.md +1209 -202
  6. package/actions.cjs +1 -0
  7. package/actions.d.ts +1 -0
  8. package/actions.js +1 -0
  9. package/actions.mjs +1 -0
  10. package/asyncStorageWrapper.cjs +4 -0
  11. package/asyncStorageWrapper.js +4 -1
  12. package/asyncStorageWrapper.mjs +4 -0
  13. package/bundle.cjs +1 -0
  14. package/bundle.js +1 -1
  15. package/bundle.mjs +1 -0
  16. package/createContext.cjs +1 -0
  17. package/createContext.js +1 -1
  18. package/createContext.mjs +1 -0
  19. package/createGlobalState.cjs +1 -0
  20. package/createGlobalState.d.ts +8 -8
  21. package/createGlobalState.js +1 -1
  22. package/createGlobalState.mjs +1 -0
  23. package/index.d.ts +11 -10
  24. package/isPromise.cjs +1 -0
  25. package/isPromise.js +1 -0
  26. package/isPromise.mjs +1 -0
  27. package/isRecord.cjs +1 -0
  28. package/isRecord.js +1 -1
  29. package/isRecord.mjs +1 -0
  30. package/package.json +48 -90
  31. package/shallowCompare.cjs +1 -0
  32. package/shallowCompare.js +1 -1
  33. package/shallowCompare.mjs +1 -0
  34. package/throwWrongKeyOnActionCollectionConfig.cjs +1 -0
  35. package/throwWrongKeyOnActionCollectionConfig.js +1 -1
  36. package/throwWrongKeyOnActionCollectionConfig.mjs +1 -0
  37. package/tryCatch.cjs +1 -0
  38. package/tryCatch.js +1 -0
  39. package/tryCatch.mjs +1 -0
  40. package/types.cjs +1 -0
  41. package/types.d.ts +15 -4
  42. package/types.js +1 -1
  43. package/types.mjs +0 -0
  44. package/uniqueId.cjs +1 -0
  45. package/uniqueId.d.ts +1 -1
  46. package/uniqueId.js +1 -1
  47. package/uniqueId.mjs +1 -0
  48. 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;
@@ -1 +1,4 @@
1
- var e;e=e=>(()=>{"use strict";var t={463:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}var o={};return(()=>{var e=o;function t(){var e,r,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",c=o.toStringTag||"@@toStringTag";function i(t,o,a,c){var i=o&&o.prototype instanceof f?o:f,s=Object.create(i.prototype);return n(s,"_invoke",function(t,n,o){var a,c,i,f=0,s=o||[],v=!1,l={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,c=0,i=e,l.n=n,u}};function d(t,n){for(c=t,i=n,r=0;!v&&f&&!o&&r<s.length;r++){var o,a=s[r],d=l.p,p=a[2];t>3?(o=p===n)&&(i=a[(c=a[4])?5:(c=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=t<2&&d<a[1])?(c=0,l.v=n,l.n=a[1]):d<p&&(o=t<3||a[0]>n||n>p)&&(a[4]=t,a[5]=n,l.n=p,c=0))}if(o||t>1)return u;throw v=!0,n}return function(o,s,p){if(f>1)throw TypeError("Generator is already running");for(v&&1===s&&d(s,p),c=s,i=p;(r=c<2?e:i)||!v;){a||(c?c<3?(c>1&&(l.n=-1),d(c,i)):l.n=i:l.v=i);try{if(f=2,a){if(c||(o="next"),r=a[o]){if(!(r=r.call(a,i)))throw TypeError("iterator result is not an object");if(!r.done)return r;i=r.value,c<2&&(c=0)}else 1===c&&(r=a.return)&&r.call(a),c<2&&(i=TypeError("The iterator does not provide a '"+o+"' method"),c=1);a=e}else if((r=(v=l.n<0)?i:t.call(n,l))!==u)break}catch(t){a=e,c=1,i=t}finally{f=1}}return{value:r,done:v}}}(t,a,c),!0),s}var u={};function f(){}function s(){}function v(){}r=Object.getPrototypeOf;var l=[][a]?r(r([][a]())):(n(r={},a,function(){return this}),r),d=v.prototype=f.prototype=Object.create(l);function p(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,n(e,c,"GeneratorFunction")),e.prototype=Object.create(d),e}return s.prototype=v,n(d,"constructor",v),n(v,"constructor",s),s.displayName="GeneratorFunction",n(v,c,"GeneratorFunction"),n(d),n(d,c,"Generator"),n(d,a,function(){return this}),n(d,"toString",function(){return"[object Generator]"}),(t=function(){return{w:i,m:p}})()}function n(e,t,r,o){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}n=function(e,t,r,o){if(t)a?a(e,t,{value:r,enumerable:!o,configurable:!o,writable:!o}):e[t]=r;else{var c=function(t,r){n(e,t,function(e){return this._invoke(t,r,e)})};c("next",0),c("throw",1),c("return",2)}},n(e,t,r,o)}var a,c=Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]},i=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},u=(a=function(e){return a=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},a(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=a(e),r=0;r<n.length;r++)"default"!==n[r]&&c(t,e,n[r]);return i(t,e),t}),f=function(e,t,n,r){return new(n||(n=Promise))(function(o,a){function c(e){try{u(r.next(e))}catch(e){a(e)}}function i(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(c,i)}u((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});var s=function(){var e,n="pending",o=null;f(void 0,void 0,void 0,t().m(function a(){var c,i,f,s,v;return t().w(function(t){for(;;)switch(t.n){case 0:return t.p=0,c=Promise.resolve().then(function(){return u(r(463))}),e=c,t.n=1,c;case 1:i=t.v,f=i.default,s=f.getItem,v=f.setItem,s.bind(f),v.bind(f),o={getItem:s,setItem:v},n="resolved",t.n=3;break;case 2:t.p=2,t.v,n="rejected";case 3:return t.p=3,e=null,t.f(3);case 4:return t.a(2)}},a,null,[[0,2,3,4]])}));var a=function(){throw new Error("[AsyncStorageManager Not Found] \n\n Please install the react-native-async-storage/async-storage to be use as the default async storage manager or\n add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.")},c=function(){return f(void 0,void 0,void 0,t().m(function r(){return t().w(function(t){for(;;)switch(t.n){case 0:if("pending"!==n||!e){t.n=1;break}return t.a(2,e);case 1:if("rejected"!==n){t.n=2;break}return t.a(2,e.catch(function(e){throw e}));case 2:return o||a(),t.a(2,o)}},r)}))};return{getItem:function(e){return f(void 0,void 0,void 0,t().m(function n(){return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,c();case 1:return t.a(2,o.getItem(e))}},n)}))},setItem:function(e,n){return f(void 0,void 0,void 0,t().m(function r(){return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,c();case 1:return t.a(2,o.setItem(e,n))}},r)}))},addAsyncStorageManager:function(r){return f(void 0,void 0,void 0,t().m(function a(){var c,i;return t().w(function(t){for(;;)switch(t.n){case 0:if(t.p=0,"pending"!==n||!e){t.n=1;break}return t.n=1,e.catch(function(){});case 1:return n="pending",c=r(),e=c,t.n=2,c;case 2:o=t.v,n="resolved",t.n=4;break;case 3:throw t.p=3,i=t.v,e=null,n="rejected",i;case 4:return t.a(2)}},a,null,[[0,3]])}))}}}();e.default=s})(),o})(),"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@react-native-async-storage/async-storage")):"function"==typeof define&&define.amd?define(["@react-native-async-storage/async-storage"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("@react-native-async-storage/async-storage")):this["react-native-global-state-hooks"]=e(this["@react-native-async-storage/async-storage"]);
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
- var e,r;e=this,r=(e,r,t,o,n,a,i,s)=>(()=>{"use strict";var l={78:r=>{r.exports=e},114:e=>{e.exports=r},361:e=>{e.exports=t},487:e=>{e.exports=o},623:e=>{e.exports=n},670:e=>{e.exports=a},673:e=>{e.exports=i},778:e=>{e.exports=s}},u={};function c(e){var r=u[e];if(void 0!==r)return r.exports;var t=u[e]={exports:{}};return l[e](t,t.exports,c),t.exports}var p={};return(()=>{var e=p,r=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.asyncStorageWrapper=e.createGlobalState=e.GlobalStore=e.createContext=e.isRecord=e.throwWrongKeyOnActionCollectionConfig=e.uniqueId=e.shallowCompare=void 0;var t=c(673);Object.defineProperty(e,"shallowCompare",{enumerable:!0,get:function(){return t.shallowCompare}});var o=c(78);Object.defineProperty(e,"uniqueId",{enumerable:!0,get:function(){return o.uniqueId}});var n=c(361);Object.defineProperty(e,"throwWrongKeyOnActionCollectionConfig",{enumerable:!0,get:function(){return n.throwWrongKeyOnActionCollectionConfig}});var a=c(487);Object.defineProperty(e,"isRecord",{enumerable:!0,get:function(){return a.isRecord}});var i=c(623);Object.defineProperty(e,"createContext",{enumerable:!0,get:function(){return i.createContext}});var s=c(778);Object.defineProperty(e,"GlobalStore",{enumerable:!0,get:function(){return r(s).default}});var l=c(670);Object.defineProperty(e,"createGlobalState",{enumerable:!0,get:function(){return l.createGlobalState}});var u=c(114);Object.defineProperty(e,"asyncStorageWrapper",{enumerable:!0,get:function(){return r(u).default}})})(),p})(),"object"==typeof exports&&"object"==typeof module?module.exports=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):"function"==typeof define&&define.amd?define(["./uniqueId.js","./asyncStorageWrapper.js","./throwWrongKeyOnActionCollectionConfig.js","./isRecord.js","./createContext.js","./createGlobalState.js","./shallowCompare.js","./GlobalStore.js"],r):"object"==typeof exports?exports["react-native-global-state-hooks"]=r(require("./uniqueId.js"),require("./asyncStorageWrapper.js"),require("./throwWrongKeyOnActionCollectionConfig.js"),require("./isRecord.js"),require("./createContext.js"),require("./createGlobalState.js"),require("./shallowCompare.js"),require("./GlobalStore.js")):e["react-native-global-state-hooks"]=r(e["./uniqueId.js"],e["./asyncStorageWrapper.js"],e["./throwWrongKeyOnActionCollectionConfig.js"],e["./isRecord.js"],e["./createContext.js"],e["./createGlobalState.js"],e["./shallowCompare.js"],e["./GlobalStore.js"]);
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
- 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-native-global-state-hooks"]=e(require("react-hooks-global-states/createContext")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/createContext"]);
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;
@@ -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<State, PublicStateMutator, Metadata>;
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<State, PublicStateMutator, Metadata>;
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>;
@@ -1 +1 @@
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-native-global-state-hooks"]=e(require("./GlobalStore.js")):this["react-native-global-state-hooks"]=e(this["./GlobalStore.js"]);
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 { StateApi, ObservableFragment, MetadataSetter, StateChanges, StoreTools, ActionCollectionResult, GlobalStoreCallbacks, UseHookOptions, UnsubscribeCallback, SubscribeCallbackConfig, SubscribeCallback, BaseMetadata as BaseMetadata, MetadataGetter, SelectorCallback, SubscriberParameters, SubscriptionCallback, StateHook, ActionCollectionConfig, } from "./types";
6
- export { shallowCompare } from "./shallowCompare";
7
- export { uniqueId, type BrandedId } from "./uniqueId";
8
- export { throwWrongKeyOnActionCollectionConfig } from "./throwWrongKeyOnActionCollectionConfig";
9
- export { isRecord } from "./isRecord";
10
- export { type ContextProvider, type ContextHook, type InferContextApi, createContext } from "./createContext";
11
- export type { AsyncStorageConfig } from "./types";
12
- export { default as GlobalStore } from "./GlobalStore";
13
- export { createGlobalState, type InferActionsType, type InferStateApi, type AnyActions, } from "./createGlobalState";
14
- export { default as asyncStorageWrapper, type AsyncStorageManager } from "./asyncStorageWrapper";
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
- 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-native-global-state-hooks"]=e(require("react-hooks-global-states/isRecord")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/isRecord"]);
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": "15.0.2",
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.js",
5
+ "main": "./bundle.cjs",
6
+ "module": "./bundle.mjs",
6
7
  "types": "./index.d.ts",
7
8
  "sideEffects": false,
8
9
  "exports": {
9
10
  ".": {
10
- "import": "./bundle.js",
11
- "require": "./bundle.js",
12
- "types": "./index.d.ts"
11
+ "types": "./index.d.ts",
12
+ "import": "./bundle.mjs",
13
+ "require": "./bundle.cjs"
13
14
  },
14
15
  "./asyncStorageWrapper": {
15
- "import": "./asyncStorageWrapper.js",
16
- "require": "./asyncStorageWrapper.js",
17
- "types": "./asyncStorageWrapper.d.ts"
16
+ "types": "./asyncStorageWrapper.d.ts",
17
+ "import": "./asyncStorageWrapper.mjs",
18
+ "require": "./asyncStorageWrapper.cjs"
18
19
  },
19
20
  "./createContext": {
20
- "import": "./createContext.js",
21
- "require": "./createContext.js",
22
- "types": "./createContext.d.ts"
21
+ "types": "./createContext.d.ts",
22
+ "import": "./createContext.mjs",
23
+ "require": "./createContext.cjs"
23
24
  },
24
25
  "./createGlobalState": {
25
- "import": "./createGlobalState.js",
26
- "require": "./createGlobalState.js",
27
- "types": "./createGlobalState.d.ts"
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
- "import": "./GlobalStore.js",
31
- "require": "./GlobalStore.js",
32
- "types": "./GlobalStore.d.ts"
36
+ "types": "./GlobalStore.d.ts",
37
+ "import": "./GlobalStore.mjs",
38
+ "require": "./GlobalStore.cjs"
33
39
  },
34
40
  "./isRecord": {
35
- "import": "./isRecord.js",
36
- "require": "./isRecord.js",
37
- "types": "./isRecord.d.ts"
41
+ "types": "./isRecord.d.ts",
42
+ "import": "./isRecord.mjs",
43
+ "require": "./isRecord.cjs"
38
44
  },
39
45
  "./shallowCompare": {
40
- "import": "./shallowCompare.js",
41
- "require": "./shallowCompare.js",
42
- "types": "./shallowCompare.d.ts"
46
+ "types": "./shallowCompare.d.ts",
47
+ "import": "./shallowCompare.mjs",
48
+ "require": "./shallowCompare.cjs"
43
49
  },
44
50
  "./throwWrongKeyOnActionCollectionConfig": {
45
- "import": "./throwWrongKeyOnActionCollectionConfig.js",
46
- "require": "./throwWrongKeyOnActionCollectionConfig.js",
47
- "types": "./throwWrongKeyOnActionCollectionConfig.d.ts"
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": "^3.0.2",
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": "^15.0.8"
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
- 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-native-global-state-hooks"]=e(require("react-hooks-global-states/shallowCompare")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/shallowCompare"]);
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
- 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-native-global-state-hooks"]=e(require("react-hooks-global-states/throwWrongKeyOnActionCollectionConfig")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/throwWrongKeyOnActionCollectionConfig"]);
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.Dispatch<React.SetStateAction<State>>;
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
- 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-native-global-state-hooks"]=e():this["react-native-global-state-hooks"]=e();
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, default } from "react-hooks-global-states/uniqueId";
1
+ export { uniqueId, default, type BrandedId, type UniqueId } from "react-hooks-global-states/uniqueId";
package/uniqueId.js CHANGED
@@ -1 +1 @@
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-native-global-state-hooks"]=e(require("react-hooks-global-states/uniqueId")):this["react-native-global-state-hooks"]=e(this["react-hooks-global-states/uniqueId"]);
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};