microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
test-microbuild1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

135lines · modeblame

5471436aRedMickey5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { MultiStepInput, InputStep } from "../multiStepInput";
5import {
6DebugConfigurationState,
7platformTypeDebugPickConfig,
8DEBUG_TYPES,
9DebugScenarioType,
10} from "../debugConfigTypesAndConstants";
11import { PlatformType } from "../../launchArgs";
12import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
09f6024fHeniker4 years ago13import { BaseConfigProvider } from "./baseConfigProvider";
5471436aRedMickey5 years ago14
15export class DebugConfigProvider extends BaseConfigProvider {
16constructor() {
17super();
18this.maxStepCount = 2;
19}
20
21public async buildConfiguration(
22input: MultiStepInput<DebugConfigurationState>,
23state: DebugConfigurationState,
24): Promise<InputStep<DebugConfigurationState> | void> {
25state.config = {};
26const config: Partial<ILaunchRequestArgs> = {
27name: "Debug application",
28request: "launch",
29type: DEBUG_TYPES.REACT_NATIVE,
30cwd: "${workspaceFolder}",
31};
32
33state.scenarioType = DebugScenarioType.DebugApp;
34
35await this.configurationProviderHelper.selectPlatform(
36input,
37config,
38platformTypeDebugPickConfig,
391,
40this.maxStepCount,
41);
42
43Object.assign(state.config, config);
44
9f8c460dEzio Li2 years ago45if (
46state.config.platform !== PlatformType.Exponent &&
47state.config.platform !== PlatformType.ExpoWeb
48) {
0d77292aJiglioNero4 years ago49return async () => {
50await this.configureApplicationType(input, state.config);
51if (
52state.config.platform === PlatformType.iOS &&
53state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
54) {
55this.maxStepCount = 3;
56await this.configureUseHermesEngine(input, state.config);
57// Direct iOS debugging using ios-webkit-debug-proxy is supported
58// only with applications running on the device
59if (state.config.useHermesEngine === false) {
60state.config.target = "device";
6f9a0779JiglioNero5 years ago61}
0d77292aJiglioNero4 years ago62}
63};
5471436aRedMickey5 years ago64} else if (state.config.platform === PlatformType.Exponent) {
9888ce28Ezio Li3 years ago65return async () => {
66await this.configureApplicationType(input, state.config);
7a4506dclexie0111 years ago67if (state.config.type === "reactnativedirect") {
68await this.configureExpoPlatform(input, state.config);
69}
9888ce28Ezio Li3 years ago70await this.configureExpoHostType(input, state.config);
71};
9f8c460dEzio Li2 years ago72} else if (state.config.platform === PlatformType.ExpoWeb) {
73return async () => {
74await this.configureBrowserTarget(input, state.config);
75await this.configureApplicationType(input, state.config);
a1824f64Ezio Li2 years ago76state.config.url = "http://localhost:8081";
9f8c460dEzio Li2 years ago77};
5471436aRedMickey5 years ago78}
09f6024fHeniker4 years ago79return;
5471436aRedMickey5 years ago80}
81
82private async configureApplicationType(
83input: MultiStepInput<DebugConfigurationState>,
84config: Partial<ILaunchRequestArgs>,
85): Promise<InputStep<DebugConfigurationState> | void> {
86await this.configurationProviderHelper.selectApplicationType(
87input,
88config,
892,
90this.maxStepCount,
91);
92}
93
94private async configureExpoHostType(
95input: MultiStepInput<DebugConfigurationState>,
96config: Partial<ILaunchRequestArgs>,
97): Promise<InputStep<DebugConfigurationState> | void> {
7a4506dclexie0111 years ago98await this.configurationProviderHelper.selectExpoHostType(input, config, 4, 4);
99}
100
101private async configureExpoPlatform(
102input: MultiStepInput<DebugConfigurationState>,
103config: Partial<ILaunchRequestArgs>,
104): Promise<InputStep<DebugConfigurationState> | void> {
105await this.configurationProviderHelper.selectExpoPlatform(input, config, 3, 4);
5471436aRedMickey5 years ago106}
6f9a0779JiglioNero5 years ago107
108private async configureUseHermesEngine(
109input: MultiStepInput<DebugConfigurationState>,
110config: Partial<ILaunchRequestArgs>,
111): Promise<InputStep<DebugConfigurationState> | void> {
112delete config.useHermesEngine;
113await this.configurationProviderHelper.shouldUseHermesEngine(
114input,
115config,
1163,
117this.maxStepCount,
118);
119if (config.useHermesEngine) {
120delete config.useHermesEngine;
121}
122}
9f8c460dEzio Li2 years ago123
124private async configureBrowserTarget(
125input: MultiStepInput<DebugConfigurationState>,
126config: Partial<ILaunchRequestArgs>,
127): Promise<InputStep<DebugConfigurationState> | void> {
128await this.configurationProviderHelper.selectBrowserTarget(
129input,
130config,
1314,
132this.maxStepCount,
133);
134}
5471436aRedMickey5 years ago135}