chromium-bidi
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -23,7 +23,7 @@ /** | ||
export { BidiServer, MapperOptions } from './BidiServer.js'; | ||
export type { ICdpConnection, ICdpConnection as CdpConnection, } from '../cdp/CdpConnection.js'; | ||
export type { ICdpClient, ICdpClient as CdpClient } from '../cdp/CdpClient.js'; | ||
export type { CdpConnection } from '../cdp/CdpConnection.js'; | ||
export type { CdpClient } from '../cdp/CdpClient.js'; | ||
export { EventEmitter } from '../utils/EventEmitter.js'; | ||
export type { IBidiTransport as BidiTransport } from './BidiTransport.js'; | ||
export type { BidiTransport } from './BidiTransport.js'; | ||
export { OutgoingMessage } from './OutgoingMessage.js'; | ||
export type { IBidiParser } from './BidiParser.js'; | ||
export type { BidiCommandParameterParser } from './BidiParser.js'; |
@@ -18,4 +18,4 @@ /** | ||
import type { BrowsingContext, Cdp, Input, Network, Script, Session } from '../protocol/protocol.js'; | ||
import type { IBidiParser } from './BidiParser.js'; | ||
export declare class BidiNoOpParser implements IBidiParser { | ||
import type { BidiCommandParameterParser } from './BidiParser.js'; | ||
export declare class BidiNoOpParser implements BidiCommandParameterParser { | ||
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters; | ||
@@ -22,0 +22,0 @@ parseCaptureScreenshotParams(params: unknown): BrowsingContext.CaptureScreenshotParameters; |
@@ -18,3 +18,3 @@ /** | ||
import type { BrowsingContext, Cdp, Input, Network, Script, Session } from '../protocol/protocol.js'; | ||
export interface IBidiParser { | ||
export interface BidiCommandParameterParser { | ||
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters; | ||
@@ -21,0 +21,0 @@ parseCaptureScreenshotParams(params: unknown): BrowsingContext.CaptureScreenshotParameters; |
@@ -17,4 +17,4 @@ /** | ||
*/ | ||
import type { ICdpClient } from '../cdp/CdpClient'; | ||
import type { ICdpConnection } from '../cdp/CdpConnection.js'; | ||
import type { CdpClient } from '../cdp/CdpClient'; | ||
import type { CdpConnection } from '../cdp/CdpConnection.js'; | ||
import type { ChromiumBidi } from '../protocol/protocol.js'; | ||
@@ -24,4 +24,4 @@ import { EventEmitter } from '../utils/EventEmitter.js'; | ||
import type { Result } from '../utils/result.js'; | ||
import type { IBidiParser } from './BidiParser.js'; | ||
import type { IBidiTransport } from './BidiTransport.js'; | ||
import type { BidiCommandParameterParser } from './BidiParser.js'; | ||
import type { BidiTransport } from './BidiTransport.js'; | ||
import type { OutgoingMessage } from './OutgoingMessage.js'; | ||
@@ -33,2 +33,3 @@ type BidiServerEvent = { | ||
acceptInsecureCerts: boolean; | ||
sharedIdWithFrame?: boolean; | ||
}; | ||
@@ -41,3 +42,3 @@ export declare class BidiServer extends EventEmitter<BidiServerEvent> { | ||
*/ | ||
static createAndStart(bidiTransport: IBidiTransport, cdpConnection: ICdpConnection, browserCdpClient: ICdpClient, selfTargetId: string, options?: MapperOptions, parser?: IBidiParser, logger?: LoggerFn): Promise<BidiServer>; | ||
static createAndStart(bidiTransport: BidiTransport, cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, options?: MapperOptions, parser?: BidiCommandParameterParser, logger?: LoggerFn): Promise<BidiServer>; | ||
/** | ||
@@ -44,0 +45,0 @@ * Sends BiDi message. |
@@ -25,4 +25,4 @@ "use strict"; | ||
const BrowsingContextStorage_js_1 = require("./domains/context/BrowsingContextStorage.js"); | ||
const EventManager_js_1 = require("./domains/events/EventManager.js"); | ||
const RealmStorage_js_1 = require("./domains/script/RealmStorage.js"); | ||
const EventManager_js_1 = require("./domains/session/EventManager.js"); | ||
class BidiServer extends EventEmitter_js_1.EventEmitter { | ||
@@ -54,3 +54,3 @@ #messageQueue; | ||
this.#eventManager = new EventManager_js_1.EventManager(this.#browsingContextStorage); | ||
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(cdpConnection, browserCdpClient, this.#eventManager, selfTargetId, this.#browsingContextStorage, new RealmStorage_js_1.RealmStorage(), options?.acceptInsecureCerts ?? false, parser, this.#logger); | ||
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(cdpConnection, browserCdpClient, this.#eventManager, selfTargetId, this.#browsingContextStorage, new RealmStorage_js_1.RealmStorage(), options?.acceptInsecureCerts ?? false, options?.sharedIdWithFrame ?? false, parser, this.#logger); | ||
this.#eventManager.on("event" /* EventManagerEvents.Event */, ({ message, event }) => { | ||
@@ -57,0 +57,0 @@ this.emitOutgoingMessage(message, event); |
@@ -18,3 +18,3 @@ /** | ||
import type { ChromiumBidi } from '../protocol/protocol.js'; | ||
export interface IBidiTransport { | ||
export interface BidiTransport { | ||
setOnMessage: (handler: (message: ChromiumBidi.Command) => Promise<void> | void) => void; | ||
@@ -21,0 +21,0 @@ sendMessage: (message: ChromiumBidi.Message) => Promise<void> | void; |
@@ -17,4 +17,4 @@ /** | ||
*/ | ||
import type { ICdpClient } from '../cdp/CdpClient'; | ||
import type { ICdpConnection } from '../cdp/CdpConnection.js'; | ||
import type { CdpClient } from '../cdp/CdpClient'; | ||
import type { CdpConnection } from '../cdp/CdpConnection.js'; | ||
import { type ChromiumBidi } from '../protocol/protocol.js'; | ||
@@ -24,6 +24,6 @@ import { EventEmitter } from '../utils/EventEmitter.js'; | ||
import type { Result } from '../utils/result.js'; | ||
import type { IBidiParser } from './BidiParser.js'; | ||
import type { BidiCommandParameterParser } from './BidiParser.js'; | ||
import type { BrowsingContextStorage } from './domains/context/BrowsingContextStorage.js'; | ||
import type { EventManager } from './domains/events/EventManager.js'; | ||
import type { RealmStorage } from './domains/script/RealmStorage.js'; | ||
import type { EventManager } from './domains/session/EventManager.js'; | ||
import { OutgoingMessage } from './OutgoingMessage.js'; | ||
@@ -41,5 +41,5 @@ export declare const enum CommandProcessorEvents { | ||
#private; | ||
constructor(cdpConnection: ICdpConnection, browserCdpClient: ICdpClient, eventManager: EventManager, selfTargetId: string, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, acceptInsecureCerts: boolean, parser?: IBidiParser, logger?: LoggerFn); | ||
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, eventManager: EventManager, selfTargetId: string, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, acceptInsecureCerts: boolean, sharedIdWithFrame: boolean, parser?: BidiCommandParameterParser, logger?: LoggerFn); | ||
processCommand(command: ChromiumBidi.Command): Promise<void>; | ||
} | ||
export {}; |
@@ -46,3 +46,3 @@ "use strict"; | ||
#logger; | ||
constructor(cdpConnection, browserCdpClient, eventManager, selfTargetId, browsingContextStorage, realmStorage, acceptInsecureCerts, parser = new BidiNoOpParser_js_1.BidiNoOpParser(), logger) { | ||
constructor(cdpConnection, browserCdpClient, eventManager, selfTargetId, browsingContextStorage, realmStorage, acceptInsecureCerts, sharedIdWithFrame, parser = new BidiNoOpParser_js_1.BidiNoOpParser(), logger) { | ||
super(); | ||
@@ -55,3 +55,3 @@ this.#parser = parser; | ||
this.#browserProcessor = new BrowserProcessor_js_1.BrowserProcessor(browserCdpClient); | ||
this.#browsingContextProcessor = new BrowsingContextProcessor_js_1.BrowsingContextProcessor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, logger); | ||
this.#browsingContextProcessor = new BrowsingContextProcessor_js_1.BrowsingContextProcessor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, sharedIdWithFrame, logger); | ||
this.#cdpProcessor = new CdpProcessor_js_1.CdpProcessor(browsingContextStorage, cdpConnection, browserCdpClient); | ||
@@ -58,0 +58,0 @@ this.#inputProcessor = new InputProcessor_js_1.InputProcessor(browsingContextStorage); |
@@ -18,7 +18,7 @@ /** | ||
import type { EmptyResult } from '../../../protocol/protocol.js'; | ||
import type { ICdpClient } from '../../BidiMapper.js'; | ||
import type { CdpClient } from '../../BidiMapper.js'; | ||
export declare class BrowserProcessor { | ||
#private; | ||
constructor(browserCdpClient: ICdpClient); | ||
constructor(browserCdpClient: CdpClient); | ||
close(): EmptyResult; | ||
} |
@@ -18,9 +18,9 @@ /** | ||
import type { Cdp } from '../../../protocol/protocol.js'; | ||
import type { ICdpClient, ICdpConnection } from '../../BidiMapper.js'; | ||
import type { CdpClient, CdpConnection } from '../../BidiMapper.js'; | ||
import type { BrowsingContextStorage } from '../context/BrowsingContextStorage.js'; | ||
export declare class CdpProcessor { | ||
#private; | ||
constructor(browsingContextStorage: BrowsingContextStorage, cdpConnection: ICdpConnection, browserCdpClient: ICdpClient); | ||
constructor(browsingContextStorage: BrowsingContextStorage, cdpConnection: CdpConnection, browserCdpClient: CdpClient); | ||
getSession(params: Cdp.GetSessionParameters): Cdp.GetSessionResult; | ||
sendCommand(params: Cdp.SendCommandParameters): Promise<Cdp.SendCommandResult>; | ||
} |
@@ -20,5 +20,5 @@ /** | ||
import { type LoggerFn } from '../../../utils/log.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import { Realm } from '../script/Realm.js'; | ||
import type { RealmStorage } from '../script/RealmStorage.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { BrowsingContextStorage } from './BrowsingContextStorage.js'; | ||
@@ -30,3 +30,3 @@ import type { CdpTarget } from './CdpTarget.js'; | ||
private constructor(); | ||
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, id: BrowsingContext.BrowsingContext, parentId: BrowsingContext.BrowsingContext | null, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn): BrowsingContextImpl; | ||
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, id: BrowsingContext.BrowsingContext, parentId: BrowsingContext.BrowsingContext | null, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, sharedIdWithFrame: boolean, logger?: LoggerFn): BrowsingContextImpl; | ||
static getTimestamp(): number; | ||
@@ -33,0 +33,0 @@ /** |
@@ -54,4 +54,5 @@ "use strict"; | ||
#maybeDefaultRealm; | ||
#sharedIdWithFrame; | ||
#logger; | ||
constructor(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, logger) { | ||
constructor(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, sharedIdWithFrame, logger) { | ||
this.#cdpTarget = cdpTarget; | ||
@@ -63,6 +64,7 @@ this.#realmStorage = realmStorage; | ||
this.#browsingContextStorage = browsingContextStorage; | ||
this.#sharedIdWithFrame = sharedIdWithFrame; | ||
this.#logger = logger; | ||
} | ||
static create(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, logger) { | ||
const context = new BrowsingContextImpl(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, logger); | ||
static create(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, sharedIdWithFrame, logger) { | ||
const context = new BrowsingContextImpl(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, sharedIdWithFrame, logger); | ||
context.#initListeners(); | ||
@@ -336,3 +338,3 @@ browsingContextStorage.addContext(context); | ||
// Sandbox name for isolated world. | ||
sandbox, this.#cdpTarget.cdpClient, this.#eventManager, this.#logger); | ||
sandbox, this.#cdpTarget.cdpClient, this.#eventManager, this.#sharedIdWithFrame, this.#logger); | ||
if (auxData.isDefault) { | ||
@@ -339,0 +341,0 @@ this.#maybeDefaultRealm = realm; |
@@ -1,13 +0,13 @@ | ||
import type { ICdpClient } from '../../../cdp/CdpClient.js'; | ||
import type { ICdpConnection } from '../../../cdp/CdpConnection.js'; | ||
import type { CdpClient } from '../../../cdp/CdpClient.js'; | ||
import type { CdpConnection } from '../../../cdp/CdpConnection.js'; | ||
import { BrowsingContext, type EmptyResult } from '../../../protocol/protocol.js'; | ||
import { type LoggerFn } from '../../../utils/log.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { NetworkStorage } from '../network/NetworkStorage.js'; | ||
import type { PreloadScriptStorage } from '../script/PreloadScriptStorage.js'; | ||
import type { RealmStorage } from '../script/RealmStorage.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { BrowsingContextStorage } from './BrowsingContextStorage.js'; | ||
export declare class BrowsingContextProcessor { | ||
#private; | ||
constructor(cdpConnection: ICdpConnection, browserCdpClient: ICdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, preloadScriptStorage: PreloadScriptStorage, acceptInsecureCerts: boolean, logger?: LoggerFn); | ||
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, preloadScriptStorage: PreloadScriptStorage, acceptInsecureCerts: boolean, sharedIdWithFrame: boolean, logger?: LoggerFn); | ||
getTree(params: BrowsingContext.GetTreeParameters): BrowsingContext.GetTreeResult; | ||
@@ -14,0 +14,0 @@ create(params: BrowsingContext.CreateParameters): Promise<BrowsingContext.CreateResult>; |
@@ -17,6 +17,7 @@ "use strict"; | ||
#acceptInsecureCerts; | ||
#sharedIdWithFrame; | ||
#preloadScriptStorage; | ||
#realmStorage; | ||
#logger; | ||
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, logger) { | ||
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, preloadScriptStorage, acceptInsecureCerts, sharedIdWithFrame, logger) { | ||
this.#acceptInsecureCerts = acceptInsecureCerts; | ||
@@ -31,2 +32,3 @@ this.#cdpConnection = cdpConnection; | ||
this.#realmStorage = realmStorage; | ||
this.#sharedIdWithFrame = sharedIdWithFrame; | ||
this.#logger = logger; | ||
@@ -183,3 +185,3 @@ this.#setEventListeners(browserCdpClient); | ||
if (parentBrowsingContext !== undefined) { | ||
BrowsingContextImpl_js_1.BrowsingContextImpl.create(parentBrowsingContext.cdpTarget, this.#realmStorage, params.frameId, params.parentFrameId, this.#eventManager, this.#browsingContextStorage, this.#logger); | ||
BrowsingContextImpl_js_1.BrowsingContextImpl.create(parentBrowsingContext.cdpTarget, this.#realmStorage, params.frameId, params.parentFrameId, this.#eventManager, this.#browsingContextStorage, this.#sharedIdWithFrame, this.#logger); | ||
} | ||
@@ -213,3 +215,3 @@ } | ||
// New context. | ||
BrowsingContextImpl_js_1.BrowsingContextImpl.create(cdpTarget, this.#realmStorage, targetInfo.targetId, null, this.#eventManager, this.#browsingContextStorage, this.#logger); | ||
BrowsingContextImpl_js_1.BrowsingContextImpl.create(cdpTarget, this.#realmStorage, targetInfo.targetId, null, this.#eventManager, this.#browsingContextStorage, this.#sharedIdWithFrame, this.#logger); | ||
} | ||
@@ -242,3 +244,3 @@ return; | ||
const { uniqueId, id, origin } = params.context; | ||
const realm = new Realm_js_1.Realm(this.#realmStorage, this.#browsingContextStorage, uniqueId, browsingContextId, id, (0, BrowsingContextImpl_js_1.serializeOrigin)(origin), 'dedicated-worker', undefined, cdpTarget.cdpClient, this.#eventManager, this.#logger); | ||
const realm = new Realm_js_1.Realm(this.#realmStorage, this.#browsingContextStorage, uniqueId, browsingContextId, id, (0, BrowsingContextImpl_js_1.serializeOrigin)(origin), 'dedicated-worker', undefined, cdpTarget.cdpClient, this.#eventManager, this.#sharedIdWithFrame, this.#logger); | ||
this.#workers.set(cdpTarget.cdpSessionId, realm); | ||
@@ -245,0 +247,0 @@ }); |
import type { Protocol } from 'devtools-protocol'; | ||
import type { ICdpClient } from '../../../cdp/CdpClient.js'; | ||
import type { CdpClient } from '../../../cdp/CdpClient.js'; | ||
import { Deferred } from '../../../utils/Deferred.js'; | ||
import type { Result } from '../../../utils/result.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { NetworkStorage } from '../network/NetworkStorage.js'; | ||
@@ -10,11 +9,12 @@ import type { ChannelProxy } from '../script/ChannelProxy.js'; | ||
import type { RealmStorage } from '../script/RealmStorage.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
export declare class CdpTarget { | ||
#private; | ||
static create(targetId: Protocol.Target.TargetID, cdpClient: ICdpClient, browserCdpClient: ICdpClient, cdpSessionId: Protocol.Target.SessionID, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean): CdpTarget; | ||
constructor(targetId: Protocol.Target.TargetID, cdpClient: ICdpClient, browserCdpClient: ICdpClient, cdpSessionId: Protocol.Target.SessionID, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean); | ||
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, cdpSessionId: Protocol.Target.SessionID, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean): CdpTarget; | ||
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, cdpSessionId: Protocol.Target.SessionID, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, networkStorage: NetworkStorage, acceptInsecureCerts: boolean); | ||
/** Returns a promise that resolves when the target is unblocked. */ | ||
get targetUnblocked(): Deferred<Result<void>>; | ||
get targetId(): Protocol.Target.TargetID; | ||
get cdpClient(): ICdpClient; | ||
get browserCdpClient(): ICdpClient; | ||
get cdpClient(): CdpClient; | ||
get browserCdpClient(): CdpClient; | ||
/** Needed for CDP escape path. */ | ||
@@ -21,0 +21,0 @@ get cdpSessionId(): Protocol.Target.SessionID; |
@@ -1,3 +0,2 @@ | ||
import { Input } from '../../../protocol/protocol.js'; | ||
import type { EmptyResult } from '../../../protocol/webdriver-bidi'; | ||
import { Input, type EmptyResult } from '../../../protocol/protocol.js'; | ||
import type { BrowsingContextStorage } from '../context/BrowsingContextStorage.js'; | ||
@@ -4,0 +3,0 @@ export declare class InputProcessor { |
@@ -54,9 +54,9 @@ /** | ||
count: number; | ||
"__#87322@#x": number; | ||
"__#87322@#y": number; | ||
"__#87322@#time": number; | ||
"__#87350@#x": number; | ||
"__#87350@#y": number; | ||
"__#87350@#time": number; | ||
compare(context: any): boolean; | ||
}; | ||
"__#87322@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#87322@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
"__#87350@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#87350@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
}; | ||
@@ -63,0 +63,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number; |
import type { CdpTarget } from '../context/CdpTarget.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { RealmStorage } from '../script/RealmStorage.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
export declare class LogManager { | ||
@@ -5,0 +5,0 @@ #private; |
import type { CdpTarget } from '../context/CdpTarget.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { NetworkStorage } from './NetworkStorage.js'; | ||
@@ -4,0 +4,0 @@ /** Maps 1:1 to CdpTarget. */ |
@@ -103,3 +103,3 @@ "use strict"; | ||
.#getOrCreateNetworkRequest(params.networkId) | ||
.onRequestPaused(params, networkManager.#networkStorage); | ||
.onRequestPaused(params); | ||
} | ||
@@ -106,0 +106,0 @@ }); |
@@ -12,3 +12,3 @@ import { Network, type EmptyResult } from '../../../protocol/protocol.js'; | ||
continueWithAuth(params: Network.ContinueWithAuthParameters): Promise<EmptyResult>; | ||
failRequest(params: Network.FailRequestParameters): Promise<EmptyResult>; | ||
failRequest({ request: networkId, }: Network.FailRequestParameters): Promise<EmptyResult>; | ||
provideResponse(params: Network.ProvideResponseParameters): Promise<EmptyResult>; | ||
@@ -15,0 +15,0 @@ removeIntercept(params: Network.RemoveInterceptParameters): Promise<EmptyResult>; |
@@ -51,4 +51,3 @@ "use strict"; | ||
const requestHeaders = (0, NetworkUtils_js_1.cdpFetchHeadersFromBidiNetworkHeaders)(headers); | ||
const request = this.#networkStorage.getRequest(networkId); | ||
(0, assert_js_1.assert)(request, `Network request with ID ${networkId} doesn't exist`); | ||
const request = this.#getRequestOrFail(networkId); | ||
await request.continueRequest(fetchId, url, method, requestHeaders); | ||
@@ -69,4 +68,3 @@ this.#networkStorage.removeBlockedRequest(networkId); | ||
// ; Step 11. credentials | ||
const request = this.#networkStorage.getRequest(networkId); | ||
(0, assert_js_1.assert)(request, `Network request with ID ${networkId} doesn't exist`); | ||
const request = this.#getRequestOrFail(networkId); | ||
await request.continueResponse(fetchId, statusCode, reasonPhrase, responseHeaders); | ||
@@ -82,4 +80,3 @@ this.#networkStorage.removeBlockedRequest(networkId); | ||
} | ||
const request = this.#networkStorage.getRequest(networkId); | ||
(0, assert_js_1.assert)(request, `Network request with ID ${networkId} doesn't exist`); | ||
const request = this.#getRequestOrFail(networkId); | ||
let username; | ||
@@ -89,4 +86,6 @@ let password; | ||
const { credentials } = params; | ||
username = params.credentials.username; | ||
password = params.credentials.password; | ||
username = credentials.username; | ||
password = credentials.password; | ||
// TODO: This should be invalid argument exception. | ||
// Spec may need to be updated. | ||
(0, assert_js_1.assert)(credentials.type === 'password', `Credentials type ${credentials.type} must be 'password'`); | ||
@@ -98,11 +97,8 @@ } | ||
} | ||
async failRequest(params) { | ||
const networkId = params.request; | ||
const blockedRequest = this.#getBlockedRequest(networkId); | ||
const { request: fetchId, phase } = blockedRequest; | ||
async failRequest({ request: networkId, }) { | ||
const { request: fetchId, phase } = this.#getBlockedRequest(networkId); | ||
if (phase === "authRequired" /* Network.InterceptPhase.AuthRequired */) { | ||
throw new protocol_js_1.InvalidArgumentException(`Blocked request for network id '${networkId}' is in 'AuthRequired' phase`); | ||
} | ||
const request = this.#networkStorage.getRequest(networkId); | ||
(0, assert_js_1.assert)(request, `Network request with ID ${networkId} doesn't exist`); | ||
const request = this.#getRequestOrFail(networkId); | ||
await request.failRequest(fetchId, 'Failed'); | ||
@@ -113,5 +109,4 @@ this.#networkStorage.removeBlockedRequest(networkId); | ||
async provideResponse(params) { | ||
const networkId = params.request; | ||
const { statusCode, reasonPhrase, headers, body, request: networkId, } = params; | ||
const { request: fetchId } = this.#getBlockedRequest(networkId); | ||
const { statusCode, reasonPhrase, headers, body } = params; | ||
// TODO: Step 6 | ||
@@ -123,4 +118,3 @@ // https://w3c.github.io/webdriver-bidi/#command-network-continueResponse | ||
// ; Step 11. credentials | ||
const request = this.#networkStorage.getRequest(networkId); | ||
(0, assert_js_1.assert)(request, `Network request with ID ${networkId} doesn't exist`); | ||
const request = this.#getRequestOrFail(networkId); | ||
await request.provideResponse(fetchId, statusCode ?? request.statusCode, reasonPhrase, responseHeaders, body?.value // TODO: Differ base64 / string | ||
@@ -182,2 +176,9 @@ ); | ||
} | ||
#getRequestOrFail(id) { | ||
const request = this.#networkStorage.getRequest(id); | ||
if (!request) { | ||
throw new protocol_js_1.NoSuchRequestException(`Network request with ID ${id} doesn't exist`); | ||
} | ||
return request; | ||
} | ||
/** | ||
@@ -184,0 +185,0 @@ * Attempts to parse the given url. |
@@ -8,3 +8,3 @@ /** | ||
import type { CdpTarget } from '../context/CdpTarget.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { NetworkStorage } from './NetworkStorage.js'; | ||
@@ -28,3 +28,3 @@ /** Abstracts one individual network request. */ | ||
/** Fired whenever a network request interception is hit. */ | ||
onRequestPaused(params: Protocol.Fetch.RequestPausedEvent, networkStorage: NetworkStorage): void; | ||
onRequestPaused(params: Protocol.Fetch.RequestPausedEvent): void; | ||
/** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-failRequest */ | ||
@@ -31,0 +31,0 @@ failRequest(networkId: Network.Request, errorReason: Protocol.Network.ErrorReason): Promise<void>; |
@@ -162,3 +162,3 @@ "use strict"; | ||
/** Fired whenever a network request interception is hit. */ | ||
onRequestPaused(params, networkStorage) { | ||
onRequestPaused(params) { | ||
if (this.#isIgnoredEvent()) { | ||
@@ -190,4 +190,3 @@ void this.continueRequest(params.requestId).catch(() => { | ||
params.responseHeaders); | ||
(0, assert_js_1.assert)(this.requestId === params.networkId); | ||
networkStorage.addBlockedRequest(this.requestId, { | ||
this.#networkStorage.addBlockedRequest(this.requestId, { | ||
request: params.requestId, // intercept request id | ||
@@ -194,0 +193,0 @@ phase, |
@@ -20,2 +20,7 @@ /** | ||
import type { NetworkRequest } from './NetworkRequest.js'; | ||
export interface BlockedRequest { | ||
request: Protocol.Fetch.RequestId; | ||
phase: Network.InterceptPhase; | ||
response: Network.ResponseData; | ||
} | ||
/** Stores network and intercept maps. */ | ||
@@ -68,7 +73,3 @@ export declare class NetworkStorage { | ||
static isSpecialScheme(protocol: string): boolean; | ||
addBlockedRequest(requestId: Network.Request, value: { | ||
request: Protocol.Fetch.RequestId; | ||
phase: Network.InterceptPhase; | ||
response: Network.ResponseData; | ||
}): void; | ||
addBlockedRequest(requestId: Network.Request, value: BlockedRequest): void; | ||
removeBlockedRequest(requestId: Network.Request): void; | ||
@@ -78,7 +79,3 @@ /** | ||
*/ | ||
getBlockedRequest(networkId: Network.Request): { | ||
request: Protocol.Fetch.RequestId; | ||
phase: Network.InterceptPhase; | ||
response: Network.ResponseData; | ||
} | undefined; | ||
getBlockedRequest(networkId: Network.Request): BlockedRequest | undefined; | ||
/** #@see https://w3c.github.io/webdriver-bidi/#get-the-network-intercepts */ | ||
@@ -85,0 +82,0 @@ getNetworkIntercepts(requestId: Network.Request, phase?: Network.InterceptPhase): Network.Intercept[]; |
@@ -123,3 +123,3 @@ "use strict"; | ||
if (protocol) { | ||
url += `${protocol}`; | ||
url += protocol; | ||
if (!protocol.endsWith(':')) { | ||
@@ -148,3 +148,3 @@ url += ':'; | ||
} | ||
url += `${search}`; | ||
url += search; | ||
} | ||
@@ -151,0 +151,0 @@ return url; |
import { Script } from '../../../protocol/protocol.js'; | ||
import { type LoggerFn } from '../../../utils/log.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { Realm } from './Realm.js'; | ||
@@ -5,0 +5,0 @@ /** |
@@ -18,7 +18,7 @@ /** | ||
import { Protocol } from 'devtools-protocol'; | ||
import type { ICdpClient } from '../../../cdp/CdpClient.js'; | ||
import type { CdpClient } from '../../../cdp/CdpClient.js'; | ||
import { type BrowsingContext, Script } from '../../../protocol/protocol.js'; | ||
import { type LoggerFn } from '../../../utils/log.js'; | ||
import type { BrowsingContextStorage } from '../context/BrowsingContextStorage.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { EventManager } from '../session/EventManager.js'; | ||
import type { RealmStorage } from './RealmStorage.js'; | ||
@@ -28,3 +28,3 @@ export declare class Realm { | ||
readonly sandbox?: string; | ||
constructor(realmStorage: RealmStorage, browsingContextStorage: BrowsingContextStorage, realmId: Script.Realm, browsingContextId: BrowsingContext.BrowsingContext, executionContextId: Protocol.Runtime.ExecutionContextId, origin: string, type: Script.RealmType, sandbox: string | undefined, cdpClient: ICdpClient, eventManager: EventManager, logger?: LoggerFn); | ||
constructor(realmStorage: RealmStorage, browsingContextStorage: BrowsingContextStorage, realmId: Script.Realm, browsingContextId: BrowsingContext.BrowsingContext, executionContextId: Protocol.Runtime.ExecutionContextId, origin: string, type: Script.RealmType, sandbox: string | undefined, cdpClient: CdpClient, eventManager: EventManager, sharedIdWithFrame: boolean, logger?: LoggerFn); | ||
cdpToBidiValue(cdpValue: Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.EvaluateResponse, resultOwnership: Script.ResultOwnership): Script.RemoteValue; | ||
@@ -37,3 +37,3 @@ get realmId(): Script.Realm; | ||
get type(): Script.RealmType; | ||
get cdpClient(): ICdpClient; | ||
get cdpClient(): CdpClient; | ||
get realmInfo(): Script.RealmInfo; | ||
@@ -40,0 +40,0 @@ evaluate(expression: string, awaitPromise: boolean, resultOwnership: Script.ResultOwnership, serializationOptions: Script.SerializationOptions, userActivation?: boolean): Promise<Script.EvaluateResult>; |
@@ -8,3 +8,3 @@ "use strict"; | ||
const ChannelProxy_js_1 = require("./ChannelProxy.js"); | ||
const SHARED_ID_DIVIDER = '_element_'; | ||
const SharedIdParser_js_1 = require("./SharedIdParser.js"); | ||
class Realm { | ||
@@ -17,2 +17,3 @@ #realmStorage; | ||
#origin; | ||
#sharedIdWithFrame; | ||
#type; | ||
@@ -23,3 +24,4 @@ #cdpClient; | ||
#logger; | ||
constructor(realmStorage, browsingContextStorage, realmId, browsingContextId, executionContextId, origin, type, sandbox, cdpClient, eventManager, logger) { | ||
constructor(realmStorage, browsingContextStorage, realmId, browsingContextId, executionContextId, origin, type, sandbox, cdpClient, eventManager, sharedIdWithFrame, logger) { | ||
this.#sharedIdWithFrame = sharedIdWithFrame; | ||
this.#realmId = realmId; | ||
@@ -103,4 +105,12 @@ this.#browsingContextId = browsingContextId; | ||
if (Object.hasOwn(bidiValue, 'backendNodeId')) { | ||
let navigableId = this.navigableId; | ||
if (Object.hasOwn(bidiValue, 'loaderId')) { | ||
// `loaderId` should be always there after ~2024-03-05, when | ||
// https://crrev.com/c/5116240 reaches stable. | ||
// TODO: remove the check after the date. | ||
navigableId = bidiValue.loaderId; | ||
delete bidiValue['loaderId']; | ||
} | ||
deepSerializedValue.sharedId = | ||
`${this.navigableId}${SHARED_ID_DIVIDER}${bidiValue.backendNodeId}`; | ||
SharedIdParser_js_1.SharedIdParser.getSharedId(this.#getBrowsingContextId(navigableId), navigableId, bidiValue.backendNodeId, this.#sharedIdWithFrame); | ||
delete bidiValue['backendNodeId']; | ||
@@ -138,2 +148,8 @@ } | ||
} | ||
#getBrowsingContextId(navigableId) { | ||
const maybeBrowsingContext = this.#browsingContextStorage | ||
.getAllContexts() | ||
.find((context) => context.navigableId === navigableId); | ||
return maybeBrowsingContext?.id ?? 'UNKNOWN'; | ||
} | ||
get realmId() { | ||
@@ -175,2 +191,5 @@ return this.#realmId; | ||
return { | ||
// TODO: add proper owners. | ||
// https://github.com/GoogleChromeLabs/chromium-bidi/issues/1667 | ||
owners: [], | ||
realm: this.realmId, | ||
@@ -336,10 +355,9 @@ origin: this.origin, | ||
if ('sharedId' in localValue && localValue.sharedId) { | ||
const [navigableId, rawBackendNodeId] = localValue.sharedId.split(SHARED_ID_DIVIDER); | ||
const backendNodeId = parseInt(rawBackendNodeId ?? ''); | ||
if (isNaN(backendNodeId) || | ||
backendNodeId === undefined || | ||
navigableId === undefined) { | ||
const parsedSharedId = SharedIdParser_js_1.SharedIdParser.parseSharedId(localValue.sharedId); | ||
if (parsedSharedId === null) { | ||
throw new protocol_js_1.NoSuchNodeException(`SharedId "${localValue.sharedId}" was not found.`); | ||
} | ||
if (this.navigableId !== navigableId) { | ||
const { documentId, backendNodeId } = parsedSharedId; | ||
// TODO: add proper validation if the element is accessible from the current realm. | ||
if (this.navigableId !== documentId) { | ||
throw new protocol_js_1.NoSuchNodeException(`SharedId "${localValue.sharedId}" belongs to different document. Current document is ${this.navigableId}.`); | ||
@@ -346,0 +364,0 @@ } |
@@ -18,3 +18,3 @@ /** | ||
import type { EmptyResult, Session } from '../../../protocol/protocol.js'; | ||
import type { EventManager } from '../events/EventManager.js'; | ||
import type { EventManager } from './EventManager.js'; | ||
export declare class SessionProcessor { | ||
@@ -21,0 +21,0 @@ #private; |
import { type ChromeReleaseChannel, type Process } from '@puppeteer/browsers'; | ||
import type { MapperOptions } from '../bidiMapper/BidiServer.js'; | ||
import { MapperCdpConnection } from './MapperCdpConnection.js'; | ||
import { MapperServerCdpConnection } from './MapperCdpConnection.js'; | ||
import type { SimpleTransport } from './SimpleTransport.js'; | ||
@@ -23,3 +23,3 @@ type ChromeOptions = { | ||
static run(chromeOptions: ChromeOptions, mapperOptions: MapperOptions, verbose: boolean): Promise<BrowserInstance>; | ||
constructor(mapperCdpConnection: MapperCdpConnection, browserProcess: Process); | ||
constructor(mapperCdpConnection: MapperServerCdpConnection, browserProcess: Process); | ||
close(): Promise<void>; | ||
@@ -26,0 +26,0 @@ bidiSession(): SimpleTransport; |
@@ -86,2 +86,3 @@ "use strict"; | ||
args: chromeArguments, | ||
env: process.env, | ||
}); | ||
@@ -95,3 +96,3 @@ const cdpEndpoint = await browserProcess.waitForLineOutput(browsers_1.CDP_WEBSOCKET_ENDPOINT_REGEX); | ||
// 3. Run `BiDi-CDP` mapper in launched browser using `MapperRunner`. | ||
const mapperCdpConnection = await MapperCdpConnection_js_1.MapperCdpConnection.create(cdpConnection, mapperTabSource, verbose, mapperOptions); | ||
const mapperCdpConnection = await MapperCdpConnection_js_1.MapperServerCdpConnection.create(cdpConnection, mapperTabSource, verbose, mapperOptions); | ||
return new BrowserInstance(mapperCdpConnection, browserProcess); | ||
@@ -120,3 +121,3 @@ } | ||
const transport = new WebsocketTransport_js_1.WebSocketTransport(ws); | ||
const connection = new CdpConnection_js_1.CdpConnection(transport); | ||
const connection = new CdpConnection_js_1.MapperCdpConnection(transport); | ||
resolve(connection); | ||
@@ -123,0 +124,0 @@ }); |
@@ -18,7 +18,7 @@ /** | ||
import type { MapperOptions } from '../bidiMapper/BidiServer.js'; | ||
import type { CdpConnection } from '../cdp/CdpConnection.js'; | ||
import type { MapperCdpConnection } from '../cdp/CdpConnection.js'; | ||
import { SimpleTransport } from './SimpleTransport.js'; | ||
export declare class MapperCdpConnection { | ||
export declare class MapperServerCdpConnection { | ||
#private; | ||
static create(cdpConnection: CdpConnection, mapperTabSource: string, verbose: boolean, mapperOptions: MapperOptions): Promise<MapperCdpConnection>; | ||
static create(cdpConnection: MapperCdpConnection, mapperTabSource: string, verbose: boolean, mapperOptions: MapperOptions): Promise<MapperServerCdpConnection>; | ||
private constructor(); | ||
@@ -25,0 +25,0 @@ close(): void; |
@@ -22,3 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MapperCdpConnection = void 0; | ||
exports.MapperServerCdpConnection = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
@@ -40,3 +40,3 @@ const SimpleTransport_js_1 = require("./SimpleTransport.js"); | ||
}; | ||
class MapperCdpConnection { | ||
class MapperServerCdpConnection { | ||
#cdpConnection; | ||
@@ -48,3 +48,3 @@ #mapperCdpClient; | ||
const mapperCdpClient = await this.#initMapper(cdpConnection, mapperTabSource, verbose, mapperOptions); | ||
return new MapperCdpConnection(cdpConnection, mapperCdpClient); | ||
return new MapperServerCdpConnection(cdpConnection, mapperCdpClient); | ||
} | ||
@@ -142,3 +142,3 @@ catch (e) { | ||
} | ||
exports.MapperCdpConnection = MapperCdpConnection; | ||
exports.MapperServerCdpConnection = MapperServerCdpConnection; | ||
//# sourceMappingURL=MapperCdpConnection.js.map |
@@ -264,3 +264,4 @@ "use strict"; | ||
const acceptInsecureCerts = capabilities?.alwaysMatch?.acceptInsecureCerts ?? false; | ||
return { acceptInsecureCerts }; | ||
const sharedIdWithFrame = capabilities?.alwaysMatch?.sharedIdWithFrame ?? false; | ||
return { acceptInsecureCerts, sharedIdWithFrame }; | ||
} | ||
@@ -267,0 +268,0 @@ static #getChromeOptions(capabilities, channel, headless) { |
@@ -17,5 +17,5 @@ /** | ||
*/ | ||
import type { IBidiParser } from '../bidiMapper/BidiMapper.js'; | ||
import type { BidiCommandParameterParser } from '../bidiMapper/BidiMapper.js'; | ||
import type { BrowsingContext, Cdp, Input, Network, Script, Session } from '../protocol/protocol.js'; | ||
export declare class BidiParser implements IBidiParser { | ||
export declare class BidiParser implements BidiCommandParameterParser { | ||
parseActivateParams(params: unknown): BrowsingContext.ActivateParameters; | ||
@@ -22,0 +22,0 @@ parseCaptureScreenshotParams(params: unknown): BrowsingContext.CaptureScreenshotParameters; |
@@ -29,9 +29,4 @@ /** | ||
sendDebugMessage?: ((message: string) => void) | null; | ||
/** | ||
* @deprecated Use `runMapperInstance` instead. Used for backward compatibility | ||
* with ChromeDriver. | ||
*/ | ||
setSelfTargetId: (targetId: string) => void; | ||
} | ||
} | ||
export {}; |
@@ -34,3 +34,3 @@ "use strict"; | ||
*/ | ||
const cdpConnection = new CdpConnection_js_1.CdpConnection(cdpTransport, mapperTabPage_js_1.log); | ||
const cdpConnection = new CdpConnection_js_1.MapperCdpConnection(cdpTransport, mapperTabPage_js_1.log); | ||
/** | ||
@@ -59,13 +59,2 @@ * Launches the BiDi mapper instance. | ||
}; | ||
/** | ||
* @deprecated Use `runMapperInstance` instead. Used for backward compatibility | ||
* with ChromeDriver. | ||
*/ | ||
// TODO: Remove this after https://crrev.com/c/4952609 reaches stable. | ||
window.setSelfTargetId = async (selfTargetId) => { | ||
const bidiServer = await runMapperInstance(selfTargetId); | ||
bidiServer.emitOutgoingMessage(BidiMapper_js_1.OutgoingMessage.createResolved({ | ||
launched: true, | ||
}), 'launched'); | ||
}; | ||
//# sourceMappingURL=bidiTab.js.map |
@@ -19,3 +19,3 @@ /** | ||
import { type ChromiumBidi } from '../protocol/protocol.js'; | ||
import type { ITransport } from '../utils/transport.js'; | ||
import type { Transport } from '../utils/transport.js'; | ||
export declare class WindowBidiTransport implements BidiTransport { | ||
@@ -30,8 +30,8 @@ #private; | ||
} | ||
export declare class WindowCdpTransport implements ITransport { | ||
export declare class WindowCdpTransport implements Transport { | ||
#private; | ||
constructor(); | ||
setOnMessage(onMessage: Parameters<ITransport['setOnMessage']>[0]): void; | ||
setOnMessage(onMessage: Parameters<Transport['setOnMessage']>[0]): void; | ||
sendMessage(message: string): void; | ||
close(): void; | ||
} |
@@ -20,3 +20,3 @@ /** | ||
import { EventEmitter } from '../utils/EventEmitter.js'; | ||
import type { CdpConnection } from './CdpConnection.js'; | ||
import type { MapperCdpConnection } from './CdpConnection.js'; | ||
export type CdpEvents = { | ||
@@ -28,3 +28,3 @@ [Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0]; | ||
} | ||
export interface ICdpClient extends EventEmitter<CdpEvents> { | ||
export interface CdpClient extends EventEmitter<CdpEvents> { | ||
/** Unique session identifier. */ | ||
@@ -50,5 +50,5 @@ sessionId: Protocol.Target.SessionID | undefined; | ||
/** Represents a high-level CDP connection to the browser. */ | ||
export declare class CdpClient extends EventEmitter<CdpEvents> implements ICdpClient { | ||
export declare class MapperCdpClient extends EventEmitter<CdpEvents> implements CdpClient { | ||
#private; | ||
constructor(cdpConnection: CdpConnection, sessionId?: Protocol.Target.SessionID); | ||
constructor(cdpConnection: MapperCdpConnection, sessionId?: Protocol.Target.SessionID); | ||
get sessionId(): Protocol.Target.SessionID | undefined; | ||
@@ -55,0 +55,0 @@ sendCommand<CdpMethod extends keyof ProtocolMapping.Commands>(method: CdpMethod, ...params: ProtocolMapping.Commands[CdpMethod]['paramsType']): Promise<ProtocolMapping.Commands[CdpMethod]['returnType']>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CdpClient = exports.CloseError = void 0; | ||
exports.MapperCdpClient = exports.CloseError = void 0; | ||
const EventEmitter_js_1 = require("../utils/EventEmitter.js"); | ||
@@ -27,3 +27,3 @@ /** A error that will be thrown if/when the connection is closed. */ | ||
/** Represents a high-level CDP connection to the browser. */ | ||
class CdpClient extends EventEmitter_js_1.EventEmitter { | ||
class MapperCdpClient extends EventEmitter_js_1.EventEmitter { | ||
#cdpConnection; | ||
@@ -46,3 +46,3 @@ #sessionId; | ||
} | ||
exports.CdpClient = CdpClient; | ||
exports.MapperCdpClient = MapperCdpClient; | ||
//# sourceMappingURL=CdpClient.js.map |
@@ -20,6 +20,6 @@ /** | ||
import type { LoggerFn } from '../utils/log.js'; | ||
import type { ITransport } from '../utils/transport.js'; | ||
import { CdpClient, type ICdpClient } from './CdpClient.js'; | ||
export interface ICdpConnection { | ||
getCdpClient(sessionId: Protocol.Target.SessionID): ICdpClient; | ||
import type { Transport } from '../utils/transport.js'; | ||
import { MapperCdpClient, type CdpClient } from './CdpClient.js'; | ||
export interface CdpConnection { | ||
getCdpClient(sessionId: Protocol.Target.SessionID): CdpClient; | ||
} | ||
@@ -32,10 +32,10 @@ /** | ||
*/ | ||
export declare class CdpConnection implements ICdpConnection { | ||
export declare class MapperCdpConnection implements CdpConnection { | ||
#private; | ||
static readonly LOGGER_PREFIX_RECV: "cdp:RECV ◂"; | ||
static readonly LOGGER_PREFIX_SEND: "cdp:SEND ▸"; | ||
constructor(transport: ITransport, logger?: LoggerFn); | ||
constructor(transport: Transport, logger?: LoggerFn); | ||
/** Closes the connection to the browser. */ | ||
close(): void; | ||
createBrowserSession(): Promise<ICdpClient>; | ||
createBrowserSession(): Promise<MapperCdpClient>; | ||
/** | ||
@@ -45,4 +45,4 @@ * Gets a CdpClient instance attached to the given session ID, | ||
*/ | ||
getCdpClient(sessionId: Protocol.Target.SessionID): CdpClient; | ||
getCdpClient(sessionId: Protocol.Target.SessionID): MapperCdpClient; | ||
sendCommand<CdpMethod extends keyof ProtocolMapping.Commands>(method: CdpMethod, params?: ProtocolMapping.Commands[CdpMethod]['paramsType'][0], sessionId?: Protocol.Target.SessionID): Promise<object>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CdpConnection = void 0; | ||
exports.MapperCdpConnection = void 0; | ||
const log_js_1 = require("../utils/log.js"); | ||
@@ -12,3 +12,3 @@ const CdpClient_js_1 = require("./CdpClient.js"); | ||
*/ | ||
class CdpConnection { | ||
class MapperCdpConnection { | ||
static LOGGER_PREFIX_RECV = `${log_js_1.LogType.cdp}:RECV ◂`; | ||
@@ -73,3 +73,3 @@ static LOGGER_PREFIX_SEND = `${log_js_1.LogType.cdp}:SEND ▸`; | ||
}); | ||
this.#logger?.(CdpConnection.LOGGER_PREFIX_SEND, cdpMessage); | ||
this.#logger?.(MapperCdpConnection.LOGGER_PREFIX_SEND, cdpMessage); | ||
}); | ||
@@ -79,3 +79,3 @@ } | ||
const message = JSON.parse(json); | ||
this.#logger?.(CdpConnection.LOGGER_PREFIX_RECV, message); | ||
this.#logger?.(MapperCdpConnection.LOGGER_PREFIX_RECV, message); | ||
// Update client map if a session is attached | ||
@@ -122,3 +122,3 @@ // Listen for these events on every session. | ||
#createCdpClient(sessionId) { | ||
const cdpClient = new CdpClient_js_1.CdpClient(this, sessionId); | ||
const cdpClient = new CdpClient_js_1.MapperCdpClient(this, sessionId); | ||
this.#sessionCdpClients.set(sessionId, cdpClient); | ||
@@ -128,3 +128,3 @@ return cdpClient; | ||
} | ||
exports.CdpConnection = CdpConnection; | ||
exports.MapperCdpConnection = MapperCdpConnection; | ||
//# sourceMappingURL=CdpConnection.js.map |
@@ -49,3 +49,3 @@ "use strict"; | ||
const protocol_js_1 = require("../protocol/protocol.js"); | ||
const WebDriverBidi = __importStar(require("./webdriver-bidi.js")); | ||
const WebDriverBidi = __importStar(require("./generated/webdriver-bidi.js")); | ||
function parseObject(obj, schema) { | ||
@@ -52,0 +52,0 @@ const parseResult = schema.safeParse(obj); |
@@ -19,3 +19,3 @@ /** | ||
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js'; | ||
import type { BrowsingContext, JsUint } from './webdriver-bidi.js'; | ||
import type { BrowsingContext, JsUint } from './generated/webdriver-bidi.js'; | ||
export type EventNames = Event['method']; | ||
@@ -22,0 +22,0 @@ export type Message = CommandResponse | Event; |
@@ -18,3 +18,3 @@ /** | ||
import type * as Cdp from './cdp.js'; | ||
import type * as WebDriverBidi from './webdriver-bidi.js'; | ||
import type * as WebDriverBidi from './generated/webdriver-bidi.js'; | ||
export type EventNames = BiDiModule | BrowsingContext.EventNames | Cdp.EventNames | Log.EventNames | Network.EventNames | Script.EventNames; | ||
@@ -21,0 +21,0 @@ export declare enum BiDiModule { |
@@ -17,4 +17,4 @@ /** | ||
*/ | ||
import type { ErrorResponse } from './webdriver-bidi.js'; | ||
import { ErrorCode } from './webdriver-bidi.js'; | ||
import type { ErrorResponse } from './generated/webdriver-bidi.js'; | ||
import { ErrorCode } from './generated/webdriver-bidi.js'; | ||
export declare class Exception { | ||
@@ -21,0 +21,0 @@ error: ErrorCode; |
@@ -19,3 +19,3 @@ /** | ||
export * as ChromiumBidi from './chromium-bidi.js'; | ||
export * from './webdriver-bidi.js'; | ||
export * from './generated/webdriver-bidi.js'; | ||
export * from './ErrorResponse.js'; |
@@ -48,4 +48,4 @@ "use strict"; | ||
exports.ChromiumBidi = __importStar(require("./chromium-bidi.js")); | ||
__exportStar(require("./webdriver-bidi.js"), exports); | ||
__exportStar(require("./generated/webdriver-bidi.js"), exports); | ||
__exportStar(require("./ErrorResponse.js"), exports); | ||
//# sourceMappingURL=protocol.js.map |
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
export interface ITransport { | ||
export interface Transport { | ||
setOnMessage: (handler: (message: string) => Promise<void> | void) => void; | ||
@@ -24,0 +24,0 @@ sendMessage: (message: string) => Promise<void> | void; |
@@ -18,4 +18,4 @@ /** | ||
import type WebSocket from 'ws'; | ||
import type { ITransport } from './transport.js'; | ||
export declare class WebSocketTransport implements ITransport { | ||
import type { Transport } from './transport.js'; | ||
export declare class WebSocketTransport implements Transport { | ||
#private; | ||
@@ -22,0 +22,0 @@ constructor(websocket: WebSocket); |
{ | ||
"name": "chromium-bidi", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.", | ||
@@ -12,3 +12,3 @@ "scripts": { | ||
"e2e": "npm run e2e-headless --", | ||
"eslint": "wireit", | ||
"eslint": "eslint --ext js --ext mjs --ext ts --fix .", | ||
"flake8": "flake8 examples/ tests/", | ||
@@ -37,5 +37,6 @@ "format": "npm run pre-commit --", | ||
"bidi-types": { | ||
"command": "tools/generate-bidi-types.sh", | ||
"command": "tools/generate-bidi-types.mjs", | ||
"output": [ | ||
"src/protocol/webdriver-bidi.ts" | ||
"src/protocol/generated/webdriver-bidi.ts", | ||
"src/protocol-parser/generated/webdriver-bidi.ts" | ||
] | ||
@@ -69,16 +70,2 @@ }, | ||
}, | ||
"eslint": { | ||
"command": "eslint --cache --ext .js,.ts --fix .", | ||
"files": [ | ||
".eslintignore", | ||
".eslintrc.js", | ||
"src/**/*.ts" | ||
], | ||
"output": [ | ||
".eslintcache" | ||
], | ||
"dependencies": [ | ||
"tsc" | ||
] | ||
}, | ||
"prepare": { | ||
@@ -164,6 +151,6 @@ "dependencies": [ | ||
"wpt-all": { | ||
"command": "tools/runWPTAll.sh", | ||
"command": "tools/run-wpt-all.mjs", | ||
"files": [ | ||
"tools/run-wpt.mjs", | ||
"tools/runWPTAll.sh", | ||
"tools/run-wpt-all.mjs", | ||
"wpt/tools/webdriver/**/*.py", | ||
@@ -195,3 +182,3 @@ "wpt/webdriver/tests/**/*.py", | ||
"@actions/core": "1.10.1", | ||
"@puppeteer/browsers": "1.8.0", | ||
"@puppeteer/browsers": "1.9.0", | ||
"@rollup/plugin-commonjs": "25.0.7", | ||
@@ -205,20 +192,19 @@ "@rollup/plugin-node-resolve": "15.2.3", | ||
"@types/mocha": "10.0.6", | ||
"@types/node": "20.10.3", | ||
"@types/node": "20.10.6", | ||
"@types/sinon": "17.0.2", | ||
"@types/websocket": "1.0.10", | ||
"@types/ws": "8.5.10", | ||
"@typescript-eslint/eslint-plugin": "6.13.2", | ||
"@typescript-eslint/parser": "6.13.2", | ||
"@typescript-eslint/eslint-plugin": "6.17.0", | ||
"@typescript-eslint/parser": "6.17.0", | ||
"argparse": "2.0.1", | ||
"chai": "4.3.10", | ||
"chai-as-promised": "7.1.1", | ||
"chai-exclude": "2.1.0", | ||
"debug": "4.3.4", | ||
"devtools-protocol": "0.0.1236148", | ||
"eslint": "8.55.0", | ||
"devtools-protocol": "0.0.1239539", | ||
"eslint": "8.56.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-import-resolver-typescript": "3.6.1", | ||
"eslint-plugin-import": "2.29.0", | ||
"eslint-plugin-import": "2.29.1", | ||
"eslint-plugin-mocha": "10.2.0", | ||
"eslint-plugin-prettier": "5.0.1", | ||
"eslint-plugin-prettier": "5.1.2", | ||
"eslint-plugin-promise": "6.1.1", | ||
@@ -228,16 +214,16 @@ "gts": "5.2.0", | ||
"nyc": "15.1.0", | ||
"pkg-dir": "7.0.0", | ||
"prettier": "3.1.0", | ||
"pkg-dir": "8.0.0", | ||
"prettier": "3.1.1", | ||
"rimraf": "5.0.5", | ||
"rollup": "3.29.4", | ||
"selenium-webdriver": "4.15.0", | ||
"selenium-webdriver": "4.16.0", | ||
"sinon": "17.0.1", | ||
"source-map-support": "0.5.21", | ||
"terser": "5.25.0", | ||
"terser": "5.26.0", | ||
"tslib": "2.6.2", | ||
"typescript": "5.3.2", | ||
"webdriverio": "8.26.1", | ||
"typescript": "5.3.3", | ||
"webdriverio": "8.27.0", | ||
"websocket": "1.0.34", | ||
"wireit": "0.14.1", | ||
"ws": "8.14.2", | ||
"ws": "8.16.0", | ||
"yargs": "17.7.2", | ||
@@ -244,0 +230,0 @@ "zod": "3.22.4" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4292756
47
231
81565
6
2