import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { readWidgetPresets, type WidgetPreset, } from "yt-dlp-transcript-common/lib/widgetPresets"; import { BUILT_IN_PRESETS, type BuiltInPreset, } from "yt-dlp-transcript-common/views/builtInPresets"; export const dynamic = "force-dynamic"; // The preset list, for the IN-WIDGET menu. The builder page SSR-seeds from // readWidgetPresets directly; the widget is a bare client page with no server // parent to seed it, so it fetches this on open and after each mutation. // // Built-ins ride along rather than being duplicated client-side, so the two // surfaces can never show different starting points. export type WidgetPresetsPayload = { builtIn: BuiltInPreset[]; saved: WidgetPreset[]; }; export async function GET() { const saved = await readWidgetPresets(getPaths()); return NextResponse.json({ builtIn: BUILT_IN_PRESETS, saved, } satisfies WidgetPresetsPayload); }