mirror of
https://github.com/stablyai/orca.git
synced 2026-11-06 12:07:58 +00:00
* Split speech session lifecycle * Split terminal output scheduler pipeline * Split mobile browser pane modules * Prune resolved max-lines suppressions * Split pane tree equalization logic * Extract mobile troubleshoot screen styles * Split external automation manager * Split main window service attachments * Split hosted review creation checks * Split automation dispatch event handling * Split settings navigation metadata * Split daemon initialization lifecycle * Split GitLab item dialog * Split relay dispatcher layers * Split mobile host screen * Retarget mobile view settings source test * Split runtime file client layers * Split ports panel layers * Split runtime environments pane layers * Split local PTY provider responsibilities * Split CDP bridge responsibilities * Fix F3-speech for #17123 * Fix F1-cycle for #17131 * Fix F4-navtest for #17157 * Fix F2-allowlist for #17161
133 lines
4.3 KiB
TypeScript
133 lines
4.3 KiB
TypeScript
import type { WebContents } from 'electron'
|
|
import type { BrowserScreenshotResult, BrowserScrollResult } from '../../shared/runtime-types'
|
|
import type { CdpTabState } from './cdp-auxiliary-commands'
|
|
import type { CdpCommandSender, RefEntry } from './snapshot-engine'
|
|
import type { CdpBridgeState, CdpQueuedCommand } from './cdp-bridge-state'
|
|
import type { CdpDebuggerLifecycle } from './cdp-debugger-lifecycle'
|
|
import type { CdpNavigationOperations } from './cdp-navigation-operations'
|
|
import type { CdpRefResolution } from './cdp-ref-resolution'
|
|
|
|
export type CdpScrollDirection = BrowserScrollResult extends { scrolled: infer Direction }
|
|
? Direction
|
|
: never
|
|
export type CdpScreenshotFormat = BrowserScreenshotResult extends { format: infer Format }
|
|
? Format
|
|
: never
|
|
|
|
export abstract class CdpBridgeCommandModule {
|
|
constructor(
|
|
private readonly bridgeState: CdpBridgeState,
|
|
private readonly debuggerLifecycle: CdpDebuggerLifecycle,
|
|
private readonly refResolution: CdpRefResolution,
|
|
private readonly navigation: CdpNavigationOperations
|
|
) {}
|
|
|
|
protected get activeWebContentsId(): number | null {
|
|
return this.bridgeState.activeWebContentsId
|
|
}
|
|
|
|
protected set activeWebContentsId(webContentsId: number | null) {
|
|
this.bridgeState.activeWebContentsId = webContentsId
|
|
}
|
|
|
|
protected get tabState(): Map<string, CdpTabState> {
|
|
return this.bridgeState.tabState
|
|
}
|
|
|
|
protected get commandQueues(): Map<string, CdpQueuedCommand[]> {
|
|
return this.bridgeState.commandQueues
|
|
}
|
|
|
|
protected getActiveGuest(): WebContents {
|
|
return this.bridgeState.getActiveGuest()
|
|
}
|
|
|
|
protected getRegisteredTabs(): Map<string, number> {
|
|
return this.bridgeState.getRegisteredTabs()
|
|
}
|
|
|
|
protected resolveTabId(webContentsId: number): string {
|
|
return this.bridgeState.resolveTabId(webContentsId)
|
|
}
|
|
|
|
protected resolveTabIdSafe(webContentsId: number): string | null {
|
|
return this.bridgeState.resolveTabIdSafe(webContentsId)
|
|
}
|
|
|
|
protected getOrCreateTabState(tabId: string): CdpTabState {
|
|
return this.bridgeState.getOrCreateTabState(tabId)
|
|
}
|
|
|
|
protected removeDebuggerListeners(guest: WebContents, state: CdpTabState): void {
|
|
this.debuggerLifecycle.removeDebuggerListeners(guest, state)
|
|
}
|
|
|
|
protected ensureDebuggerAttached(guest: WebContents): Promise<void> {
|
|
return this.debuggerLifecycle.ensureDebuggerAttached(guest)
|
|
}
|
|
|
|
protected makeCdpSender(guest: WebContents, sessionId?: string): CdpCommandSender {
|
|
return this.debuggerLifecycle.makeCdpSender(guest, sessionId)
|
|
}
|
|
|
|
protected senderForRef(guest: WebContents, ref: RefEntry): CdpCommandSender {
|
|
return this.refResolution.senderForRef(guest, ref)
|
|
}
|
|
|
|
protected resolveRef(
|
|
guest: WebContents,
|
|
sender: CdpCommandSender,
|
|
ref: string
|
|
): Promise<RefEntry> {
|
|
return this.refResolution.resolveRef(guest, sender, ref)
|
|
}
|
|
|
|
protected scrollIntoView(sender: CdpCommandSender, backendNodeId: number): Promise<void> {
|
|
return this.refResolution.scrollIntoView(sender, backendNodeId)
|
|
}
|
|
|
|
protected getElementCenter(
|
|
sender: CdpCommandSender,
|
|
backendNodeId: number
|
|
): Promise<{ cx: number; cy: number }> {
|
|
return this.refResolution.getElementCenter(sender, backendNodeId)
|
|
}
|
|
|
|
protected getPageCoordinates(
|
|
guest: WebContents,
|
|
refEntry: RefEntry,
|
|
localCx: number,
|
|
localCy: number
|
|
): Promise<{ cx: number; cy: number }> {
|
|
return this.refResolution.getPageCoordinates(guest, refEntry, localCx, localCy)
|
|
}
|
|
|
|
protected getNavigationId(sender: CdpCommandSender): Promise<string> {
|
|
return this.navigation.getNavigationId(sender)
|
|
}
|
|
|
|
protected getPreviousHistoryEntryId(sender: CdpCommandSender): Promise<number> {
|
|
return this.navigation.getPreviousHistoryEntryId(sender)
|
|
}
|
|
|
|
protected waitForLoad(sender: CdpCommandSender, guest: WebContents): Promise<void> {
|
|
return this.navigation.waitForLoad(sender, guest)
|
|
}
|
|
|
|
protected waitForNetworkIdle(
|
|
guest: WebContents,
|
|
timeoutMs: number,
|
|
idleMs: number
|
|
): Promise<void> {
|
|
return this.navigation.waitForNetworkIdle(guest, timeoutMs, idleMs)
|
|
}
|
|
|
|
protected invalidateRefMap(webContentsId: number): void {
|
|
this.bridgeState.invalidateRefMap(webContentsId)
|
|
}
|
|
|
|
protected enqueueCommand<T>(execute: () => Promise<T>): Promise<T> {
|
|
return this.bridgeState.enqueueCommand(execute)
|
|
}
|
|
}
|