11import { openWebSocket } from './web-socket' ;
2- import { debug } from './debug' ;
2+ import { runnerDebug } from './debug' ;
33
4- const debugBidi = debug . scoped ( 'bidi' ) ;
4+ const debug = runnerDebug . extend ( 'bidi' ) ;
55
66export interface BidiConnection extends Disposable {
77 send < T > ( method : string , params : any , timeout ?: number ) : Promise < T > ;
@@ -12,18 +12,18 @@ export async function createBidiConnection(
1212 baseUrl : string ,
1313) : Promise < BidiConnection > {
1414 const url = new URL ( '/session' , baseUrl ) ;
15- debugBidi ( 'Connecting to BiDi server @' , url . href ) ;
15+ debug ( 'Connecting to BiDi server @' , url . href ) ;
1616
1717 const webSocket = await openWebSocket ( url . href ) ;
18- debugBidi ( 'Connected' ) ;
18+ debug ( 'Connected' ) ;
1919
2020 let requestId = 0 ;
2121
2222 return {
2323 send ( method , params , timeout = 10e3 ) {
2424 const id = ++ requestId ;
2525 const command = { id, method, params } ;
26- debugBidi ( 'Sending command:' , command ) ;
26+ debug ( 'Sending command:' , command ) ;
2727
2828 return new Promise ( ( resolve , reject ) => {
2929 const cleanup = ( ) => {
@@ -43,7 +43,7 @@ export async function createBidiConnection(
4343 const onMessage = ( event : MessageEvent ) => {
4444 const data = JSON . parse ( event . data ) ;
4545 if ( data . id === id ) {
46- debugBidi ( 'Received response:' , data ) ;
46+ debug ( 'Received response:' , data ) ;
4747 cleanup ( ) ;
4848 if ( data . type === 'success' ) resolve ( data . result ) ;
4949 else reject ( Error ( data . message , { cause : data } ) ) ;
@@ -62,14 +62,14 @@ export async function createBidiConnection(
6262 } ,
6363
6464 close ( ) {
65- debugBidi ( 'Closing connection...' ) ;
65+ debug ( 'Closing connection...' ) ;
6666 webSocket . close ( ) ;
67- debugBidi ( 'Closed connection' ) ;
67+ debug ( 'Closed connection' ) ;
6868 } ,
6969 [ Symbol . dispose ] ( ) {
70- debugBidi ( 'Disposing connection...' ) ;
70+ debug ( 'Disposing connection...' ) ;
7171 webSocket . close ( ) ;
72- debugBidi ( 'Disposed connection' ) ;
72+ debug ( 'Disposed connection' ) ;
7373 } ,
7474 } ;
7575}
0 commit comments