diff options
| author | amankumarsingh77 <amankumarsingh7702@gmail.com> | 2026-07-28 20:25:38 +0530 |
|---|---|---|
| committer | Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> | 2026-08-02 19:12:46 +0530 |
| commit | 330767d862458386e804bde240a1f0d7835b9b8e (patch) | |
| tree | 13a5f2086d265959c1bfa10bb88641a6804fd1f5 /src/cdp/daemon-transport.ts | |
| parent | 12d7a38ba0f1b1e4e301fce81e22f4b93036d211 (diff) | |
refactor(cdp): strip comment noise
Removes module banners, section dividers, and comments restating the code.
Keeps one-line notes for the window.open/browserContextId constraint, the
seed-tab claim, the unverifiable-pin reuse rule, the SeedTargetProvider
rationale, the deliberate dialog retention, the discovery-time browser
quirks, and the guarded CDP decoder assertion.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp/daemon-transport.ts')
| -rw-r--r-- | src/cdp/daemon-transport.ts | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/src/cdp/daemon-transport.ts b/src/cdp/daemon-transport.ts index 819e581..101108d 100644 --- a/src/cdp/daemon-transport.ts +++ b/src/cdp/daemon-transport.ts @@ -1,15 +1,3 @@ -/** - * DaemonTransport — CdpTransport backed by a Unix socket to the browser daemon. - * - * Satisfies the exact CdpTransport interface so BrowserClient, CdpSession, and - * all domain tools work without changes. Internally uses newline-delimited JSON - * over a Unix domain socket instead of a WebSocket to Chrome. - * - * References: - * - CdpTransport interface: src/cdp/transport.ts - * - net.createConnection IPC: https://nodejs.org/docs/latest-v22.x/api/net.html#netcreateconnection - * - readline.createInterface: https://nodejs.org/docs/latest-v22.x/api/readline.html#readlinecreateinterfaceoptions - */ import { createConnection, type Socket } from "node:net"; import { createInterface } from "node:readline"; @@ -26,7 +14,6 @@ import { serialize, } from "../daemon/protocol"; -// ── Implementation ───────────────────────────────────────────────────────────── export const createDaemonTransport = (clientId: string): CdpTransport => { let socket: Socket | null = null; @@ -49,10 +36,8 @@ export const createDaemonTransport = (clientId: string): CdpTransport => { for (const cb of closeListeners) cb(); }; - // ── Connect ──────────────────────────────────────────────────────────── const connect = (_url: string, opts?: { timeoutMs?: number }): Promise<Result<void, CdpError>> => { - // url is ignored — we always connect to the daemon socket const timeoutMs = opts?.timeoutMs ?? 10_000; if (socket && !socket.destroyed && registered) { @@ -133,17 +118,14 @@ export const createDaemonTransport = (clientId: string): CdpTransport => { }); sock.on("error", () => { - // Errors are surfaced via 'close' }); sock.on("close", () => { clearTimeout(connectTimer); cleanup("Daemon socket closed"); - // If connect hasn't settled yet, settle with error settle(err(cdpError("transport_closed", "Daemon socket closed before registration"))); }); - // Send registration const regMsg: WireControl = { type: "control", action: "register", clientId }; sock.write(serialize(regMsg) + "\n"); }); @@ -158,7 +140,6 @@ export const createDaemonTransport = (clientId: string): CdpTransport => { }); }; - // ── Close ────────────────────────────────────────────────────────────── const close = async (): Promise<void> => { if (registered && socket && !socket.destroyed) { @@ -168,7 +149,6 @@ export const createDaemonTransport = (clientId: string): CdpTransport => { cleanup("close() called"); }; - // ── Request ──────────────────────────────────────────────────────────── const request = ( method: string, @@ -195,11 +175,9 @@ export const createDaemonTransport = (clientId: string): CdpTransport => { return sendWithTimeout(pending, id, method, timeoutMs, "Daemon", () => sock.write(serialize(req) + "\n")); }; - // ── Events ───────────────────────────────────────────────────────────── const events = (): AsyncIterable<CdpEvent> => queue.iter; - // ── State ────────────────────────────────────────────────────────────── const state = (): "open" | "closed" | "connecting" => { if (!socket) return "closed"; |
