Repository navigation
Expand file tree
/
Copy pathconstants.ts
More file actions
292 lines (247 loc) · 13.4 KB
/
Copy pathconstants.ts
File metadata and controls
292 lines (247 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
import * as fs from "fs";
import { DevToolsPage } from "./interfaces";
import { versionIsAtLeast } from "./utils";
export type SdkTypeString = "Dart" | "Flutter";
export const dartCodeExtensionIdentifier = "Dart-Code.dart-code";
export const flutterExtensionIdentifier = "Dart-Code.flutter";
export const debugAdapterPath = "out/dist/debug.js";
/// The default location of the ".dart_code" folder that holds files like autolaunch.json.
/// This can be overridden by setting the env variable named in `dartCodeConfigurationPathEnvironmentVariableName`.
export const defaultDartCodeConfigurationPath = ".dart_code";
/// The name of the environment variable that allows overriding the configuration path.
///
/// The path may be provided as a relative path (in which case it may exist within each workspace folder (not project),
/// or an absolute path (in which case there is just one for the whole workspace).
export const dartCodeConfigurationPathEnvironmentVariableName = "DART_CODE_CONFIGURATION_PATH";
/// The name of an environment variable set by Firebase Studio.
export const firebaseStudioEnvironmentVariableName = "MONOSPACE_ENV";
export const autoLaunchFilename = "autolaunch.json";
export const isCI = !!process.env.CI;
export const isDartCodeTestRun = !!process.env.DART_CODE_IS_TEST_RUN;
export const isWin = process.platform.startsWith("win");
export const isMac = process.platform === "darwin";
export const isLinux = !isWin && !isMac;
export const isChromeOS = isChromeOsImpl();
export const isWSL = isWslImpl();
// Used for code checks and in Dart SDK urls so Chrome OS is considered Linux.
export const dartPlatformName = isWin ? "win" : isMac ? "mac" : "linux";
// Used for display (logs, analytics) so Chrome OS is its own.
export const platformDisplayName = isWin ? "win" : isMac ? "mac" : isChromeOS ? "chromeos" : "linux";
export const platformEol = isWin ? "\r\n" : "\n";
const androidStudioExecutableNames = isWin ? ["studio64.exe"] : ["studio", "studio.sh"];
export const executableNames = {
dart: isWin ? "dart.exe" : "dart",
dartaotruntime: isWin ? "dartaotruntime.exe" : "dartaotruntime",
dartdoc: isWin ? "dartdoc.bat" : "dartdoc",
devToolsToolBinary: isWin ? "dt.bat" : "dt",
devToolsToolLegacyBinary: isWin ? "devtools_tool.bat" : "devtools_tool",
flutter: isWin ? "flutter.bat" : "flutter",
flutterDev: isWin ? "flutter-dev.bat" : "flutter-dev",
pub: isWin ? "pub.bat" : "pub",
};
export const getExecutableName = (cmd: string) => (executableNames as Record<string, string | undefined>)[cmd] ?? cmd;
export const dartVMPath = "bin/" + executableNames.dart;
export const dartAotRuntimePath = "bin/" + executableNames.dartaotruntime;
export const devToolsToolPath = "tool/bin/" + executableNames.devToolsToolBinary;
export const devToolsToolLegacyPath = "tool/bin/" + executableNames.devToolsToolLegacyBinary;
export let flutterPath = "bin/" + executableNames.flutter;
export function setFlutterDev(useFlutterDev: boolean) {
flutterPath = "bin/" + (useFlutterDev ? executableNames.flutterDev : executableNames.flutter);
}
export const analyzerSnapshotPath = "bin/snapshots/analysis_server.dart.snapshot";
export const androidStudioPaths = androidStudioExecutableNames.map((s) => "bin/" + s);
export const DART_DOWNLOAD_URL = "https://dart.dev/get-dart";
export const FLUTTER_DOWNLOAD_URL = "https://flutter.dev/setup/";
export const showLogAction = "Show Log";
export const captureLogsMaxLineLength = 999999999;
export const restartReasonManual = "manual";
export const restartReasonSave = "save";
export enum ExtensionRestartReason {
Unknown = "unknown",
AfterFlutterClone = "afterFlutterClone",
AfterFlutterExtensionInstall = "afterFlutterExtensionInstall",
AfterFlutterUpgrade = "afterFlutterUpgrade",
AfterSdkVersionFileChange = "afterSdkVersionFileChange",
AnalysisServerCrashedManyTimes = "analysisServerCrashedManyTimes",
AnalysisServerFromSourceMismatch = "analysisServerFromSourceMismatch",
AnalysisServerRestartCommand = "analysisServerRestartCommand",
AnalyzerTerminated = "analyzerTerminated",
ChangeWorkspaceFolders = "changeWorkspaceFolders",
ConfigurationChange = "configurationChange",
FlutterDaemonTerminatedExit = "flutterDaemonTerminatedExit",
FlutterDaemonTerminatedPing = "flutterDaemonTerminatedPing",
FlutterDaemonTerminatedSend = "flutterDaemonTerminatedSend",
FlutterDaemonTimeout = "flutterDaemonTimeout",
FlutterProjectAdded = "flutterProjectAdded",
FlutterSdkActivationFailure = "flutterSdkActivationFailure",
LocatedSdk = "locatedSdk",
NewPlatformEnabledPrompt = "newPlatformEnabledPrompt",
RestartMacDaemonMessage = "restartMacDaemonMessage",
ToolingDaemonStatusBar = "toolingDaemonStatusBar",
ToolingDaemonTerminated = "toolingDaemonTerminated",
// For test use only.
Test = "test",
}
export const debugLaunchProgressId = "launch";
export const debugTerminatingProgressId = "terminate";
export const pubGlobalDocsUrl = "https://dart.dev/tools/pub/cmd/pub-global";
export const issueTrackerAction = "Issue Tracker";
export const issueTrackerUri = "https://github.com/Dart-Code/Dart-Code/issues";
export const wantToTryDevToolsPrompt = "Dart DevTools includes additional tools for debugging and profiling Flutter apps, including a Widget Inspector. Try it?";
export const openAction = "Open";
export const alwaysOpenAction = "Always Open";
export const notTodayAction = "Not Now";
export const doNotAskAgainAction = "Never Ask";
export const doNotShowAgainAction = "Don't Show Again";
export const moreInfoAction = "More Info";
export const flutterSurveyDataUrl = "https://docs.flutter.dev/f/flutter-survey-metadata.json";
export const takeSurveyAction = "Take Survey";
export const skipThisSurveyAction = "Skip This Survey";
export const noSdkAvailablePrompt = "No SDK is available to add to PATH";
export const sdkAlreadyOnPathPrompt = (sdkType: SdkTypeString) => `The ${sdkType} SDK is already in your PATH`;
export const addedToPathPrompt = (sdkType: SdkTypeString) => `The ${sdkType} SDK was added to your PATH`;
export const addSdkToPathPrompt = (sdkType: SdkTypeString) => `Do you want to add the ${sdkType} SDK to PATH so it's accessible in external terminals?`;
export const unableToAddToPathPrompt = (sdkType: SdkTypeString) => `Unable to add the ${sdkType} SDK to PATH automatically. Show instructions to add manually?`;
export const openInstructionsAction = "Open Instructions";
export const copySdkPathToClipboardAction = "Copy SDK path to Clipboard";
export const addSdkToPathAction = "Add SDK to PATH";
export const addToPathInstructionsUrl = isWin
? "https://flutter.dev/to/update-windows-path"
: isMac
? "https://flutter.dev/to/update-macos-path"
: isLinux && !isChromeOS
? "https://flutter.dev/to/update-linux-path"
: undefined;
export const modifyingFilesOutsideWorkspaceInfoUrl = "https://dartcode.org/docs/modifying-files-outside-workspace/";
export const initializingFlutterMessage = "Initializing the Flutter SDK. This could take a few minutes.";
export const cloningFlutterMessage = "Downloading the Flutter SDK. This could take a few minutes.";
// Seconds.
export const oneSecondInMs = 1000;
export const fiveSecondsInMs = 1000 * 5;
export const tenSecondsInMs = 1000 * 10;
export const twentySecondsInMs = 1000 * 20;
export const thirtySecondsInMs = 1000 * 30;
export const twoMinutesInMs = 1000 * 60 * 2;
export const fiveMinutesInMs = 1000 * 60 * 5;
export const tenMinutesInMs = 1000 * 60 * 10;
// Hours.
export const twoHoursInMs = 1000 * 60 * 60 * 2;
const twentyHoursInMs = 1000 * 60 * 60 * 20;
const fortyHoursInMs = 1000 * 60 * 60 * 40;
// Duration for not showing a prompt that has been shown before.
export const noRepeatPromptThreshold = twentyHoursInMs;
export const longRepeatPromptThreshold = fortyHoursInMs;
export const pleaseReportBug = "Please raise a bug against the Dart extension for VS Code.";
export const projectSearchProgressText = "Searching for projects...";
// Search for 2s before showing progress notification.
export const projectSearchProgressNotificationDelayInMs = 2000;
export const projectSearchCacheTimeInMs = fiveMinutesInMs;
export const packageTestCapabilitiesCacheTimeInMs = fiveMinutesInMs;
export const DART_CREATE_PROJECT_TRIGGER_FILE = "dart.create";
export const FLUTTER_CREATE_PROJECT_TRIGGER_FILE = "flutter.create";
export const flutterCreateAvailablePlatforms = ["android", "ios", "linux", "macos", "windows", "web"];
export const flutterCreateTemplatesSupportingPlatforms = ["app", "plugin", "plugin_ffi", "skeleton"];
export const showErrorsAction = "Show Errors";
export const runAnywayAction = "Run Anyway";
export const userPromptContextPrefix = "hasPrompted.";
export const installFlutterExtensionPromptKey = "install_flutter_extension_3";
export const useRecommendedSettingsPromptKey = "use_recommended_settings";
export const cursorInstallMcpServer = "cursor_install_mcp_server";
export const onlyAnalyzeProjectsWithOpenFilesPromptKey = "only_analyze_projects_with_open_files_deprecation";
export const yesAction = "Yes";
export const noAction = "No";
export const noThanksAction = "No Thanks";
export const skipAction = "Skip";
export const iUnderstandAction = "I Understand";
export const showRecommendedSettingsAction = "Show Recommended Settings";
export const recommendedSettingsUrl = "https://dartcode.org/docs/recommended-settings/";
export const onlyAnalyzeProjectsWithOpenFilesDeprecationUrl = "https://github.com/dart-lang/sdk/issues/61742";
export const openSettingsAction = "Open Settings File";
export const sdkDeprecationInformationUrl = "https://dartcode.org/sdk-version-compatibility/";
/// Constants used in reporting of where commands are executed from.
///
/// Used in DevTools querystring, so do not change.
export abstract class CommandSource {
static commandPalette = "command";
static dtdServiceRequest = "dtdServiceRequest";
static sidebarContent = "sidebarContent";
static sidebarTitle = "sidebarToolbar";
static touchbar = "touchbar"; // MacOS touchbar button
static launchConfiguration = "launchConfiguration"; // Configured explicitly in launch configuration
static onDebugAutomatic = "onDebugAutomatic"; // Configured to always run on debug session start
static onDebugPrompt = "onDebugPrompt"; // Responded to prompt when running a debug session
static languageStatus = "languageStatus"; // Launched from the language status popout
static onSidebarShown = "onSidebarShown"; // Showed this page specifically in the sidebar.
}
export const validMethodNameRegex = new RegExp("^[a-zA-Z_][a-zA-Z0-9_]*$");
export const validClassNameRegex = validMethodNameRegex;
// This isn't included in [devToolsPages] because we only use it as a default.
export const devToolsHomePage = { id: "home", commandSuffix: "Home", title: "DevTools Home", requiredDartSdkVersion: "3.3.0-0" };
export const widgetInspectorPage: DevToolsPage = { id: "inspector", commandSuffix: "Inspector", title: "Widget Inspector", requiresFlutter: true };
export const cpuProfilerPage: DevToolsPage = { id: "cpu-profiler", commandSuffix: "CpuProfiler", title: "CPU Profiler" };
export const performancePage: DevToolsPage = {
commandSuffix: "Performance",
id: "performance",
requiresFlutter: true,
routeId: (flutterVersion) => !flutterVersion || versionIsAtLeast(flutterVersion, "2.3.1" /* 2.3.0-16.0? */) ? "performance" : "legacy-performance",
title: "Performance",
};
export const devToolsPages: DevToolsPage[] = [
widgetInspectorPage,
cpuProfilerPage,
{ id: "memory", commandSuffix: "Memory", title: "Memory" },
performancePage,
{ id: "network", commandSuffix: "Network", title: "Network" },
{ id: "logging", commandSuffix: "Logging", title: "Logging" },
{ id: "deep-links", commandSuffix: "DeepLinks", title: "Deep Links", requiresFlutter: true, requiredDartSdkVersion: "3.3.0-277", isStaticTool: true },
];
export const dartRecommendedConfig = {
// Automatically format code on save and during typing of certain characters
// (like `;` and `}`).
"editor.formatOnSave": true,
"editor.formatOnType": true,
// Draw a guide line at 80 characters, where Dart's formatting will wrap code.
"editor.rulers": [80],
// Disables built-in highlighting of words that match your selection. Without
// this, all instances of the selected text will be highlighted, interfering
// with Dart's ability to highlight only exact references to the selected variable.
"editor.selectionHighlight": false,
// Allows pressing <TAB> to complete snippets such as `for` even when the
// completion list is not visible.
"editor.tabCompletion": "onlySnippets",
// By default, VS Code will populate code completion with words found in the
// matching documents when a language service does not provide its own completions.
// This results in code completion suggesting words when editing comments and
// strings. This setting will prevent that.
"editor.wordBasedSuggestions": "off",
};
export const defaultLaunchJson = JSON.stringify(
{
configurations: [
{
name: "Dart & Flutter",
request: "launch",
type: "dart",
},
],
version: "0.2.0",
},
undefined, "\t"
);
// This indicates that a version is the latest possible, used for Bazel workspaces.
export const MAX_VERSION = "999.999.999";
// This indicates the Flutter version file was missing and we are also assuming the highest.
export const MISSING_VERSION_FILE_VERSION = "999.999.888";
function isChromeOsImpl() {
return isLinux && fs.existsSync("/dev/.cros_milestone");
}
function isWslImpl() {
try {
return isLinux && (
fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")
|| fs.readFileSync("/proc/sys/kernel/osrelease", "utf8").toLowerCase().includes("microsoft")
);
} catch {
return false;
}
}