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

@darkroom.engineering/hamo

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkroom.engineering/hamo - npm Package Compare versions

Comparing version 0.6.39 to 0.6.40

2

dist/hamo.js

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

var e=require("react"),t=require("@darkroom.engineering/tempus"),n=require("just-debounce-it"),r=require("nanoevents");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/o(t),i=/*#__PURE__*/o(n);function c(){var t=e.useState(!1),n=t[0],r=t[1];return e.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function a(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","static"),e.dataset.sticky="true"),e.offsetParent&&a(e.offsetParent)}function f(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&f(e.parentNode)}function d(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?d(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function l(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.offsetParent?l(e.offsetParent,n):n+window.scrollY}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.offsetParent?h(e.offsetParent,n):n+window.scrollX}var m=r.createNanoEvents();function p(t){var n=void 0===t?{}:t,r=n.ignoreTransform,o=void 0!==r&&r,u=n.ignoreSticky,c=void 0===u||u,p=n.debounce,g=void 0===p?500:p,b=n.lazy,w=void 0!==b&&b,E=n.callback,y=e.useState(),S=y[0],x=y[1],z=e.useRef({}),k=e.useState({}),P=k[0],R=k[1],C=e.useCallback(function(e){var t,n,r,o,u,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,a=null!=(r=a)?r:z.current.width,f=null!=(o=f)?o:z.current.height,d=null!=(u=d)?u:z.current.element,i===z.current.top&&c===z.current.left&&a===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=a,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+a,z.current.element=d,null==E||E(z.current),w||R(s({},z.current)))},[w]);e.useEffect(function(){if(S){var e=S.getBoundingClientRect();C({width:e.width,height:e.height});var t=i.default(function(e){var t=e[0];C({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},g),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,g,C]);var L=e.useState(),O=L[0],M=L[1],I=e.useCallback(function(){if(S){var e,t;if(c&&a(S),o)e=d(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+l(S),t=n.left+h(S)}c&&f(S),C({top:e,left:t,element:S})}},[o,c,S,C]);e.useEffect(function(){I();var e=i.default(I,g),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,g,I]);var T=e.useCallback(function(){if(console.log("onResize"),S){var e=S.getBoundingClientRect();C({width:e.width,height:e.height}),I()}},[S,I,C]);e.useEffect(function(){return z.current.resize=T,w||R(s({},z.current)),m.on("resize",T)},[T,w]);var j=e.useCallback(function(){return z.current},[]);return[x,w?j:P,M]}p.resize=function(){m.emit("resize")},exports.useDebug=function(){var t=c();return e.useMemo(function(){if(t){var e=window.location,n=e.href,r=new URLSearchParams(e.search),o=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,u=n.includes("#production")||r.has("production");return o&&!u}},[t])},exports.useDocumentReadyState=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},exports.useFrame=function(t,n){void 0===n&&(n=0),e.useEffect(function(){if(t)return u.default.add(t,n),function(){return u.default.remove(t)}},[t,n])},exports.useIntersectionObserver=function(t,n){var r=void 0===t?{}:t,o=r.root,u=void 0===o?null:o,i=r.rootMargin,c=void 0===i?"0px":i,s=r.threshold,a=void 0===s?0:s,f=r.once,d=void 0!==f&&f,v=r.lazy,l=void 0!==v&&v,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var p=e.useRef({}),g=e.useState({}),b=g[0],w=g[1],E=e.useState(),y=E[0],S=E[1];e.useEffect(function(){if(y){var e=new IntersectionObserver(function(t){var n=t[0];l?p.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:u,rootMargin:c,threshold:a});return e.observe(y),function(){e.disconnect()}}},[y,u,c,a,l,d].concat(n));var x=e.useCallback(function(){return p.current},[]);return[S,l?x:b]},exports.useInterval=function(t,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),e.useEffect(function(){var e=setInterval(t,n);return function(){return clearInterval(e)}},[n].concat(r))},exports.useIsClient=c,exports.useIsTouchDevice=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},exports.useMediaQuery=function(t){var n=e.useState(),r=n[0],o=n[1];return e.useEffect(function(){var e=window.matchMedia(t);function n(){o(e.matches)}return e.addEventListener("change",n,!1),n(),function(){return e.removeEventListener("change",n,!1)}},[t]),r},exports.useOutsideClickEvent=function(t,n){var r=e.useCallback(function(e){t.current&&!t.current.contains(e.target)&&n()},[t,n]);e.useEffect(function(){if(t.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,t])},exports.useRect=p,exports.useResizeObserver=function(t){var n=void 0===t?{}:t,r=n.lazy,o=void 0!==r&&r,u=n.debounce,c=void 0===u?500:u,s=n.box,a=void 0===s?"border-box":s,f=n.callback,d=void 0===f?function(){}:f,v=e.useRef({}),l=e.useState({}),h=l[0],m=l[1],p=e.useState(),g=p[0],b=p[1];e.useEffect(function(){if(g){var e=i.default(function(e){var t=e[0];v.current=t,d(t),o||m(t)},c,!0),t=new ResizeObserver(e);return t.observe(g,{box:a}),function(){t.disconnect(),e.cancel()}}},[g,o,c,a]);var w=e.useCallback(function(){return v.current},[]);return[b,o?w:h]},exports.useSlots=function(t,n){void 0===t&&(t=[]),void 0===n&&(n=[]);var r=e.useMemo(function(){return n&&[n].flat()},[n]),o=e.useMemo(function(){return t&&[t].flat()},[t]);return e.useMemo(function(){if(r&&o){var e=o.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return t[0]?e:e[0]}},[r,o])},exports.useWindowSize=function(t){void 0===t&&(t=500);var n=e.useState(),r=n[0],o=n[1],u=e.useState(),c=u[0],s=u[1];return e.useEffect(function(){var e=i.default(function(){o(Math.min(window.innerWidth,document.documentElement.clientWidth)),s(Math.min(window.innerHeight,document.documentElement.clientHeight))},t);return window.addEventListener("resize",e,!1),e(),function(){return window.removeEventListener("resize",e,!1)}},[t]),{width:r,height:c}};
var e=require("react"),t=require("@darkroom.engineering/tempus"),n=require("just-debounce-it"),r=require("nanoevents");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=/*#__PURE__*/o(t),i=/*#__PURE__*/o(n);function c(){var t=e.useState(!1),n=t[0],r=t[1];return e.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function a(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","static"),e.dataset.sticky="true"),e.offsetParent&&a(e.offsetParent)}function f(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&f(e.parentNode)}function d(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?d(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function l(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.offsetParent?l(e.offsetParent,n):n+window.scrollY}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.offsetParent?h(e.offsetParent,n):n+window.scrollX}var m=r.createNanoEvents();function p(t){var n=void 0===t?{}:t,r=n.ignoreTransform,o=void 0!==r&&r,u=n.ignoreSticky,c=void 0===u||u,p=n.debounce,b=void 0===p?500:p,g=n.lazy,w=void 0!==g&&g,E=n.callback,y=e.useState(),S=y[0],x=y[1],z=e.useRef({}),k=e.useState({}),P=k[0],C=k[1],L=e.useCallback(function(e){var t,n,r,o,u,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:z.current.top,c=null!=(n=c)?n:z.current.left,a=null!=(r=a)?r:z.current.width,f=null!=(o=f)?o:z.current.height,d=null!=(u=d)?u:z.current.element,i===z.current.top&&c===z.current.left&&a===z.current.width&&f===z.current.height&&d===z.current.element||(z.current.top=i,z.current.y=i,z.current.width=a,z.current.height=f,z.current.left=c,z.current.x=c,z.current.bottom=i+f,z.current.right=c+a,z.current.element=d,null==E||E(z.current),w||C(s({},z.current)))},[w]);e.useEffect(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height});var t=i.default(function(e){var t=e[0];L({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},b),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,b,L]);var R=e.useState(),O=R[0],M=R[1],I=e.useCallback(function(){if(S){var e,t;if(c&&a(S),o)e=d(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+l(S),t=n.left+h(S)}c&&f(S),L({top:e,left:t,element:S})}},[o,c,S,L]);e.useEffect(function(){I();var e=i.default(I,b),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,b,I]);var T=e.useCallback(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height}),I()}},[S,I,L]);e.useEffect(function(){return z.current.resize=T,w||C(s({},z.current)),m.on("resize",T)},[T,w]);var j=e.useCallback(function(){return z.current},[]);return[x,w?j:P,M]}p.resize=function(){m.emit("resize")},exports.useDebug=function(){var t=c();return e.useMemo(function(){if(t){var e=window.location,n=e.href,r=new URLSearchParams(e.search),o=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,u=n.includes("#production")||r.has("production");return o&&!u}},[t])},exports.useDocumentReadyState=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},exports.useFrame=function(t,n){void 0===n&&(n=0),e.useEffect(function(){if(t)return u.default.add(t,n),function(){return u.default.remove(t)}},[t,n])},exports.useIntersectionObserver=function(t,n){var r=void 0===t?{}:t,o=r.root,u=void 0===o?null:o,i=r.rootMargin,c=void 0===i?"0px":i,s=r.threshold,a=void 0===s?0:s,f=r.once,d=void 0!==f&&f,v=r.lazy,l=void 0!==v&&v,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var p=e.useRef({}),b=e.useState({}),g=b[0],w=b[1],E=e.useState(),y=E[0],S=E[1];e.useEffect(function(){if(y){var e=new IntersectionObserver(function(t){var n=t[0];l?p.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:u,rootMargin:c,threshold:a});return e.observe(y),function(){e.disconnect()}}},[y,u,c,a,l,d].concat(n));var x=e.useCallback(function(){return p.current},[]);return[S,l?x:g]},exports.useInterval=function(t,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),e.useEffect(function(){var e=setInterval(t,n);return function(){return clearInterval(e)}},[n].concat(r))},exports.useIsClient=c,exports.useIsTouchDevice=function(){var t=e.useState(),n=t[0],r=t[1];return e.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},exports.useMediaQuery=function(t){var n=e.useState(),r=n[0],o=n[1];return e.useEffect(function(){var e=window.matchMedia(t);function n(){o(e.matches)}return e.addEventListener("change",n,!1),n(),function(){return e.removeEventListener("change",n,!1)}},[t]),r},exports.useOutsideClickEvent=function(t,n){var r=e.useCallback(function(e){t.current&&!t.current.contains(e.target)&&n()},[t,n]);e.useEffect(function(){if(t.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,t])},exports.useRect=p,exports.useResizeObserver=function(t){var n=void 0===t?{}:t,r=n.lazy,o=void 0!==r&&r,u=n.debounce,c=void 0===u?500:u,s=n.box,a=void 0===s?"border-box":s,f=n.callback,d=void 0===f?function(){}:f,v=e.useRef({}),l=e.useState({}),h=l[0],m=l[1],p=e.useState(),b=p[0],g=p[1];e.useEffect(function(){if(b){var e=i.default(function(e){var t=e[0];v.current=t,d(t),o||m(t)},c,!0),t=new ResizeObserver(e);return t.observe(b,{box:a}),function(){t.disconnect(),e.cancel()}}},[b,o,c,a]);var w=e.useCallback(function(){return v.current},[]);return[g,o?w:h]},exports.useSlots=function(t,n){void 0===t&&(t=[]),void 0===n&&(n=[]);var r=e.useMemo(function(){return n&&[n].flat()},[n]),o=e.useMemo(function(){return t&&[t].flat()},[t]);return e.useMemo(function(){if(r&&o){var e=o.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return t[0]?e:e[0]}},[r,o])},exports.useWindowSize=function(t){void 0===t&&(t=500);var n=e.useState(),r=n[0],o=n[1],u=e.useState(),c=u[0],s=u[1];return e.useEffect(function(){var e=i.default(function(){o(Math.min(window.innerWidth,document.documentElement.clientWidth)),s(Math.min(window.innerHeight,document.documentElement.clientHeight))},t);return window.addEventListener("resize",e,!1),e(),function(){return window.removeEventListener("resize",e,!1)}},[t]),{width:r,height:c}};
//# sourceMappingURL=hamo.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@darkroom.engineering/tempus"),require("just-debounce-it"),require("nanoevents")):"function"==typeof define&&define.amd?define(["exports","react","@darkroom.engineering/tempus","just-debounce-it","nanoevents"],t):t((e||self).hamo={},e.react,e.Tempus,e.justDebounceIt,e.nanoevents)}(this,function(e,t,n,r,o){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/u(n),c=/*#__PURE__*/u(r);function a(){var e=t.useState(!1),n=e[0],r=e[1];return t.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function f(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","static"),e.dataset.sticky="true"),e.offsetParent&&f(e.offsetParent)}function d(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&d(e.parentNode)}function l(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?l(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.offsetParent?h(e.offsetParent,n):n+window.scrollY}function m(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.offsetParent?m(e.offsetParent,n):n+window.scrollX}var b=o.createNanoEvents();function g(e){var n=void 0===e?{}:e,r=n.ignoreTransform,o=void 0!==r&&r,u=n.ignoreSticky,i=void 0===u||u,a=n.debounce,g=void 0===a?500:a,p=n.lazy,w=void 0!==p&&p,y=n.callback,E=t.useState(),S=E[0],z=E[1],k=t.useRef({}),P=t.useState({}),R=P[0],C=P[1],L=t.useCallback(function(e){var t,n,r,o,u,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:k.current.top,c=null!=(n=c)?n:k.current.left,a=null!=(r=a)?r:k.current.width,f=null!=(o=f)?o:k.current.height,d=null!=(u=d)?u:k.current.element,i===k.current.top&&c===k.current.left&&a===k.current.width&&f===k.current.height&&d===k.current.element||(k.current.top=i,k.current.y=i,k.current.width=a,k.current.height=f,k.current.left=c,k.current.x=c,k.current.bottom=i+f,k.current.right=c+a,k.current.element=d,null==y||y(k.current),w||C(s({},k.current)))},[w]);t.useEffect(function(){if(S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height});var t=c.default(function(e){var t=e[0];L({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},g),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,g,L]);var x=t.useState(),O=x[0],M=x[1],I=t.useCallback(function(){if(S){var e,t;if(i&&f(S),o)e=l(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+h(S),t=n.left+m(S)}i&&d(S),L({top:e,left:t,element:S})}},[o,i,S,L]);t.useEffect(function(){I();var e=c.default(I,g),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,g,I]);var T=t.useCallback(function(){if(console.log("onResize"),S){var e=S.getBoundingClientRect();L({width:e.width,height:e.height}),I()}},[S,I,L]);t.useEffect(function(){return k.current.resize=T,w||C(s({},k.current)),b.on("resize",T)},[T,w]);var j=t.useCallback(function(){return k.current},[]);return[z,w?j:R,M]}g.resize=function(){b.emit("resize")},e.useDebug=function(){var e=a();return t.useMemo(function(){if(e){var t=window.location,n=t.href,r=new URLSearchParams(t.search),o=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,u=n.includes("#production")||r.has("production");return o&&!u}},[e])},e.useDocumentReadyState=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},e.useFrame=function(e,n){void 0===n&&(n=0),t.useEffect(function(){if(e)return i.default.add(e,n),function(){return i.default.remove(e)}},[e,n])},e.useIntersectionObserver=function(e,n){var r=void 0===e?{}:e,o=r.root,u=void 0===o?null:o,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,l=r.lazy,v=void 0!==l&&l,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var b=t.useRef({}),g=t.useState({}),p=g[0],w=g[1],y=t.useState(),E=y[0],S=y[1];t.useEffect(function(){if(E){var e=new IntersectionObserver(function(t){var n=t[0];v?b.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:u,rootMargin:c,threshold:s});return e.observe(E),function(){e.disconnect()}}},[E,u,c,s,v,d].concat(n));var z=t.useCallback(function(){return b.current},[]);return[S,v?z:p]},e.useInterval=function(e,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),t.useEffect(function(){var t=setInterval(e,n);return function(){return clearInterval(t)}},[n].concat(r))},e.useIsClient=a,e.useIsTouchDevice=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},e.useMediaQuery=function(e){var n=t.useState(),r=n[0],o=n[1];return t.useEffect(function(){var t=window.matchMedia(e);function n(){o(t.matches)}return t.addEventListener("change",n,!1),n(),function(){return t.removeEventListener("change",n,!1)}},[e]),r},e.useOutsideClickEvent=function(e,n){var r=t.useCallback(function(t){e.current&&!e.current.contains(t.target)&&n()},[e,n]);t.useEffect(function(){if(e.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,e])},e.useRect=g,e.useResizeObserver=function(e){var n=void 0===e?{}:e,r=n.lazy,o=void 0!==r&&r,u=n.debounce,i=void 0===u?500:u,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,l=t.useRef({}),v=t.useState({}),h=v[0],m=v[1],b=t.useState(),g=b[0],p=b[1];t.useEffect(function(){if(g){var e=c.default(function(e){var t=e[0];l.current=t,d(t),o||m(t)},i,!0),t=new ResizeObserver(e);return t.observe(g,{box:s}),function(){t.disconnect(),e.cancel()}}},[g,o,i,s]);var w=t.useCallback(function(){return l.current},[]);return[p,o?w:h]},e.useSlots=function(e,n){void 0===e&&(e=[]),void 0===n&&(n=[]);var r=t.useMemo(function(){return n&&[n].flat()},[n]),o=t.useMemo(function(){return e&&[e].flat()},[e]);return t.useMemo(function(){if(r&&o){var t=o.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return e[0]?t:t[0]}},[r,o])},e.useWindowSize=function(e){void 0===e&&(e=500);var n=t.useState(),r=n[0],o=n[1],u=t.useState(),i=u[0],a=u[1];return t.useEffect(function(){var t=c.default(function(){o(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},e);return window.addEventListener("resize",t,!1),t(),function(){return window.removeEventListener("resize",t,!1)}},[e]),{width:r,height:i}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@darkroom.engineering/tempus"),require("just-debounce-it"),require("nanoevents")):"function"==typeof define&&define.amd?define(["exports","react","@darkroom.engineering/tempus","just-debounce-it","nanoevents"],t):t((e||self).hamo={},e.react,e.Tempus,e.justDebounceIt,e.nanoevents)}(this,function(e,t,n,r,o){function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/u(n),c=/*#__PURE__*/u(r);function a(){var e=t.useState(!1),n=e[0],r=e[1];return t.useEffect(function(){r(!0)},[]),n}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s.apply(this,arguments)}function f(e){"sticky"===getComputedStyle(e).position&&(e.style.setProperty("position","static"),e.dataset.sticky="true"),e.offsetParent&&f(e.offsetParent)}function d(e){var t;"true"===(null==e||null==(t=e.dataset)?void 0:t.sticky)&&(e.style.removeProperty("position"),delete e.dataset.sticky),e.parentNode&&d(e.parentNode)}function l(e,t){void 0===t&&(t=0);var n=t+e.offsetTop;return e.offsetParent?l(e.offsetParent,n):n}function v(e,t){void 0===t&&(t=0);var n=t+e.offsetLeft;return e.offsetParent?v(e.offsetParent,n):n}function h(e,t){void 0===t&&(t=0);var n=t+e.scrollTop;return e.offsetParent?h(e.offsetParent,n):n+window.scrollY}function m(e,t){void 0===t&&(t=0);var n=t+e.scrollLeft;return e.offsetParent?m(e.offsetParent,n):n+window.scrollX}var b=o.createNanoEvents();function g(e){var n=void 0===e?{}:e,r=n.ignoreTransform,o=void 0!==r&&r,u=n.ignoreSticky,i=void 0===u||u,a=n.debounce,g=void 0===a?500:a,p=n.lazy,w=void 0!==p&&p,y=n.callback,E=t.useState(),S=E[0],z=E[1],k=t.useRef({}),P=t.useState({}),C=P[0],L=P[1],R=t.useCallback(function(e){var t,n,r,o,u,i=e.top,c=e.left,a=e.width,f=e.height,d=e.element;i=null!=(t=i)?t:k.current.top,c=null!=(n=c)?n:k.current.left,a=null!=(r=a)?r:k.current.width,f=null!=(o=f)?o:k.current.height,d=null!=(u=d)?u:k.current.element,i===k.current.top&&c===k.current.left&&a===k.current.width&&f===k.current.height&&d===k.current.element||(k.current.top=i,k.current.y=i,k.current.width=a,k.current.height=f,k.current.left=c,k.current.x=c,k.current.bottom=i+f,k.current.right=c+a,k.current.element=d,null==y||y(k.current),w||L(s({},k.current)))},[w]);t.useEffect(function(){if(S){var e=S.getBoundingClientRect();R({width:e.width,height:e.height});var t=c.default(function(e){var t=e[0];R({width:t.borderBoxSize[0].inlineSize,height:t.borderBoxSize[0].blockSize})},g),n=new ResizeObserver(t);return n.observe(S),function(){n.disconnect(),t.cancel()}}},[S,g,R]);var x=t.useState(),O=x[0],M=x[1],I=t.useCallback(function(){if(S){var e,t;if(i&&f(S),o)e=l(S),t=v(S);else{var n=S.getBoundingClientRect();e=n.top+h(S),t=n.left+m(S)}i&&d(S),R({top:e,left:t,element:S})}},[o,i,S,R]);t.useEffect(function(){I();var e=c.default(I,g),t=new ResizeObserver(e);return t.observe(null!=O?O:document.body),function(){t.disconnect(),e.cancel()}},[O,g,I]);var T=t.useCallback(function(){if(S){var e=S.getBoundingClientRect();R({width:e.width,height:e.height}),I()}},[S,I,R]);t.useEffect(function(){return k.current.resize=T,w||L(s({},k.current)),b.on("resize",T)},[T,w]);var j=t.useCallback(function(){return k.current},[]);return[z,w?j:C,M]}g.resize=function(){b.emit("resize")},e.useDebug=function(){var e=a();return t.useMemo(function(){if(e){var t=window.location,n=t.href,r=new URLSearchParams(t.search),o=n.includes("#debug")||n.includes("/_debug")||r.has("debug")||"development"===process.env.NODE_ENV,u=n.includes("#production")||r.has("production");return o&&!u}},[e])},e.useDocumentReadyState=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r(document.readyState)}return document.addEventListener("readystatechange",e,!1),e(),function(){return document.removeEventListener("readystatechange",e,!1)}},[]),n},e.useFrame=function(e,n){void 0===n&&(n=0),t.useEffect(function(){if(e)return i.default.add(e,n),function(){return i.default.remove(e)}},[e,n])},e.useIntersectionObserver=function(e,n){var r=void 0===e?{}:e,o=r.root,u=void 0===o?null:o,i=r.rootMargin,c=void 0===i?"0px":i,a=r.threshold,s=void 0===a?0:a,f=r.once,d=void 0!==f&&f,l=r.lazy,v=void 0!==l&&l,h=r.callback,m=void 0===h?function(){}:h;void 0===n&&(n=[]);var b=t.useRef({}),g=t.useState({}),p=g[0],w=g[1],y=t.useState(),E=y[0],S=y[1];t.useEffect(function(){if(E){var e=new IntersectionObserver(function(t){var n=t[0];v?b.current=n:w(n),m(n),d&&n.isIntersecting&&e.disconnect()},{root:u,rootMargin:c,threshold:s});return e.observe(E),function(){e.disconnect()}}},[E,u,c,s,v,d].concat(n));var z=t.useCallback(function(){return b.current},[]);return[S,v?z:p]},e.useInterval=function(e,n,r){void 0===n&&(n=1e3),void 0===r&&(r=[]),t.useEffect(function(){var t=setInterval(e,n);return function(){return clearInterval(t)}},[n].concat(r))},e.useIsClient=a,e.useIsTouchDevice=function(){var e=t.useState(),n=e[0],r=e[1];return t.useEffect(function(){function e(){r("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0)}return window.addEventListener("resize",e,!1),e(),function(){window.removeEventListener("resize",e,!1)}},[]),n},e.useMediaQuery=function(e){var n=t.useState(),r=n[0],o=n[1];return t.useEffect(function(){var t=window.matchMedia(e);function n(){o(t.matches)}return t.addEventListener("change",n,!1),n(),function(){return t.removeEventListener("change",n,!1)}},[e]),r},e.useOutsideClickEvent=function(e,n){var r=t.useCallback(function(t){e.current&&!e.current.contains(t.target)&&n()},[e,n]);t.useEffect(function(){if(e.current)return document.addEventListener("mousedown",r),function(){document.removeEventListener("mousedown",r)}},[r,e])},e.useRect=g,e.useResizeObserver=function(e){var n=void 0===e?{}:e,r=n.lazy,o=void 0!==r&&r,u=n.debounce,i=void 0===u?500:u,a=n.box,s=void 0===a?"border-box":a,f=n.callback,d=void 0===f?function(){}:f,l=t.useRef({}),v=t.useState({}),h=v[0],m=v[1],b=t.useState(),g=b[0],p=b[1];t.useEffect(function(){if(g){var e=c.default(function(e){var t=e[0];l.current=t,d(t),o||m(t)},i,!0),t=new ResizeObserver(e);return t.observe(g,{box:s}),function(){t.disconnect(),e.cancel()}}},[g,o,i,s]);var w=t.useCallback(function(){return l.current},[]);return[p,o?w:h]},e.useSlots=function(e,n){void 0===e&&(e=[]),void 0===n&&(n=[]);var r=t.useMemo(function(){return n&&[n].flat()},[n]),o=t.useMemo(function(){return e&&[e].flat()},[e]);return t.useMemo(function(){if(r&&o){var t=o.map(function(e){var t;return null==(t=r.find(function(t){return t.type===e}))?void 0:t.props.children});return e[0]?t:t[0]}},[r,o])},e.useWindowSize=function(e){void 0===e&&(e=500);var n=t.useState(),r=n[0],o=n[1],u=t.useState(),i=u[0],a=u[1];return t.useEffect(function(){var t=c.default(function(){o(Math.min(window.innerWidth,document.documentElement.clientWidth)),a(Math.min(window.innerHeight,document.documentElement.clientHeight))},e);return window.addEventListener("resize",t,!1),t(),function(){return window.removeEventListener("resize",t,!1)}},[e]),{width:r,height:i}}});
//# sourceMappingURL=hamo.umd.js.map
{
"name": "@darkroom.engineering/hamo",
"version": "0.6.39",
"version": "0.6.40",
"description": "hamo means hook, do the math.",

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

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

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