microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.11.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/debugConfigTypesAndConstants.ts

289lines · 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 * as vscode from "vscode";
5import * as nls from "vscode-nls";
6import { PlatformType } from "../launchArgs";
7import { ILaunchRequestArgs } from "../../debugger/debugSessionBase";
8import { IWDPHelper } from "../../debugger/direct/IWDPHelper";
9
10nls.config({
11 messageFormat: nls.MessageFormat.bundle,
12 bundleFormat: nls.BundleFormat.standalone,
13})();
14const localize = nls.loadMessageBundle();
15
16export interface DebugConfigurationState {
17 config: Partial<ILaunchRequestArgs>;
18 scenarioType: DebugScenarioType;
19 folder?: vscode.WorkspaceFolder;
20 token?: vscode.CancellationToken;
21}
22
23export type DebugConfigurationQuickPickItem = vscode.QuickPickItem & { type: string };
24
25export enum DebugScenarioType {
26 RunApp = "runapp",
27 DebugApp = "debugapp",
28 AttachApp = "attachapp",
29}
30
31export const DEBUG_TYPES = {
32 REACT_NATIVE: "reactnative",
33 REACT_NATIVE_DIRECT: "reactnativedirect",
34};
35
36export const platformTypeRunPickConfig: DebugConfigurationQuickPickItem[] = [
37 {
38 label: "Android",
39 type: PlatformType.Android,
40 },
41 {
42 label: "iOS",
43 type: PlatformType.iOS,
44 },
45 {
46 label: "MacOS",
47 type: PlatformType.macOS,
48 },
49 {
50 label: "Windows",
51 type: PlatformType.Windows,
52 },
53];
54
55export const platformTypeDebugPickConfig: DebugConfigurationQuickPickItem[] = [
56 ...platformTypeRunPickConfig,
57 {
58 label: "Exponent",
59 type: PlatformType.Exponent,
60 },
61];
62
63export const platformTypeDirectPickConfig: DebugConfigurationQuickPickItem[] = [
64 {
65 label: "Hermes engine",
66 type: "",
67 },
68 {
69 label: "Direct iOS - Experimental",
70 type: PlatformType.iOS,
71 },
72];
73
74export const appTypePickConfig: DebugConfigurationQuickPickItem[] = [
75 {
76 label: "Application in direct mode(Hermes)",
77 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
78 },
79 {
80 label: "Classic application",
81 type: DEBUG_TYPES.REACT_NATIVE,
82 },
83];
84
85export const shouldUseHermesEngine: DebugConfigurationQuickPickItem[] = [
86 {
87 label: "Yes",
88 type: "yes",
89 },
90 {
91 label: "No",
92 type: "no",
93 },
94];
95
96export const expoHostTypePickConfig: DebugConfigurationQuickPickItem[] = [
97 {
98 label: "Tunnel",
99 description: localize(
100 "expoHostTypeTunnel",
101 "Allows to deploy and debug an application by means of Expo cloud services",
102 ),
103 type: "tunnel",
104 },
105 {
106 label: "LAN",
107 description: localize(
108 "expoHostTypeLAN",
109 "Allows to deploy and install an application via your LAN",
110 ),
111 type: "lan",
112 },
113 {
114 label: "Local",
115 description: localize(
116 "expoHostTypeLocal",
117 "Allows to debug an application on an emulator or an Android device without network connection",
118 ),
119 type: "local",
120 },
121];
122
123export const DEBUG_CONFIGURATION_NAMES = {
124 ATTACH_TO_HERMES_APPLICATION: "Attach to Hermes application",
125 ATTACH_TO_DIRECT_IOS_EXPERIMENTAL: "Attach to Direct iOS - Experimental",
126 ATTACH_TO_PACKAGER: "Attach to packager",
127 DEBUG_ANDROID: "Debug Android",
128 DEBUG_IOS: "Debug iOS",
129 DEBUG_WINDOWS: "Debug Windows",
130 DEBUG_MACOS: "Debug macOS",
131 DEBUG_IN_EXPONENT: "Debug in Exponent",
132 DEBUG_ANDROID_HERMES: "Debug Android Hermes",
133 DEBUG_DIRECT_IOS_EXPERIMENTAL: "Debug Direct iOS - Experimental",
134 DEBUG_IOS_HERMES: "Debug iOS Hermes",
135 DEBUG_MACOS_HERMES_EXPERIMENTAL: "Debug macOS Hermes - Experimental",
136 DEBUG_WINDOWS_HERMES_EXPERIMENTAL: "Debug Windows Hermes - Experimental",
137 RUN_ANDROID: "Run Android",
138 RUN_IOS: "Run iOS",
139 RUN_ANDROID_HERMES: "Run Android Hermes",
140 RUN_IOS_HERMES: "Run iOS Hermes",
141 RUN_DIRECT_IOS_EXPERIMENTAL: "Run Direct iOS - Experimental",
142 DEBUG_IN_EXPONENT_HERMES_EXPERIMENTAL: "Debug in Hermes Exponent - Experimental",
143};
144
145export const debugConfigurations: Record<string, vscode.DebugConfiguration> = {
146 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION]: {
147 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION,
148 cwd: "${workspaceFolder}",
149 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
150 request: "attach",
151 },
152 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL]: {
153 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL,
154 cwd: "${workspaceFolder}",
155 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
156 request: "attach",
157 platform: PlatformType.iOS,
158 useHermesEngine: false,
159 port: IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT, // 9221
160 },
161 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER]: {
162 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER,
163 cwd: "${workspaceFolder}",
164 type: DEBUG_TYPES.REACT_NATIVE,
165 request: "attach",
166 },
167 [DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID]: {
168 name: DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID,
169 cwd: "${workspaceFolder}",
170 type: DEBUG_TYPES.REACT_NATIVE,
171 request: "launch",
172 platform: PlatformType.Android,
173 },
174 [DEBUG_CONFIGURATION_NAMES.DEBUG_IOS]: {
175 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IOS,
176 cwd: "${workspaceFolder}",
177 type: DEBUG_TYPES.REACT_NATIVE,
178 request: "launch",
179 platform: PlatformType.iOS,
180 },
181 [DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS]: {
182 name: DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS,
183 cwd: "${workspaceFolder}",
184 type: DEBUG_TYPES.REACT_NATIVE,
185 request: "launch",
186 platform: PlatformType.Windows,
187 },
188 [DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS]: {
189 name: DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS,
190 cwd: "${workspaceFolder}",
191 type: DEBUG_TYPES.REACT_NATIVE,
192 request: "launch",
193 platform: PlatformType.macOS,
194 },
195 [DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT]: {
196 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT,
197 cwd: "${workspaceFolder}",
198 type: DEBUG_TYPES.REACT_NATIVE,
199 request: "launch",
200 platform: PlatformType.Exponent,
201 },
202 [DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES]: {
203 name: DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES,
204 cwd: "${workspaceFolder}",
205 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
206 request: "launch",
207 platform: PlatformType.Android,
208 },
209 [DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL]: {
210 name: DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL,
211 cwd: "${workspaceFolder}",
212 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
213 request: "launch",
214 platform: PlatformType.iOS,
215 useHermesEngine: false,
216 target: "device",
217 port: IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT, // 9221
218 },
219 [DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES]: {
220 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES,
221 cwd: "${workspaceFolder}",
222 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
223 request: "launch",
224 platform: PlatformType.iOS,
225 },
226 [DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL]: {
227 name: DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL,
228 cwd: "${workspaceFolder}",
229 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
230 request: "launch",
231 platform: PlatformType.macOS,
232 },
233 [DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL]: {
234 name: DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL,
235 cwd: "${workspaceFolder}",
236 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
237 request: "launch",
238 platform: PlatformType.Windows,
239 },
240 [DEBUG_CONFIGURATION_NAMES.RUN_ANDROID]: {
241 name: DEBUG_CONFIGURATION_NAMES.RUN_ANDROID,
242 cwd: "${workspaceFolder}",
243 type: DEBUG_TYPES.REACT_NATIVE,
244 request: "launch",
245 platform: PlatformType.Android,
246 enableDebug: false,
247 },
248 [DEBUG_CONFIGURATION_NAMES.RUN_IOS]: {
249 name: DEBUG_CONFIGURATION_NAMES.RUN_IOS,
250 cwd: "${workspaceFolder}",
251 type: DEBUG_TYPES.REACT_NATIVE,
252 request: "launch",
253 platform: PlatformType.iOS,
254 enableDebug: false,
255 },
256 [DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES]: {
257 name: DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES,
258 cwd: "${workspaceFolder}",
259 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
260 request: "launch",
261 platform: PlatformType.Android,
262 enableDebug: false,
263 },
264 [DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES]: {
265 name: DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES,
266 cwd: "${workspaceFolder}",
267 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
268 request: "launch",
269 platform: PlatformType.iOS,
270 enableDebug: false,
271 },
272 [DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL]: {
273 name: DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL,
274 cwd: "${workspaceFolder}",
275 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
276 request: "launch",
277 platform: PlatformType.iOS,
278 enableDebug: false,
279 useHermesEngine: false,
280 target: "device",
281 },
282 [DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT_HERMES_EXPERIMENTAL]: {
283 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT_HERMES_EXPERIMENTAL,
284 cwd: "${workspaceFolder}",
285 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
286 request: "launch",
287 platform: PlatformType.Exponent,
288 },
289};
290