microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.9.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/debugConfigTypesAndConstants.ts

281lines · 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 - Experimental",
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",
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_EXPERIMENTAL: "Attach to Hermes application - Experimental",
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_EXPERIMENTAL: "Debug Android Hermes - Experimental",
133 DEBUG_DIRECT_IOS_EXPERIMENTAL: "Debug Direct iOS - Experimental",
134 DEBUG_IOS_HERMES_EXPERIMENTAL: "Debug iOS Hermes - Experimental",
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_EXPERIMENTAL: "Run Android Hermes - Experimental",
140 RUN_IOS_HERMES_EXPERIMENTAL: "Run iOS Hermes - Experimental",
141 RUN_DIRECT_IOS_EXPERIMENTAL: "Run Direct iOS - Experimental",
142};
143
144export const debugConfigurations: Record<string, vscode.DebugConfiguration> = {
145 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION_EXPERIMENTAL]: {
146 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION_EXPERIMENTAL,
147 cwd: "${workspaceFolder}",
148 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
149 request: "attach",
150 },
151 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL]: {
152 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL,
153 cwd: "${workspaceFolder}",
154 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
155 request: "attach",
156 platform: PlatformType.iOS,
157 useHermesEngine: false,
158 port: IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT, // 9221
159 },
160 [DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER]: {
161 name: DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER,
162 cwd: "${workspaceFolder}",
163 type: DEBUG_TYPES.REACT_NATIVE,
164 request: "attach",
165 },
166 [DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID]: {
167 name: DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID,
168 cwd: "${workspaceFolder}",
169 type: DEBUG_TYPES.REACT_NATIVE,
170 request: "launch",
171 platform: PlatformType.Android,
172 },
173 [DEBUG_CONFIGURATION_NAMES.DEBUG_IOS]: {
174 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IOS,
175 cwd: "${workspaceFolder}",
176 type: DEBUG_TYPES.REACT_NATIVE,
177 request: "launch",
178 platform: PlatformType.iOS,
179 },
180 [DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS]: {
181 name: DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS,
182 cwd: "${workspaceFolder}",
183 type: DEBUG_TYPES.REACT_NATIVE,
184 request: "launch",
185 platform: PlatformType.Windows,
186 },
187 [DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS]: {
188 name: DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS,
189 cwd: "${workspaceFolder}",
190 type: DEBUG_TYPES.REACT_NATIVE,
191 request: "launch",
192 platform: PlatformType.macOS,
193 },
194 [DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT]: {
195 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT,
196 cwd: "${workspaceFolder}",
197 type: DEBUG_TYPES.REACT_NATIVE,
198 request: "launch",
199 platform: PlatformType.Exponent,
200 },
201 [DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES_EXPERIMENTAL]: {
202 name: DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES_EXPERIMENTAL,
203 cwd: "${workspaceFolder}",
204 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
205 request: "launch",
206 platform: PlatformType.Android,
207 },
208 [DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL]: {
209 name: DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL,
210 cwd: "${workspaceFolder}",
211 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
212 request: "launch",
213 platform: PlatformType.iOS,
214 useHermesEngine: false,
215 target: "device",
216 port: IWDPHelper.iOS_WEBKIT_DEBUG_PROXY_DEFAULT_PORT, // 9221
217 },
218 [DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES_EXPERIMENTAL]: {
219 name: DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES_EXPERIMENTAL,
220 cwd: "${workspaceFolder}",
221 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
222 request: "launch",
223 platform: PlatformType.iOS,
224 },
225 [DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL]: {
226 name: DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL,
227 cwd: "${workspaceFolder}",
228 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
229 request: "launch",
230 platform: PlatformType.macOS,
231 },
232 [DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL]: {
233 name: DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL,
234 cwd: "${workspaceFolder}",
235 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
236 request: "launch",
237 platform: PlatformType.Windows,
238 },
239 [DEBUG_CONFIGURATION_NAMES.RUN_ANDROID]: {
240 name: DEBUG_CONFIGURATION_NAMES.RUN_ANDROID,
241 cwd: "${workspaceFolder}",
242 type: DEBUG_TYPES.REACT_NATIVE,
243 request: "launch",
244 platform: PlatformType.Android,
245 enableDebug: false,
246 },
247 [DEBUG_CONFIGURATION_NAMES.RUN_IOS]: {
248 name: DEBUG_CONFIGURATION_NAMES.RUN_IOS,
249 cwd: "${workspaceFolder}",
250 type: DEBUG_TYPES.REACT_NATIVE,
251 request: "launch",
252 platform: PlatformType.iOS,
253 enableDebug: false,
254 },
255 [DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES_EXPERIMENTAL]: {
256 name: DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES_EXPERIMENTAL,
257 cwd: "${workspaceFolder}",
258 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
259 request: "launch",
260 platform: PlatformType.Android,
261 enableDebug: false,
262 },
263 [DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES_EXPERIMENTAL]: {
264 name: DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES_EXPERIMENTAL,
265 cwd: "${workspaceFolder}",
266 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
267 request: "launch",
268 platform: PlatformType.iOS,
269 enableDebug: false,
270 },
271 [DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL]: {
272 name: DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL,
273 cwd: "${workspaceFolder}",
274 type: DEBUG_TYPES.REACT_NATIVE_DIRECT,
275 request: "launch",
276 platform: PlatformType.iOS,
277 enableDebug: false,
278 useHermesEngine: false,
279 target: "device",
280 },
281};
282