microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
5884987e1e77357b25c6f9bfec909aa4116c17ec

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

113lines · 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 { BaseConfigProvider } from "./baseConfigProvider";
5import { MultiStepInput, InputStep } from "../multiStepInput";
6import {
7DebugConfigurationState,
8platformTypeDebugPickConfig,
9DEBUG_TYPES,
10DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
12import { PlatformType } from "../../launchArgs";
13import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
14
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
45if (
46state.config.platform === PlatformType.iOS ||
5c9b8eb8RedMickey5 years ago47state.config.platform === PlatformType.Android ||
48state.config.platform === PlatformType.macOS
5471436aRedMickey5 years ago49) {
6f9a0779JiglioNero5 years ago50return () =>
51this.configureApplicationType(input, state.config).then(() => {
52if (
53state.config.platform === PlatformType.iOS &&
54state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
55) {
56this.maxStepCount = 3;
57return 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
60if (state.config.useHermesEngine === false) {
61state.config.target = "device";
62}
63});
64}
65return Promise.resolve();
66});
5471436aRedMickey5 years ago67} else if (state.config.platform === PlatformType.Exponent) {
68return () => this.configureExpoHostType(input, state.config);
69} else {
70return;
71}
72}
73
74private async configureApplicationType(
75input: MultiStepInput<DebugConfigurationState>,
76config: Partial<ILaunchRequestArgs>,
77): Promise<InputStep<DebugConfigurationState> | void> {
78await this.configurationProviderHelper.selectApplicationType(
79input,
80config,
812,
82this.maxStepCount,
83);
84}
85
86private async configureExpoHostType(
87input: MultiStepInput<DebugConfigurationState>,
88config: Partial<ILaunchRequestArgs>,
89): Promise<InputStep<DebugConfigurationState> | void> {
90await this.configurationProviderHelper.selectExpoHostType(
91input,
92config,
932,
94this.maxStepCount,
95);
96}
6f9a0779JiglioNero5 years ago97
98private async configureUseHermesEngine(
99input: MultiStepInput<DebugConfigurationState>,
100config: Partial<ILaunchRequestArgs>,
101): Promise<InputStep<DebugConfigurationState> | void> {
102delete config.useHermesEngine;
103await this.configurationProviderHelper.shouldUseHermesEngine(
104input,
105config,
1063,
107this.maxStepCount,
108);
109if (config.useHermesEngine) {
110delete config.useHermesEngine;
111}
112}
5471436aRedMickey5 years ago113}