microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
341dba36c6e7ac21203bd58ef861c4803cd85fc0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/debugger/jsDebugConfigAdapter.ts

62lines · 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 // Fixes https://github.com/microsoft/vscode/issues/102042
19 resolveSourceMapLocations: [
20 "!**/debuggerWorker.js"
21 ],
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,
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 ],
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 }
52 existingExtraArgs.sourceMaps = attachArgs.sourceMaps;
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}
63