openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.05 kB
JavaScript
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Ca as t}from"./control-ui-boot-shared-DoKu-5Ju.js";async function n(e,n,{fresh:a=!1}={}){if(n?.throwIfAborted(),document.visibilityState===`hidden`)throw new DOMException(`Page is hidden`,`AbortError`);let{client:o,hello:s,phase:c}=e.snapshot;if(!o||c!==`connected`)throw new DOMException(`Gateway is disconnected`,`AbortError`);let l=i.get(e);if(!l||l.client!==o||l.hello!==s||l.revision!==e.connectionRevision||l.controller.signal.aborted||l.settled&&(a||l.expiresAt<=Date.now())){l?.controller.abort();let t=new AbortController,n=performance.now(),a=o.request(`system.info`,{},{signal:t.signal,timeoutMs:r}).then(e=>({value:e,at:Date.now(),roundTripMs:performance.now()-n})),c={client:o,hello:s,revision:e.connectionRevision,expiresAt:Date.now()+r,settled:!1,controller:t,subscribers:new Set,promise:a};a.then(()=>{c.settled=!0},()=>{i.get(e)===c&&i.delete(e)}),i.set(e,c),l=c}return t(l,{},n)}var r,i;function a(){return(a=e((()=>{r=1e4,i=new WeakMap})))()}export{a as n,n as r,r as t};