import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { readSchedulerState } from "yt-dlp-transcript-common/jobs/syncSchedulerState"; import type { WidgetSyncInputs } from "yt-dlp-transcript-common/views/widgetSync"; import { getChannelBriefs } from "../../lib/requestCache"; // THE READS BEHIND THE WIDGET'S SYNC STRIP. // // The payload itself is `common/views/widgetSync.ts` — a pure fold over these // four values. They are gathered here rather than in the route because BOTH the // route and the dashboard's SSR seed need them, and a builder that lived in a // route file was the smell that made `app/page.tsx` import out of // `api/widget/sync/route.ts` to render a page. (That route is gone; /api/widget/sync // is rewritten to /api/view/widgetSync, whose handler calls this.) // // `getChannelBriefs` is the per-request memo (lib/requestCache.ts): the // dashboard derives the channel list three ways in one render, and this is one // of the three. export async function widgetSyncInputs(): Promise { const paths = getPaths(); const [state, briefs] = await Promise.all([ readSchedulerState(paths), getChannelBriefs(paths), ]); return { settings: getSettings(), now: Date.now(), state, briefs }; }