chrome-debugging-client
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
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
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
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
18944
8
214
0
147
+ Added@tracerbench/find-chrome@1.3.1(transitive)
+ Added@tracerbench/message-transport@1.3.1(transitive)
+ Added@tracerbench/protocol-connection@1.3.1(transitive)
+ Added@tracerbench/protocol-transport@1.3.1(transitive)
+ Added@tracerbench/spawn@1.3.1(transitive)
+ Added@tracerbench/spawn-chrome@1.3.1(transitive)
+ Added@tracerbench/websocket-message-transport@1.3.1(transitive)
+ Addedchrome-launcher@0.13.4(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexeca@4.1.0(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedhuman-signals@1.1.1(transitive)
+ Addedis-docker@2.2.1(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedis-wsl@2.2.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedwhich@2.0.2(transitive)
- Removed@tracerbench/message-transport@1.0.0-beta.1(transitive)
- Removed@tracerbench/protocol-connection@1.0.0-beta.1(transitive)
- Removed@tracerbench/protocol-transport@1.0.0-beta.1(transitive)
- Removed@tracerbench/spawn@1.0.0-beta.1(transitive)
- Removed@tracerbench/spawn-chrome@1.0.0-beta.1(transitive)
- Removed@tracerbench/websocket-message-transport@1.0.0-beta.1(transitive)
- Removedcross-spawn@6.0.6(transitive)
- Removedexeca@1.0.0(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedtmp@0.1.0(transitive)
- Removedwhich@1.3.1(transitive)
Updated@tracerbench/websocket-message-transport@^1.0.0-beta.2