| 52 | } |
| 53 | |
| 54 | class VsDebugServer implements ISessionLauncher<VSDebugSession> { |
| 55 | private readonly sessionServer: ServerSessionManager<VSDebugSession>; |
| 56 | |
| 57 | constructor(host?: string, inputStream?: Readable, outputStream?: Writable) { |
| 58 | const services = createGlobalContainer({ storagePath, isVsCode: false }); |
| 59 | this.sessionServer = new ServerSessionManager(services, this, host); |
| 60 | |
| 61 | const deferredConnection: IDeferred<DapConnection> = getDeferred(); |
| 62 | const rootSession = new VSDebugSession( |
| 63 | 'root', |
| 64 | l10n.t('JavaScript debug adapter'), |
| 65 | deferredConnection.promise, |
| 66 | { type: DebugType.Chrome, name: 'root', request: 'launch' }, |
| 67 | ); |
| 68 | if (inputStream && outputStream) { |
| 69 | this.launchRootFromExisting(deferredConnection, rootSession, inputStream, outputStream); |
| 70 | } else { |
| 71 | this.launchRoot(deferredConnection, rootSession); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | private launchRootFromExisting( |
| 76 | deferredConnection: IDeferred<DapConnection>, |
| 77 | session: VSDebugSession, |
| 78 | inputStream: Readable, |
| 79 | outputStream: Writable, |
| 80 | ) { |
| 81 | const newSession = this.sessionServer.createRootDebugSessionFromStreams( |
| 82 | session, |
| 83 | inputStream, |
| 84 | outputStream, |
| 85 | ); |
| 86 | deferredConnection.resolve(newSession.connection); |
| 87 | } |
| 88 | |
| 89 | async launchRoot(deferredConnection: IDeferred<DapConnection>, session: VSDebugSession) { |
| 90 | const result = await this.sessionServer.createRootDebugServer(session, debugServerPort ?? 0); |
| 91 | result.connectionPromise.then(x => deferredConnection.resolve(x)); |
| 92 | console.log((result.server.address() as net.AddressInfo).port.toString()); |
| 93 | } |
| 94 | |
| 95 | public launch( |
| 96 | parentSession: Session<VSDebugSession>, |
| 97 | target: ITarget, |
| 98 | config: IPseudoAttachConfiguration, |
| 99 | ): void { |
| 100 | const childAttachConfig = { ...config, sessionId: target.id, __jsDebugChildServer: '' }; |
| 101 | const deferredConnection: IDeferred<DapConnection> = getDeferred(); |
| 102 | const session = new VSDebugSession( |
| 103 | target.id(), |
| 104 | target.name(), |
| 105 | deferredConnection.promise, |
| 106 | childAttachConfig, |
| 107 | ); |
| 108 | |
| 109 | this.sessionServer.createChildDebugServer(session, 0).then( |
| 110 | ({ server, connectionPromise }) => { |
| 111 | connectionPromise.then(x => deferredConnection.resolve(x)); |
nothing calls this directly
no outgoing calls
no test coverage detected