build(frontend): knip also checks what ships; strict indexing in every project
`npm run knip` now runs a second, --production pass, which asks whether the code that ships uses an export, not just whether anything does. Of the 47 exports only tests reached: - 34 are exported for their test and say so with @internal, naming the test. - 11 were module-private names with a stray `export`. Two of them were not used at all and are deleted. - The unused alreadyReported re-export is gone. Test kits, the e2e suite and the two build-tooling modules are excluded from the production project, each named in knip.jsonc. noUncheckedIndexedAccess is now on for the node and e2e tsconfigs too (0 errors), matching the app project. tsconfig.node.json listed a tailwind.config.js that has not existed since Tailwind 4. That entry is now playwright.config.ts, which the typed lint finds through this project.
This commit is contained in:
@@ -58,6 +58,7 @@ export interface StatRow {
|
||||
const DASH = "—";
|
||||
|
||||
// bits-per-second → "4.2 Mbps" / "820 kbps". Undefined/0 → dash (hls.js reports 0 before a level loads).
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtBitrate(bps: number | undefined, lang: string): string {
|
||||
if (!bps || bps <= 0) return DASH;
|
||||
if (bps >= 1_000_000) return `${formatDecimal(bps / 1_000_000, lang)} Mbps`;
|
||||
@@ -65,12 +66,14 @@ export function fmtBitrate(bps: number | undefined, lang: string): string {
|
||||
}
|
||||
|
||||
// Seconds of buffer ahead of the playhead → "12.3 sec" / "12,3 mp".
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtBufferSecs(s: number, lang: string): string {
|
||||
if (!Number.isFinite(s) || s < 0) return DASH;
|
||||
return formatUnit(s, "second", lang, 1);
|
||||
}
|
||||
|
||||
// Dropped / total decoded frames, with a drop percentage once any frames have been decoded.
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtFrames(dropped: number, total: number, lang: string): string {
|
||||
if (total <= 0) return DASH;
|
||||
const pct = (dropped / total) * 100;
|
||||
@@ -80,12 +83,14 @@ export function fmtFrames(dropped: number, total: number, lang: string): string
|
||||
|
||||
// Intrinsic decoded resolution. 0×0 means the browser hasn't decoded (or can't) — an honest dash,
|
||||
// which is itself the tell for a not-yet-playable codec pre-transcode.
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtRes(w: number, h: number): string {
|
||||
if (w <= 0 || h <= 0) return DASH;
|
||||
return `${w}×${h}`;
|
||||
}
|
||||
|
||||
// Seconds → m:ss (offsets/positions are small; hours are folded into minutes deliberately).
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtClock(s: number): string {
|
||||
if (!Number.isFinite(s) || s < 0) return DASH;
|
||||
const total = Math.floor(s);
|
||||
@@ -95,6 +100,7 @@ export function fmtClock(s: number): string {
|
||||
}
|
||||
|
||||
// hls.js active level → "2 / 4 · 1280×720" (1-based index for humans). Auto/unknown level → dash + count.
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtLevel(l: HlsLevelInfo | null): string {
|
||||
if (!l || l.total <= 0) return DASH;
|
||||
const idx = l.index >= 0 ? `${l.index + 1} / ${l.total}` : `auto / ${l.total}`;
|
||||
@@ -103,6 +109,7 @@ export function fmtLevel(l: HlsLevelInfo | null): string {
|
||||
}
|
||||
|
||||
// Video/audio codec from the active hls.js level (only HLS exposes them; direct play → dash).
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtCodec(video: string | undefined, audio: string | undefined): string {
|
||||
const v = video?.split(".")[0] || null; // "avc1.640028" → "avc1"
|
||||
const a = audio?.split(".")[0] || null;
|
||||
@@ -115,6 +122,7 @@ export function fmtCodec(video: string | undefined, audio: string | undefined):
|
||||
// "· HDR→SDR" tag when the GPU OpenCL tonemap path handled a 10-bit/HDR source ("transcode · GPU ·
|
||||
// HDR→SDR"). Non-transcode modes (direct/remux) and an unknown encoder read as the bare mode. Raw tokens
|
||||
// (not i18n'd), consistent with the other technical values in this overlay (e.g. transport "hls").
|
||||
/** @internal exported for plexStats.test.ts */
|
||||
export function fmtMode(
|
||||
playable: string,
|
||||
hwEncoder?: boolean | null,
|
||||
|
||||
Reference in New Issue
Block a user