feat(cloudflare): typed Cloudflare.* CDP commands (handoff, session, live view)#218
Draft
jonnyparris wants to merge 2 commits into
Draft
feat(cloudflare): typed Cloudflare.* CDP commands (handoff, session, live view)#218jonnyparris wants to merge 2 commits into
jonnyparris wants to merge 2 commits into
Conversation
Declares the request/response types for Cloudflare's custom CDP domain
(handoff, handoffComplete, getHandoffState, getSessionId, getLiveView)
and merges them into Protocol.CommandParameters / CommandReturnValues so
calls like cdpSession.send('Cloudflare.handoff', {...}) type-check with
full param and return-type inference.
The augmentation lives outside the build-generated types/ directory so it
survives copy_types.js rebuilds, mirroring the existing Browser.sessionId()
augmentation in index.d.ts.
The shared interface block is the canonical definition, vendored
identically into the puppeteer and playwright forks; it is intended to be
promoted to a shared package once the cloudflare/browser-run monorepo
lands. Only the Protocol augmentation is fork-specific.
BRAPI-1194, BRAPI-1218
commit: |
- GetSessionIdRequest: use Record<string, never> instead of an empty interface, matching the puppeteer fork's lint-clean canonical block - scope an eslint-disable for no-namespace on the Protocol augmentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds typed support for Cloudflare's custom
Cloudflare.*CDP domain so calls like:type-check with full parameter and return-type inference, instead of being rejected as an unknown CDP command. (The wire layer already accepts arbitrary command strings at runtime; this adds the missing types.)
Covers the full domain:
Cloudflare.handoffHandoffRequestHandoffResponseCloudflare.handoffCompleteHandoffCompleteRequestHandoffCompleteResponseCloudflare.getHandoffStateGetHandoffStateRequestGetHandoffStateResponseCloudflare.getSessionIdGetSessionIdRequestGetSessionIdResponseCloudflare.getLiveViewGetLiveViewRequestGetLiveViewResponseHow
packages/playwright-cloudflare/cloudflare-cdp.d.tsdeclares the request/response interfaces and merges the commands intoProtocol.CommandParameters/Protocol.CommandReturnValues— the two mapsCDPSession.send()is keyed on.types/directory (overwritten byutils/copy_types.js) so the augmentation survives rebuilds, mirroring the existingBrowser.sessionId()augmentation inindex.d.ts.export * from './cloudflare-cdp'inindex.d.ts(pulls in the augmentation and exposes the interfaces to consumers).Shared source of truth
The interface block is byte-identical to the one vendored into the puppeteer fork (companion PR). Only the
declare moduleglue differs per fork. This is the canonical definition pending thecloudflare/browser-runmonorepo, at which point both copies are replaced by a shared imported package.Tickets
Companion PR:
cloudflare/puppeteer(same types, puppeteer augmentation).beep-boop-ruskin-agent-🤖