microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.7.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/debugger/jsDebugConfigAdapter.ts

67lines · 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(
8 attachArgs: IAttachRequestArgs,
9 cdpProxyPort: number,
10 sessionId: string,
11 ): any {
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,
22 // Fixes https://github.com/microsoft/vscode/issues/102042
23 resolveSourceMapLocations: ["!**/debuggerWorker.js"],
24 });
25 }
26
27 public static createDebuggingConfigForRNHermes(
28 attachArgs: IAttachRequestArgs,
29 cdpProxyPort: number,
30 sessionId: string,
31 ): any {
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,
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)/**"],
45 });
46 }
47
48 private static getExistingExtraArgs(attachArgs: IAttachRequestArgs): any {
49 let existingExtraArgs: any = {};
50 if (attachArgs.env) {
51 existingExtraArgs.env = attachArgs.env;
52 }
53 if (attachArgs.envFile) {
54 existingExtraArgs.envFile = attachArgs.envFile;
55 }
56 existingExtraArgs.sourceMaps = attachArgs.sourceMaps;
57 existingExtraArgs.sourceMapRenames = attachArgs.sourceMapRenames;
58 if (attachArgs.sourceMapPathOverrides) {
59 existingExtraArgs.sourceMapPathOverrides = attachArgs.sourceMapPathOverrides;
60 }
61 if (attachArgs.skipFiles) {
62 existingExtraArgs.skipFiles = attachArgs.skipFiles;
63 }
64
65 return existingExtraArgs;
66 }
67}
68