aboutsummaryrefslogtreecommitdiff
path: root/src/cdp/attach.ts
blob: 9be539d1721585e3188b1753d41531093969926a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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<Result<string, CdpError>> =>
  map(
    await session.callBrowser("Target.attachToTarget", { targetId, flatten: true }),
    (d) => d.sessionId,
  );