import { REPORTS_ROOT } from "@/lib/paths.mjs"; import { sharedWalk } from "@/lib/projects/walk.mjs"; import { cutPointsFor } from "@/lib/report/cutPoints.mjs"; export const dynamic = "force-dynamic"; // Where the render will cut each clip (lib/report/cutPoints.mjs): the build's // own source resolution, silence detection and snap, cached on disk, so the // Play view plays the render's edges and the clip bench draws them. // // GET ?project[&take][&clip=...] every clip of the cut (or the named // ones): { knobs, transition, montage, clips } // // Nothing is fetched and nothing in the project is written; the first read // of a clip measures its source (two ffmpeg passes over the clip and its pad), // every later one is read from the cache. export async function GET(request: Request) { const url = new URL(request.url); const projectId = url.searchParams.get("project") ?? ""; const take = url.searchParams.get("take") || null; const clips = url.searchParams.getAll("clip").filter(Boolean); const project = (await sharedWalk(REPORTS_ROOT)).find((p: { id: string }) => p.id === projectId); if (!project) return Response.json({ error: "no such project" }, { status: 404 }); try { const got = await cutPointsFor(project, { take, clips: clips.length ? clips : null }); return Response.json(got, { headers: { "cache-control": "no-store" } }); } catch (e) { return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 422 }); } }