UNPKG

@sanity/visual-editing

Version:

[![npm stat](https://img.shields.io/npm/dm/@sanity/visual-editing.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@sanity/visual-editing) [![npm version](https://img.shields.io/npm/v/@sanity/visual-editing.svg?style=flat-square)](https://

2 lines (1 loc) 1.52 kB
import{c as e}from"react-compiler-runtime";import{useRef as t,useState as r,useEffect as a}from"react";import{useNavigate as n,useRevalidator as s,useLocation as o}from"react-router";import{e as p}from"./enableVisualEditing.js";function c(c){const u=e(20),{components:l,refresh:h,zIndex:i}=c,m=n(),d=t(m),[f,y]=r(),b=s(),[v,x]=r(null),[$,g]=r(!1);let w,z,E,I,P,j;u[0]!==m?(w=()=>{d.current=m},z=[m],u[0]=m,u[1]=w,u[2]=z):(w=u[1],z=u[2]),a(w,z),u[3]!==b.state||u[4]!==$||u[5]!==v?(E=()=>{v&&"loading"===b.state?g(!0):v&&$&&"idle"===b.state&&(v(),x(null),g(!1))},I=[$,b.state,v],u[3]=b.state,u[4]=$,u[5]=v,u[6]=E,u[7]=I):(E=u[6],I=u[7]),a(E,I),u[8]!==l||u[9]!==h||u[10]!==b||u[11]!==i?(P=()=>{const e=p({components:l,zIndex:i,refresh:e=>{const t=function(){return("mutation"!==e.source||!e.livePreviewEnabled)&&new Promise((e=>{b.revalidate(),x((()=>e))}))};return h?h(e,t):t()},history:{subscribe:e=>(y((()=>e)),()=>y(void 0)),update:e=>{"push"===e.type||"replace"===e.type?d.current(e.url,{replace:"replace"===e.type}):"pop"===e.type&&d.current(-1)}}});return()=>e()},j=[l,h,b,i],u[8]=l,u[9]=h,u[10]=b,u[11]=i,u[12]=P,u[13]=j):(P=u[12],j=u[13]),a(P,j);const V=o();let k,q;return u[14]!==V.hash||u[15]!==V.pathname||u[16]!==V.search||u[17]!==f?(k=()=>{f&&f({type:"push",url:`${V.pathname}${V.search}${V.hash}`})},q=[V.hash,V.pathname,V.search,f],u[14]=V.hash,u[15]=V.pathname,u[16]=V.search,u[17]=f,u[18]=k,u[19]=q):(k=u[18],q=u[19]),a(k,q),null}export{c as default};//# sourceMappingURL=VisualEditingComponent2.js.map