eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 909 B
JavaScript
import{resolve}from"node:path";import{build,prepare}from"nitro/builder";async function buildDevelopmentHostCandidate(e){let t=e.nitro,n=!1,r,i,a,o=new Promise(e=>{a=e}),s=t.hooks.hook(`dev:reload`,e=>{n||(n=!0,r={entry:e?.entry??resolve(t.options.output.dir,t.options.output.serverDir,`index.mjs`),workerData:e?.workerData??{}},a?.())}),c=t.hooks.hook(`dev:error`,e=>{n||(n=!0,i=e,a?.())});try{if(await prepare(t),await build(t),await waitForSignal(o),i!==void 0)throw i instanceof Error?i:Error(String(i));if(r===void 0||r.entry.length===0)throw Error(`Nitro did not emit a development worker entry.`);return r}finally{s(),c(),await t.close().catch(()=>void 0)}}async function waitForSignal(e){let t;try{await Promise.race([e,new Promise((e,n)=>{t=setTimeout(()=>n(Error(`Timed out waiting for the Nitro dev build to emit a worker.`)),12e4)})])}finally{clearTimeout(t)}}export{buildDevelopmentHostCandidate};