mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
1145e131da
- Remove CSS properties absent from subsequent subtitle style updates - Broadcast subtitle:set clear when media path changes - Preserve launcher lifecycle ownership for already-managed overlay apps - Clamp negative autoplay current time to zero - Reject blank subminerBinaryPath values via parseNonEmptyString - Log and rethrow legacy config migration errors instead of swallowing - Normalize modifier aliases (e.g. CommandOrControl) in keybinding display
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { parseMpvLaunchMode } from '../../src/shared/mpv-launch-mode.js';
|
|
import type { Backend } from '../types.js';
|
|
import type { LauncherMpvConfig } from '../types.js';
|
|
|
|
function parseBackend(value: unknown): Backend | undefined {
|
|
if (typeof value !== 'string') return undefined;
|
|
const normalized = value.trim().toLowerCase();
|
|
if (
|
|
normalized === 'auto' ||
|
|
normalized === 'hyprland' ||
|
|
normalized === 'sway' ||
|
|
normalized === 'x11' ||
|
|
normalized === 'macos' ||
|
|
normalized === 'windows'
|
|
) {
|
|
return normalized;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
function parseNonEmptyString(value: unknown): string | undefined {
|
|
if (typeof value !== 'string') return undefined;
|
|
const trimmed = value.trim();
|
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
}
|
|
|
|
export function parseLauncherMpvConfig(root: Record<string, unknown>): LauncherMpvConfig {
|
|
const mpvRaw = root.mpv;
|
|
if (!mpvRaw || typeof mpvRaw !== 'object') return {};
|
|
const mpv = mpvRaw as Record<string, unknown>;
|
|
|
|
return {
|
|
launchMode: parseMpvLaunchMode(mpv.launchMode),
|
|
socketPath: parseNonEmptyString(mpv.socketPath),
|
|
backend: parseBackend(mpv.backend),
|
|
autoStartSubMiner:
|
|
typeof mpv.autoStartSubMiner === 'boolean' ? mpv.autoStartSubMiner : undefined,
|
|
pauseUntilOverlayReady:
|
|
typeof mpv.pauseUntilOverlayReady === 'boolean' ? mpv.pauseUntilOverlayReady : undefined,
|
|
subminerBinaryPath: parseNonEmptyString(mpv.subminerBinaryPath),
|
|
aniskipEnabled: typeof mpv.aniskipEnabled === 'boolean' ? mpv.aniskipEnabled : undefined,
|
|
aniskipButtonKey: parseNonEmptyString(mpv.aniskipButtonKey),
|
|
};
|
|
}
|