@@ -179,6 +179,24 @@ export class UserNotify extends Notify {
179179 }
180180}
181181
182+ export class Stream {
183+ /** Type of stream */
184+ type : string
185+ /** Data of the stream */
186+ value : string
187+
188+ /** Constructs a stream object from an XML node from a Xdebug response */
189+ constructor ( document : XMLDocument ) {
190+ this . type = document . documentElement . getAttribute ( 'type' ) !
191+ const encoding = document . documentElement . getAttribute ( 'encoding' )
192+ if ( encoding ) {
193+ this . value = iconv . encode ( document . documentElement . textContent ! , encoding ) . toString ( )
194+ } else {
195+ this . value = document . documentElement . textContent !
196+ }
197+ }
198+ }
199+
182200export type BreakpointType = 'line' | 'call' | 'return' | 'exception' | 'conditional' | 'watch'
183201export type BreakpointState = 'enabled' | 'disabled'
184202export type BreakpointResolved = 'resolved' | 'unresolved'
@@ -745,6 +763,7 @@ export declare interface Connection extends DbgpConnection {
745763 on ( event : 'log' , listener : ( text : string ) => void ) : this
746764 on ( event : 'notify_user' , listener : ( notify : UserNotify ) => void ) : this
747765 on ( event : 'notify_breakpoint_resolved' , listener : ( notify : BreakpointResolvedNotify ) => void ) : this
766+ on ( event : 'stream' , listener : ( stream : Stream ) => void ) : this
748767}
749768
750769/**
@@ -809,6 +828,9 @@ export class Connection extends DbgpConnection {
809828 } else if ( response . documentElement . nodeName === 'notify' ) {
810829 const n = Notify . fromXml ( response , this )
811830 this . emit ( 'notify_' + n . name , n )
831+ } else if ( response . documentElement . nodeName === 'stream' ) {
832+ const s = new Stream ( response )
833+ this . emit ( 'stream' , s )
812834 } else {
813835 const transactionId = parseInt ( response . documentElement . getAttribute ( 'transaction_id' ) ! )
814836 if ( this . _pendingCommands . has ( transactionId ) ) {
@@ -1115,4 +1137,14 @@ export class Connection extends DbgpConnection {
11151137 public async sendEvalCommand ( expression : string ) : Promise < EvalResponse > {
11161138 return new EvalResponse ( await this . _enqueueCommand ( 'eval' , undefined , expression ) , this )
11171139 }
1140+
1141+ // ------------------------------ stream ----------------------------------------
1142+
1143+ public async sendStdout ( mode : 0 | 1 | 2 ) : Promise < Response > {
1144+ return new Response ( await this . _enqueueCommand ( 'stdout' , `-c ${ mode } ` ) , this )
1145+ }
1146+
1147+ public async sendStderr ( mode : 0 | 1 | 2 ) : Promise < Response > {
1148+ return new Response ( await this . _enqueueCommand ( 'stderr' , `-c ${ mode } ` ) , this )
1149+ }
11181150}
0 commit comments