mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 03:16:46 -07:00
style: restore repo formatting
This commit is contained in:
@@ -10,8 +10,7 @@ export function mergeAiConfig(
|
||||
sharedConfig: AiConfig | undefined,
|
||||
featureConfig?: AiFeatureConfig | boolean | null,
|
||||
): AiConfig {
|
||||
const overrides =
|
||||
featureConfig && typeof featureConfig === 'object' ? featureConfig : undefined;
|
||||
const overrides = featureConfig && typeof featureConfig === 'object' ? featureConfig : undefined;
|
||||
const modelOverride = trimToOverride(overrides?.model);
|
||||
const systemPromptOverride = trimToOverride(overrides?.systemPrompt);
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ function trimToNonEmptyString(value: unknown): string | null {
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
function normalizeAnkiAiConfig(config: AnkiConnectConfig['ai']): NonNullable<AnkiConnectConfig['ai']> {
|
||||
function normalizeAnkiAiConfig(
|
||||
config: AnkiConnectConfig['ai'],
|
||||
): NonNullable<AnkiConnectConfig['ai']> {
|
||||
if (config && typeof config === 'object') {
|
||||
return {
|
||||
enabled: config.enabled === true,
|
||||
|
||||
@@ -131,8 +131,7 @@ export function parseArgs(argv: string[]): CliArgs {
|
||||
args.launchMpv = true;
|
||||
args.launchMpvTargets = argv.slice(i + 1).filter((value) => value && !value.startsWith('--'));
|
||||
break;
|
||||
}
|
||||
else if (arg === '--stop') args.stop = true;
|
||||
} else if (arg === '--stop') args.stop = true;
|
||||
else if (arg === '--toggle') args.toggle = true;
|
||||
else if (arg === '--toggle-visible-overlay') args.toggleVisibleOverlay = true;
|
||||
else if (arg === '--settings' || arg === '--yomitan') args.settings = true;
|
||||
|
||||
@@ -131,12 +131,7 @@ export function applySubtitleDomainConfig(context: ResolveContext): void {
|
||||
);
|
||||
}
|
||||
} else if (src.youtubeSubgen.ai !== undefined) {
|
||||
warn(
|
||||
'youtubeSubgen.ai',
|
||||
src.youtubeSubgen.ai,
|
||||
resolved.youtubeSubgen.ai,
|
||||
'Expected object.',
|
||||
);
|
||||
warn('youtubeSubgen.ai', src.youtubeSubgen.ai, resolved.youtubeSubgen.ai, 'Expected object.');
|
||||
}
|
||||
|
||||
if (Array.isArray(src.youtubeSubgen.primarySubLanguages)) {
|
||||
|
||||
@@ -92,11 +92,7 @@ function firstString(value: unknown): string | null {
|
||||
}
|
||||
|
||||
function normalizeGuessitTitlePart(value: string): string {
|
||||
return value
|
||||
.replace(/[._]+/g, ' ')
|
||||
.replace(/-/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
return value.replace(/[._]+/g, ' ').replace(/-/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
function readGuessitTitle(value: unknown): string | null {
|
||||
|
||||
@@ -212,8 +212,14 @@ test('handleCliCommand reconnects MPV for second-instance --start when overlay r
|
||||
handleCliCommand(args, 'second-instance', deps);
|
||||
|
||||
assert.ok(calls.includes('setMpvClientSocketPath:/tmp/subminer.sock'));
|
||||
assert.equal(calls.some((value) => value.includes('connectMpvClient')), true);
|
||||
assert.equal(calls.some((value) => value.includes('initializeOverlayRuntime')), false);
|
||||
assert.equal(
|
||||
calls.some((value) => value.includes('connectMpvClient')),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
calls.some((value) => value.includes('initializeOverlayRuntime')),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('handleCliCommand processes --start for second-instance when overlay runtime is not initialized', () => {
|
||||
|
||||
@@ -133,7 +133,10 @@ export function resolveDefaultLogFilePath(options?: {
|
||||
const homeDir = options?.homeDir ?? os.homedir();
|
||||
const baseDir =
|
||||
platform === 'win32'
|
||||
? path.join(options?.appDataDir?.trim() || path.join(homeDir, 'AppData', 'Roaming'), 'SubMiner')
|
||||
? path.join(
|
||||
options?.appDataDir?.trim() || path.join(homeDir, 'AppData', 'Roaming'),
|
||||
'SubMiner',
|
||||
)
|
||||
: path.join(homeDir, '.config', 'SubMiner');
|
||||
return path.join(baseDir, 'logs', `SubMiner-${date}.log`);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
interface ElectronSecondInstanceAppLike {
|
||||
requestSingleInstanceLock: () => boolean;
|
||||
on: (
|
||||
event: 'second-instance',
|
||||
listener: (_event: unknown, argv: string[]) => void,
|
||||
) => unknown;
|
||||
on: (event: 'second-instance', listener: (_event: unknown, argv: string[]) => void) => unknown;
|
||||
}
|
||||
|
||||
let cachedSingleInstanceLock: boolean | null = null;
|
||||
|
||||
@@ -8,7 +8,9 @@ type ConfigHotReloadAppliedDeps = {
|
||||
refreshGlobalAndOverlayShortcuts: () => void;
|
||||
setSecondarySubMode: (mode: SecondarySubMode) => void;
|
||||
broadcastToOverlayWindows: (channel: string, payload: unknown) => void;
|
||||
applyAnkiRuntimeConfigPatch: (patch: { ai: ResolvedConfig['ankiConnect']['ai']['enabled'] }) => void;
|
||||
applyAnkiRuntimeConfigPatch: (patch: {
|
||||
ai: ResolvedConfig['ankiConnect']['ai']['enabled'];
|
||||
}) => void;
|
||||
};
|
||||
|
||||
type ConfigHotReloadMessageDeps = {
|
||||
|
||||
@@ -65,7 +65,9 @@ export function createBuildConfigHotReloadAppliedMainDepsHandler(deps: {
|
||||
refreshGlobalAndOverlayShortcuts: () => void;
|
||||
setSecondarySubMode: (mode: SecondarySubMode) => void;
|
||||
broadcastToOverlayWindows: (channel: string, payload: unknown) => void;
|
||||
applyAnkiRuntimeConfigPatch: (patch: { ai: ResolvedConfig['ankiConnect']['ai']['enabled'] }) => void;
|
||||
applyAnkiRuntimeConfigPatch: (patch: {
|
||||
ai: ResolvedConfig['ankiConnect']['ai']['enabled'];
|
||||
}) => void;
|
||||
}) {
|
||||
return () => ({
|
||||
setKeybindings: (keybindings: ConfigHotReloadPayload['keybindings']) =>
|
||||
|
||||
@@ -73,10 +73,7 @@ test('installFirstRunPluginToDefaultLocation installs plugin and backs up existi
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.pluginInstallStatus, 'installed');
|
||||
assert.equal(detectInstalledFirstRunPlugin(installPaths), true);
|
||||
assert.equal(
|
||||
fs.readFileSync(installPaths.pluginEntrypointPath, 'utf8'),
|
||||
'-- packaged plugin',
|
||||
);
|
||||
assert.equal(fs.readFileSync(installPaths.pluginEntrypointPath, 'utf8'), '-- packaged plugin');
|
||||
assert.equal(fs.readFileSync(installPaths.pluginConfigPath, 'utf8'), 'configured=true\n');
|
||||
|
||||
const scriptsDirEntries = fs.readdirSync(installPaths.scriptsDir);
|
||||
@@ -121,14 +118,8 @@ test('installFirstRunPluginToDefaultLocation installs plugin to Windows mpv defa
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.pluginInstallStatus, 'installed');
|
||||
assert.equal(detectInstalledFirstRunPlugin(installPaths), true);
|
||||
assert.equal(
|
||||
fs.readFileSync(installPaths.pluginEntrypointPath, 'utf8'),
|
||||
'-- packaged plugin',
|
||||
);
|
||||
assert.equal(
|
||||
fs.readFileSync(installPaths.pluginConfigPath, 'utf8'),
|
||||
'configured=true\n',
|
||||
);
|
||||
assert.equal(fs.readFileSync(installPaths.pluginEntrypointPath, 'utf8'), '-- packaged plugin');
|
||||
assert.equal(fs.readFileSync(installPaths.pluginConfigPath, 'utf8'), 'configured=true\n');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -22,10 +22,7 @@ function resolveLegacyPluginDebugLoaderPath(installPaths: MpvInstallPaths): stri
|
||||
|
||||
function rewriteInstalledWindowsPluginConfig(configPath: string): void {
|
||||
const content = fs.readFileSync(configPath, 'utf8');
|
||||
const updated = content.replace(
|
||||
/^socket_path=.*$/m,
|
||||
'socket_path=\\\\.\\pipe\\subminer-socket',
|
||||
);
|
||||
const updated = content.replace(/^socket_path=.*$/m, 'socket_path=\\\\.\\pipe\\subminer-socket');
|
||||
if (updated !== content) {
|
||||
fs.writeFileSync(configPath, updated, 'utf8');
|
||||
}
|
||||
|
||||
@@ -279,9 +279,7 @@ export function buildFirstRunSetupHtml(model: FirstRunSetupHtmlModel): string {
|
||||
</html>`;
|
||||
}
|
||||
|
||||
export function parseFirstRunSetupSubmissionUrl(
|
||||
rawUrl: string,
|
||||
): FirstRunSetupSubmission | null {
|
||||
export function parseFirstRunSetupSubmissionUrl(rawUrl: string): FirstRunSetupSubmission | null {
|
||||
if (!rawUrl.startsWith('subminer://first-run-setup')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,10 @@ export function resolveWindowsMpvShortcutPaths(options: {
|
||||
desktopDir: string;
|
||||
}): WindowsMpvShortcutPaths {
|
||||
return {
|
||||
startMenuPath: path.join(resolveWindowsStartMenuProgramsDir(options.appDataDir), WINDOWS_MPV_SHORTCUT_NAME),
|
||||
startMenuPath: path.join(
|
||||
resolveWindowsStartMenuProgramsDir(options.appDataDir),
|
||||
WINDOWS_MPV_SHORTCUT_NAME,
|
||||
),
|
||||
desktopPath: path.join(options.desktopDir, WINDOWS_MPV_SHORTCUT_NAME),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,8 +30,14 @@ test('release workflow generates release notes from committed changelog output',
|
||||
});
|
||||
|
||||
test('release workflow includes the Windows installer in checksums and uploaded assets', () => {
|
||||
assert.match(releaseWorkflow, /files=\(release\/\*\.AppImage release\/\*\.dmg release\/\*\.exe release\/\*\.zip release\/\*\.tar\.gz dist\/launcher\/subminer\)/);
|
||||
assert.match(releaseWorkflow, /artifacts=\([\s\S]*release\/\*\.exe[\s\S]*release\/SHA256SUMS\.txt[\s\S]*\)/);
|
||||
assert.match(
|
||||
releaseWorkflow,
|
||||
/files=\(release\/\*\.AppImage release\/\*\.dmg release\/\*\.exe release\/\*\.zip release\/\*\.tar\.gz dist\/launcher\/subminer\)/,
|
||||
);
|
||||
assert.match(
|
||||
releaseWorkflow,
|
||||
/artifacts=\([\s\S]*release\/\*\.exe[\s\S]*release\/SHA256SUMS\.txt[\s\S]*\)/,
|
||||
);
|
||||
});
|
||||
|
||||
test('release package scripts disable implicit electron-builder publishing', () => {
|
||||
@@ -51,6 +57,9 @@ test('windows release workflow publishes unsigned artifacts directly without Sig
|
||||
});
|
||||
|
||||
test('Makefile routes Windows install-plugin setup through bun and documents Windows builds', () => {
|
||||
assert.match(makefile, /windows\) printf '%s\\n' "\[INFO\] Windows builds run via: bun run build:win" ;;/);
|
||||
assert.match(
|
||||
makefile,
|
||||
/windows\) printf '%s\\n' "\[INFO\] Windows builds run via: bun run build:win" ;;/,
|
||||
);
|
||||
assert.match(makefile, /bun \.\/scripts\/configure-plugin-binary-path\.mjs/);
|
||||
});
|
||||
|
||||
@@ -36,7 +36,10 @@ function getSubtitleContainerHeight(ctx: RendererContext): number {
|
||||
function resolveYPercentClampRange(ctx: RendererContext): { min: number; max: number } {
|
||||
const viewportHeight = getViewportHeight();
|
||||
const subtitleHeight = getSubtitleContainerHeight(ctx);
|
||||
const minPercent = Math.max(PREFERRED_Y_PERCENT_MIN, (SUBTITLE_EDGE_PADDING_PX / viewportHeight) * 100);
|
||||
const minPercent = Math.max(
|
||||
PREFERRED_Y_PERCENT_MIN,
|
||||
(SUBTITLE_EDGE_PADDING_PX / viewportHeight) * 100,
|
||||
);
|
||||
const maxMarginBottomPx = Math.max(
|
||||
SUBTITLE_EDGE_PADDING_PX,
|
||||
viewportHeight - subtitleHeight - SUBTITLE_EDGE_PADDING_PX,
|
||||
|
||||
@@ -78,10 +78,7 @@ test('ensureDefaultConfigBootstrap does not seed default config into an existing
|
||||
});
|
||||
|
||||
assert.equal(fs.existsSync(path.join(configDir, 'config.jsonc')), false);
|
||||
assert.equal(
|
||||
fs.readFileSync(path.join(configDir, 'existing-user-file.txt'), 'utf8'),
|
||||
'keep\n',
|
||||
);
|
||||
assert.equal(fs.readFileSync(path.join(configDir, 'existing-user-file.txt'), 'utf8'), 'keep\n');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -190,13 +187,7 @@ test('resolveDefaultMpvInstallPaths resolves linux, macOS, and Windows defaults'
|
||||
supported: true,
|
||||
mpvConfigDir: path.win32.join('C:\\Users\\tester', 'AppData', 'Roaming', 'mpv'),
|
||||
scriptsDir: path.win32.join('C:\\Users\\tester', 'AppData', 'Roaming', 'mpv', 'scripts'),
|
||||
scriptOptsDir: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
'Roaming',
|
||||
'mpv',
|
||||
'script-opts',
|
||||
),
|
||||
scriptOptsDir: path.win32.join('C:\\Users\\tester', 'AppData', 'Roaming', 'mpv', 'script-opts'),
|
||||
pluginEntrypointPath: path.win32.join(
|
||||
'C:\\Users\\tester',
|
||||
'AppData',
|
||||
|
||||
@@ -58,8 +58,7 @@ export function parseMacOSHelperOutput(result: string): MacOSHelperWindowState |
|
||||
}
|
||||
|
||||
const focusedRaw = parts[4]?.trim().toLowerCase();
|
||||
const focused =
|
||||
focusedRaw === undefined ? true : focusedRaw === '1' || focusedRaw === 'true';
|
||||
const focused = focusedRaw === undefined ? true : focusedRaw === '1' || focusedRaw === 'true';
|
||||
|
||||
return {
|
||||
geometry: {
|
||||
|
||||
@@ -64,16 +64,13 @@ function inferHelperKindFromPath(helperPath: string): WindowsTrackerHelperKind |
|
||||
function materializeAsarHelper(
|
||||
sourcePath: string,
|
||||
kind: WindowsTrackerHelperKind,
|
||||
deps: Required<
|
||||
Pick<ResolveWindowsTrackerHelperOptions, 'mkdirSync' | 'copyFileSync'>
|
||||
>,
|
||||
deps: Required<Pick<ResolveWindowsTrackerHelperOptions, 'mkdirSync' | 'copyFileSync'>>,
|
||||
): string | null {
|
||||
if (!sourcePath.includes('.asar')) {
|
||||
return sourcePath;
|
||||
}
|
||||
|
||||
const fileName =
|
||||
kind === 'native' ? 'get-mpv-window-windows.exe' : 'get-mpv-window-windows.ps1';
|
||||
const fileName = kind === 'native' ? 'get-mpv-window-windows.exe' : 'get-mpv-window-windows.ps1';
|
||||
const targetDir = windowsPath.join(os.tmpdir(), 'subminer', 'helpers');
|
||||
const targetPath = windowsPath.join(targetDir, fileName);
|
||||
|
||||
@@ -130,7 +127,10 @@ function normalizeHelperPathOverride(
|
||||
return { path: helperPath, kind };
|
||||
}
|
||||
|
||||
function getHelperCandidates(dirname: string, resourcesPath: string | undefined): Array<{
|
||||
function getHelperCandidates(
|
||||
dirname: string,
|
||||
resourcesPath: string | undefined,
|
||||
): Array<{
|
||||
path: string;
|
||||
kind: WindowsTrackerHelperKind;
|
||||
}> {
|
||||
|
||||
@@ -48,8 +48,7 @@ function runHelperWithExecFile(
|
||||
targetMpvSocketPath: string | null,
|
||||
): Promise<WindowsTrackerRunnerResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const modeArgs =
|
||||
spec.kind === 'native' ? ['--mode', mode] : ['-Mode', mode];
|
||||
const modeArgs = spec.kind === 'native' ? ['--mode', mode] : ['-Mode', mode];
|
||||
const args = targetMpvSocketPath
|
||||
? [...spec.args, ...modeArgs, targetMpvSocketPath]
|
||||
: [...spec.args, ...modeArgs];
|
||||
|
||||
Reference in New Issue
Block a user