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/event-queue.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/event-queue.ts')
| -rw-r--r-- | src/cdp/event-queue.ts | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/cdp/event-queue.ts b/src/cdp/event-queue.ts index 87f5551..5e154ea 100644 --- a/src/cdp/event-queue.ts +++ b/src/cdp/event-queue.ts @@ -1,12 +1,3 @@ -/** - * Shared transport primitives for CdpTransport implementations. - * - * Both the WebSocket transport (transport.ts, talking to Chrome directly) and - * the daemon transport (daemon-transport.ts, talking to the daemon over a Unix - * socket) need an identical single-consumer async event queue plus the same - * pending-request bookkeeping. This module is the single source of truth for - * that shared machinery. - */ import { type Result, err } from "../util/result"; import { type CdpError, cdpError } from "./errors"; @@ -14,14 +5,6 @@ import type { CdpEvent } from "./types"; export type CdpResult = Result<unknown, CdpError>; -/** - * A single-consumer async queue of CDP events. - * - * `push` enqueues an event (dropped silently after `end`). `end` terminates the - * stream — any pending and future iterator `next()` calls resolve `done:true`. - * `iter` is the AsyncIterable consumed by one for-await loop; a second consumer - * would silently steal events from the first. - */ export type EventQueue = { readonly push: (e: CdpEvent) => void; readonly end: () => void; @@ -59,18 +42,12 @@ export const makeEventQueue = (): EventQueue => { }; }; -/** An in-flight CDP request awaiting its response or timeout. */ export type Pending = { readonly resolve: (v: Result<unknown, CdpError>) => void; readonly timer: ReturnType<typeof setTimeout>; readonly method: string; }; -/** - * Reject every in-flight request with a transport_closed error and clear the - * map. Called from each transport's cleanup path when the underlying connection - * goes away. - */ export const rejectAllPending = (pending: Map<number, Pending>, reason: string): void => { for (const [, p] of pending) { clearTimeout(p.timer); @@ -79,18 +56,6 @@ export const rejectAllPending = (pending: Map<number, Pending>, reason: string): pending.clear(); }; -/** - * Send a CDP request and return a promise that settles when the matching - * response arrives, the request times out, or the send throws. - * - * The transport supplies a `send` callback that puts the already-serialized - * payload onto its wire (WebSocket frame or Unix-socket line); everything else - * — registering the pending entry, the timeout timer, and synchronous send - * failure handling — is identical across transports and lives here. - * - * `timeoutLabel` is the transport's prefix for the timeout error message - * (e.g. "CDP" or "Daemon"). - */ export const sendWithTimeout = ( pending: Map<number, Pending>, id: number, @@ -114,10 +79,6 @@ export const sendWithTimeout = ( } }); -/** - * Register a close listener, returning an unsubscribe function. Identical - * across transports, so it lives here. - */ export const makeOnClose = (closeListeners: Set<() => void>) => (cb: () => void): (() => void) => { closeListeners.add(cb); |
