microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.7.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

107lines · 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 (state.config.platform !== PlatformType.Exponent) {
46 return async () => {
47 await this.configureApplicationType(input, state.config);
48 if (
49 state.config.platform === PlatformType.iOS &&
50 state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
51 ) {
52 this.maxStepCount = 3;
53 await this.configureUseHermesEngine(input, state.config);
54 // Direct iOS debugging using ios-webkit-debug-proxy is supported
55 // only with applications running on the device
56 if (state.config.useHermesEngine === false) {
57 state.config.target = "device";
58 }
59 }
60 };
61 } else if (state.config.platform === PlatformType.Exponent) {
62 return () => this.configureExpoHostType(input, state.config);
63 } else {
64 return;
65 }
66 }
67
68 private async configureApplicationType(
69 input: MultiStepInput<DebugConfigurationState>,
70 config: Partial<ILaunchRequestArgs>,
71 ): Promise<InputStep<DebugConfigurationState> | void> {
72 await this.configurationProviderHelper.selectApplicationType(
73 input,
74 config,
75 2,
76 this.maxStepCount,
77 );
78 }
79
80 private async configureExpoHostType(
81 input: MultiStepInput<DebugConfigurationState>,
82 config: Partial<ILaunchRequestArgs>,
83 ): Promise<InputStep<DebugConfigurationState> | void> {
84 await this.configurationProviderHelper.selectExpoHostType(
85 input,
86 config,
87 2,
88 this.maxStepCount,
89 );
90 }
91
92 private async configureUseHermesEngine(
93 input: MultiStepInput<DebugConfigurationState>,
94 config: Partial<ILaunchRequestArgs>,
95 ): Promise<InputStep<DebugConfigurationState> | void> {
96 delete config.useHermesEngine;
97 await this.configurationProviderHelper.shouldUseHermesEngine(
98 input,
99 config,
100 3,
101 this.maxStepCount,
102 );
103 if (config.useHermesEngine) {
104 delete config.useHermesEngine;
105 }
106 }
107}
108