Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-debugging-client

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-debugging-client - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

LICENSE

24

dist/index.d.ts
import { AttachMessageTransport } from "@tracerbench/message-transport";
import { ProtocolConnection } from "@tracerbench/protocol-connection";
import { RootConnection } from "@tracerbench/protocol-connection";
import { Process, Stdio } from "@tracerbench/spawn";
import { Chrome, SpawnOptions } from "@tracerbench/spawn-chrome";
import { RaceCancellation } from "race-cancellation";
export declare function spawnChrome(options?: SpawnOptions): ChromeWithPipeConnection;
export * from "@tracerbench/message-transport";
export * from "@tracerbench/protocol-connection/types";
export * from "@tracerbench/spawn/types";
export * from "@tracerbench/spawn-chrome/types";
export declare function spawnChrome(options?: Partial<SpawnOptions>): ChromeWithPipeConnection;
export declare function spawnWithPipe(executable: string, args: string[], stdio?: Stdio): ProcessWithPipeConnection;
export declare function spawnWithWebSocket(executable: string, args: string[], stdio?: Stdio, raceCancellation?: RaceCancellation): Promise<ProcessWithWebSocketConnection>;
export declare function newProtocolConnection(attach: AttachMessageTransport): ProtocolConnection;
export declare function newProtocolConnection(attach: AttachMessageTransport): RootConnection;
export { default as openWebSocket, } from "@tracerbench/websocket-message-transport";

@@ -16,3 +20,7 @@ export { default as findChrome } from "@tracerbench/find-chrome";

*/
connection: ProtocolConnection;
connection: RootConnection;
/**
* Close browser.
*/
close(timeout?: number, raceCancellation?: RaceCancellation): Promise<void>;
}

@@ -23,3 +31,7 @@ export interface ProcessWithPipeConnection extends Process {

*/
connection: ProtocolConnection;
connection: RootConnection;
/**
* Close browser.
*/
close(timeout?: number, raceCancellation?: RaceCancellation): Promise<void>;
}

@@ -30,3 +42,3 @@ export interface ProcessWithWebSocketConnection extends Process {

*/
connection: ProtocolConnection;
connection: RootConnection;
/**

@@ -33,0 +45,0 @@ * Closes the web socket.

@@ -37,4 +37,22 @@ "use strict";

const connection = newProtocolConnection(process.attach);
return Object.assign(process, { connection });
return Object.assign(process, { close, connection });
async function close(timeout, raceCancellation) {
if (process.hasExited) {
return;
}
try {
const waitForExit = process.waitForExit(timeout, raceCancellation);
await Promise.race([waitForExit, connection.send("Browser.close")]);
// double check in case send() won the race which is most of the time
// sometimes chrome exits before send() gets a response
await waitForExit;
}
catch (e) {
// if we closed then we dont really care what the error is
if (!process.hasExited) {
throw e;
}
}
}
}
//# sourceMappingURL=index.js.map
{
"name": "chrome-debugging-client",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "An async/await friendly Chrome debugging client with TypeScript support",

@@ -20,7 +20,7 @@ "license": "BSD-2-Clause",

"@tracerbench/find-chrome": "1.0.0-beta.1",
"@tracerbench/message-transport": "1.0.0-beta.1",
"@tracerbench/protocol-connection": "1.0.0-beta.1",
"@tracerbench/spawn": "1.0.0-beta.1",
"@tracerbench/spawn-chrome": "1.0.0-beta.1",
"@tracerbench/websocket-message-transport": "1.0.0-beta.1",
"@tracerbench/message-transport": "^1.0.0-beta.2",
"@tracerbench/protocol-connection": "^1.0.0-beta.2",
"@tracerbench/spawn": "^1.0.0-beta.2",
"@tracerbench/spawn-chrome": "^1.0.0-beta.2",
"@tracerbench/websocket-message-transport": "^1.0.0-beta.2",
"debug": "^4.1.1"

@@ -40,3 +40,4 @@ },

"devtools-protocol": "*"
}
},
"gitHead": "3ea82b331ae8908e4a0e6f0d458f9768488eac82"
}

@@ -53,9 +53,3 @@ # chrome-debugging-client

const page = browser.connection(
await browser.send("Target.attachToTarget", {
targetId,
// this library only supports flattened sessions
flatten: true,
}),
);
const page = await browser.attachToTarget(targetId);

@@ -76,5 +70,4 @@ let buffer = "";

await browser.send("Browser.close");
await chrome.waitForExit();
// graceful browser shutdown
await chrome.close();
} finally {

@@ -81,0 +74,0 @@ await chrome.dispose();

import { AttachMessageTransport } from "@tracerbench/message-transport";
import _newProtocolConnection, {
ProtocolConnection,
RootConnection,
} from "@tracerbench/protocol-connection";

@@ -18,3 +18,10 @@ import _spawn, {

export function spawnChrome(options?: SpawnOptions): ChromeWithPipeConnection {
export * from "@tracerbench/message-transport";
export * from "@tracerbench/protocol-connection/types";
export * from "@tracerbench/spawn/types";
export * from "@tracerbench/spawn-chrome/types";
export function spawnChrome(
options?: Partial<SpawnOptions>,
): ChromeWithPipeConnection {
return attachPipeTransport(_spawnChrome(options));

@@ -47,5 +54,3 @@ }

export function newProtocolConnection(
attach: AttachMessageTransport,
): ProtocolConnection {
export function newProtocolConnection(attach: AttachMessageTransport) {
return _newProtocolConnection(

@@ -66,5 +71,26 @@ attach,

process: P,
): P & { connection: ProtocolConnection } {
): P & {
connection: RootConnection;
close(timeout?: number, raceCancellation?: RaceCancellation): Promise<void>;
} {
const connection = newProtocolConnection(process.attach);
return Object.assign(process, { connection });
return Object.assign(process, { close, connection });
async function close(timeout?: number, raceCancellation?: RaceCancellation) {
if (process.hasExited) {
return;
}
try {
const waitForExit = process.waitForExit(timeout, raceCancellation);
await Promise.race([waitForExit, connection.send("Browser.close")]);
// double check in case send() won the race which is most of the time
// sometimes chrome exits before send() gets a response
await waitForExit;
} catch (e) {
// if we closed then we dont really care what the error is
if (!process.hasExited) {
throw e;
}
}
}
}

@@ -76,3 +102,8 @@

*/
connection: ProtocolConnection;
connection: RootConnection;
/**
* Close browser.
*/
close(timeout?: number, raceCancellation?: RaceCancellation): Promise<void>;
}

@@ -84,3 +115,8 @@

*/
connection: ProtocolConnection;
connection: RootConnection;
/**
* Close browser.
*/
close(timeout?: number, raceCancellation?: RaceCancellation): Promise<void>;
}

@@ -92,3 +128,3 @@

*/
connection: ProtocolConnection;
connection: RootConnection;

@@ -95,0 +131,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc