mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 00:03:15 +00:00
The five oversized src/main/browser modules and src/main/ipc/browser.ts each carried a file-level `eslint-disable max-lines` and ran 377-654 counted lines against a 300-line budget. AGENTS.md calls for splitting rather than suppressing, and config/max-lines-baseline.txt is a shrink-only ratchet, so this removes all six suppressions and prunes their entries (341 -> 335). Pure move, no behavior change. cdp-ws-proxy is decomposed into collaborating objects rather than free functions because its state is genuinely per-connection: every collaborator is a private readonly instance field built in the constructor with live closures over `this`, so per-connection state stays per-connection. Likewise the screencast pacer's isClosed/isStopping and snapshot capture's getSeq are live thunks, not values captured at wiring time, so guards inside already-armed timers still observe a later stop(). browser-guest-ui.ts is renamed to browser-guest-shortcut-forwarding.ts: after the split it exports exactly one function, setupGuestShortcutForwarding, so the old name no longer described its contents. Also restores a single `webContents.debugger` read in the screencast path. The extraction had left three reads where the original had one; the accessor is stable today, so this is not a behavior fix but it removes a latent divergence. Verified: oxlint clean, ratchet passes, typecheck clean, full unit suite green (remaining failures are pre-existing load flakes in untouched files, each green when re-run serially), no new runtime import cycles, and the IPC channel set diffed identical before/after with all 23 handlers still trust-gated.
26 lines
767 B
TypeScript
26 lines
767 B
TypeScript
let trustedBrowserRendererWebContentsId: number | null = null
|
|
|
|
export function setTrustedBrowserRendererWebContentsId(webContentsId: number | null): void {
|
|
trustedBrowserRendererWebContentsId = webContentsId
|
|
}
|
|
|
|
export function isTrustedBrowserRenderer(sender: Electron.WebContents): boolean {
|
|
if (sender.isDestroyed() || sender.getType() !== 'window') {
|
|
return false
|
|
}
|
|
if (trustedBrowserRendererWebContentsId != null) {
|
|
return sender.id === trustedBrowserRendererWebContentsId
|
|
}
|
|
|
|
const senderUrl = sender.getURL()
|
|
if (process.env.ELECTRON_RENDERER_URL) {
|
|
try {
|
|
return new URL(senderUrl).origin === new URL(process.env.ELECTRON_RENDERER_URL).origin
|
|
} catch {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return senderUrl.startsWith('file://')
|
|
}
|