export const NUM_BARS = 150; export const BAR_W = 3; export const BAR_GAP = 1; export const WAVEFORM_H = 48; export const VIEWBOX_W = NUM_BARS * (BAR_W + BAR_GAP); // 600 // Module-level cache: survives StrictMode double-effect and re-renders const peaksCache = new Map(); export async function extractPeaks( url: string, n: number, ): Promise { if (peaksCache.has(url)) return peaksCache.get(url)!; // /api/files is public (no auth middleware). Plain fetch avoids the CORS // preflight that credentials/Authorization would trigger — the server's // oakCors config doesn't set Allow-Credentials so credentialed fetches // are blocked, while