microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/jsDebugConfigAdapter.ts
55lines · 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, | |
| 18 | }); | |
| 19 | } | |
| 20 | | |
| 21 | public static createDebuggingConfigForRNHermes(attachArgs: IAttachRequestArgs, cdpProxyPort: number, sessionId: string): any { | |
| 22 | return Object.assign({}, JsDebugConfigAdapter.getExistingExtraArgs(attachArgs), { | |
| 23 | type: "pwa-node", | |
| 24 | request: "attach", | |
| 25 | name: "Attach", | |
| 26 | continueOnAttach: true, | |
| 27 | port: cdpProxyPort, | |
| 28 | // The unique identifier of the debug session. It is used to distinguish React Native extension's | |
| 29 | // debug sessions from other ones. So we can save and process only the extension's debug sessions | |
| 30 | // in vscode.debug API methods "onDidStartDebugSession" and "onDidTerminateDebugSession". | |
| 31 | rnDebugSessionId: sessionId, | |
| 32 | }); | |
| 33 | } | |
| 34 | | |
| 35 | private static getExistingExtraArgs(attachArgs: IAttachRequestArgs): any { | |
| 36 | let existingExtraArgs: any = {}; | |
| 37 | if (attachArgs.env) { | |
| 38 | existingExtraArgs.env = attachArgs.env; | |
| 39 | } | |
| 40 | if (attachArgs.envFile) { | |
| 41 | existingExtraArgs.envFile = attachArgs.envFile; | |
| 42 | } | |
| 43 | if (attachArgs.sourceMaps) { | |
| 44 | existingExtraArgs.sourceMaps = attachArgs.sourceMaps; | |
| 45 | } | |
| 46 | if (attachArgs.sourceMapPathOverrides) { | |
| 47 | existingExtraArgs.sourceMapPathOverrides = attachArgs.sourceMapPathOverrides; | |
| 48 | } | |
| 49 | if (attachArgs.skipFiles) { | |
| 50 | existingExtraArgs.skipFiles = attachArgs.skipFiles; | |
| 51 | } | |
| 52 | | |
| 53 | return existingExtraArgs; | |
| 54 | } | |
| 55 | } |