-
Notifications
You must be signed in to change notification settings - Fork 82
[WIP] Expose minimal API for flutter_tools consumption #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
34de754
9c82eab
9ab6b16
7ded2b2
fd69c42
99c677f
7efc75b
a8f4e3a
fa16121
860e79d
82bb0eb
77e5770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:build_daemon/data/build_status.dart'; | ||
import 'package:shelf/shelf.dart'; | ||
import 'package:webdev/src/serve/handlers/dev_handler.dart'; | ||
|
||
import 'src/command/configuration.dart'; | ||
import 'src/serve/chrome.dart'; | ||
import 'src/serve/debugger/app_debug_services.dart'; | ||
import 'src/serve/debugger/devtools.dart'; | ||
import 'src/serve/webdev_server.dart'; | ||
|
||
export 'src/command/configuration.dart' show Configuration, ReloadConfiguration; | ||
export 'src/daemon_client.dart' show daemonPort; | ||
export 'src/serve/debugger/app_debug_services.dart' show AppDebugServices; | ||
export 'src/serve/debugger/devtools.dart' show DevTools; | ||
|
||
Future<WebDevHandler> connectToWebdev( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the first stab at a basic API - I tried to expose as little as possible - really only the configuration needed to initialize the server and the interfaces we use to get the vm service or debug. See https://github.com/flutter/flutter/pull/34252/files#diff-01a7653ade6cc1a5182fdebf929ad64bR291 for example usage |
||
Configuration configuration, | ||
int port, | ||
int assetPort, | ||
String target, | ||
Stream<BuildResults> buildResults, | ||
DevTools devTools, { | ||
Handler optionalHandler, | ||
}) async { | ||
var serverOptions = ServerOptions( | ||
configuration, | ||
port, | ||
target, | ||
assetPort, | ||
optionalHandler, | ||
); | ||
var webDevServer = | ||
await WebDevServer.start(serverOptions, buildResults, devTools); | ||
var chrome = await Chrome.start( | ||
<String>['http://${webDevServer.host}:${webDevServer.port}/'], | ||
port: configuration.chromeDebugPort); | ||
var devHandler = webDevServer.devHandler; | ||
var connection = await devHandler.connectedApps.first; | ||
jakemac53 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var appDebugServices = await devHandler.loadAppServices( | ||
connection.request.appId, connection.request.instanceId); | ||
return WebDevHandler(appDebugServices, connection, chrome, webDevServer); | ||
} | ||
|
||
class WebDevHandler { | ||
final AppDebugServices appDebugServices; | ||
final DevConnection devConnection; | ||
final Chrome _chrome; | ||
final WebDevServer _webDevServer; | ||
|
||
WebDevHandler(this.appDebugServices, this.devConnection, this._chrome, this._webDevServer); | ||
|
||
Future<void> close() async { | ||
await _webDevServer.stop(); | ||
await _chrome.close(); | ||
await appDebugServices.close(); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.