MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / launch

Method launch

src/extension/sdk/dev_tools/manager.ts:347–392  ·  view source on GitHub ↗
(allowLaunchThroughService: boolean, session: DartDebugSessionInformation & { vmServiceUri: string } | undefined, options: DevToolsOptions, forceShow: boolean)

Source from the content-addressed store, hash-verified

345 }
346
347 private async launch(allowLaunchThroughService: boolean, session: DartDebugSessionInformation & { vmServiceUri: string } | undefined, options: DevToolsOptions, forceShow: boolean) {
348 const url = await this.devtoolsUrl;
349 if (!url) {
350 this.showError(`DevTools URL not available`);
351 return;
352 }
353
354 const queryParams: Record<string, string | undefined> = {
355 ...this.getDefaultQueryParams(),
356 ideFeature: options.commandSource,
357 inspectorRef: options.inspectorRef,
358 theme: config.useDevToolsDarkTheme && options.location === "external" ? "dark" : undefined,
359 };
360
361 const pageId = options.pageId ?? this.getDefaultPage().id;
362 const page = devToolsPages.find((p) => p.id === pageId);
363 const routeId = page ? this.routeIdForPage(page) : pageId;
364
365 // Try to launch via service if allowed.
366 if (allowLaunchThroughService && session && await this.launchThroughService(session, { ...options, queryParams, page: routeId }))
367 return true;
368
369 // Otherwise, fall back to embedded or launching manually.
370 if (pageId)
371 queryParams.page = routeId;
372 const vmServiceUri = page?.isStaticTool ? undefined : session?.vmServiceUri;
373 // We currently only support embedded for pages we know about statically, although since we seem
374 // to only use that for a title, we may be able to relax that.
375 if (options.location !== "external") {
376 if (this.dartCapabilities.requiresDevToolsEmbedFlag)
377 queryParams.embed = "true";
378 queryParams.embedMode = "one";
379 const fullUrls = await this.buildDevToolsUrl(url, queryParams, vmServiceUri, session?.clientVmServiceUri);
380 const exposedUrls = await exposeWebViewUrls(fullUrls, this.logger);
381
382 const pageInfo = page ?? { id: pageId, title: pageId.replace(/_ext$/, "") };
383 await this.launchInEmbeddedWebView(exposedUrls, session, pageInfo, options.location, options.triggeredAutomatically, forceShow);
384 } else {
385 const fullUrls = await this.buildDevToolsUrl(url, queryParams, vmServiceUri, session?.clientVmServiceUri);
386 // For the browser, we don't care about auth URLs, but call exposeUrl so we get better logging because
387 // "Open DevTools in Browser" is a convenient way to help troubleshoot URL mapping issues like
388 // https://github.com/flutter/devtools/issues/9827
389 const exposedUrl = await envUtils.exposeUrl(fullUrls.viewUrl, this.logger);
390 await envUtils.openInBrowser(exposedUrl, this.logger);
391 }
392 }
393
394 private getCacheBust(): string {
395 // Add the version to the querystring to avoid any caching of the index.html page.

Callers 2

spawnMethod · 0.95

Calls 10

showErrorMethod · 0.95
getDefaultQueryParamsMethod · 0.95
getDefaultPageMethod · 0.95
routeIdForPageMethod · 0.95
launchThroughServiceMethod · 0.95
buildDevToolsUrlMethod · 0.95
exposeWebViewUrlsFunction · 0.90
exposeUrlMethod · 0.80
openInBrowserMethod · 0.80

Tested by

no test coverage detected