microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
d55f3c22ee18a37c605867c8bf588451292bd24e

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/debugger/jsDebugConfigAdapter.ts

58lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { IAttachRequestArgs } from "./debugSessionBase";
5
6export 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 // We need to provide js-debug with the "**" pattern, so that it can get source maps over a http URL
33 resolveSourceMapLocations: [
34 "**",
35 "!**/node_modules/**"
36 ],
37 });
38 }
39
40 private static getExistingExtraArgs(attachArgs: IAttachRequestArgs): any {
41 let existingExtraArgs: any = {};
42 if (attachArgs.env) {
43 existingExtraArgs.env = attachArgs.env;
44 }
45 if (attachArgs.envFile) {
46 existingExtraArgs.envFile = attachArgs.envFile;
47 }
48 existingExtraArgs.sourceMaps = attachArgs.sourceMaps;
49 if (attachArgs.sourceMapPathOverrides) {
50 existingExtraArgs.sourceMapPathOverrides = attachArgs.sourceMapPathOverrides;
51 }
52 if (attachArgs.skipFiles) {
53 existingExtraArgs.skipFiles = attachArgs.skipFiles;
54 }
55
56 return existingExtraArgs;
57 }
58}
59