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

@immobiliarelabs/atomic-state

Package Overview
Dependencies
Maintainers
6
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@immobiliarelabs/atomic-state - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [1.0.2](https://github.com/immobiliare/atomic-state/compare/v1.0.1...v1.0.2) (2021-11-24)
### Bug Fixes
* **devtools:** makes the currently installed devtools work again ([#15](https://github.com/immobiliare/atomic-state/issues/15)) ([555a674](https://github.com/immobiliare/atomic-state/commit/555a67433a07a092b6c622cebefb18809dfe7fd5))
## [1.0.1](https://github.com/immobiliare/atomic-state/compare/v1.0.0...v1.0.1) (2021-10-08)

@@ -2,0 +9,0 @@

2

dist/atomic-state.js

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

var e=require("react"),t=Object.prototype.hasOwnProperty;function n(e,r){var u,o;if(e===r)return!0;if(e&&r&&(u=e.constructor)===r.constructor){if(u===Date)return e.getTime()===r.getTime();if(u===RegExp)return e.toString()===r.toString();if(u===Array){if((o=e.length)===r.length)for(;o--&&n(e[o],r[o]););return-1===o}if(!u||"object"==typeof e){for(u in o=0,e){if(t.call(e,u)&&++o&&!t.call(r,u))return!1;if(!(u in r)||!n(e[u],r[u]))return!1}return Object.keys(r).length===o}}return e!=e&&r!=r}function r(e,t,n){var r;"undefined"!=typeof window&&window.postMessage({from:"atomic-state",type:t,key:e,value:(r=n,r?JSON.parse(JSON.stringify(r)):r)},"*")}var u="production"!==process.env.NODE_ENV;function o(e){if("object"==typeof e&&e&&!Object.isFrozen(e))for(var n in Object.freeze(e),e)t.call(e,n)&&o(e[n])}function c(e){var t=new Map,n=[],r={_load:function n(r){var o=t.get(r.key);if(void 0===o&&(t.set(r.key,null),o=r(n,u,e[r.key]),t.set(r.key,o)),null===o)throw new Error("Detected circular reference from "+r.key);return o},_update:function(n){for(var u in r.state=e=n,e){var o=t.get(u);o&&o.setState(e[u])}},state:e,_cleanup:function(){t.forEach(function(e){e&&e._cleanup()}),t.clear()},_queue:n};function u(e){n.push(e),n._process&&n._process()}return r}function a(e){var t=e.key,c=e.default,a=e.setup,i=e.deepEqualityCheck,f=function e(f,s,l){var d=new Set,p=new Set,_=function(e){if("function"==typeof e&&(e=e(g.state)),i){if(n(e,g.state))return}else if(e===g.state)return;u&&o(e),g.state=e,d.forEach(function(t){return t(e)})},v={get:function(t){return e===t?g.state:f(t).state},set:function(t,n){e===t?_(n):f(t).setState(n)}},g={add:d.add.bind(d),remove:d.delete.bind(d),state:l,setState:_,_cleanup:function(){p.forEach(function(e){e&&e()})}};if(void 0===l&&_("function"==typeof c?c(v):c),u&&(r(t,"NEW_ATOM",g.state),g.add(function(){return r(t,"UPDATE_ATOM",g.state)})),a){var b=!1,y=function(n,r,o){var c;function a(){c&&c(),p.delete(c),c=n(),p.add(c)}b&&u&&console.warn("Watch calls should not be nested. Check the setup function of "+t);var i="e"===o?function(){s(a)}:a;b=!0,r.forEach(function(t){t===e?g.add(i):f(t).add(i)}),i(),b=!1};p.add(a(e,{get:v.get,set:v.set,watch:function(e,t){y(e,t,"s")},effect:function(e,t){y(e,t,"e")}}))}return g};return f.key=t,f}var i=e.createContext(c({}));function f(t){return e.useContext(i)._load(t)}function s(t){var n=f(t),r=function(t){var n=t._getCurrentValue,r=t._subscribe,u=e.useState(function(){return{_getCurrentValue:n,_subscribe:r,_value:n()}}),o=u[0],c=u[1],a=o._value;return o._getCurrentValue===n&&o._subscribe===r||(a=n(),c({_getCurrentValue:n,_subscribe:r,_value:a})),e.useEffect(function(){var e=!1,t=function(){if(!e){var t=n();c(function(e){return e._getCurrentValue!==n||e._subscribe!==r||e._value===t?e:{_getCurrentValue:e._getCurrentValue,_subscribe:e._subscribe,_value:t}})}},u=r(t);return t(),function(){e=!0,u()}},[n,r]),a}(e.useMemo(function(){return{_getCurrentValue:function(){return n.state},_subscribe:function(e){return n.add(e),function(){return n.remove(e)}}}},[n]));return e.useDebugValue(r),[r,n.setState]}exports.AtomicStateProvider=function(t){var n=t.children,r=t.state,u=e.useMemo(function(){return c(r||{})},[]),o=e.useReducer(function(e){return!e},!1)[1];return e.useEffect(function(){r&&u.state!==r&&u._update(r)},[r,u]),e.useEffect(function(){u._queue.forEach(function(e){e&&e()}),u._queue._process=o,u._queue.length=0}),e.useEffect(function(){return u._cleanup},[]),e.createElement(i.Provider,{value:u},n)},exports.createDerivedAtom=function(e){var t=e.key,n=e.get,r=e.set,u=e.setup,o=e.deepEqualityCheck,c=function(e,c){var i={get:function(t){return e(t).state},set:function(t,n){e(t).setState(n)}},f={get:function(t){return e(t).add(d),e(t).state},set:i.set},s=a({key:t,default:function(){return n(f)},setup:u,deepEqualityCheck:o})(e,c),l=s.setState;function d(){l(n(f))}return s.setState=function(e){r&&("function"==typeof e&&(e=e(s.state)),r(e,i))},s};return c.key=t,c},exports.createStateAtom=a,exports.useAtom=f,exports.useAtomSetState=function(e){return f(e).setState},exports.useAtomValue=function(e){return s(e)[0]},exports.useStateAtom=s;
var e=require("react"),t=Object.prototype.hasOwnProperty;function n(e,r){var u,o;if(e===r)return!0;if(e&&r&&(u=e.constructor)===r.constructor){if(u===Date)return e.getTime()===r.getTime();if(u===RegExp)return e.toString()===r.toString();if(u===Array){if((o=e.length)===r.length)for(;o--&&n(e[o],r[o]););return-1===o}if(!u||"object"==typeof e){for(u in o=0,e){if(t.call(e,u)&&++o&&!t.call(r,u))return!1;if(!(u in r)||!n(e[u],r[u]))return!1}return Object.keys(r).length===o}}return e!=e&&r!=r}function r(e,t,n){var r;"undefined"!=typeof window&&window.postMessage({from:"state-atom",type:t,key:e,value:(r=n,r?JSON.parse(JSON.stringify(r)):r)},"*")}var u="production"!==process.env.NODE_ENV;function o(e){if("object"==typeof e&&e&&!Object.isFrozen(e))for(var n in Object.freeze(e),e)t.call(e,n)&&o(e[n])}function a(e){var t=new Map,n=[],r={_load:function n(r){var o=t.get(r.key);if(void 0===o&&(t.set(r.key,null),o=r(n,u,e[r.key]),t.set(r.key,o)),null===o)throw new Error("Detected circular reference from "+r.key);return o},_update:function(n){for(var u in r.state=e=n,e){var o=t.get(u);o&&o.setState(e[u])}},state:e,_cleanup:function(){t.forEach(function(e){e&&e._cleanup()}),t.clear()},_queue:n};function u(e){n.push(e),n._process&&n._process()}return r}function c(e){var t=e.key,a=e.default,c=e.setup,i=e.deepEqualityCheck,f=function e(f,s,l){var d=new Set,p=new Set,_=function(e){if("function"==typeof e&&(e=e(g.state)),i){if(n(e,g.state))return}else if(e===g.state)return;u&&o(e),g.state=e,d.forEach(function(t){return t(e)})},v={get:function(t){return e===t?g.state:f(t).state},set:function(t,n){e===t?_(n):f(t).setState(n)}},g={add:d.add.bind(d),remove:d.delete.bind(d),state:l,setState:_,_cleanup:function(){p.forEach(function(e){e&&e()})}};if(void 0===l&&_("function"==typeof a?a(v):a),u&&(r(t,"NEW_ATOM",g.state),g.add(function(){return r(t,"UPDATE_ATOM",g.state)})),c){var b=!1,y=function(n,r,o){var a;function c(){a&&a(),p.delete(a),a=n(),p.add(a)}b&&u&&console.warn("Watch calls should not be nested. Check the setup function of "+t);var i="e"===o?function(){s(c)}:c;b=!0,r.forEach(function(t){t===e?g.add(i):f(t).add(i)}),i(),b=!1};p.add(c(e,{get:v.get,set:v.set,watch:function(e,t){y(e,t,"s")},effect:function(e,t){y(e,t,"e")}}))}return g};return f.key=t,f}var i=e.createContext(a({}));function f(t){return e.useContext(i)._load(t)}function s(t){var n=f(t),r=function(t){var n=t._getCurrentValue,r=t._subscribe,u=e.useState(function(){return{_getCurrentValue:n,_subscribe:r,_value:n()}}),o=u[0],a=u[1],c=o._value;return o._getCurrentValue===n&&o._subscribe===r||(c=n(),a({_getCurrentValue:n,_subscribe:r,_value:c})),e.useEffect(function(){var e=!1,t=function(){if(!e){var t=n();a(function(e){return e._getCurrentValue!==n||e._subscribe!==r||e._value===t?e:{_getCurrentValue:e._getCurrentValue,_subscribe:e._subscribe,_value:t}})}},u=r(t);return t(),function(){e=!0,u()}},[n,r]),c}(e.useMemo(function(){return{_getCurrentValue:function(){return n.state},_subscribe:function(e){return n.add(e),function(){return n.remove(e)}}}},[n]));return e.useDebugValue(r),[r,n.setState]}exports.AtomicStateProvider=function(t){var n=t.children,r=t.state,u=e.useMemo(function(){return a(r||{})},[]),o=e.useReducer(function(e){return!e},!1)[1];return e.useEffect(function(){r&&u.state!==r&&u._update(r)},[r,u]),e.useEffect(function(){u._queue.forEach(function(e){e&&e()}),u._queue._process=o,u._queue.length=0}),e.useEffect(function(){return u._cleanup},[]),e.createElement(i.Provider,{value:u},n)},exports.createDerivedAtom=function(e){var t=e.key,n=e.get,r=e.set,u=e.setup,o=e.deepEqualityCheck,a=function(e,a){var i={get:function(t){return e(t).state},set:function(t,n){e(t).setState(n)}},f={get:function(t){return e(t).add(d),e(t).state},set:i.set},s=c({key:t,default:function(){return n(f)},setup:u,deepEqualityCheck:o})(e,a),l=s.setState;function d(){l(n(f))}return s.setState=function(e){r&&("function"==typeof e&&(e=e(s.state)),r(e,i))},s};return a.key=t,a},exports.createStateAtom=c,exports.useAtom=f,exports.useAtomSetState=function(e){return f(e).setState},exports.useAtomValue=function(e){return s(e)[0]},exports.useStateAtom=s;
//# sourceMappingURL=atomic-state.js.map

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

import{useState as t,useEffect as e,createContext as n,useMemo as r,useReducer as u,createElement as o,useContext as c,useDebugValue as i}from"react";var a=Object.prototype.hasOwnProperty;function f(t,e){var n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&f(t[r],e[r]););return-1===r}if(!n||"object"==typeof t){for(n in r=0,t){if(a.call(t,n)&&++r&&!a.call(e,n))return!1;if(!(n in e)||!f(t[n],e[n]))return!1}return Object.keys(e).length===r}}return t!=t&&e!=e}function s(t,e,n){var r;"undefined"!=typeof window&&window.postMessage({from:"atomic-state",type:e,key:t,value:(r=n,r?JSON.parse(JSON.stringify(r)):r)},"*")}var l="production"!==process.env.NODE_ENV;function d(t){if("object"==typeof t&&t&&!Object.isFrozen(t))for(var e in Object.freeze(t),t)a.call(t,e)&&d(t[e])}function _(t){var e=new Map,n=[],r={_load:function n(r){var o=e.get(r.key);if(void 0===o&&(e.set(r.key,null),o=r(n,u,t[r.key]),e.set(r.key,o)),null===o)throw new Error("Detected circular reference from "+r.key);return o},_update:function(n){for(var u in r.state=t=n,t){var o=e.get(u);o&&o.setState(t[u])}},state:t,_cleanup:function(){e.forEach(function(t){t&&t._cleanup()}),e.clear()},_queue:n};function u(t){n.push(t),n._process&&n._process()}return r}function p(t){var e=t.key,n=t.default,r=t.setup,u=t.deepEqualityCheck,o=function t(o,c,i){var a=new Set,_=new Set,p=function(t){if("function"==typeof t&&(t=t(g.state)),u){if(f(t,g.state))return}else if(t===g.state)return;l&&d(t),g.state=t,a.forEach(function(e){return e(t)})},v={get:function(e){return t===e?g.state:o(e).state},set:function(e,n){t===e?p(n):o(e).setState(n)}},g={add:a.add.bind(a),remove:a.delete.bind(a),state:i,setState:p,_cleanup:function(){_.forEach(function(t){t&&t()})}};if(void 0===i&&p("function"==typeof n?n(v):n),l&&(s(e,"NEW_ATOM",g.state),g.add(function(){return s(e,"UPDATE_ATOM",g.state)})),r){var y=!1,b=function(n,r,u){var i;function a(){i&&i(),_.delete(i),i=n(),_.add(i)}y&&l&&console.warn("Watch calls should not be nested. Check the setup function of "+e);var f="e"===u?function(){c(a)}:a;y=!0,r.forEach(function(e){e===t?g.add(f):o(e).add(f)}),f(),y=!1};_.add(r(t,{get:v.get,set:v.set,watch:function(t,e){b(t,e,"s")},effect:function(t,e){b(t,e,"e")}}))}return g};return o.key=e,o}function v(t){var e=t.key,n=t.get,r=t.set,u=t.setup,o=t.deepEqualityCheck,c=function(t,c){var i={get:function(e){return t(e).state},set:function(e,n){t(e).setState(n)}},a={get:function(e){return t(e).add(l),t(e).state},set:i.set},f=p({key:e,default:function(){return n(a)},setup:u,deepEqualityCheck:o})(t,c),s=f.setState;function l(){s(n(a))}return f.setState=function(t){r&&("function"==typeof t&&(t=t(f.state)),r(t,i))},f};return c.key=e,c}var g=n(_({}));function y(t){var n=t.children,c=t.state,i=r(function(){return _(c||{})},[]),a=u(function(t){return!t},!1)[1];return e(function(){c&&i.state!==c&&i._update(c)},[c,i]),e(function(){i._queue.forEach(function(t){t&&t()}),i._queue._process=a,i._queue.length=0}),e(function(){return i._cleanup},[]),o(g.Provider,{value:i},n)}function b(t){return c(g)._load(t)}function h(n){var u=b(n),o=function(n){var r=n._getCurrentValue,u=n._subscribe,o=t(function(){return{_getCurrentValue:r,_subscribe:u,_value:r()}}),c=o[0],i=o[1],a=c._value;return c._getCurrentValue===r&&c._subscribe===u||(a=r(),i({_getCurrentValue:r,_subscribe:u,_value:a})),e(function(){var t=!1,e=function(){if(!t){var e=r();i(function(t){return t._getCurrentValue!==r||t._subscribe!==u||t._value===e?t:{_getCurrentValue:t._getCurrentValue,_subscribe:t._subscribe,_value:e}})}},n=u(e);return e(),function(){t=!0,n()}},[r,u]),a}(r(function(){return{_getCurrentValue:function(){return u.state},_subscribe:function(t){return u.add(t),function(){return u.remove(t)}}}},[u]));return i(o),[o,u.setState]}function k(t){return b(t).setState}function E(t){return h(t)[0]}export{y as AtomicStateProvider,v as createDerivedAtom,p as createStateAtom,b as useAtom,k as useAtomSetState,E as useAtomValue,h as useStateAtom};
import{useState as t,useEffect as e,createContext as n,useMemo as r,useReducer as u,createElement as o,useContext as c,useDebugValue as a}from"react";var i=Object.prototype.hasOwnProperty;function f(t,e){var n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&f(t[r],e[r]););return-1===r}if(!n||"object"==typeof t){for(n in r=0,t){if(i.call(t,n)&&++r&&!i.call(e,n))return!1;if(!(n in e)||!f(t[n],e[n]))return!1}return Object.keys(e).length===r}}return t!=t&&e!=e}function s(t,e,n){var r;"undefined"!=typeof window&&window.postMessage({from:"state-atom",type:e,key:t,value:(r=n,r?JSON.parse(JSON.stringify(r)):r)},"*")}var l="production"!==process.env.NODE_ENV;function d(t){if("object"==typeof t&&t&&!Object.isFrozen(t))for(var e in Object.freeze(t),t)i.call(t,e)&&d(t[e])}function _(t){var e=new Map,n=[],r={_load:function n(r){var o=e.get(r.key);if(void 0===o&&(e.set(r.key,null),o=r(n,u,t[r.key]),e.set(r.key,o)),null===o)throw new Error("Detected circular reference from "+r.key);return o},_update:function(n){for(var u in r.state=t=n,t){var o=e.get(u);o&&o.setState(t[u])}},state:t,_cleanup:function(){e.forEach(function(t){t&&t._cleanup()}),e.clear()},_queue:n};function u(t){n.push(t),n._process&&n._process()}return r}function p(t){var e=t.key,n=t.default,r=t.setup,u=t.deepEqualityCheck,o=function t(o,c,a){var i=new Set,_=new Set,p=function(t){if("function"==typeof t&&(t=t(g.state)),u){if(f(t,g.state))return}else if(t===g.state)return;l&&d(t),g.state=t,i.forEach(function(e){return e(t)})},v={get:function(e){return t===e?g.state:o(e).state},set:function(e,n){t===e?p(n):o(e).setState(n)}},g={add:i.add.bind(i),remove:i.delete.bind(i),state:a,setState:p,_cleanup:function(){_.forEach(function(t){t&&t()})}};if(void 0===a&&p("function"==typeof n?n(v):n),l&&(s(e,"NEW_ATOM",g.state),g.add(function(){return s(e,"UPDATE_ATOM",g.state)})),r){var y=!1,b=function(n,r,u){var a;function i(){a&&a(),_.delete(a),a=n(),_.add(a)}y&&l&&console.warn("Watch calls should not be nested. Check the setup function of "+e);var f="e"===u?function(){c(i)}:i;y=!0,r.forEach(function(e){e===t?g.add(f):o(e).add(f)}),f(),y=!1};_.add(r(t,{get:v.get,set:v.set,watch:function(t,e){b(t,e,"s")},effect:function(t,e){b(t,e,"e")}}))}return g};return o.key=e,o}function v(t){var e=t.key,n=t.get,r=t.set,u=t.setup,o=t.deepEqualityCheck,c=function(t,c){var a={get:function(e){return t(e).state},set:function(e,n){t(e).setState(n)}},i={get:function(e){return t(e).add(l),t(e).state},set:a.set},f=p({key:e,default:function(){return n(i)},setup:u,deepEqualityCheck:o})(t,c),s=f.setState;function l(){s(n(i))}return f.setState=function(t){r&&("function"==typeof t&&(t=t(f.state)),r(t,a))},f};return c.key=e,c}var g=n(_({}));function y(t){var n=t.children,c=t.state,a=r(function(){return _(c||{})},[]),i=u(function(t){return!t},!1)[1];return e(function(){c&&a.state!==c&&a._update(c)},[c,a]),e(function(){a._queue.forEach(function(t){t&&t()}),a._queue._process=i,a._queue.length=0}),e(function(){return a._cleanup},[]),o(g.Provider,{value:a},n)}function b(t){return c(g)._load(t)}function h(n){var u=b(n),o=function(n){var r=n._getCurrentValue,u=n._subscribe,o=t(function(){return{_getCurrentValue:r,_subscribe:u,_value:r()}}),c=o[0],a=o[1],i=c._value;return c._getCurrentValue===r&&c._subscribe===u||(i=r(),a({_getCurrentValue:r,_subscribe:u,_value:i})),e(function(){var t=!1,e=function(){if(!t){var e=r();a(function(t){return t._getCurrentValue!==r||t._subscribe!==u||t._value===e?t:{_getCurrentValue:t._getCurrentValue,_subscribe:t._subscribe,_value:e}})}},n=u(e);return e(),function(){t=!0,n()}},[r,u]),i}(r(function(){return{_getCurrentValue:function(){return u.state},_subscribe:function(t){return u.add(t),function(){return u.remove(t)}}}},[u]));return a(o),[o,u.setState]}function k(t){return b(t).setState}function E(t){return h(t)[0]}export{y as AtomicStateProvider,v as createDerivedAtom,p as createStateAtom,b as useAtom,k as useAtomSetState,E as useAtomValue,h as useStateAtom};
//# sourceMappingURL=atomic-state.module.js.map
{
"name": "@immobiliarelabs/atomic-state",
"version": "1.0.1",
"version": "1.0.2",
"description": "A decentralized state management library for React inspired by Recoil.js",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/immobiliare/atomic-state",

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

# AtomicState
<p align="center">
<img src="logo.svg" alt="AtomicState" width="903" height="177" />
</p>

@@ -3,0 +5,0 @@ ![CI](https://github.com/immobiliare/atomic-state/workflows/CI/badge.svg)

@@ -16,3 +16,3 @@ function serialize(state: any) {

{
from: 'atomic-state',
from: 'state-atom',
type,

@@ -19,0 +19,0 @@ key,

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