@@ -48,6 +48,12 @@ export interface JerryDebugProtocolDelegate {
48
48
onError ?( code : number , message : string ) : void ;
49
49
onResume ?( ) : void ;
50
50
onScriptParsed ?( message : JerryMessageScriptParsed ) : void ;
51
+ onWaitForSource ?( ) : JerryMessageSource ;
52
+ }
53
+
54
+ export interface JerryMessageSource {
55
+ name : string ;
56
+ source : string ;
51
57
}
52
58
53
59
export interface JerryMessageScriptParsed {
@@ -113,6 +119,7 @@ export class JerryDebugProtocolHandler {
113
119
private lastBreakpointExact : boolean = true ;
114
120
private activeBreakpoints : Array < Breakpoint > = [ ] ;
115
121
private nextBreakpointIndex : number = 0 ;
122
+ private waitForSourceEnabled : boolean = false ;
116
123
117
124
constructor ( delegate : JerryDebugProtocolDelegate ) {
118
125
this . delegate = delegate ;
@@ -140,6 +147,7 @@ export class JerryDebugProtocolHandler {
140
147
[ SP . SERVER . JERRY_DEBUGGER_BACKTRACE_END ] : this . onBacktrace ,
141
148
[ SP . SERVER . JERRY_DEBUGGER_EVAL_RESULT ] : this . onEvalResult ,
142
149
[ SP . SERVER . JERRY_DEBUGGER_EVAL_RESULT_END ] : this . onEvalResult ,
150
+ [ SP . SERVER . JERRY_DEBUGGER_WAIT_FOR_SOURCE ] : this . onWaitForSource
143
151
} ;
144
152
}
145
153
@@ -627,4 +635,40 @@ export class JerryDebugProtocolHandler {
627
635
this . delegate . onResume ( ) ;
628
636
}
629
637
}
638
+
639
+ sendClientSource ( fileName , fileSourceCode ) {
640
+ if ( ! this . waitForSourceEnabled ) {
641
+ throw new Error ( 'wait-for-source not enabled' ) ;
642
+ }
643
+
644
+ this . waitForSourceEnabled = false ;
645
+ let array = stringToCesu8 ( `${ fileName } \0${ fileSourceCode } ` , 5 , this . byteConfig ) ;
646
+ const byteLength = array . byteLength ;
647
+
648
+ array [ 0 ] = SP . CLIENT . JERRY_DEBUGGER_CLIENT_SOURCE ;
649
+
650
+ if ( byteLength <= this . maxMessageSize ) {
651
+ this . debuggerClient . send ( array ) ;
652
+ return true ;
653
+ }
654
+
655
+ this . debuggerClient . send ( array . slice ( 0 , this . maxMessageSize ) ) ;
656
+
657
+ let offset = this . maxMessageSize - 1 ;
658
+
659
+ while ( offset < byteLength ) {
660
+ array [ offset ] = SP . CLIENT . JERRY_DEBUGGER_CLIENT_SOURCE_PART ;
661
+ this . debuggerClient . send ( array . slice ( offset , offset + this . maxMessageSize ) ) ;
662
+ offset += this . maxMessageSize - 1 ;
663
+ }
664
+
665
+ return true ;
666
+ }
667
+
668
+ onWaitForSource ( ) {
669
+ this . waitForSourceEnabled = true ;
670
+ if ( this . delegate . onWaitForSource ) {
671
+ this . delegate . onWaitForSource ( ) ;
672
+ }
673
+ }
630
674
}
0 commit comments