microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/jsDebugConfigAdapter.ts
62lines · modeblame
1bdccb66RedMickey6 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
| 4 | import { IAttachRequestArgs } from "./debugSessionBase"; | |
| 5 | | |
| 6 | export class JsDebugConfigAdapter { | |
| 7 | public static createDebuggingConfigForPureRN(attachArgs: IAttachRequestArgs, cdpProxyPort: number, sessionId: string): any { | |
| 8 | return Object.assign({}, JsDebugConfigAdapter.getExistingExtraArgs(attachArgs), { | |
| 9 | type: "pwa-node", | |
| 10 | request: "attach", | |
| 11 | name: "Attach", | |
| 12 | continueOnAttach: true, | |
| 13 | port: cdpProxyPort, | |
| 14 | // The unique identifier of the debug session. It is used to distinguish React Native extension's | |
| 15 | // debug sessions from other ones. So we can save and process only the extension's debug sessions | |
| 16 | // in vscode.debug API methods "onDidStartDebugSession" and "onDidTerminateDebugSession". | |
| 17 | rnDebugSessionId: sessionId, | |
a32e1e1fYuri Skorokhodov5 years ago | 18 | // Fixes https://github.com/microsoft/vscode/issues/102042 |
| 19 | resolveSourceMapLocations: [ | |
| 20 | "!**/debuggerWorker.js" | |
| 21 | ], | |
1bdccb66RedMickey6 years ago | 22 | }); |
| 23 | } | |
| 24 | | |
| 25 | public static createDebuggingConfigForRNHermes(attachArgs: IAttachRequestArgs, cdpProxyPort: number, sessionId: string): any { | |
| 26 | return Object.assign({}, JsDebugConfigAdapter.getExistingExtraArgs(attachArgs), { | |
| 27 | type: "pwa-node", | |
| 28 | request: "attach", | |
| 29 | name: "Attach", | |
| 30 | continueOnAttach: true, | |
| 31 | port: cdpProxyPort, | |
| 32 | // The unique identifier of the debug session. It is used to distinguish React Native extension's | |
| 33 | // debug sessions from other ones. So we can save and process only the extension's debug sessions | |
| 34 | // in vscode.debug API methods "onDidStartDebugSession" and "onDidTerminateDebugSession". | |
| 35 | rnDebugSessionId: sessionId, | |
2eb6cdb6RedMickey5 years ago | 36 | // We need to provide js-debug with the "**" pattern, so that it can get source maps over a http URL |
| 37 | resolveSourceMapLocations: [ | |
| 38 | "**", | |
| 39 | "!**/node_modules/**" | |
| 40 | ], | |
1bdccb66RedMickey6 years ago | 41 | }); |
| 42 | } | |
| 43 | | |
| 44 | private static getExistingExtraArgs(attachArgs: IAttachRequestArgs): any { | |
| 45 | let existingExtraArgs: any = {}; | |
| 46 | if (attachArgs.env) { | |
| 47 | existingExtraArgs.env = attachArgs.env; | |
| 48 | } | |
| 49 | if (attachArgs.envFile) { | |
| 50 | existingExtraArgs.envFile = attachArgs.envFile; | |
| 51 | } | |
4dfc9ffdRedMickey5 years ago | 52 | existingExtraArgs.sourceMaps = attachArgs.sourceMaps; |
1bdccb66RedMickey6 years ago | 53 | if (attachArgs.sourceMapPathOverrides) { |
| 54 | existingExtraArgs.sourceMapPathOverrides = attachArgs.sourceMapPathOverrides; | |
| 55 | } | |
| 56 | if (attachArgs.skipFiles) { | |
| 57 | existingExtraArgs.skipFiles = attachArgs.skipFiles; | |
| 58 | } | |
| 59 | | |
| 60 | return existingExtraArgs; | |
| 61 | } | |
| 62 | } |