diff options
| author | amankumarsingh77 <amankumarsingh7702@gmail.com> | 2026-07-28 22:01:47 +0530 |
|---|---|---|
| committer | Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> | 2026-08-02 19:12:46 +0530 |
| commit | c88082515dcd9c0df1328b85420e97d7286ad428 (patch) | |
| tree | d3a45084e5bea7473d6b6bcbe5163165c4368f64 /src/cdp/target-factory.ts | |
| parent | 86045450c208bc51670dd9554e581f2a62b181c9 (diff) | |
refactor: attach and windowId become session methods
cdp/attach.ts and cdp/window.ts were a module each for a single
`map(await session.callBrowser(...))` one-liner that took the session as
its first argument — two files, two imports and two names for what the
session can expose itself. They are now session.attach(targetId) and
session.windowId(targetId).
session.ts also repeated `targetId ? tabs.get(targetId) : undefined`
eight times; that is now currentTab().
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src/cdp/target-factory.ts')
| -rw-r--r-- | src/cdp/target-factory.ts | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/cdp/target-factory.ts b/src/cdp/target-factory.ts index 62c46f1..17d01be 100644 --- a/src/cdp/target-factory.ts +++ b/src/cdp/target-factory.ts @@ -3,9 +3,7 @@ import { randomUUID } from "node:crypto"; import type { BrowserClient } from "../client"; import { type Result, err, ok } from "../util/result"; -import { attachTo } from "./attach"; import { type CdpError, cdpError } from "./errors"; -import { getWindowId } from "./window"; const SPAWN_DEADLINE_MS = 8_000; const SPAWN_POLL_MS = 100; @@ -31,7 +29,7 @@ const listPageTargets = async (client: BrowserClient): Promise<Result<ReadonlyAr const sessionForTarget = async (client: BrowserClient, targetId: string): Promise<Result<string, CdpError>> => { const current = client.current(); if (current?.targetId === targetId) return ok(current.sessionId); - return attachTo(client.session(), targetId); + return client.session().attach(targetId); }; const spawnTabViaOpener = async ( @@ -130,7 +128,7 @@ const createDedicatedWindow = async (client: BrowserClient): Promise<Result<stri const ownership = client.ownership(); ownership.setHarnessWindow(targetId); ownership.add(targetId); - const win = await getWindowId(client.session(), targetId); + const win = await client.session().windowId(targetId); if (win.success) ownership.setHarnessWindowId(win.data); return ok(targetId); }; |
