import * as vscode from "vscode" // The adapter is shared with the standalone NX Tcl Remote Debugger. It is // bundled by esbuild into this extension, so no child process or additional // VS Code extension is required. // eslint-disable-next-line @typescript-eslint/no-var-requires const { NxInlineDebugAdapter } = require("./inlineAdapter") class NxDebugAdapterFactory implements vscode.DebugAdapterDescriptorFactory { createDebugAdapterDescriptor(): vscode.ProviderResult { return new vscode.DebugAdapterInlineImplementation(new NxInlineDebugAdapter()) } } function resolveDebugConfiguration( folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration ): vscode.DebugConfiguration { const resolved = { ...config } if (!resolved.type) resolved.type = "nx-tcl" if (!resolved.request) resolved.request = "attach" if (!resolved.name) resolved.name = "Attach to NX Post Tcl" if (!resolved.host) resolved.host = "127.0.0.1" if (!resolved.port) resolved.port = 4711 if (!resolved.connectTimeout) resolved.connectTimeout = 120000 if (resolved.stopOnEntry === undefined) resolved.stopOnEntry = false if (resolved.breakOnError === undefined) resolved.breakOnError = true if (!resolved.localRoot && folder) resolved.localRoot = folder.uri.fsPath return resolved } export function registerNxTclDebugger(context: vscode.ExtensionContext): void { const factory = new NxDebugAdapterFactory() context.subscriptions.push( vscode.debug.registerDebugAdapterDescriptorFactory("nx-tcl", factory), vscode.debug.registerDebugConfigurationProvider("nx-tcl", { resolveDebugConfiguration }) ) } export { resolveDebugConfiguration }