microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ffdf159274093d12e32a09aafae6d0de3099bb4a

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

113lines · 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 { BaseConfigProvider } from "./baseConfigProvider";
5import { MultiStepInput, InputStep } from "../multiStepInput";
6import {
7 DebugConfigurationState,
8 platformTypeDebugPickConfig,
9 DEBUG_TYPES,
10 DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
12import { PlatformType } from "../../launchArgs";
13import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
14
15export class DebugConfigProvider extends BaseConfigProvider {
16 constructor() {
17 super();
18 this.maxStepCount = 2;
19 }
20
21 public async buildConfiguration(
22 input: MultiStepInput<DebugConfigurationState>,
23 state: DebugConfigurationState,
24 ): Promise<InputStep<DebugConfigurationState> | void> {
25 state.config = {};
26 const config: Partial<ILaunchRequestArgs> = {
27 name: "Debug application",
28 request: "launch",
29 type: DEBUG_TYPES.REACT_NATIVE,
30 cwd: "${workspaceFolder}",
31 };
32
33 state.scenarioType = DebugScenarioType.DebugApp;
34
35 await this.configurationProviderHelper.selectPlatform(
36 input,
37 config,
38 platformTypeDebugPickConfig,
39 1,
40 this.maxStepCount,
41 );
42
43 Object.assign(state.config, config);
44
45 if (
46 state.config.platform === PlatformType.iOS ||
47 state.config.platform === PlatformType.Android ||
48 state.config.platform === PlatformType.macOS
49 ) {
50 return () =>
51 this.configureApplicationType(input, state.config).then(() => {
52 if (
53 state.config.platform === PlatformType.iOS &&
54 state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
55 ) {
56 this.maxStepCount = 3;
57 return this.configureUseHermesEngine(input, state.config).then(() => {
58 // Direct iOS debugging using ios-webkit-debug-proxy is supported
59 // only with applications running on the device
60 if (state.config.useHermesEngine === false) {
61 state.config.target = "device";
62 }
63 });
64 }
65 return Promise.resolve();
66 });
67 } else if (state.config.platform === PlatformType.Exponent) {
68 return () => this.configureExpoHostType(input, state.config);
69 } else {
70 return;
71 }
72 }
73
74 private async configureApplicationType(
75 input: MultiStepInput<DebugConfigurationState>,
76 config: Partial<ILaunchRequestArgs>,
77 ): Promise<InputStep<DebugConfigurationState> | void> {
78 await this.configurationProviderHelper.selectApplicationType(
79 input,
80 config,
81 2,
82 this.maxStepCount,
83 );
84 }
85
86 private async configureExpoHostType(
87 input: MultiStepInput<DebugConfigurationState>,
88 config: Partial<ILaunchRequestArgs>,
89 ): Promise<InputStep<DebugConfigurationState> | void> {
90 await this.configurationProviderHelper.selectExpoHostType(
91 input,
92 config,
93 2,
94 this.maxStepCount,
95 );
96 }
97
98 private async configureUseHermesEngine(
99 input: MultiStepInput<DebugConfigurationState>,
100 config: Partial<ILaunchRequestArgs>,
101 ): Promise<InputStep<DebugConfigurationState> | void> {
102 delete config.useHermesEngine;
103 await this.configurationProviderHelper.shouldUseHermesEngine(
104 input,
105 config,
106 3,
107 this.maxStepCount,
108 );
109 if (config.useHermesEngine) {
110 delete config.useHermesEngine;
111 }
112 }
113}
114