mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 04:19:25 -07:00
[codex] Replace mpv fullscreen toggle with launch mode config (#48)
Co-authored-by: bee <autumn@skerritt.blog>
This commit is contained in:
15
src/shared/mpv-launch-mode.test.ts
Normal file
15
src/shared/mpv-launch-mode.test.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { buildMpvLaunchModeArgs, parseMpvLaunchMode } from './mpv-launch-mode';
|
||||
|
||||
test('parseMpvLaunchMode normalizes valid string values', () => {
|
||||
assert.equal(parseMpvLaunchMode(' fullscreen '), 'fullscreen');
|
||||
assert.equal(parseMpvLaunchMode('MAXIMIZED'), 'maximized');
|
||||
assert.equal(parseMpvLaunchMode('normal'), 'normal');
|
||||
});
|
||||
|
||||
test('buildMpvLaunchModeArgs returns the expected mpv flags', () => {
|
||||
assert.deepEqual(buildMpvLaunchModeArgs('normal'), []);
|
||||
assert.deepEqual(buildMpvLaunchModeArgs('maximized'), ['--window-maximized=yes']);
|
||||
assert.deepEqual(buildMpvLaunchModeArgs('fullscreen'), ['--fullscreen']);
|
||||
});
|
||||
24
src/shared/mpv-launch-mode.ts
Normal file
24
src/shared/mpv-launch-mode.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { MpvLaunchMode } from '../types/config';
|
||||
|
||||
export const MPV_LAUNCH_MODE_VALUES = ['normal', 'maximized', 'fullscreen'] as const satisfies
|
||||
readonly MpvLaunchMode[];
|
||||
|
||||
export function parseMpvLaunchMode(value: unknown): MpvLaunchMode | undefined {
|
||||
if (typeof value !== 'string') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const normalized = value.trim().toLowerCase();
|
||||
return MPV_LAUNCH_MODE_VALUES.find((candidate) => candidate === normalized);
|
||||
}
|
||||
|
||||
export function buildMpvLaunchModeArgs(launchMode: MpvLaunchMode): string[] {
|
||||
switch (launchMode) {
|
||||
case 'fullscreen':
|
||||
return ['--fullscreen'];
|
||||
case 'maximized':
|
||||
return ['--window-maximized=yes'];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user