import { RUNTIME_PROGRAM_ENV_VAR } from '@rxjs-debugging/runtime/out/consts' ; import { inject , injectable } from 'inversify' ; import { join , resolve } from 'path' ; import { DebugConfiguration , DebugConfigurationProvider , window , WorkspaceFolder } from 'vscode' ; import { ILogger } from './logger' ; import { IRxJSDetector } from './workspaceMonitor/detector' ; const runtimeNodeJsPath = resolve ( join ( __dirname , 'runtime-nodejs' , 'runtime.js' ) ) ; export const INodeWithRxJSDebugConfigurationResolver = Symbol ( 'NodeWithRxJSDebugConfigurationResolver' ) ; @ injectable ( ) export class NodeWithRxJSDebugConfigurationResolver implements DebugConfigurationProvider { static readonly types = [ 'node' , 'pwa-node' ] ; constructor ( @ inject ( IRxJSDetector ) private readonly rxJsDetector , @ inject ( ILogger ) private readonly logger ) { } async resolveDebugConfiguration ( folder , debugConfiguration ) { if ( ! hasParentDebugConfiguration ( debugConfiguration ) && folder && ( await this . rxJsDetector . detect ( folder ) ) ) { this . logger . info ( 'Extension' , `Augment debug configuration "${ debugConfiguration . name }" with NodeJS Runtime.` ) ; const originalRuntimeArgs = debugConfiguration . runtimeArgs ?? [ ] ; const augmentedRuntimeArgs = [ ... originalRuntimeArgs , '-r' , runtimeNodeJsPath ] ; const program = debugConfiguration . program ?? '' ; const env = debugConfiguration . env ?? { } ; if ( program === '' ) { this . logger . error ( 'Extension' , `Debug configuration "${ debugConfiguration . name }" is missing "program" property` ) ; window . showErrorMessage ( `Add "program" property to debug configuration "${ debugConfiguration . name }" to enable RxJS Debugging.` ) ; } const augmentedConfiguration = { ... debugConfiguration , env : { ... env , [ RUNTIME_PROGRAM_ENV_VAR ] : program , } , runtimeArgs : augmentedRuntimeArgs , } ; return augmentedConfiguration ; } return debugConfiguration ; } } param debugConfiguration returns see Could export function hasParentDebugConfiguration ( debugConfiguration ) { return typeof debugConfiguration . __parentId === 'string' ; }