mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
6ba91780c1
- Replace subminer.conf plugin config with mpv.* fields in config.jsonc - Add socketPath, backend, autoStartSubMiner, pauseUntilOverlayReady, aniskipEnabled/buttonKey, subminerBinaryPath to mpv config - Add subtitleSidebar.css field; migrate legacy sidebar appearance fields - Add paintOrder and WebkitTextStroke to subtitle style options - Update default subtitle/sidebar fontFamily to CJK-first stack - Fix overlay visible state surviving mpv y-r restart - Fix live config saves applying subtitle CSS immediately to open overlays - Migrate legacy primary/secondary subtitle appearance into subtitleStyle.css on load - Switch AniSkip button key setting to click-to-learn key capture
46 lines
1.6 KiB
TypeScript
46 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:
|
|
typeof mpv.subminerBinaryPath === 'string' ? mpv.subminerBinaryPath.trim() : undefined,
|
|
aniskipEnabled: typeof mpv.aniskipEnabled === 'boolean' ? mpv.aniskipEnabled : undefined,
|
|
aniskipButtonKey: parseNonEmptyString(mpv.aniskipButtonKey),
|
|
};
|
|
}
|