hermes-io 2.8.70 → 2.8.72

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.
@@ -1 +1 @@
1
- export*from"./useObserver";export*from"./useMutations";export*from"./useStore";
1
+ export*from"./useObserver";export*from"./useMutations";export*from"./useStore";export*from"./useStoreFactory";
@@ -1 +1 @@
1
- function _array_like_to_array(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=Array(t);e<t;e++)n[e]=r[e];return n}function _extends(){return(_extends=Object.assign||function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r}).apply(this,arguments)}import{useState as r,useRef as t}from"react";import{useObserver as e}from"./useObserver";var randomId=function(){var r,t;return(null==(t=crypto)?void 0:null==(r=t.randomUUID)?void 0:r.call(t))||Math.random().toString(36).substring(2,16)};export var useMutations=function(n){void 0===n&&(n={});var o=n.events,a=n.onChange,i=n.store,l=n.id,u=n.initialState,d=r(randomId()),c=(d[0],d[1]),v=t({state:_extends({},void 0===u?{}:u)}),s=function(r){return n.noUpdate=r};return e({id:l,microStore:i,listener:function(r,t){for(var e,i=function(r,t){var e="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(e)return(e=e.call(r)).next.bind(e);if(Array.isArray(r)||(e=function(r,t){if(r){if("string"==typeof r)return _array_like_to_array(r,void 0);var e=Object.prototype.toString.call(r).slice(8,-1);if("Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e)return Array.from(e);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return _array_like_to_array(r,void 0)}}(r))){e&&(r=e);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(o);!(e=i()).done;)!function(){var o=e.value;if(r.value.type===o){var i=null==(y=r.value)?void 0:null==(f=y.payload)?void 0:f.value,l=null==(p=r.value)?void 0:p.targets,u=!l,d=!1;if(null==l||null==(m=l.forEach)||m.call(l,function(r){if(r===n.id){d=!0;var e,o=null!=(e=null==a?void 0:a(i,t,s,v.current.state))?e:{};v.current.state=_extends({},v.current.state,o)}}),u){var f,y,p,m,_,b=null!=(_=null==a?void 0:a(i,t,s,v.current.state))?_:{};v.current.state=_extends({},v.current.state,b)}!0!==n.noUpdate&&!1!==d&&c(randomId())}}()},contexts:[null==i?void 0:i.context],observer:null==i?void 0:i.observer}),v.current};
1
+ function _array_like_to_array(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function _extends(){return(_extends=Object.assign||function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r}).apply(this,arguments)}function _create_for_of_iterator_helper_loose(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return _array_like_to_array(r,void 0);var t=Object.prototype.toString.call(r).slice(8,-1);if("Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return _array_like_to_array(r,void 0)}}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0;return function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}import{useState as r,useRef as e}from"react";import{useObserver as t}from"./useObserver";var randomId=function(){var r,e;return(null==(e=crypto)?void 0:null==(r=e.randomUUID)?void 0:r.call(e))||Math.random().toString(36).substring(2,16)};export var useMutations=function(n){void 0===n&&(n={});var o=n.events,a=void 0===o?[]:o,l=n.onChange,i=n.store,u=n.id,v=n.initialState,c=r(randomId()),d=(c[0],c[1]),s=e({state:_extends({},void 0===v?{}:v),events:[],onEvent:function(r,e){return s.current.events=[].concat(s.current.events,[{event:r,onChange:e}])}}),f=function(r){return n.noUpdate=r},_=function(r,e,t,o){var a=!r,l=!1;if(null==r||null==(i=r.forEach)||i.call(r,function(r){if(r===n.id){l=!0;var a,i=null!=(a=null==o?void 0:o(e,t,f,s.current.state))?a:{};n.noUpdate&&(i={}),s.current.state=_extends({},s.current.state,i)}}),a){var i,u,v=null!=(u=null==o?void 0:o(e,t,f,s.current.state))?u:{};n.noUpdate&&(v={}),s.current.state=_extends({},s.current.state,v)}!0!==n.noUpdate&&!1!==l&&d(randomId())};return t({id:u,microStore:i,listener:function(r,e){var t=null==(u=r.value)?void 0:null==(i=u.payload)?void 0:i.value,n=null==(v=r.value)?void 0:v.targets,o=null==(c=s.current)?void 0:c.events;if(o.length>0){for(var i,u,v,c,d,f=_create_for_of_iterator_helper_loose(o);!(d=f()).done;){var p=d.value;r.value.type===p.event&&_(n,t,e,p.onChange)}return}for(var y,m=_create_for_of_iterator_helper_loose(a);!(y=m()).done;){var h=y.value;r.value.type===h&&_(n,t,e,l)}},contexts:[null==i?void 0:i.context],observer:null==i?void 0:i.observer}),s.current};
@@ -0,0 +1 @@
1
+ import{useStore as r}from"./useStore";import{Context as e}from"../context/context";import{Observer as o}from"../observer/observer";export var useStoreFactory=function(t,n,c,m){var s={store:new Store({id:t,context:new e("Context_"+t),observer:new o}),reducer:c,data:n};return m&&(s.microStore=m),{store:r(s)}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermes-io",
3
- "version": "2.8.70",
3
+ "version": "2.8.72",
4
4
  "description": "A lightweight React library that allows communication between Reactjs components by using the observer pattern and the hook api",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",