diff --git a/src/main/download.ts b/src/main/download.ts index 44662ac..52f9abc 100644 --- a/src/main/download.ts +++ b/src/main/download.ts @@ -80,9 +80,9 @@ export function hasActiveDownloads(): boolean { } // --- Formatting helpers (raw yt-dlp numbers → human strings) ---------------- -// Implementations live in lib/formatters.ts (no electron import chain) so they -// can be unit-tested in isolation (L37). Re-exported here for external callers. -export { fmtBytes, fmtEta, parseProgress } from './lib/formatters' +// parseProgress lives in lib/formatters.ts (no electron import chain) so it can +// be unit-tested in isolation (L37). Byte/ETA formatters live in @shared/format. +export { parseProgress } from './lib/formatters' import { parseProgress } from './lib/formatters' function send(wc: WebContents, ev: DownloadEvent): void { diff --git a/src/main/lib/formatters.ts b/src/main/lib/formatters.ts index 1a7277d..9a96a19 100644 --- a/src/main/lib/formatters.ts +++ b/src/main/lib/formatters.ts @@ -2,10 +2,9 @@ import type { DownloadProgress } from '@shared/ipc' import { fmtBytes } from '@shared/format' // yt-dlp progress-line parsing. Extracted from download.ts so it can be -// unit-tested without pulling in the electron import chain (L37). The byte/ -// speed/ETA formatters now live in @shared/format (one home for both sides of -// the IPC boundary); re-exported here so existing importers keep working. -export { fmtBytes, fmtSpeed, fmtEta } from '@shared/format' +// unit-tested without pulling in the electron import chain (L37). Byte/speed/ETA +// formatting lives in @shared/format — the one home for both sides of the IPC +// boundary; consumers import it directly. function num(s?: string): number | undefined { if (!s || s === 'NA') return undefined diff --git a/src/main/probe.ts b/src/main/probe.ts index 266ceb3..59e467b 100644 --- a/src/main/probe.ts +++ b/src/main/probe.ts @@ -1,7 +1,7 @@ import { execFile } from 'child_process' import { existsSync } from 'fs' import { getYtdlpPath, YTDLP_MISSING_MSG } from './binaries' -import { fmtBytes } from './lib/formatters' +import { fmtBytes } from '@shared/format' import { cleanError } from './log' import { assertHttpUrl } from './url' import { entryUrl, fmtDuration, type RawEntry } from './indexerCore' diff --git a/test/download.test.ts b/test/download.test.ts index 55b2038..d81a7bb 100644 --- a/test/download.test.ts +++ b/test/download.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect } from 'vitest' -// Import from the pure formatter module directly — no electron import chain (L37). -import { fmtBytes, fmtEta, parseProgress } from '../src/main/lib/formatters' +// Import from the pure modules directly — no electron import chain (L37). +import { parseProgress } from '../src/main/lib/formatters' +import { fmtBytes, fmtEta } from '../src/shared/format' describe('fmtBytes', () => { it('formats bytes under 1 KB verbatim', () => {