-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathasync.js
More file actions
1 lines (1 loc) · 1.81 KB
/
Copy pathasync.js
File metadata and controls
1 lines (1 loc) · 1.81 KB
1
self.uhooks=function(e){"use strict";let t=null,n=new Set;const s=e=>{const{$:t,r:n,h:s}=e;l(n)&&(o.get(s).delete(e),n()),l(e.r=t())&&o.get(s).add(e)},c=()=>{const e=n;n=new Set,e.forEach((({h:e,c:t,a:n,e:s})=>{s&&e.apply(t,n)}))},o=new WeakMap,a=[],r=[];function u(e,t){return e!==this[t]}const h=()=>t,l=e=>"function"==typeof e,i=e=>{const n={h:c,c:null,a:null,e:0,i:0,s:[]};return c;function c(){const c=t;t=n,n.e=n.i=0;try{return e.apply(n.c=this,n.a=arguments)}finally{t=c,a.length&&f.then(a.forEach.bind(a.splice(0),s)),r.length&&r.splice(0).forEach(s)}}},f=Promise.resolve();function p(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach((({h:e,c:t,a:n})=>{e.apply(t,n)})))}const d=(e,t)=>{const n=h(),{i:s,s:c}=n;return s!==c.length&&t&&!t.some(u,c[s]._)||(c[s]={$:e(),_:t}),c[n.i++].$},g=e=>(t,n)=>{const s=h(),{i:c,s:a,h:r}=s,l=c===a.length;s.i++,l&&(o.has(r)||o.set(r,new Set),a[c]={$:t,_:n,r:null,d:!1,h:r}),(l||!n||a[c].d||n.some(u,a[c]._))&&e.push(a[c]),a[c].$=t,a[c]._=n,a[c].d=!1},w=g(a),y=g(r),E=(e,t)=>l(t)?t(e):t,$=(e,t,s)=>{const o=h(),{i:a,s:r}=o;a===r.length&&r.push({$:l(s)?s(t):E(void 0,t),set:t=>{r[a].$=e(r[a].$,t),(e=>{n.has(e)||(e.e=1,n.add(e),f.then(c))})(o)}});const{$:u,set:i}=r[o.i++];return[u,i]},_=new WeakMap;return e.createContext=e=>({_:new Set,provide:p,value:e}),e.dropEffect=e=>(e=>{const t=o.get(e);t&&f.then((()=>{t.forEach((e=>{e.r(),e.r=null,e.d=!0})),t.clear()}))})(_.get(e)),e.hasEffect=e=>(e=>o.has(e))(_.get(e)),e.hooked=e=>{const t=i(e);return _.set(n,t),n;async function n(){return await t.apply(this,arguments)}},e.useCallback=(e,t)=>d((()=>e),t),e.useContext=({_:e,value:t})=>(e.add(h()),t),e.useEffect=w,e.useLayoutEffect=y,e.useMemo=d,e.useReducer=$,e.useRef=e=>{const t=h(),{i:n,s:s}=t;return n===s.length&&s.push({current:e}),s[t.i++]},e.useState=e=>$(E,e),e.wait=f,e}({});