hermes-io 2.9.83 → 2.9.84
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.
package/lib/context/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return(_extends=Object.assign||function(
|
|
1
|
+
function _extends(){return(_extends=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}import e from"../constants";var _obj,_window_addEventListener,_window,recording=!1,collection=[];export var listenersMap=new Map;var actions=((_obj={})[e.START_RECORDING]=function(){recording=!0},_obj[e.STOP_RECORDING]=function(){recording=!1},_obj[e.RESET_RECORDING]=function(){collection=[],recording=!1},_obj[e.SET_CONTEXT]=function(e){var n=e.id,t=void 0===n?"":n,r=collection.find(function(e){return e._internalId===t});if(r){if(r.isFromExternalRecording){var i=listenersMap.get(r.listener);return null==i?void 0:i({value:JSON.parse(r.value)})}return r.listener(r.value)}},_obj[e.LOAD_RECORDING]=function(e){collection=e.recording.map(function(e){return void 0===e&&(e={}),_extends({},e,{isFromExternalRecording:!0,_internalId:e.id})})},_obj);try{null==(_window=window)||null==(_window_addEventListener=_window.addEventListener)||_window_addEventListener.call(_window,"message",function(n){try{var t=n.data,r=t.source,i=t.payload;if(r===e.CHROME_EXTENSION){if(null==i?void 0:i.type)return actions[i.type](i);actions[i]()}}catch(e){console.error(e)}})}catch(e){console.error(e)}export var Context=function(n){var t=this;this.id=null,this._internalId=null,this.date=null,this.value=null,this.listener=null,this.stackTrace=null,this.update=function(e){var n=e.value,r=e.listener;t.date=new Date,t.value=n,t.stackTrace=t.getStackTrace(),t.listener=r,recording&&t.sendSnapshot()},this.sendSnapshot=function(){var n,r,i=t.takeSnapshot(),a=i.listener,o=i.stackTrace,l=i.value,c=i.date,s=i._internalId;collection.push(i);try{null==(r=window)||null==(n=r.postMessage)||n.call(r,{type:e.CONTEXT_SNAPSHOT,payload:{value:JSON.stringify(l.value),listener:a.name,stackTrace:o,date:c,id:s},source:"hermes-io"},"*")}catch(e){console.error(e)}},this.takeSnapshot=function(){return{_internalId:crypto.randomUUID(),value:t.value,date:t.date,listener:t.listener,stackTrace:t.stackTrace}},this.getStackTrace=function(){return Error().stack},this.id=Symbol(n)};
|
package/lib/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./useObserver";export*from"./useMutations";export*from"./useStore";export*from"./useObservableStore";
|
|
1
|
+
export*from"./useObserver.js";export*from"./useMutations.js";export*from"./useStore.js";export*from"./useObservableStore.js";
|
|
@@ -1 +1 @@
|
|
|
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,i=n.onChange,l=n.store,u=n.id,v=n.initialState,c=r(randomId()),
|
|
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.js";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,i=n.onChange,l=n.store,u=n.id,v=n.initialState,c=r(randomId()),s=(c[0],c[1]),d=e({state:_extends({},void 0===v?{}:v),events:[],onEvent:function(r,e){var t=d.current.events;t.some(function(e){return e.event===r})||t.push({event:r,onChange:e})}}),f=function(r){return n.noUpdate=r},_=function(r,e,t,o){var a=!r,i=!1;if(null==r||null==(l=r.forEach)||l.call(r,function(r){if(r===n.id){i=!0;var a,l=null!=(a=null==o?void 0:o(e,t,f,d.current.state))?a:{};n.noUpdate&&(l={}),d.current.state=_extends({},d.current.state,l)}}),a){var l,u,v=null!=(u=null==o?void 0:o(e,t,f,d.current.state))?u:{};n.noUpdate&&(v={}),d.current.state=_extends({},d.current.state,v)}!0!==n.noUpdate&&!1!==i&&s(randomId())};return t({id:u,microStore:l,listener:function(r,e){var t=null==(u=r.value)?void 0:null==(l=u.payload)?void 0:l.value,n=null==(v=r.value)?void 0:v.targets,o=null==(c=d.current)?void 0:c.events;if(o.length>0){for(var l,u,v,c,s,f=_create_for_of_iterator_helper_loose(o);!(s=f()).done;){var p=s.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,i)}},contexts:[null==l?void 0:l.context],observer:null==l?void 0:l.observer}),d.current};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useStore as r}from"./useStore";import{Context as e}from"../context/context";import{Observer as o}from"../observer/observer";import{Store as t}from"../store/store";export var useObservableStore=function(s,n,m,i){var c={store:new t({id:s,context:new e("Context_"+s),observer:new o}),reducer:m,data:n};return i&&(c.microStore=i),{store:r(c).store}};
|
|
1
|
+
import{useStore as r}from"./useStore.js";import{Context as e}from"../context/context.js";import{Observer as o}from"../observer/observer.js";import{Store as t}from"../store/store.js";export var useObservableStore=function(s,n,m,i){var c={store:new t({id:s,context:new e("Context_"+s),observer:new o}),reducer:m,data:n};return i&&(c.microStore=i),{store:r(c).store}};
|
package/lib/hooks/useObserver.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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])};
|
|
1
|
+
import{useEffect as l}from"react";import{MicroStore as n}from"../store/store.js";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/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./hooks";export*from"./observer/observer";export*from"./context/context";export*from"./store/store";export*from"./components/withNotify/withNotify";
|
|
1
|
+
export*from"./hooks";export*from"./observer/observer.js";export*from"./context/context.js";export*from"./store/store.js";export*from"./components/withNotify/withNotify.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hermes-io",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.84",
|
|
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",
|