aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/types.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 22:41:18 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commitdcb79fc62bdd4d9ec0cbdb2c97d3eb2b2dacdf22 (patch)
tree1b7d35ec51db118b06811aa72ea6cc36fdad948e /src/cdp/types.ts
parentb484c017807acb902eaaaa4e242f8b79f8e8eba6 (diff)
refactor: merge nine files whose reason to exist was gone
src/ goes from 84 files to 75 at the same line count — every merge below had exactly one consumer. cdp/event-queue.ts and cdp/pending-requests.ts become daemon/queue.ts. I split these in the daemon-internals commit on the grounds that they held two unrelated concerns, but the transport commit had already deleted the second transport, so both halves had one consumer and the split bought nothing. They also sat in cdp/ while only daemon/ used them. cdp/transport.ts held only the CdpTransport interface after the second transport went; five of its six consumers import it type-only, so it moves to cdp/types.ts. cdp/evaluate.ts moves into cdp/session.ts rather than into its lone consumer isolated-tab.ts — it reaches session.call directly, so under src/domains/ it would trip the raw-cdp-call rule. util/keycodes.ts and util/time.ts fold into their only callers (keyboard.ts, page.ts); util/bytes.ts into util/truncate.ts, which already owns output-size formatting; readpage/capture.ts and search/extract.ts into the tools beside them; profile/picker.ts into profile/command.ts. Kept deliberately: mutex.ts and domains/target.ts each have their own test suite, and folding target.ts into click.ts would make a tool file export a helper. sharp-shim.ts is an isolation boundary carrying two allowlisted casts. result.ts, guards.ts, js-template.ts and paths.ts are small but have 44, 12, 8 and 3 consumers. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp/types.ts')
-rw-r--r--src/cdp/types.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cdp/types.ts b/src/cdp/types.ts
index 984b930..6119b69 100644
--- a/src/cdp/types.ts
+++ b/src/cdp/types.ts
@@ -1,4 +1,6 @@
+import type { Result } from "../util/result";
import { isRecord } from "../util/guards";
+import type { CdpError } from "./errors";
export type CdpEvent = {
readonly method: string;
@@ -63,3 +65,18 @@ export const isCdpRawMessage = (v: unknown): v is CdpRawMessage => {
}
return true;
};
+
+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;
+};