Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hooks-global-state

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hooks-global-state - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

2

dist/index.modern.js

@@ -1,2 +0,2 @@

import{createMutableSource as t,useCallback as e,useMutableSource as r}from"react";const o=(t,e)=>"function"==typeof e?e(t):e,n=(t,e)=>{if(!t.includes(e))throw new Error(`'${e}' not found. It must be provided in initialState as a property key.`)};function s(e,r){const s=Object.keys(e);let a=e;const c=(()=>{const t=new Map;return s.forEach(e=>{t.set(e,new Set)}),t.set(null,new Set),t})(),u=(t,e)=>{s.forEach(r=>{t[r]!==e[r]&&c.get(r).forEach(t=>{t()})}),c.get(null).forEach(t=>{t()})},i={getState:()=>a,setState:t=>{const e=a;a=o(e,t),u(e,a)},getStateByKey:t=>("production"!==process.env.NODE_ENV&&n(s,t),a[t]),setStateByKey:(t,e)=>{var r;"production"!==process.env.NODE_ENV&&n(s,t),r=a,a={...r,[t]:o(r[t],e)},c.get(t).forEach(t=>{t()}),c.get(null).forEach(t=>{t()})},dispatch:t=>{if(!r)throw new Error("no reducer specified");const e=a;return a=r(e,t),u(e,a),t},subscribe:(t,e)=>{const r=c.get(t);return r.add(e),()=>{r.delete(e)}},mutableSource:void 0};return i.mutableSource=t(i,()=>a),i}function a(t,o){const n=e(t=>o?t.getStateByKey(o):t.getState(),[o]),s=e((t,e)=>t.subscribe(o||null,e),[o]);return[r(t.mutableSource,n,s),e(e=>{o?t.setStateByKey(o,e):t.setState(e)},[t,o])]}const c=t=>{const e=s(t);return{useGlobalState:t=>a(e,t),getGlobalState:e.getStateByKey,setGlobalState:e.setStateByKey}},u=(t,e=t(void 0,{type:void 0}),r)=>{if(r)return r(u)(t,e);const o=s(e,t);return{useGlobalState:t=>a(o,t),getState:o.getState,setState:o.setState,dispatch:o.dispatch}},i=()=>{if(!window.__REDUX_DEVTOOLS_EXTENSION__)return t=>t;const{before:t,after:e}=(()=>{let t,e;return{before:r=>(o,n,s)=>{if(t=o,e=n,s)return s(r)(o,n);const a=r(o,n);return{...a,useGlobalState:t=>{const[e]=a.useGlobalState(t);return[e,()=>{throw new Error("Update is not allowed when using DevTools")}]}}},after:r=>(o,n,s)=>{if(s)return s(r)(o,n);const a=r(t,e);let c={...o(n,{type:"@@redux/INIT"}),...e};const u=[];return{...a,getState:()=>c,dispatch:t=>(c=o(c,t),a.setState(c.computedStates[c.currentStateIndex].state),u.forEach(t=>t()),t),subscribe:t=>(u.push(t),()=>{const e=u.indexOf(t);u.splice(e,1)})}}}})();return((...t)=>t.reduce((t,e)=>(...r)=>t(e(...r))))(t,window.__REDUX_DEVTOOLS_EXTENSION__(),e)};export{s as createAtom,c as createGlobalState,u as createStore,i as reduxDevToolsExt,a as useAtom};
import{unstable_createMutableSource as t,useCallback as e,unstable_useMutableSource as r}from"react";const o=(t,e)=>"function"==typeof e?e(t):e,n=(t,e)=>{if(!t.includes(e))throw new Error(`'${e}' not found. It must be provided in initialState as a property key.`)};function s(e,r){const s=Object.keys(e);let a=e;const c=(()=>{const t=new Map;return s.forEach(e=>{t.set(e,new Set)}),t.set(null,new Set),t})(),u=(t,e)=>{s.forEach(r=>{t[r]!==e[r]&&c.get(r).forEach(t=>{t()})}),c.get(null).forEach(t=>{t()})},i={getState:()=>a,setState:t=>{const e=a;a=o(e,t),u(e,a)},getStateByKey:t=>("production"!==process.env.NODE_ENV&&n(s,t),a[t]),setStateByKey:(t,e)=>{var r;"production"!==process.env.NODE_ENV&&n(s,t),r=a,a={...r,[t]:o(r[t],e)},c.get(t).forEach(t=>{t()}),c.get(null).forEach(t=>{t()})},dispatch:t=>{if(!r)throw new Error("no reducer specified");const e=a;return a=r(e,t),u(e,a),t},subscribe:(t,e)=>{const r=c.get(t);return r.add(e),()=>{r.delete(e)}},mutableSource:void 0};return i.mutableSource=t(i,()=>a),i}function a(t,o){const n=e(t=>o?t.getStateByKey(o):t.getState(),[o]),s=e((t,e)=>t.subscribe(o||null,e),[o]);return[r(t.mutableSource,n,s),e(e=>{o?t.setStateByKey(o,e):t.setState(e)},[t,o])]}const c=t=>{const e=s(t);return{useGlobalState:t=>a(e,t),getGlobalState:e.getStateByKey,setGlobalState:e.setStateByKey}},u=(t,e=t(void 0,{type:void 0}),r)=>{if(r)return r(u)(t,e);const o=s(e,t);return{useGlobalState:t=>a(o,t),getState:o.getState,setState:o.setState,dispatch:o.dispatch}},i=()=>{if(!window.__REDUX_DEVTOOLS_EXTENSION__)return t=>t;const{before:t,after:e}=(()=>{let t,e;return{before:r=>(o,n,s)=>{if(t=o,e=n,s)return s(r)(o,n);const a=r(o,n);return{...a,useGlobalState:t=>{const[e]=a.useGlobalState(t);return[e,()=>{throw new Error("Update is not allowed when using DevTools")}]}}},after:r=>(o,n,s)=>{if(s)return s(r)(o,n);const a=r(t,e);let c={...o(n,{type:"@@redux/INIT"}),...e};const u=[];return{...a,getState:()=>c,dispatch:t=>(c=o(c,t),a.setState(c.computedStates[c.currentStateIndex].state),u.forEach(t=>t()),t),subscribe:t=>(u.push(t),()=>{const e=u.indexOf(t);u.splice(e,1)})}}}})();return((...t)=>t.reduce((t,e)=>(...r)=>t(e(...r))))(t,window.__REDUX_DEVTOOLS_EXTENSION__(),e)};export{s as createAtom,c as createGlobalState,u as createStore,i as reduxDevToolsExt,a as useAtom};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).reactHooksGlobalState={},t.react)}(this,function(t,e){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var r=function(t,e){return"function"==typeof e?e(t):e},u=function(t,e){if(!t.includes(e))throw new Error("'"+e+"' not found. It must be provided in initialState as a property key.")};function o(t,o){var c=Object.keys(t),a=t,i=function(){var t=new Map;return c.forEach(function(e){t.set(e,new Set)}),t.set(null,new Set),t}(),f=function(t,e){c.forEach(function(n){t[n]!==e[n]&&i.get(n).forEach(function(t){t()})}),i.get(null).forEach(function(t){t()})},s={getState:function(){return a},setState:function(t){var e=a;a=r(e,t),f(e,a)},getStateByKey:function(t){return"production"!==process.env.NODE_ENV&&u(c,t),a[t]},setStateByKey:function(t,e){var o,f;"production"!==process.env.NODE_ENV&&u(c,t),a=n({},o=a,((f={})[t]=r(o[t],e),f)),i.get(t).forEach(function(t){t()}),i.get(null).forEach(function(t){t()})},dispatch:function(t){if(!o)throw new Error("no reducer specified");var e=a;return a=o(e,t),f(e,a),t},subscribe:function(t,e){var n=i.get(t);return n.add(e),function(){n.delete(e)}},mutableSource:void 0};return s.mutableSource=e.createMutableSource(s,function(){return a}),s}function c(t,n){var r=e.useCallback(function(t){return n?t.getStateByKey(n):t.getState()},[n]),u=e.useCallback(function(t,e){return t.subscribe(n||null,e)},[n]);return[e.useMutableSource(t.mutableSource,r,u),e.useCallback(function(e){n?t.setStateByKey(n,e):t.setState(e)},[t,n])]}t.createAtom=o,t.createGlobalState=function(t){var e=o(t);return{useGlobalState:function(t){return c(e,t)},getGlobalState:e.getStateByKey,setGlobalState:e.setStateByKey}},t.createStore=function t(e,n,r){if(void 0===n&&(n=e(void 0,{type:void 0})),r)return r(t)(e,n);var u=o(n,e);return{useGlobalState:function(t){return c(u,t)},getState:u.getState,setState:u.setState,dispatch:u.dispatch}},t.reduxDevToolsExt=function(){return window.__REDUX_DEVTOOLS_EXTENSION__?function(){return[].slice.call(arguments).reduce(function(t,e){return function(){return t(e.apply(void 0,[].slice.call(arguments)))}})}(function(r){return function(u,o,c){if(t=u,e=o,c)return c(r)(u,o);var a=r(u,o);return n({},a,{useGlobalState:function(t){return[a.useGlobalState(t)[0],function(){throw new Error("Update is not allowed when using DevTools")}]}})}},window.__REDUX_DEVTOOLS_EXTENSION__(),function(r){return function(u,o,c){if(c)return c(r)(u,o);var a=r(t,e),i=n({},u(o,{type:"@@redux/INIT"}),e),f=[];return n({},a,{getState:function(){return i},dispatch:function(t){return i=u(i,t),a.setState(i.computedStates[i.currentStateIndex].state),f.forEach(function(t){return t()}),t},subscribe:function(t){return f.push(t),function(){var e=f.indexOf(t);f.splice(e,1)}}})}}):function(t){return t};var t,e},t.useAtom=c});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((t=t||self).reactHooksGlobalState={},t.react)}(this,function(t,e){function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var r=function(t,e){return"function"==typeof e?e(t):e},u=function(t,e){if(!t.includes(e))throw new Error("'"+e+"' not found. It must be provided in initialState as a property key.")};function o(t,o){var a=Object.keys(t),c=t,i=function(){var t=new Map;return a.forEach(function(e){t.set(e,new Set)}),t.set(null,new Set),t}(),f=function(t,e){a.forEach(function(n){t[n]!==e[n]&&i.get(n).forEach(function(t){t()})}),i.get(null).forEach(function(t){t()})},s={getState:function(){return c},setState:function(t){var e=c;c=r(e,t),f(e,c)},getStateByKey:function(t){return"production"!==process.env.NODE_ENV&&u(a,t),c[t]},setStateByKey:function(t,e){var o,f;"production"!==process.env.NODE_ENV&&u(a,t),c=n({},o=c,((f={})[t]=r(o[t],e),f)),i.get(t).forEach(function(t){t()}),i.get(null).forEach(function(t){t()})},dispatch:function(t){if(!o)throw new Error("no reducer specified");var e=c;return c=o(e,t),f(e,c),t},subscribe:function(t,e){var n=i.get(t);return n.add(e),function(){n.delete(e)}},mutableSource:void 0};return s.mutableSource=e.unstable_createMutableSource(s,function(){return c}),s}function a(t,n){var r=e.useCallback(function(t){return n?t.getStateByKey(n):t.getState()},[n]),u=e.useCallback(function(t,e){return t.subscribe(n||null,e)},[n]);return[e.unstable_useMutableSource(t.mutableSource,r,u),e.useCallback(function(e){n?t.setStateByKey(n,e):t.setState(e)},[t,n])]}t.createAtom=o,t.createGlobalState=function(t){var e=o(t);return{useGlobalState:function(t){return a(e,t)},getGlobalState:e.getStateByKey,setGlobalState:e.setStateByKey}},t.createStore=function t(e,n,r){if(void 0===n&&(n=e(void 0,{type:void 0})),r)return r(t)(e,n);var u=o(n,e);return{useGlobalState:function(t){return a(u,t)},getState:u.getState,setState:u.setState,dispatch:u.dispatch}},t.reduxDevToolsExt=function(){return window.__REDUX_DEVTOOLS_EXTENSION__?function(){return[].slice.call(arguments).reduce(function(t,e){return function(){return t(e.apply(void 0,[].slice.call(arguments)))}})}(function(r){return function(u,o,a){if(t=u,e=o,a)return a(r)(u,o);var c=r(u,o);return n({},c,{useGlobalState:function(t){return[c.useGlobalState(t)[0],function(){throw new Error("Update is not allowed when using DevTools")}]}})}},window.__REDUX_DEVTOOLS_EXTENSION__(),function(r){return function(u,o,a){if(a)return a(r)(u,o);var c=r(t,e),i=n({},u(o,{type:"@@redux/INIT"}),e),f=[];return n({},c,{getState:function(){return i},dispatch:function(t){return i=u(i,t),c.setState(i.computedStates[i.currentStateIndex].state),f.forEach(function(t){return t()}),t},subscribe:function(t){return f.push(t),function(){var e=f.indexOf(t);f.splice(e,1)}}})}}):function(t){return t};var t,e},t.useAtom=a});
//# sourceMappingURL=index.umd.js.map

