refactor: remove dead exports, unused params, and stale config

This commit is contained in:
2026-04-04 13:36:46 -07:00
parent 2a4ca6f37e
commit 0dfe919d4f
6 changed files with 16 additions and 58 deletions
-10
View File
@@ -1,5 +1,4 @@
import Store from 'electron-store';
import { detectPlatform } from './platform';
export interface Keybind {
key: string;
@@ -112,10 +111,6 @@ export interface AppConfig {
y: number | undefined;
maximized: boolean;
};
platform: {
detectedOS: string;
gpuBackend: string;
};
}
export const DEFAULT_KEYBINDS: AppConfig['keybinds'] = {
@@ -131,7 +126,6 @@ export const DEFAULT_KEYBINDS: AppConfig['keybinds'] = {
fullscreenToggle: { key: 'F11', ctrl: false, shift: false, alt: false },
};
const platformInfo = detectPlatform();
export const config = new Store<AppConfig>({
name: 'krunker-civilian-config',
@@ -222,9 +216,5 @@ export const config = new Store<AppConfig>({
y: undefined,
maximized: true,
},
platform: {
detectedOS: platformInfo.os,
gpuBackend: platformInfo.gpuBackend,
},
},
});
+2 -2
View File
@@ -551,7 +551,7 @@ async function launchApp(): Promise<void> {
const ALLOWED_CONFIG_KEYS = new Set<string>([
'window', 'performance', 'game', 'swapper', 'matchmaker',
'keybinds', 'userscripts', 'ui', 'discord', 'translator',
'advanced', 'accounts', 'tabWindow', 'platform',
'advanced', 'accounts', 'tabWindow',
]);
ipcMain.handle('get-version', () => appVersion);
@@ -745,7 +745,7 @@ async function launchApp(): Promise<void> {
// ── Action button IPC handlers ──
ipcMain.handle('open-electron-log', () => {
shell.openPath(getLogPath('electron'));
shell.openPath(getLogPath());
});
ipcMain.handle('reset-swapper', async () => {
try {
+1 -1
View File
@@ -67,7 +67,7 @@ function makeLogger(getStream: () => WriteStream) {
export const electronLog = makeLogger(() => electronStream);
export function getLogPath(_type: 'electron'): string {
export function getLogPath(): string {
init();
return electronPath;
}
+4 -9
View File
@@ -61,10 +61,10 @@ function startHPCounter(): void {
}
function stopHPCounter(): void {
if (hpCheckInterval) { clearInterval(hpCheckInterval); hpCheckInterval = null; }
if (hpObserver) { hpObserver.disconnect(); hpObserver = null; }
if (hpCounterEl) { hpCounterEl.remove(); hpCounterEl = null; }
if (hpTimeout) { clearTimeout(hpTimeout); hpTimeout = null; }
clearInterval(hpCheckInterval!); hpCheckInterval = null;
hpObserver?.disconnect(); hpObserver = null;
hpCounterEl?.remove(); hpCounterEl = null;
clearTimeout(hpTimeout!); hpTimeout = null;
hpPointCounter = null;
hpEnemyOBJ = 0;
}
@@ -72,11 +72,6 @@ function stopHPCounter(): void {
export function initHPCounter(): void { startHPCounter(); }
export function destroyHPCounter(): void { stopHPCounter(); }
export function setHPCounterEnabled(enabled: boolean): void {
stopHPCounter();
if (enabled) startHPCounter();
}
// ── Rank Progress Tracker ──
interface RankInfo {
+7 -7
View File
@@ -1427,7 +1427,7 @@ function renderUserscriptsSection(body: HTMLElement): void {
function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement): void {
if (!inst.settings) return;
for (const [key, setting] of Object.entries(inst.settings)) {
for (const [, setting] of Object.entries(inst.settings)) {
const typeClass = setting.type === 'bool' ? 'bool' : setting.type === 'sel' ? 'sel' : setting.type === 'num' ? 'num' : setting.type === 'keybind' ? 'keybind' : '';
const row = document.createElement('div');
row.className = 'setting settName safety-0' + (typeClass ? ' ' + typeClass : '');
@@ -1447,7 +1447,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
input.addEventListener('change', () => {
setting.value = input.checked;
if (typeof setting.changed === 'function') setting.changed(setting.value);
saveScriptSetting(inst, key);
saveScriptSetting(inst);
});
break;
}
@@ -1463,7 +1463,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
input.addEventListener('change', () => {
setting.value = parseFloat(input.value) || 0;
if (typeof setting.changed === 'function') setting.changed(setting.value);
saveScriptSetting(inst, key);
saveScriptSetting(inst);
});
break;
}
@@ -1483,7 +1483,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
select.addEventListener('change', () => {
setting.value = select.value;
if (typeof setting.changed === 'function') setting.changed(setting.value);
saveScriptSetting(inst, key);
saveScriptSetting(inst);
});
break;
}
@@ -1496,7 +1496,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
input.addEventListener('input', () => {
setting.value = input.value;
if (typeof setting.changed === 'function') setting.changed(setting.value);
saveScriptSetting(inst, key);
saveScriptSetting(inst);
});
break;
}
@@ -1510,7 +1510,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
setting.value = newBind;
keyEl.textContent = keybindDisplayString(newBind);
if (typeof setting.changed === 'function') setting.changed(setting.value);
saveScriptSetting(inst, key);
saveScriptSetting(inst);
});
});
row.appendChild(keyEl);
@@ -1522,7 +1522,7 @@ function renderScriptSettings(inst: UserscriptInstance, container: HTMLElement):
}
}
function saveScriptSetting(inst: UserscriptInstance, _key: string): void {
function saveScriptSetting(inst: UserscriptInstance): void {
if (!inst.settings) return;
const prefs: Record<string, unknown> = {};
for (const [k, s] of Object.entries(inst.settings)) {
+2 -29
View File
@@ -19,37 +19,10 @@ export function escapeHtml(s: string): string {
return s.replace(/[&<>"']/g, c => HTML_ESCAPE_MAP[c]);
}
// ── Chat message injection ──
// Creates messages in #chatHolder inside a persistent #kpcMessageHolder div.
// timeout=0 means the message is persistent (not auto-removed).
export function genChatMsg(text: string, timeout = 2.25): HTMLElement | null {
const chatHolder = document.getElementById('chatHolder');
if (!chatHolder) return null;
if (!document.getElementById('kpcMessageHolder')) {
chatHolder.insertAdjacentHTML('afterbegin', '<div id="kpcMessageHolder"></div>');
}
const holder = document.getElementById('kpcMessageHolder')!;
holder.insertAdjacentHTML('beforeend',
'<div class="chatHolder_kpc"><div class="chatItem_kpc"><span class="chatMsg_kpc">' +
escapeHtml(text) + '</span></div></div>');
const elem = holder.lastElementChild as HTMLElement;
if (timeout !== 0) {
setTimeout(() => { elem.remove(); }, timeout * 1000);
}
return elem;
}
// ── Filename sanitisation ──
export function sanitizeFilename(name: string): string {
return name.replace(/[^a-zA-Z0-9_-]/g, '_');
}
// ── Shared CSS constants ──
export const DEATH_ANIM_BLOCK_ID = 'kpc-animationBlock';
export const DEATH_ANIM_BLOCK_CSS =
const DEATH_ANIM_BLOCK_ID = 'kpc-animationBlock';
const DEATH_ANIM_BLOCK_CSS =
'.death-ui-bottom, .death-ui-bottom-empty { animation: none !important; transition: none !important; }';
/** Inject or remove the death screen animation block style element. */