UNPKG

morphbox

Version:

Docker-based AI sandbox for development with Claude integration

48 lines (44 loc) 1.24 kB
import { watch } from 'fs'; import { join } from 'path'; import { homedir } from 'os'; import { mkdir } from 'fs/promises'; const PANELS_DIR = join(homedir(), "morphbox", "panels"); const GET = async () => { try { await mkdir(PANELS_DIR, { recursive: true }); } catch (error) { console.error("Failed to create panels directory:", error); } const stream = new ReadableStream({ start(controller) { const encoder = new TextEncoder(); controller.enqueue(encoder.encode("event: connected\ndata: {}\n\n")); const watcher = watch(PANELS_DIR, (eventType, filename) => { if (filename && filename.endsWith(".svelte")) { const data = JSON.stringify({ type: eventType, path: join(PANELS_DIR, filename), filename }); controller.enqueue( encoder.encode(`event: change data: ${data} `) ); } }); return () => { watcher.close(); }; } }); return new Response(stream, { headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache", "Connection": "keep-alive" } }); }; export { GET }; //# sourceMappingURL=_server.ts-B0lv9Dew.js.map