11import { existsSync , readFileSync } from 'fs' ;
2+ import * as _ from 'lodash' ;
23import { join } from 'path' ;
3- import { ChromeDebugAdapter , IRestartRequestArgs } from 'vscode-chrome-debug-core' ;
4+ import {
5+ ChromeDebugAdapter ,
6+ IRestartRequestArgs ,
7+ ISetBreakpointsArgs ,
8+ ISetBreakpointsResponseBody ,
9+ ITelemetryPropertyCollector ,
10+ } from 'vscode-chrome-debug-core' ;
411import { Event , TerminatedEvent } from 'vscode-debugadapter' ;
512import { DebugProtocol } from 'vscode-debugprotocol' ;
613import * as extProtocol from '../common/extensionProtocol' ;
14+ import { NativeScriptSourceMapTransformer } from './nativeScriptSourceMapTransformer' ;
715
816const reconnectAfterLiveSyncTimeout = 10 * 1000 ;
917
@@ -14,6 +22,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
1422 private portWaitingResolve : any ;
1523 private isDisconnecting : boolean = false ;
1624 private isLiveSyncRestart : boolean = false ;
25+ private breakPointsCache : { [ file : string ] : { args : ISetBreakpointsArgs , requestSeq : number , ids : number [ ] } } = { } ;
1726
1827 public attach ( args : any ) : Promise < void > {
1928 return this . processRequestAndAttach ( args ) ;
@@ -41,6 +50,27 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
4150 super . disconnect ( args ) ;
4251 }
4352
53+ public async setCachedBreakpointsForScript ( script : string ) : Promise < void > {
54+ const breakPointData = this . breakPointsCache [ script ] ;
55+
56+ if ( breakPointData ) {
57+ await this . setBreakpoints ( breakPointData . args , null , breakPointData . requestSeq , breakPointData . ids ) ;
58+ }
59+ }
60+
61+ public async setBreakpoints (
62+ args : ISetBreakpointsArgs ,
63+ telemetryPropertyCollector : ITelemetryPropertyCollector ,
64+ requestSeq : number ,
65+ ids ?: number [ ] ) : Promise < ISetBreakpointsResponseBody > {
66+
67+ if ( args && args . source && args . source . path ) {
68+ this . breakPointsCache [ args . source . path ] = { args : _ . cloneDeep ( args ) , requestSeq, ids } ;
69+ }
70+
71+ return super . setBreakpoints ( args , telemetryPropertyCollector , requestSeq , ids ) ;
72+ }
73+
4474 protected async terminateSession ( reason : string , disconnectArgs ?: DebugProtocol . DisconnectArguments , restart ?: IRestartRequestArgs ) : Promise < void > {
4575 let restartRequestArgs = restart ;
4676 let timeoutId ;
@@ -113,6 +143,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
113143 const appDirPath = this . getAppDirPath ( transformedArgs . webRoot ) ;
114144
115145 ( this . pathTransformer as any ) . setTransformOptions ( args . platform , appDirPath , transformedArgs . webRoot ) ;
146+ ( this . sourceMapTransformer as NativeScriptSourceMapTransformer ) . setDebugAdapter ( this ) ;
116147 ( ChromeDebugAdapter as any ) . SET_BREAKPOINTS_TIMEOUT = 20000 ;
117148
118149 this . isLiveSync = args . watch ;
@@ -145,7 +176,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
145176 }
146177
147178 if ( ! args . sourceMapPathOverrides ) {
148- args . sourceMapPathOverrides = { } ;
179+ args . sourceMapPathOverrides = { } ;
149180 }
150181
151182 if ( ! args . sourceMapPathOverrides [ 'webpack:///*' ] ) {
0 commit comments