mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-09 16:19:25 -07:00
- Validate stats session IDs/limits and add AnkiConnect request timeouts - Stabilize stats window/runtime lifecycle and tighten window security defaults - Fix Electron CLI debug startup by unsetting `ELECTRON_RUN_AS_NODE` and wiring Yomitan session state - Expand regression coverage for tracker queries/events ordering and session aggregates - Update docs for stats dashboard usage and Yomitan lookup troubleshooting
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import type { BrowserWindowConstructorOptions } from 'electron';
|
|
import type { WindowGeometry } from '../../types';
|
|
|
|
const DEFAULT_STATS_WINDOW_WIDTH = 900;
|
|
const DEFAULT_STATS_WINDOW_HEIGHT = 700;
|
|
|
|
function isBareToggleKeyInput(input: Electron.Input, toggleKey: string): boolean {
|
|
return (
|
|
input.type === 'keyDown' &&
|
|
input.code === toggleKey &&
|
|
!input.control &&
|
|
!input.alt &&
|
|
!input.meta &&
|
|
!input.shift &&
|
|
!input.isAutoRepeat
|
|
);
|
|
}
|
|
|
|
export function shouldHideStatsWindowForInput(
|
|
input: Electron.Input,
|
|
toggleKey: string,
|
|
): boolean {
|
|
return (
|
|
(input.type === 'keyDown' && input.key === 'Escape') ||
|
|
isBareToggleKeyInput(input, toggleKey)
|
|
);
|
|
}
|
|
|
|
export function buildStatsWindowOptions(options: {
|
|
preloadPath: string;
|
|
bounds?: WindowGeometry | null;
|
|
}): BrowserWindowConstructorOptions {
|
|
return {
|
|
x: options.bounds?.x,
|
|
y: options.bounds?.y,
|
|
width: options.bounds?.width ?? DEFAULT_STATS_WINDOW_WIDTH,
|
|
height: options.bounds?.height ?? DEFAULT_STATS_WINDOW_HEIGHT,
|
|
frame: false,
|
|
transparent: true,
|
|
alwaysOnTop: true,
|
|
resizable: false,
|
|
skipTaskbar: true,
|
|
hasShadow: false,
|
|
focusable: true,
|
|
acceptFirstMouse: true,
|
|
fullscreenable: false,
|
|
backgroundColor: '#1e1e2e',
|
|
show: false,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
preload: options.preloadPath,
|
|
sandbox: true,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function buildStatsWindowLoadFileOptions(): { query: Record<string, string> } {
|
|
return {
|
|
query: {
|
|
overlay: '1',
|
|
},
|
|
};
|
|
}
|