aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/transport.ts
blob: 4036ff7ddf35d2ac76ff3ac9d1a80033861cb557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { Result } from "../util/result";
import type { CdpError } from "./errors";
import type { CdpEvent } from "./types";

export const DEFAULT_TIMEOUT_MS = 15_000;

export type CdpTransport = {
  connect(url: string, opts?: { timeoutMs?: number }): Promise<Result<void, CdpError>>;
  close(): Promise<void>;
  request(
    method: string,
    params: Record<string, unknown>,
    opts?: { sessionId?: string | null; timeoutMs?: number },
  ): Promise<Result<unknown, CdpError>>;
  events(): AsyncIterable<CdpEvent>;
  state(): "open" | "closed" | "connecting";
  onClose(cb: () => void): () => void;
};