import { CORE_DESIGN_SYSTEMS } from "@wrnexus/design-system"; // Exercise the compiled entry point, including package-relative Studio assets. const reservation = Bun.serve({ port: 0, hostname: "127.0.0.1", fetch: () => new Response(), }); const port = reservation.port!; reservation.stop(true); const server = Bun.spawn([process.execPath, "dist/server.js"], { env: { ...process.env, PORT: String(port) }, stdout: "pipe", stderr: "pipe", }); const origin = `http://127.0.0.1:${port}`; try { let ready = false; for (let attempt = 0; attempt < 60; attempt++) { try { ready = (await fetch(origin)).ok; } catch { /* Wait for the server to listen. */ } if (ready) break; await Bun.sleep(100); } if (!ready) throw Error("Compiled server did not become ready."); for (const path of [ "/", "/components/button", "/design-studio/", "/design-studio/studio.js", "/design-studio/studio.css", "/design-studio/site-help.js", ]) { const response = await fetch(origin + path); if (!response.ok) throw Error(`${path} returned ${response.status}`); if ( path === "/design-studio/studio.js" && !(await response.clone().text()).includes("respond-async") ) throw Error( "The deployed Studio client is missing background generation polling.", ); if (path === "/design-studio/") { const html = await response.clone().text(); const presetMenu = html.match(/