microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/debugger/jsDebugConfigAdapter.ts
88lines · 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 { | |
34472878RedMickey5 years ago | 7 | public static createDebuggingConfigForPureRN( |
| 8 | attachArgs: IAttachRequestArgs, | |
| 9 | cdpProxyPort: number, | |
| 10 | sessionId: string, | |
| 11 | ): any { | |
1bdccb66RedMickey6 years ago | 12 | return Object.assign({}, JsDebugConfigAdapter.getExistingExtraArgs(attachArgs), { |
| 13 | type: "pwa-node", | |
| 14 | request: "attach", | |
| 15 | name: "Attach", | |
| 16 | continueOnAttach: true, | |
| 17 | port: cdpProxyPort, | |
| 18 | // The unique identifier of the debug session. It is used to distinguish React Native extension's | |
| 19 | // debug sessions from other ones. So we can save and process only the extension's debug sessions | |
| 20 | // in vscode.debug API methods "onDidStartDebugSession" and "onDidTerminateDebugSession". | |
| 21 | rnDebugSessionId: sessionId, | |
a32e1e1fYuri Skorokhodov5 years ago | 22 | // Fixes https://github.com/microsoft/vscode/issues/102042 |
34472878RedMickey5 years ago | 23 | resolveSourceMapLocations: ["!**/debuggerWorker.js"], |
1bdccb66RedMickey6 years ago | 24 | }); |
| 25 | } | |
| 26 | | |
34472878RedMickey5 years ago | 27 | public static createDebuggingConfigForRNHermes( |
| 28 | attachArgs: IAttachRequestArgs, | |
| 29 | cdpProxyPort: number, | |
| 30 | sessionId: string, | |
| 31 | ): any { | |
1bdccb66RedMickey6 years ago | 32 | return Object.assign({}, JsDebugConfigAdapter.getExistingExtraArgs(attachArgs), { |
| 33 | type: "pwa-node", | |
| 34 | request: "attach", | |
| 35 | name: "Attach", | |
| 36 | continueOnAttach: true, | |
| 37 | port: cdpProxyPort, | |
| 38 | // The unique identifier of the debug session. It is used to distinguish React Native extension's | |
| 39 | // debug sessions from other ones. So we can save and process only the extension's debug sessions | |
| 40 | // in vscode.debug API methods "onDidStartDebugSession" and "onDidTerminateDebugSession". | |
| 41 | rnDebugSessionId: sessionId, | |
ccef4e60RedMickey4 years ago | 42 | // We need to provide js-debug with the "**" pattern, so that it can get source maps over a http URL. |
| 43 | // We need to allow "**/node_modules/expo/**" path, since Expo source maps URL contains it. | |
| 44 | resolveSourceMapLocations: ["**", "!**/node_modules/!(expo)/**"], | |
1bdccb66RedMickey6 years ago | 45 | }); |
| 46 | } | |
| 47 | | |
9f8c460dEzio Li2 years ago | 48 | public static createChromeDebuggingConfig( |
| 49 | attachArgs: IAttachRequestArgs, | |
| 50 | cdpProxyPort: number, | |
| 51 | pwaSessionName: string, | |
| 52 | sessionId: string, | |
| 53 | ): any { | |
| 54 | const extraArgs: any = {}; | |
| 55 | | |
| 56 | return Object.assign({}, this.getExistingExtraArgs(attachArgs), extraArgs, { | |
| 57 | type: pwaSessionName, | |
| 58 | request: "attach", | |
| 59 | name: "Attach", | |
| 60 | port: cdpProxyPort, | |
| 61 | webRoot: attachArgs.cwd, | |
| 62 | rnDebugSessionId: sessionId, | |
| 63 | }); | |
| 64 | } | |
| 65 | | |
1bdccb66RedMickey6 years ago | 66 | private static getExistingExtraArgs(attachArgs: IAttachRequestArgs): any { |
09f6024fHeniker4 years ago | 67 | const existingExtraArgs: any = {}; |
1bdccb66RedMickey6 years ago | 68 | if (attachArgs.env) { |
| 69 | existingExtraArgs.env = attachArgs.env; | |
| 70 | } | |
| 71 | if (attachArgs.envFile) { | |
| 72 | existingExtraArgs.envFile = attachArgs.envFile; | |
| 73 | } | |
4dfc9ffdRedMickey5 years ago | 74 | existingExtraArgs.sourceMaps = attachArgs.sourceMaps; |
81fc1822JiglioNero4 years ago | 75 | existingExtraArgs.sourceMapRenames = attachArgs.sourceMapRenames; |
1bdccb66RedMickey6 years ago | 76 | if (attachArgs.sourceMapPathOverrides) { |
| 77 | existingExtraArgs.sourceMapPathOverrides = attachArgs.sourceMapPathOverrides; | |
| 78 | } | |
| 79 | if (attachArgs.skipFiles) { | |
| 80 | existingExtraArgs.skipFiles = attachArgs.skipFiles; | |
| 81 | } | |
2d89fb47Ezio Li3 years ago | 82 | if (attachArgs.jsDebugTrace) { |
| 83 | existingExtraArgs.trace = attachArgs.jsDebugTrace; | |
| 84 | } | |
1bdccb66RedMickey6 years ago | 85 | |
| 86 | return existingExtraArgs; | |
| 87 | } | |
| 88 | } |