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(r){let i=r.nitro,a=!1,o,s,c,l=new Promise(e=>{c=e}),u=i.hooks.hook(`dev:reload`,t=>{a||(a=!0,o={entry:t?.entry??resolve(i.options.output.dir,i.options.output.serverDir,`index.mjs`),workerData:t?.workerData??{}},c?.())}),d=i.hooks.hook(`dev:error`,e=>{a||(a=!0,s=e,c?.())});try{if(await prepare(i),await build(i),await waitForSignal(l),s!==void 0)throw s instanceof Error?s:Error(String(s));if(o===void 0||o.entry.length===0)throw Error(`Nitro did not emit a development worker entry.`);return o}finally{u(),d(),await i.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};