Comparing version 0.1.1 to 0.2.0
@@ -1,1 +0,1 @@ | ||
(function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l.Chinooks={},l.React))})(this,function(l,i){"use strict";var oe=Object.defineProperty,ce=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t,n)=>(ce(e,typeof t!="symbol"?t+"":t,n),n),$=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},r=(e,t,n)=>($(e,t,"read from private field"),n?n.call(e):t.get(e)),b=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},a=(e,t,n,s)=>($(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Q=(e,t,n,s)=>({set _(c){a(e,t,c,n)},get _(){return r(e,t,s)}}),N=(e,t,n)=>($(e,t,"access private method"),n);class le{constructor(t){q(this,"parent"),q(this,"point"),q(this,"left"),q(this,"right"),this.point=t,this.parent=null,this.left=null,this.right=null}}var p,w,C,X,Z,V,O;class he{constructor(t,n={clone:!0}){b(this,X),b(this,V),b(this,p,void 0),b(this,w,void 0),b(this,C,void 0);var s;a(this,p,t?n!=null&&n.clone?[...t]:t:[]),a(this,w,((s=t==null?void 0:t[0])==null?void 0:s.length)??0),a(this,C,N(this,V,O).call(this,r(this,p),0,null))}get dimensions(){return r(this,w)}get tree(){return r(this,C)}[Symbol.iterator](){return r(this,p)[Symbol.iterator]()}insert(t){if(!r(this,p).length)a(this,w,t.length);else if(r(this,w)!==t.length)throw new TypeError(`Point [${t}] has ${t.length} dimensions, but should have ${r(this,w)}`);r(this,p).push(t),a(this,C,N(this,V,O).call(this,r(this,p),0,null))}remove(t){if(!r(this,p).length||t.length!==r(this,w))return;const n=this.nearestNeighbor(t);if(n.distance===0){const s=r(this,p).findIndex(c=>c===n.point);return r(this,p).splice(s,1),a(this,C,N(this,V,O).call(this,r(this,p),0,null)),n.point}}has(t){return t.length!==r(this,w)?!1:this.nearestNeighbor(t).distance===0}nearestNeighbor(t){function n(o,h){return h?o.reduce((y,m,S)=>y+(m-h[S])**2,0):1/0}function s(o,h){return o&&(!h||n(t,o.point)<=n(t,h.point))?o:h}const c=(o,h)=>{if(!o)return null;let y,m;t[h%r(this,w)]<=o.point[h%this.dimensions]?(y=o.left,m=o.right):(y=o.right,m=o.left);let S=c(y,h+1),g=s(S,o);const D=n(t,g==null?void 0:g.point),k=t[h%r(this,w)]-o.point[h%r(this,w)];return D>=k**2&&(S=c(m,h+1),g=s(S,g)),g},u=c(r(this,C),0);return{point:(u==null?void 0:u.point)??null,distance:Math.sqrt(n(t,u==null?void 0:u.point))}}}p=new WeakMap,w=new WeakMap,C=new WeakMap,X=new WeakSet,Z=function(e){const t=Math.floor(e.length/2);return[e[t],t]},V=new WeakSet,O=function(e,t,n){if(e.length===0)return null;e.sort((h,y)=>h[t]-y[t]);const[s,c]=N(this,X,Z).call(this,e),u=(t+1)%r(this,w),o=new le(s);return o.parent=n,o.left=N(this,V,O).call(this,e.slice(0,c),u,o),o.right=N(this,V,O).call(this,e.slice(c+1),u,o),o};var v,M,W,T;const ee=class{constructor(e){if(b(this,v,void 0),b(this,M,void 0),b(this,W,0),b(this,T,0),typeof e!="number"||e<=0)throw new RangeError("Must be initialized with a capacity");a(this,v,new Array(e).fill(null)),a(this,M,e)}static from(e){const t=new ee(e.length);return a(t,v,e),t}get capacity(){return r(this,M)}get data(){return r(this,v)}get isEmpty(){return r(this,v).every(e=>e===null)}get isFull(){return r(this,v).every(e=>e!==null)}get[Symbol.toStringTag](){return"RingBuffer"}toString(){return JSON.stringify({data:r(this,v),capacity:r(this,M)})}[Symbol.iterator](){return r(this,v)[Symbol.iterator]()}peek(e=0){return r(this,v).at((r(this,W)+e)%r(this,M))??null}enqueue(e){r(this,v)[Q(this,T)._++]=e,a(this,T,r(this,T)%r(this,M))}dequeue(){const[e]=r(this,v).splice(Q(this,W)._++,1,null);return a(this,W,r(this,W)%r(this,M)),e}drain(){const e=r(this,v).filter(t=>t!==null);return a(this,v,[]),a(this,W,0),a(this,T,0),e}};let ae=ee;v=new WeakMap,M=new WeakMap,W=new WeakMap,T=new WeakMap;function _(e,t,n){if(e>t)throw new RangeError("Minimum must be less than maximum");if(!(typeof n>"u")&&(e>n||n>t))throw new RangeError("Value must be between minimum and maximum")}function j(e){const t=typeof e=="number"?e:Number(e);if(!Number.isSafeInteger(t))throw new RangeError("Values must be safe integers");return t.valueOf()}function F(e,t,n){return Math.min(Math.max(n,e),t)}function fe(e,t,n){return _(e,t),F(e,t,n)}function de(e,t,n){if(0>n||n>1)throw new RangeError("Value must be between 0 and 1 inclusive");return e+(t-e)*n}var P,I,d;const te=class{constructor({max:e,min:t=0},n){if(b(this,P,void 0),b(this,I,void 0),b(this,d,void 0),!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||typeof n<"u"&&!Number.isSafeInteger(n))throw new RangeError("Values must be integers");_(t,e,n),a(this,P,e),a(this,I,t),a(this,d,n??t)}static from(e){return new te({max:e.max,min:e.min},e.value)}add(e){const t=typeof e=="number"?e:Number(e);if(!Number.isSafeInteger(t))throw new RangeError("Values must be integers");return t===0?this:(a(this,d,F(r(this,I),r(this,P),r(this,d)+t)),this)}sub(e){return this.add(-e)}mul(e){const t=j(e);return t===1?this:(a(this,d,F(r(this,I),r(this,P),r(this,d)*t)),this)}div(e){const t=j(e);if(t===0)throw new Error("Cannot divide by zero");return a(this,d,F(r(this,I),r(this,P),Math.trunc(r(this,d)/t))),this}get value(){return r(this,d)}get min(){return r(this,I)}get max(){return r(this,P)}valueOf(){return r(this,d)}toFixed(e){return r(this,d).toFixed(e)}toExponential(e){return r(this,d).toExponential(e)}toPrecision(e){return r(this,d).toPrecision(e)}toString(e){return r(this,d).toString(e)}toLocaleString(e,t){return r(this,d).toLocaleString(e,t)}[Symbol.toPrimitive](e){return e==="string"?this.toString():r(this,d)}get[Symbol.toStringTag](){return"Saturating"}};let J=te;P=new WeakMap,I=new WeakMap,d=new WeakMap;class me{}var R,E,f;const ne=class{constructor({max:e,min:t=0},n){if(b(this,R,void 0),b(this,E,void 0),b(this,f,void 0),!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||typeof n<"u"&&!Number.isSafeInteger(n))throw new RangeError("Values must be safe integers");_(t,e,n),a(this,R,e),a(this,E,t),a(this,f,n??t)}static from(e){return new ne({max:e.max,min:e.min},e.value)}add(e){const t=j(e);if(t===0)return this;if(r(this,f)+t<=r(this,R)&&r(this,f)+t>=r(this,E))return a(this,f,r(this,f)+t),this;const n=t%(Math.abs(r(this,R)-r(this,E))+1);return r(this,f)+n<=r(this,R)&&r(this,f)+n>=r(this,E)?(a(this,f,r(this,f)+n),this):n>0?(a(this,f,n-(r(this,R)-r(this,f))+(r(this,E)-1)),this):n<0?(a(this,f,n-(r(this,E)-r(this,f))+(r(this,R)+1)),this):this}sub(e){return this.add(-e)}get value(){return r(this,f)}get min(){return r(this,E)}get max(){return r(this,R)}valueOf(){return r(this,f)}toFixed(e){return r(this,f).toFixed(e)}toExponential(e){return r(this,f).toExponential(e)}toPrecision(e){return r(this,f).toPrecision(e)}toString(e){return r(this,f).toString(e)}toLocaleString(e,t){return r(this,f).toLocaleString(e,t)}[Symbol.toPrimitive](e){return e==="string"?this.toString():r(this,f)}get[Symbol.toStringTag](){return"Wrapping"}};let x=ne;R=new WeakMap,E=new WeakMap,f=new WeakMap;const ge=e=>null,be=e=>(e+1)%1e6,B=()=>{const[,e]=i.useReducer(be,0);return e},ve=(e,t)=>{const n=i.useRef(new x({max:[...e].length-1},t??0)),[s,c]=i.useState([...e][n.current.value]);i.useEffect(()=>{const o=[...e];o.length-1!==n.current.max&&(n.current=new x({max:o.length-1},t??0),c(o[n.current.value]))},[e]);const u=i.useCallback(o=>{const h=[...e];c(h[n.current.add(o??1).value])},[e]);return console.log(n.current.value),[s,u]},we=(e,t)=>{const n=B(),s=i.useRef(Array.isArray(e)?e:[...e]),c=i.useRef(new x({max:s.current.length-1},t??0)),u=i.useCallback(o=>{c.current.add(o??1),n()},[]);return[s.current[c.current.value],u]},pe=()=>{const e=i.useRef(null),t=i.useRef(0),n=i.useRef(0),s=i.useRef(0),c=i.useRef(0),u=i.useCallback(m=>{if(!e.current)return;const S=m.pageX-e.current.offsetLeft,g=m.pageY-e.current.offsetTop;e.current.scrollLeft=s.current-(S-t.current),e.current.scrollTop=c.current-(g-n.current)},[]),o=i.useCallback(m=>{e.current&&(t.current=m.pageX-e.current.offsetLeft,n.current=m.pageY-e.current.offsetTop,s.current=e.current.scrollLeft,c.current=e.current.scrollTop,e.current.addEventListener("pointermove",u,{passive:!0}))},[u]),h=i.useCallback(()=>{e.current&&e.current.removeEventListener("pointermove",u)},[u]),y=i.useCallback(()=>{e.current&&e.current.removeEventListener("pointermove",u)},[u]);return i.useEffect(()=>()=>{var m;return(m=e.current)==null?void 0:m.removeEventListener("pointermove",u)},[u]),{ref:e,onPointerDown:o,onPointerUp:h,onPointerLeave:y}},re=e=>{i.useEffect(()=>{const t=e();if(!(t instanceof Promise))return t},[])},se=(...e)=>{},Se=e=>{if(!(typeof window>"u"||!CSS||!("paintWorklet"in CSS)))return CSS.paintWorklet.addModule(URL.createObjectURL(new Blob([e],{type:"text/javascript"})))},ye=(e,t)=>{const n=i.useRef(e??null),[s,c]=i.useState(new DOMRectReadOnly);return i.useEffect(()=>{if(n.current&&(window!=null&&window.ResizeObserver)){const u=new ResizeObserver(([o])=>{c(o.contentRect)});return u.observe(n.current,t),()=>{u==null||u.disconnect()}}else return se},[]),{ref:n,size:s}},Re=({target:e,intersectionOptions:t,mutationTarget:n,mutationOptions:s})=>{const c=i.useRef(typeof e=="string"?document.querySelector(e):(e==null?void 0:e.current)??e),[u,o]=i.useState(!1),h=i.useRef(!1),[y,m]=i.useState(!1),S=i.useRef(!1);return re(()=>{const g=typeof e=="string"?document.querySelector(e):(e==null?void 0:e.current)??e;if(!g||!(g instanceof Element))return;const D=new IntersectionObserver(L=>{var U;const A=!!((U=L[0])!=null&&U.isIntersecting);let z=!1;if(A){const{x:K,y:G,width:H,height:Y}=L[0].boundingClientRect,Ve=K+H/2,We=G+Y/2;z=g.contains(document.elementFromPoint(Ve,We)),z&&!S.current&&(S.current=!0),h.current||(h.current=!0)}o(A),m(z)},t),k=n?new MutationObserver(L=>{if(!L.length)return;const{x:A,y:z,width:U,height:K}=g.getBoundingClientRect(),G=A+U/2,H=z+K/2,Y=g.contains(document.elementFromPoint(G,H));Y&&!S.current&&(S.current=!0),m(Y)}):null;if(k){const L=typeof n=="string"?document.querySelector(n):(n==null?void 0:n.current)??n;L&&(k==null||k.observe(L,s))}return D.observe(g),()=>{k==null||k.disconnect(),g&&D.unobserve(g)}}),{ref:c,isVisible:y,wasVisible:h.current,isInViewport:u,wasInViewport:h.current}},ie=(e,t,n,s)=>{i.useEffect(()=>{const c=s??document;return c.addEventListener(e,t,n),()=>c.removeEventListener(e,t)},[s,e])},Ee=(e,t)=>{const[n,s]=i.useState(document.visibilityState==="visible");return ie("visibilitychange",c=>{s(document.visibilityState==="visible"),e==null||e(c)},t),n},ke=({initial:e,...t})=>{const n=B(),s=i.useRef(new J(t,e));i.useEffect(()=>{s.current=new J(t,e)},[t.min,t.max,e]);const c=i.useMemo(()=>({add(u){s.current.add(u),n()},sub(u){s.current.sub(u),n()},mul(u){s.current.mul(u),n()},div(u){s.current.div(u),n()}}),[]);return{value:s.current.value,min:s.current.min,max:s.current.max,...c}},ue=(e,t=0)=>{const n=i.useRef(!1),s=i.useRef(),c=i.useRef(e),u=i.useCallback(()=>n.current,[]),o=i.useCallback(()=>{n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{n.current=!0,c.current()},t)},[t]),h=i.useCallback(()=>{n.current=null,s.current&&clearTimeout(s.current)},[]);return i.useEffect(()=>{c.current=e},[e]),i.useEffect(()=>(o(),h),[t]),[u,h,o]},Me=(e,t=1e3)=>{const[n,s]=i.useState(e),[,c,u]=ue(()=>s(e),t);i.useEffect(()=>{c(),s(e)},[e,t]);const o=i.useCallback(h=>{s(h),u()},[u]);return[n,o]},Ce=({initial:e,...t})=>{const n=B(),s=i.useRef(new x(t,e));i.useEffect(()=>{s.current=new x(t,e)},[t.min,t.max,e]);const c=i.useMemo(()=>({add(u){s.current.add(u),n()},sub(u){s.current.sub(u),n()}}),[]);return{value:s.current.value,min:s.current.min,max:s.current.max,...c}};l.Bounded=me,l.KDTree=he,l.Null=ge,l.RingBuffer=ae,l.Saturating=J,l.Wrapping=x,l.addPaintWorkletModuleFromSource=Se,l.assertValidRange=_,l.castInteger=j,l.clamp=fe,l.lerp=de,l.noOp=se,l.uncheckedClamp=F,l.useCycle=ve,l.useCycleStable=we,l.useDragScroll=pe,l.useEffectOnce=re,l.useElementSize=ye,l.useElementVisibility=Re,l.useEvent=ie,l.usePageVisibility=Ee,l.useRerender=B,l.useSaturating=ke,l.useTimeoutFunction=ue,l.useTransientState=Me,l.useWrapping=Ce,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}); | ||
(function(l,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],i):(l=typeof globalThis<"u"?globalThis:l||self,i(l.Chinooks={},l.React))})(this,function(l,i){"use strict";var oe=Object.defineProperty,ce=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t,n)=>(ce(e,typeof t!="symbol"?t+"":t,n),n),Y=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},r=(e,t,n)=>(Y(e,t,"read from private field"),n?n.call(e):t.get(e)),g=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},a=(e,t,n,s)=>(Y(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Q=(e,t,n,s)=>({set _(c){a(e,t,c,n)},get _(){return r(e,t,s)}}),N=(e,t,n)=>(Y(e,t,"access private method"),n);class le{constructor(t){_(this,"parent"),_(this,"point"),_(this,"left"),_(this,"right"),this.point=t,this.parent=null,this.left=null,this.right=null}}var p,w,M,$,Z,V,O;class he{constructor(t,n={clone:!0}){g(this,$),g(this,V),g(this,p,void 0),g(this,w,void 0),g(this,M,void 0);var s;a(this,p,t?n!=null&&n.clone?[...t]:t:[]),a(this,w,((s=t==null?void 0:t[0])==null?void 0:s.length)??0),a(this,M,N(this,V,O).call(this,r(this,p),0,null))}get dimensions(){return r(this,w)}get tree(){return r(this,M)}[Symbol.iterator](){return r(this,p)[Symbol.iterator]()}insert(t){if(!r(this,p).length)a(this,w,t.length);else if(r(this,w)!==t.length)throw new TypeError(`Point [${t}] has ${t.length} dimensions, but should have ${r(this,w)}`);r(this,p).push(t),a(this,M,N(this,V,O).call(this,r(this,p),0,null))}remove(t){if(!r(this,p).length||t.length!==r(this,w))return;const n=this.nearestNeighbor(t);if(n.distance===0){const s=r(this,p).findIndex(c=>c===n.point);return r(this,p).splice(s,1),a(this,M,N(this,V,O).call(this,r(this,p),0,null)),n.point}}has(t){return t.length!==r(this,w)?!1:this.nearestNeighbor(t).distance===0}nearestNeighbor(t){function n(o,h){return h?o.reduce((y,m,S)=>y+(m-h[S])**2,0):1/0}function s(o,h){return o&&(!h||n(t,o.point)<=n(t,h.point))?o:h}const c=(o,h)=>{if(!o)return null;let y,m;t[h%r(this,w)]<=o.point[h%this.dimensions]?(y=o.left,m=o.right):(y=o.right,m=o.left);let S=c(y,h+1),b=s(S,o);const D=n(t,b==null?void 0:b.point),k=t[h%r(this,w)]-o.point[h%r(this,w)];return D>=k**2&&(S=c(m,h+1),b=s(S,b)),b},u=c(r(this,M),0);return{point:(u==null?void 0:u.point)??null,distance:Math.sqrt(n(t,u==null?void 0:u.point))}}}p=new WeakMap,w=new WeakMap,M=new WeakMap,$=new WeakSet,Z=function(e){const t=Math.floor(e.length/2);return[e[t],t]},V=new WeakSet,O=function(e,t,n){if(e.length===0)return null;e.sort((h,y)=>h[t]-y[t]);const[s,c]=N(this,$,Z).call(this,e),u=(t+1)%r(this,w),o=new le(s);return o.parent=n,o.left=N(this,V,O).call(this,e.slice(0,c),u,o),o.right=N(this,V,O).call(this,e.slice(c+1),u,o),o};var v,C,W,T;const ee=class{constructor(e){if(g(this,v,void 0),g(this,C,void 0),g(this,W,0),g(this,T,0),typeof e!="number"||e<=0)throw new RangeError("Must be initialized with a capacity");a(this,v,new Array(e).fill(null)),a(this,C,e)}static from(e){const t=new ee(e.length);return a(t,v,e),t}get capacity(){return r(this,C)}get data(){return r(this,v)}get isEmpty(){return r(this,v).every(e=>e===null)}get isFull(){return r(this,v).every(e=>e!==null)}get[Symbol.toStringTag](){return"RingBuffer"}toString(){return JSON.stringify({data:r(this,v),capacity:r(this,C)})}[Symbol.iterator](){return r(this,v)[Symbol.iterator]()}peek(e=0){return r(this,v).at((r(this,W)+e)%r(this,C))??null}enqueue(e){r(this,v)[Q(this,T)._++]=e,a(this,T,r(this,T)%r(this,C))}dequeue(){const[e]=r(this,v).splice(Q(this,W)._++,1,null);return a(this,W,r(this,W)%r(this,C)),e}drain(){const e=r(this,v).filter(t=>t!==null);return a(this,v,[]),a(this,W,0),a(this,T,0),e}};let ae=ee;v=new WeakMap,C=new WeakMap,W=new WeakMap,T=new WeakMap;function q(e,t,n){if(e>t)throw new RangeError("Minimum must be less than maximum");if(!(typeof n>"u")&&(e>n||n>t))throw new RangeError("Value must be between minimum and maximum")}function j(e){const t=typeof e=="number"?e:Number(e);if(!Number.isSafeInteger(t))throw new RangeError("Values must be safe integers");return t.valueOf()}function F(e,t,n){return Math.min(Math.max(n,e),t)}function fe(e,t,n){return q(e,t),F(e,t,n)}function de(e,t,n){if(0>n||n>1)throw new RangeError("Value must be between 0 and 1 inclusive");return e+(t-e)*n}var P,I,d;const te=class{constructor({max:e,min:t=0},n){if(g(this,P,void 0),g(this,I,void 0),g(this,d,void 0),!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||typeof n<"u"&&!Number.isSafeInteger(n))throw new RangeError("Values must be integers");q(t,e,n),a(this,P,e),a(this,I,t),a(this,d,n??t)}static from(e){return new te({max:e.max,min:e.min},e.value)}add(e){const t=typeof e=="number"?e:Number(e);if(!Number.isSafeInteger(t))throw new RangeError("Values must be integers");return t===0?this:(a(this,d,F(r(this,I),r(this,P),r(this,d)+t)),this)}sub(e){return this.add(-e)}mul(e){const t=j(e);return t===1?this:(a(this,d,F(r(this,I),r(this,P),r(this,d)*t)),this)}div(e){const t=j(e);if(t===0)throw new Error("Cannot divide by zero");return a(this,d,F(r(this,I),r(this,P),Math.trunc(r(this,d)/t))),this}get value(){return r(this,d)}get min(){return r(this,I)}get max(){return r(this,P)}valueOf(){return r(this,d)}toFixed(e){return r(this,d).toFixed(e)}toExponential(e){return r(this,d).toExponential(e)}toPrecision(e){return r(this,d).toPrecision(e)}toString(e){return r(this,d).toString(e)}toLocaleString(e,t){return r(this,d).toLocaleString(e,t)}[Symbol.toPrimitive](e){return e==="string"?this.toString():r(this,d)}get[Symbol.toStringTag](){return"Saturating"}};let X=te;P=new WeakMap,I=new WeakMap,d=new WeakMap;class me{}var R,E,f;const ne=class{constructor({max:e,min:t=0},n){if(g(this,R,void 0),g(this,E,void 0),g(this,f,void 0),!Number.isSafeInteger(t)||!Number.isSafeInteger(e)||typeof n<"u"&&!Number.isSafeInteger(n))throw new RangeError("Values must be safe integers");q(t,e,n),a(this,R,e),a(this,E,t),a(this,f,n??t)}static from(e){return new ne({max:e.max,min:e.min},e.value)}add(e){const t=j(e);if(t===0)return this;if(r(this,f)+t<=r(this,R)&&r(this,f)+t>=r(this,E))return a(this,f,r(this,f)+t),this;const n=t%(Math.abs(r(this,R)-r(this,E))+1);return r(this,f)+n<=r(this,R)&&r(this,f)+n>=r(this,E)?(a(this,f,r(this,f)+n),this):n>0?(a(this,f,n-(r(this,R)-r(this,f))+(r(this,E)-1)),this):n<0?(a(this,f,n-(r(this,E)-r(this,f))+(r(this,R)+1)),this):this}sub(e){return this.add(-e)}get value(){return r(this,f)}get min(){return r(this,E)}get max(){return r(this,R)}valueOf(){return r(this,f)}toFixed(e){return r(this,f).toFixed(e)}toExponential(e){return r(this,f).toExponential(e)}toPrecision(e){return r(this,f).toPrecision(e)}toString(e){return r(this,f).toString(e)}toLocaleString(e,t){return r(this,f).toLocaleString(e,t)}[Symbol.toPrimitive](e){return e==="string"?this.toString():r(this,f)}get[Symbol.toStringTag](){return"Wrapping"}};let x=ne;R=new WeakMap,E=new WeakMap,f=new WeakMap;const be=e=>null,ge=(...e)=>i.useCallback(t=>{e.forEach(n=>{typeof n=="function"?n(t):n!==null&&(n.current=t)})},[]),ve=e=>(e+1)%1e6,B=()=>{const[,e]=i.useReducer(ve,0);return e},we=(e,t)=>{const n=i.useRef(new x({max:[...e].length-1},t??0)),[s,c]=i.useState([...e][n.current.value]);i.useEffect(()=>{const o=[...e];o.length-1!==n.current.max&&(n.current=new x({max:o.length-1},t??0),c(o[n.current.value]))},[e]);const u=i.useCallback(o=>{const h=[...e];c(h[n.current.add(o??1).value])},[e]);return console.log(n.current.value),[s,u]},pe=(e,t)=>{const n=B(),s=i.useRef(Array.isArray(e)?e:[...e]),c=i.useRef(new x({max:s.current.length-1},t??0)),u=i.useCallback(o=>{c.current.add(o??1),n()},[]);return[s.current[c.current.value],u]},Se=()=>{const e=i.useRef(null),t=i.useRef(0),n=i.useRef(0),s=i.useRef(0),c=i.useRef(0),u=i.useCallback(m=>{if(!e.current)return;const S=m.pageX-e.current.offsetLeft,b=m.pageY-e.current.offsetTop;e.current.scrollLeft=s.current-(S-t.current),e.current.scrollTop=c.current-(b-n.current)},[]),o=i.useCallback(m=>{e.current&&(t.current=m.pageX-e.current.offsetLeft,n.current=m.pageY-e.current.offsetTop,s.current=e.current.scrollLeft,c.current=e.current.scrollTop,e.current.addEventListener("pointermove",u,{passive:!0}))},[u]),h=i.useCallback(()=>{e.current&&e.current.removeEventListener("pointermove",u)},[u]),y=i.useCallback(()=>{e.current&&e.current.removeEventListener("pointermove",u)},[u]);return i.useEffect(()=>()=>{var m;return(m=e.current)==null?void 0:m.removeEventListener("pointermove",u)},[u]),{ref:e,onPointerDown:o,onPointerUp:h,onPointerLeave:y}},re=e=>{i.useEffect(()=>{const t=e();if(!(t instanceof Promise))return t},[])},se=(...e)=>{},ye=e=>{if(!(typeof window>"u"||!CSS||!("paintWorklet"in CSS)))return CSS.paintWorklet.addModule(URL.createObjectURL(new Blob([e],{type:"text/javascript"})))},Re=(e,t)=>{const n=i.useRef(e??null),[s,c]=i.useState(new DOMRectReadOnly);return i.useEffect(()=>{if(n.current&&(window!=null&&window.ResizeObserver)){const u=new ResizeObserver(([o])=>{c(o.contentRect)});return u.observe(n.current,t),()=>{u==null||u.disconnect()}}else return se},[]),{ref:n,size:s}},Ee=({target:e,intersectionOptions:t,mutationTarget:n,mutationOptions:s})=>{const c=i.useRef(typeof e=="string"?document.querySelector(e):(e==null?void 0:e.current)??e),[u,o]=i.useState(!1),h=i.useRef(!1),[y,m]=i.useState(!1),S=i.useRef(!1);return re(()=>{const b=typeof e=="string"?document.querySelector(e):(e==null?void 0:e.current)??e;if(!b||!(b instanceof Element))return;const D=new IntersectionObserver(L=>{var A;const H=!!((A=L[0])!=null&&A.isIntersecting);let z=!1;if(H){const{x:J,y:K,width:G,height:U}=L[0].boundingClientRect,Pe=J+G/2,Ie=K+U/2;z=b.contains(document.elementFromPoint(Pe,Ie)),z&&!S.current&&(S.current=!0),h.current||(h.current=!0)}o(H),m(z)},t),k=n?new MutationObserver(L=>{if(!L.length)return;const{x:H,y:z,width:A,height:J}=b.getBoundingClientRect(),K=H+A/2,G=z+J/2,U=b.contains(document.elementFromPoint(K,G));U&&!S.current&&(S.current=!0),m(U)}):null;if(k){const L=typeof n=="string"?document.querySelector(n):(n==null?void 0:n.current)??n;L&&(k==null||k.observe(L,s))}return D.observe(b),()=>{k==null||k.disconnect(),b&&D.unobserve(b)}}),{ref:c,isVisible:y,wasVisible:h.current,isInViewport:u,wasInViewport:h.current}},ie=(e,t,n,s)=>{i.useEffect(()=>{const c=s??document;return c.addEventListener(e,t,n),()=>c.removeEventListener(e,t)},[s,e])},ke=()=>{const e=i.useRef(null),[t,n]=i.useState(!1),s=i.useCallback(u=>n(!0),[]),c=i.useCallback(u=>n(!1),[]);return[t,{ref:e,onPointerEnter:s,onPointerLeave:c}]},Ce=(e,t)=>{const[n,s]=i.useState(document.visibilityState==="visible");return ie("visibilitychange",c=>{s(document.visibilityState==="visible"),e==null||e(c)},t),n},Me=({initial:e,...t})=>{const n=B(),s=i.useRef(new X(t,e));i.useEffect(()=>{s.current=new X(t,e)},[t.min,t.max,e]);const c=i.useMemo(()=>({add(u){s.current.add(u),n()},sub(u){s.current.sub(u),n()},mul(u){s.current.mul(u),n()},div(u){s.current.div(u),n()}}),[]);return{value:s.current.value,min:s.current.min,max:s.current.max,...c}},ue=(e,t=0)=>{const n=i.useRef(!1),s=i.useRef(),c=i.useRef(e),u=i.useCallback(()=>n.current,[]),o=i.useCallback(()=>{n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{n.current=!0,c.current()},t)},[t]),h=i.useCallback(()=>{n.current=null,s.current&&clearTimeout(s.current)},[]);return i.useEffect(()=>{c.current=e},[e]),i.useEffect(()=>(o(),h),[t]),[u,h,o]},Ve=(e,t=1e3)=>{const[n,s]=i.useState(e),[,c,u]=ue(()=>s(e),t);i.useEffect(()=>{c(),s(e)},[e,t]);const o=i.useCallback(h=>{s(h),u()},[u]);return[n,o]},We=({initial:e,...t})=>{const n=B(),s=i.useRef(new x(t,e));i.useEffect(()=>{s.current=new x(t,e)},[t.min,t.max,e]);const c=i.useMemo(()=>({add(u){s.current.add(u),n()},sub(u){s.current.sub(u),n()}}),[]);return{value:s.current.value,min:s.current.min,max:s.current.max,...c}};l.Bounded=me,l.KDTree=he,l.Null=be,l.RingBuffer=ae,l.Saturating=X,l.Wrapping=x,l.addPaintWorkletModuleFromSource=ye,l.assertValidRange=q,l.castInteger=j,l.clamp=fe,l.lerp=de,l.noOp=se,l.uncheckedClamp=F,l.useCombineRefs=ge,l.useCycle=we,l.useCycleStable=pe,l.useDragScroll=Se,l.useEffectOnce=re,l.useElementSize=Re,l.useElementVisibility=Ee,l.useEvent=ie,l.useHover=ke,l.usePageVisibility=Ce,l.useRerender=B,l.useSaturating=Me,l.useTimeoutFunction=ue,l.useTransientState=Ve,l.useWrapping=We,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}); |
export * from "./Null"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
export * from "./useCombineRefs"; | ||
export * from "./useCycle"; | ||
@@ -7,2 +8,3 @@ export * from "./useDragScroll"; | ||
export * from "./useEvent"; | ||
export * from "./useHover"; | ||
export * from "./usePageVisibility"; | ||
@@ -9,0 +11,0 @@ export * from "./useRerender"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { MutableRefObject, PointerEventHandler } from "react"; |
@@ -0,0 +0,0 @@ import { EffectCallback } from "react"; |
@@ -0,0 +0,0 @@ /// <reference types="react" /> |
@@ -0,0 +0,0 @@ import { RefObject, MutableRefObject } from "react"; |
@@ -0,0 +0,0 @@ export type UseEventTarget = HTMLElement | SVGElement | Document | Window; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { BoundedOptions } from "kdim"; |
@@ -0,0 +0,0 @@ type UseTimeoutFunctionReturn = [() => boolean | null, () => void, () => void]; |
@@ -0,0 +0,0 @@ import { SetStateAction } from "react"; |
@@ -0,0 +0,0 @@ import { BoundedOptions } from "kdim"; |
@@ -0,0 +0,0 @@ export * from "kdim"; |
export * from "./noOp"; | ||
export * from "./styles"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
export * from "./addPaintWorklet"; |
{ | ||
"name": "chinooks", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "React hooks and utilities", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/rektdeckard/chinooks.git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42633
26
873