PageSourceSearch

https://laconote.com/assets/useMutation-VeM2LXAO.js

js laconote.com collected 2026-09-24 14:47:04 UTC 3,038 bytes, 1 lines download raw bytes

1var K=i=>{throw TypeError(i)};var g=(i,t,s)=>t.has(i)||K("Cannot "+s);var e=(i,t,s)=>(g(i,t,"read from private field"),s?s.call(i):t.get(i)),m=(i,t,s)=>t.has(i)?K("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),p=(i,t,s,r)=>(g(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),b=(i,t,s)=>(g(i,t,"access private method"),s);import{r as f}from"./workspace-BPfcH8Ex.js";import{w as U,x as q,y as w,z as L,B as k,C as j,E as z}from"./configStore-Bu6ZuCYs.js";import{k as A}from"./index-BsVvkFrY.js";var h,l,o,n,u,M,E,R,B=(R=class extends U{constructor(t,s){super();m(this,u);m(this,h);m(this,l);m(this,o);m(this,n);p(this,h,t),this.setOptions(s),this.bindMethods(),b(this,u,M).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var r;const s=this.options;this.options=e(this,h).defaultMutationOptions(t),q(this.options,s)||e(this,h).getMutationCache().notify({type:"observerOptionsUpdated",mutation:e(this,o),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&w(s.mutationKey)!==w(this.options.mutationKey)?this.reset():((r=e(this,o))==null?void 0:r.state.status)==="pending"&&e(this,o).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=e(this,o))==null||t.removeObserver(this)}onMutationUpdate(t){b(this,u,M).call(this),b(this,u,E).call(this,t)}getCurrentResult(){return e(this,l)}reset(){var t;(t=e(this,o))==null||t.removeObserver(this),p(this,o,void 0),b(this,u,M).call(this),b(this,u,E).call(this)}mutate(t,s){var r;return p(this,n,s),(r=e(this,o))==null||r.removeObserver(this),p(this,o,e(this,h).getMutationCache().build(e(this,h),this.options)),e(this,o).addObserver(this),e(this,o).execute(t)}},h=new WeakMap,l=new WeakMap,o=new WeakMap,n=new WeakMap,u=new WeakSet,M=function(){var s;const t=((s=e(this,o))==null?void 0:s.state)??L();p(this,l,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},E=function(t){k.batch(()=>{var s,r,a,y,c,v,S,x;if(e(this,n)&&this.hasListeners()){const d=e(this,l).variables,O=e(this,l).context,C={client:e(this,h),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((r=(s=e(this,n)).onSuccess)==null||r.call(s,t.data,d,O,C),(y=(a=e(this,n)).onSettled)==null||y.call(a,t.data,null,d,O,C)):(t==null?void 0:t.type)==="error"&&((v=(c=e(this,n)).onError)==null||v.call(c,t.error,d,O,C),(x=(S=e(this,n)).onSettled)==null||x.call(S,void 0,t.error,d,O,C))}this.listeners.forEach(d=>{d(e(this,l))})})},R);function T(i,t){const s=A(),[r]=f.useState(()=>new B(s,i));f.useEffect(()=>{r.setOptions(i)},[r,i]);const a=f.useSyncExternalStore(f.useCallback(c=>r.subscribe(k.batchCalls(c)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),y=f.useCallback((c,v)=>{r.mutate(c,v).catch(j)},[r]);if(a.error&&z(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:y,mutateAsync:a.mutate}}export{T as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.