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

amos

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amos - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

1

dist/amos.cjs.js

@@ -531,2 +531,3 @@ 'use strict';

}
React.useEffect(function () { return function () { var _a; return (_a = lastStore.current) === null || _a === void 0 ? void 0 : _a.disposer(); }; }, []);
if (lastStore.current.error) {

@@ -533,0 +534,0 @@ var error = lastStore.current.error;

@@ -523,2 +523,3 @@ import { __spread, __values, __read } from 'tslib';

}
useEffect(function () { return function () { var _a; return (_a = lastStore.current) === null || _a === void 0 ? void 0 : _a.disposer(); }; }, []);
if (lastStore.current.error) {

@@ -525,0 +526,0 @@ var error = lastStore.current.error;

2

dist/amos.umd.js

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).Amos={},e.React)}(this,(function(e,r){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(r),o=function(){function e(e,r,t){this.key=e,this.initialState=r,this.preload=t,this.listeners={}}return e.prototype.subscribe=function(e,r){this.listeners["string"==typeof e?e:e.type]=r},e.prototype.mutation=function(e,r){var t=this;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"mutation",type:r,box:t,args:n,result:n[0],mutator:e}}},e}();function u(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,u=t.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(n=u.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=u.return)&&t.call(u)}finally{if(o)throw o.error}}return s}function i(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(s(arguments[r]));return e}function a(e,r){return e===r}function c(e,r){if(e.length!==r.length)return!1;for(var t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}var f=Array.isArray,l=function(e){return e};function p(e,r){return r.hasOwnProperty("object")||Object.defineProperty(r,"object",{value:e}),r}function d(e,r){return!!r&&r.object===e}var y=r.createContext(null);function v(){var e=r.useContext(y);if(!e)throw new Error("[Amos] you are using hooks without <Provider />.");return e.store}var h={selectors:[],deps:[],snapshots:[],results:[]};function g(e,r){for(var t in e)if(e.hasOwnProperty(t)&&r.hasOwnProperty(t))return!0;return!1}function b(e,r,t,n){var o,u;if(!(null===(u=e.factory)||void 0===u?void 0:u.deps)||!t[n])return!0;var s=(o=e.factory).deps.apply(o,i([r.select],e.args)),a=c(t[n]||[],s);return t[n]=s,!a}function m(e,r,t){return e.factory?e.factory.compare(r,t):a(r,t)}function w(e,r,t,n,o){var u,s;if(!(e&&"function"==typeof e&&t&&e.args&&r.args))return!0;if(!(e===r||r.factory&&r.factory===e.factory))return!0;if(void 0===(null===(s=r.factory)||void 0===s?void 0:s.deps))return!c(e.args,r.args);var a=(u=r.factory).deps.apply(u,i([n.select],r.args));return!c(o||[],a)&&a}e.Box=o,e.Consumer=function(e){var r=e.children;return n.default.createElement(y.Consumer,null,(function(e){if(!e)throw new Error("[Amos] <Consumer /> should use inside <Provider />.");return r(e.store)}))},e.Provider=function(e){var t=e.store,o=e.children,u=s(r.useState({store:t}),2),i=u[0],a=u[1];return r.useEffect((function(){i.store!=i.store&&a({store:t})}),[t]),n.default.createElement(y.Provider,{value:i},o)},e.action=function(e,r){return Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"action",type:r,args:t,actor:e}}),{type:r})},e.createStore=function(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var n,o={},s=[],a=[],c=function(r){if(!o.hasOwnProperty(r.key)){var t=r.initialState;(null==e?void 0:e.hasOwnProperty(r.key))&&(t=r.preload(e[r.key],t)),o[r.key]=t,s.push(r)}},l=0,d={},y=function(e,r){(r!==o[e]||d.hasOwnProperty(e))&&(d[e]=r,o[e]=r)},v=function(e){var r,t;switch(e.object){case"action":return e.actor.apply(e,i([h.dispatch,h.select],e.args));case"mutation":return c(e.box),y(e.box.key,e.mutator.apply(e,i([o[e.box.key]],e.args))),e.result;case"signal":try{for(var n=u(s),a=n.next();!a.done;a=n.next()){var f=a.value,l=f.listeners[e.type];l&&y(f.key,l(o[f.key],e.data))}}catch(e){r={error:e}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}return e.data}},h={snapshot:function(){return o},subscribe:function(e){return a.push(e),function(){var r=a.indexOf(e);r>-1&&a.splice(r,1)}},dispatch:p("store.dispatch",(function(e){1==++l&&(d={});try{return f(e)?e.map(v):v(e)}finally{0==--l&&Object.keys(d).length>0&&a.forEach((function(e){return e(d)}))}})),select:p("store.select",(function(e,r){if("function"!=typeof e)return c(e),n&&(n[e.key]=o[e.key]),o[e.key];if(!r)return e(h.select);if(n)throw new Error("[Amos] recursive snapshot collection is not supported.");n=r;try{return e(h.select)}finally{n=void 0}}))};return(h=r.reduce((function(e,r){return r(e)}),h)).dispatch=p("store.dispatch",h.dispatch),h.select=p("store.select",h.select),"object"==typeof process&&"development"===process.env.NODE_ENV&&Object.freeze(h),h},e.identity=l,e.selector=function(e,r,t,n){void 0===t&&(t=a);var o=Object.assign((function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=r[0];if(d("store.select",n))return e.apply(void 0,i(r));var u=function(t){return e.apply(void 0,i([t],r))};return u.factory=o,u.args=r,u}),{deps:r,compare:t,type:n});return o},e.signal=function(e,r){return void 0===r&&(r=l),Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"signal",type:e,data:r.apply(void 0,i(t))}}),{type:e})},e.useDispatch=function(){return v().dispatch},e.useSelector=function(){for(var e,t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var u,i=s(r.useReducer((function(e){return e+1}),0),2),a=i[1],c=v(),f=r.useRef(h),l=r.useRef();if((null===(e=l.current)||void 0===e?void 0:e.store)!==c&&(f.current=h,null===(t=l.current)||void 0===t||t.disposer(),l.current={store:c,updated:!1,error:void 0,disposer:c.subscribe((function(e){var r,t=0,n=f.current,o=n.selectors,u=n.snapshots,s=n.results,i=n.deps,p=o.length;try{for(;t<p;t++){var d=o[t],y=u[t];if("function"==typeof d){if((!y||g(y,e))&&b(d,c,i,t)){var v={},h=c.select(d,v);(r=l.current).updated||(r.updated=!m(d,s[t],h)),u[t]=v,s[t]=h}}else e.hasOwnProperty(d.key)&&(s[t]=e[d.key],l.current.updated=!0)}l.current.updated&&a()}catch(e){u.length=s.length=t-1,l.current.error="object"==typeof e&&e?Object.assign(e,{message:"[Amos] selector throws error: "+e.message}):new Error("[Amos] selector throws falsy error: "+e),a()}}))}),l.current.error){var p=l.current.error;throw l.current.error=void 0,p}if(l.current.updated)l.current.updated=!1,u=f.current.results;else{f.current===h&&(f.current={selectors:[],deps:[],snapshots:[],results:[]});for(var d=f.current,y=d.selectors,j=d.deps,O=d.snapshots,k=d.results,x=0;x<n.length;x++){var P=y[x],E=n[x];if("object"==typeof E)k[x]=c.select(E),y[x]=E;else{var S=w(P,E,O[x],c,j[x]);if(S){O[x]=void 0;var A={};k[x]=c.select(E,A),j[x]=!0===S?void 0:S,O[x]=A,y[x]=E}}}k.length=n.length,u=k}return r.useDebugValue(u,(function(e){return e.reduce((function(e,r,t){var o,u,s,i=n[t],a="function"==typeof i?null!==(s=null!==(o=i.type)&&void 0!==o?o:null===(u=i.factory)||void 0===u?void 0:u.type)&&void 0!==s?s:i.name:i.key;return e.hasOwnProperty(a)&&(a=a+"_"+t),e[a]=r,e}),{})})),u},e.useStore=v,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).Amos={},e.React)}(this,(function(e,r){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(r),o=function(){function e(e,r,t){this.key=e,this.initialState=r,this.preload=t,this.listeners={}}return e.prototype.subscribe=function(e,r){this.listeners["string"==typeof e?e:e.type]=r},e.prototype.mutation=function(e,r){var t=this;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return{object:"mutation",type:r,box:t,args:n,result:n[0],mutator:e}}},e}();function u(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,u=t.call(e),s=[];try{for(;(void 0===r||r-- >0)&&!(n=u.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=u.return)&&t.call(u)}finally{if(o)throw o.error}}return s}function i(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(s(arguments[r]));return e}function c(e,r){return e===r}function a(e,r){if(e.length!==r.length)return!1;for(var t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}var f=Array.isArray,l=function(e){return e};function p(e,r){return r.hasOwnProperty("object")||Object.defineProperty(r,"object",{value:e}),r}function d(e,r){return!!r&&r.object===e}var y=r.createContext(null);function v(){var e=r.useContext(y);if(!e)throw new Error("[Amos] you are using hooks without <Provider />.");return e.store}var h={selectors:[],deps:[],snapshots:[],results:[]};function g(e,r){for(var t in e)if(e.hasOwnProperty(t)&&r.hasOwnProperty(t))return!0;return!1}function b(e,r,t,n){var o,u;if(!(null===(u=e.factory)||void 0===u?void 0:u.deps)||!t[n])return!0;var s=(o=e.factory).deps.apply(o,i([r.select],e.args)),c=a(t[n]||[],s);return t[n]=s,!c}function m(e,r,t){return e.factory?e.factory.compare(r,t):c(r,t)}function w(e,r,t,n,o){var u,s;if(!(e&&"function"==typeof e&&t&&e.args&&r.args))return!0;if(!(e===r||r.factory&&r.factory===e.factory))return!0;if(void 0===(null===(s=r.factory)||void 0===s?void 0:s.deps))return!a(e.args,r.args);var c=(u=r.factory).deps.apply(u,i([n.select],r.args));return!a(o||[],c)&&c}e.Box=o,e.Consumer=function(e){var r=e.children;return n.default.createElement(y.Consumer,null,(function(e){if(!e)throw new Error("[Amos] <Consumer /> should use inside <Provider />.");return r(e.store)}))},e.Provider=function(e){var t=e.store,o=e.children,u=s(r.useState({store:t}),2),i=u[0],c=u[1];return r.useEffect((function(){i.store!=i.store&&c({store:t})}),[t]),n.default.createElement(y.Provider,{value:i},o)},e.action=function(e,r){return Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"action",type:r,args:t,actor:e}}),{type:r})},e.createStore=function(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var n,o={},s=[],c=[],a=function(r){if(!o.hasOwnProperty(r.key)){var t=r.initialState;(null==e?void 0:e.hasOwnProperty(r.key))&&(t=r.preload(e[r.key],t)),o[r.key]=t,s.push(r)}},l=0,d={},y=function(e,r){(r!==o[e]||d.hasOwnProperty(e))&&(d[e]=r,o[e]=r)},v=function(e){var r,t;switch(e.object){case"action":return e.actor.apply(e,i([h.dispatch,h.select],e.args));case"mutation":return a(e.box),y(e.box.key,e.mutator.apply(e,i([o[e.box.key]],e.args))),e.result;case"signal":try{for(var n=u(s),c=n.next();!c.done;c=n.next()){var f=c.value,l=f.listeners[e.type];l&&y(f.key,l(o[f.key],e.data))}}catch(e){r={error:e}}finally{try{c&&!c.done&&(t=n.return)&&t.call(n)}finally{if(r)throw r.error}}return e.data}},h={snapshot:function(){return o},subscribe:function(e){return c.push(e),function(){var r=c.indexOf(e);r>-1&&c.splice(r,1)}},dispatch:p("store.dispatch",(function(e){1==++l&&(d={});try{return f(e)?e.map(v):v(e)}finally{0==--l&&Object.keys(d).length>0&&c.forEach((function(e){return e(d)}))}})),select:p("store.select",(function(e,r){if("function"!=typeof e)return a(e),n&&(n[e.key]=o[e.key]),o[e.key];if(!r)return e(h.select);if(n)throw new Error("[Amos] recursive snapshot collection is not supported.");n=r;try{return e(h.select)}finally{n=void 0}}))};return(h=r.reduce((function(e,r){return r(e)}),h)).dispatch=p("store.dispatch",h.dispatch),h.select=p("store.select",h.select),"object"==typeof process&&"development"===process.env.NODE_ENV&&Object.freeze(h),h},e.identity=l,e.selector=function(e,r,t,n){void 0===t&&(t=c);var o=Object.assign((function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=r[0];if(d("store.select",n))return e.apply(void 0,i(r));var u=function(t){return e.apply(void 0,i([t],r))};return u.factory=o,u.args=r,u}),{deps:r,compare:t,type:n});return o},e.signal=function(e,r){return void 0===r&&(r=l),Object.assign((function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return{object:"signal",type:e,data:r.apply(void 0,i(t))}}),{type:e})},e.useDispatch=function(){return v().dispatch},e.useSelector=function(){for(var e,t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var u,i=s(r.useReducer((function(e){return e+1}),0),2),c=i[1],a=v(),f=r.useRef(h),l=r.useRef();if((null===(e=l.current)||void 0===e?void 0:e.store)!==a&&(f.current=h,null===(t=l.current)||void 0===t||t.disposer(),l.current={store:a,updated:!1,error:void 0,disposer:a.subscribe((function(e){var r,t=0,n=f.current,o=n.selectors,u=n.snapshots,s=n.results,i=n.deps,p=o.length;try{for(;t<p;t++){var d=o[t],y=u[t];if("function"==typeof d){if((!y||g(y,e))&&b(d,a,i,t)){var v={},h=a.select(d,v);(r=l.current).updated||(r.updated=!m(d,s[t],h)),u[t]=v,s[t]=h}}else e.hasOwnProperty(d.key)&&(s[t]=e[d.key],l.current.updated=!0)}l.current.updated&&c()}catch(e){u.length=s.length=t-1,l.current.error="object"==typeof e&&e?Object.assign(e,{message:"[Amos] selector throws error: "+e.message}):new Error("[Amos] selector throws falsy error: "+e),c()}}))}),r.useEffect((function(){return function(){var e;return null===(e=l.current)||void 0===e?void 0:e.disposer()}}),[]),l.current.error){var p=l.current.error;throw l.current.error=void 0,p}if(l.current.updated)l.current.updated=!1,u=f.current.results;else{f.current===h&&(f.current={selectors:[],deps:[],snapshots:[],results:[]});for(var d=f.current,y=d.selectors,j=d.deps,O=d.snapshots,k=d.results,x=0;x<n.length;x++){var P=y[x],E=n[x];if("object"==typeof E)k[x]=a.select(E),y[x]=E;else{var S=w(P,E,O[x],a,j[x]);if(S){O[x]=void 0;var A={};k[x]=a.select(E,A),j[x]=!0===S?void 0:S,O[x]=A,y[x]=E}}}k.length=n.length,u=k}return r.useDebugValue(u,(function(e){return e.reduce((function(e,r,t){var o,u,s,i=n[t],c="function"==typeof i?null!==(s=null!==(o=i.type)&&void 0!==o?o:null===(u=i.factory)||void 0===u?void 0:u.type)&&void 0!==s?s:i.name:i.key;return e.hasOwnProperty(c)&&(c=c+"_"+t),e[c]=r,e}),{})})),u},e.useStore=v,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=amos.umd.js.map
{
"name": "amos",
"version": "0.1.1",
"version": "0.1.2",
"description": "A decentralized state manager for react",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,3 +6,3 @@ /*

import { useContext, useDebugValue, useReducer, useRef } from 'react';
import { useContext, useDebugValue, useEffect, useReducer, useRef } from 'react';
import { __Context } from './context';

@@ -204,2 +204,3 @@ import { Selector } from './selector';

}
useEffect(() => () => lastStore.current?.disposer(), []);
if (lastStore.current.error) {

@@ -206,0 +207,0 @@ const error = lastStore.current.error;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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