From 9e9bf2a3badb59d0ce5bdb47c4e9d09ffb259e69 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Mon, 27 Jul 2026 01:17:32 +0530 Subject: refactor(cdp): extract attachTo, getWindowId, evaluateJson helpers Target.attachToTarget was decoded at 5 sites, Browser.getWindowForTarget at 5, and Runtime.evaluate unwrapped at another. Each is now one typed helper. Deletes the dead cdp/window-binding.ts. Co-Authored-By: Claude Opus 5 (1M context) --- src/cdp/attach.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/cdp/attach.ts (limited to 'src/cdp/attach.ts') diff --git a/src/cdp/attach.ts b/src/cdp/attach.ts new file mode 100644 index 0000000..9be539d --- /dev/null +++ b/src/cdp/attach.ts @@ -0,0 +1,13 @@ +import { map, type Result } from "../util/result"; +import type { CdpError } from "./errors"; +import type { CdpSession } from "./session"; + +/** Target.attachToTarget, unwrapped to the new session id. */ +export const attachTo = async ( + session: CdpSession, + targetId: string, +): Promise> => + map( + await session.callBrowser("Target.attachToTarget", { targetId, flatten: true }), + (d) => d.sessionId, + ); -- cgit v1.2.3