hermes-io 2.8.67 → 2.8.68
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
|
-
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"
|
|
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};
|
package/lib/hooks/useObserver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as l}from"react";import{
|
|
1
|
+
import{useEffect as l}from"react";import{MicroStore as n}from"../store/store";export var useObserver=function(e){l(function(){var l,u,o,r=function(l,n){var e,u;(null==v?void 0:null==(e=v.find)?void 0:e.call(v,function(n){var e;return n.id===(null==l?void 0:null==(e=l.context)?void 0:e.id)}))&&(null==l||null==(u=l.context)||u.update({value:l,listener:i}),null==i||i(l,n))},t=function(){var l,n,e=null==s?void 0:null==(l=s.get)?void 0:l.call(s,c);a=null==e?void 0:e.observer,v=(null==e?void 0:e.context)?[e.context]:[],null==a||null==(n=a.subscribe)||n.call(a,r)},i=e.listener,c=e.id,s=e.microStore,a=e.observer,v=e.contexts;return(null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](s):s instanceof n)&&c?((null==s?void 0:null==(l=s.get)?void 0:l.call(s,c))&&t(),null==s||null==(u=s.subscribe)||u.call(s,t)):null==a||null==(o=a.subscribe)||o.call(a,r),function(){var l,n;null==a||null==(l=a.unsubscribe)||l.call(a,r),null==s||null==(n=s.unsubscribe)||n.call(s,t)}},[e.id,e.listener,e.observer,e.contexts,e.microStore])};
|
package/lib/hooks/useStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as t,useEffect as
|
|
1
|
+
function _extends(){return(_extends=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t[e]=r[e])}return t}).apply(this,arguments)}import{useCallback as t,useEffect as n,useRef as r}from"react";export function useStore(e){var l,a=e.microStore,o=e.reducer,u=e.data,i=r(e.store).current,d=i.mutate=t(function(t){var n=t.type,r=t.payload,e=t.targets,l=o(i.state,{type:n,payload:r});return i.notify({type:n,payload:r,state:l,targets:e})},[]),c=i.query=t(function(t,n){var r;return null!=(r=t(i))?r:n},[]);return i.state||(i.state=_extends({},u,null!=(l=i.state)?l:{})),n(function(){var t,n;return null==a||null==(t=a.add)||t.call(a,null==i?void 0:i.id,i),null==a||null==(n=a.notify)||n.call(a),function(){var t;return null==a?void 0:null==(t=a.remove)?void 0:t.call(a,null==i?void 0:i.id)}},[null==a?void 0:a.add,null==a?void 0:a.notify,null==i?void 0:i.id]),{query:c,mutate:d,store:i}}
|
package/lib/store/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _set_prototype_of(t,e){return(_set_prototype_of=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}import{Observer as t}from"../observer/observer";export var Store=function(t){var e=this,o=t.context,r=t.observer,n=t.id;this.context=null,this.observer=null,this.id=null,this.notify=function(t){return e.observer.notify({context:e.context,value:t})},this.query=function(){return console.log("method is not conencted to the reducer, please call useStore first")},this.mutate=function(){return console.log("method is not connected to the store, you need call useStore first")},this.context=o,this.observer=r,this.
|
|
1
|
+
function _set_prototype_of(t,e){return(_set_prototype_of=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}import{Observer as t}from"../observer/observer";export var Store=function(t){var e=this,o=t.context,r=t.observer,n=t.id,i=t.initialState;this.context=null,this.observer=null,this.id=null,this.notify=function(t){return e.observer.notify({context:e.context,value:t})},this.query=function(){return console.log("method is not conencted to the reducer, please call useStore first")},this.mutate=function(){return console.log("method is not connected to the store, you need call useStore first")},this.id=n,this.context=o,this.observer=r,this.state=void 0===i?{}:i};export var MicroStore=function(t){function e(){var e;return e=t.apply(this,arguments)||this,e.collection=new Map,e.add=function(t,o){return e.collection.set(t,o),o},e.remove=function(t){return e.collection.delete(t)},e.get=function(t){return e.collection.get(t)},e}return!function(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_set_prototype_of(t,e)}(e,t),e}(t);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-io",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.68",
|
|
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",
|