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/runConfigProvider.ts

100lines · 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 platformTypeRunPickConfig,
9 DEBUG_TYPES,
10 DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
12import { PlatformType } from "../../launchArgs";
13import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
14
15export class RunConfigProvider 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: "Run application",
28 request: "launch",
29 type: DEBUG_TYPES.REACT_NATIVE,
30 cwd: "${workspaceFolder}",
31 enableDebug: false,
32 };
33
34 state.scenarioType = DebugScenarioType.RunApp;
35
36 await this.configurationProviderHelper.selectPlatform(
37 input,
38 config,
39 platformTypeRunPickConfig,
40 1,
41 this.maxStepCount,
42 );
43
44 Object.assign(state.config, config);
45
46 if (
47 state.config.platform === PlatformType.iOS ||
48 state.config.platform === PlatformType.Android ||
49 state.config.platform === PlatformType.macOS
50 ) {
51 return () =>
52 this.configureApplicationType(input, state.config).then(() => {
53 if (
54 state.config.platform === PlatformType.iOS &&
55 state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
56 ) {
57 this.maxStepCount = 3;
58 return this.configureUseHermesEngine(input, state.config).then(() => {
59 // Direct iOS debugging using ios-webkit-debug-proxy is supported
60 // only with applications running on the device
61 if (state.config.useHermesEngine === false) {
62 state.config.target = "device";
63 }
64 });
65 }
66 return Promise.resolve();
67 });
68 } else {
69 return;
70 }
71 }
72
73 private async configureApplicationType(
74 input: MultiStepInput<DebugConfigurationState>,
75 config: Partial<ILaunchRequestArgs>,
76 ): Promise<InputStep<DebugConfigurationState> | void> {
77 await this.configurationProviderHelper.selectApplicationType(
78 input,
79 config,
80 2,
81 this.maxStepCount,
82 );
83 }
84
85 private async configureUseHermesEngine(
86 input: MultiStepInput<DebugConfigurationState>,
87 config: Partial<ILaunchRequestArgs>,
88 ): Promise<InputStep<DebugConfigurationState> | void> {
89 delete config.useHermesEngine;
90 await this.configurationProviderHelper.shouldUseHermesEngine(
91 input,
92 config,
93 3,
94 this.maxStepCount,
95 );
96 if (config.useHermesEngine) {
97 delete config.useHermesEngine;
98 }
99 }
100}
101