aboutsummaryrefslogtreecommitdiff
path: root/src/client.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-27 01:17:32 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit9e9bf2a3badb59d0ce5bdb47c4e9d09ffb259e69 (patch)
tree602a6e33a98de62bf1f0c1d873eeb2676c650242 /src/client.ts
parentd1b57558ff40ef6d6b19ee7eff0a44f7f4a585f6 (diff)
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) <noreply@anthropic.com>
Diffstat (limited to 'src/client.ts')
-rw-r--r--src/client.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/client.ts b/src/client.ts
index 9808e59..c1c8951 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -244,11 +244,10 @@ export const createBrowserClient = (opts: BrowserClientOptions): BrowserClient =
? await session.callOnTarget("Runtime.evaluate", { expression: wrapped, returnByValue: true, awaitPromise: true }, sessionId)
: await session.call("Runtime.evaluate", { expression: wrapped, returnByValue: true, awaitPromise: true });
if (!r.success) return r;
- const data = r.data as { result?: { value?: unknown }; exceptionDetails?: unknown };
- if (data.exceptionDetails) {
- return err(cdpError("remote_error", `JS evaluation failed: ${JSON.stringify(data.exceptionDetails)}`, "Runtime.evaluate"));
+ if (r.data.exceptionDetails !== undefined) {
+ return err(cdpError("remote_error", `JS evaluation failed: ${JSON.stringify(r.data.exceptionDetails)}`, "Runtime.evaluate"));
}
- return ok(data.result?.value);
+ return ok(r.data.result.value);
};
const readPageInfo = async (): Promise<Result<PageInfo, CdpError>> => {