UNPKG

@getontime/cli

Version:

Time keeping for live events

2 lines 3.09 kB
(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`f14ad0099eab1969fdd065b56af5fdd3cf530de6`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`08ea447a-1f2f-4a71-a914-e8c8d5eaf809`,e._sentryDebugIdIdentifier=`sentry-dbid-08ea447a-1f2f-4a71-a914-e8c8d5eaf809`)}catch{}})();import{a as e,n as t}from"./jsx-runtime-BNC90REB.js";import{Zt as n}from"./useSocket-B9-0Z7zf.js";import{Bn as r,En as i,Fn as a,Hn as o,In as s,Mn as c,On as l,Sn as u,Un as d,Vn as f,bn as p,zn as m}from"./constants-8b9Q9Bj6.js";var h,g,_,v,y,b=(h=new WeakMap,g=new WeakMap,_=new WeakMap,v=new WeakMap,y=new WeakSet,class extends d{constructor(e,t){super(),u(this,y),o(this,h,void 0),o(this,g,void 0),o(this,_,void 0),o(this,v,void 0),r(h,this,e),this.setOptions(t),this.bindMethods(),f(y,this,x).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=m(h,this).defaultMutationOptions(e),a(this.options,t)||m(h,this).getMutationCache().notify({type:`observerOptionsUpdated`,mutation:m(_,this),observer:this}),t?.mutationKey&&this.options.mutationKey&&l(t.mutationKey)!==l(this.options.mutationKey)?this.reset():m(_,this)?.state.status===`pending`&&m(_,this).setOptions(this.options)}onUnsubscribe(){this.hasListeners()||m(_,this)?.removeObserver(this)}onMutationUpdate(e){f(y,this,x).call(this),f(y,this,S).call(this,e)}getCurrentResult(){return m(g,this)}reset(){m(_,this)?.removeObserver(this),r(_,this,void 0),f(y,this,x).call(this),f(y,this,S).call(this)}mutate(e,t){return r(v,this,t),m(_,this)?.removeObserver(this),r(_,this,m(h,this).getMutationCache().build(m(h,this),this.options)),m(_,this).addObserver(this),m(_,this).execute(e)}});function x(){let e=m(_,this)?.state??n();r(g,this,{...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset})}function S(e){i.batch(()=>{if(m(v,this)&&this.hasListeners()){let t=m(g,this).variables,n=m(g,this).context,r={client:m(h,this),meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{m(v,this).onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{m(v,this).onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{m(v,this).onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{m(v,this).onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(m(g,this))})})}var C=e(t(),1);function w(e,t){let n=p(t),[r]=C.useState(()=>new b(n,e));C.useEffect(()=>{r.setOptions(e)},[r,e]);let a=C.useSyncExternalStore(C.useCallback(e=>r.subscribe(i.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=C.useCallback((e,t)=>{r.mutate(e,t).catch(c)},[r]);if(a.error&&s(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}export{w as t}; //# sourceMappingURL=useMutation-BQgDt5L8.js.map