@@ -1,2 +0,2 @@

import { Reducer, SetStateAction, createMutableSource } from 'react';
import { Reducer, SetStateAction, unstable_createMutableSource as createMutableSource } from 'react';
declare type Unsubscribe = () => void;

@@ -3,0 +3,0 @@ export declare type Atom<State, Action> = {

{
"name": "react-hooks-global-state",
"description": "Simple global state for React with Hooks API",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"publishConfig": {

@@ -67,29 +67,29 @@ "tag": "next"

"devDependencies": {
"@babel/core": "^7.10.4",
"@pmmmwh/react-refresh-webpack-plugin": "^0.3.3",
"@testing-library/react": "^10.4.3",
"@babel/core": "^7.11.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.1",
"@testing-library/react": "^10.4.7",
"@types/expect-puppeteer": "^4.4.3",
"@types/jest": "^26.0.3",
"@types/jest": "^26.0.8",
"@types/jest-environment-puppeteer": "^4.3.2",
"@types/puppeteer": "^3.0.1",
"@types/react": "^16.9.41",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"@types/redux-logger": "^3.0.8",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"babel-loader": "^8.1.0",
"documentation": "^13.0.2",
"eslint": "^7.4.0",
"eslint": "^7.6.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.5",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"html-webpack-plugin": "^4.3.0",
"immer": "^7.0.5",
"jest": "^26.1.0",
"immer": "^7.0.7",
"jest": "^26.2.2",
"jest-puppeteer": "^4.4.0",
"microbundle": "^0.12.2",
"microbundle": "^0.12.3",
"npm-run-all": "^4.1.5",
"puppeteer": "^5.0.0",
"puppeteer": "^5.2.1",
"react": "experimental",

@@ -101,7 +101,7 @@ "react-dom": "experimental",

"redux-thunk": "^2.3.0",
"start-server-and-test": "^1.11.0",
"ts-jest": "^26.1.1",
"ts-loader": "^7.0.5",
"typescript": "^3.9.6",
"webpack": "^4.43.0",
"start-server-and-test": "^1.11.2",
"ts-jest": "^26.1.4",
"ts-loader": "^8.0.2",
"typescript": "^3.9.7",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",

@@ -108,0 +108,0 @@ "webpack-dev-server": "^3.11.0"

@@ -8,3 +8,3 @@ /* eslint @typescript-eslint/ban-ts-comment: off */

// @ts-ignore
createMutableSource,
unstable_createMutableSource as createMutableSource,
} from 'react';

@@ -11,0 +11,0 @@

@@ -8,3 +8,3 @@ /* eslint @typescript-eslint/ban-ts-comment: off */

// @ts-ignore
useMutableSource,
unstable_useMutableSource as useMutableSource,
} from 'react';

@@ -11,0 +11,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc