Revert "fix devicelab manfiest (#33698)" This reverts commit5a6a00dc54. This reverts commit0d79f0fc79.
This commit is contained in:
@@ -43,8 +43,8 @@ import 'macos/xcode_validator.dart';
|
||||
import 'run_hot.dart';
|
||||
import 'usage.dart';
|
||||
import 'version.dart';
|
||||
import 'web/chrome.dart';
|
||||
import 'web/compile.dart';
|
||||
import 'web/web_device.dart';
|
||||
import 'windows/windows_workflow.dart';
|
||||
|
||||
Future<T> runInContext<T>(
|
||||
|
||||
@@ -5,14 +5,11 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
|
||||
|
||||
import 'asset.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'build_info.dart';
|
||||
import 'bundle.dart';
|
||||
import 'dart/package_map.dart';
|
||||
@@ -22,8 +19,8 @@ import 'project.dart';
|
||||
import 'resident_runner.dart';
|
||||
import 'run_hot.dart';
|
||||
import 'web/asset_server.dart';
|
||||
import 'web/chrome.dart';
|
||||
import 'web/compile.dart';
|
||||
import 'web/web_device.dart';
|
||||
|
||||
/// A hot-runner which handles browser specific delegation.
|
||||
class ResidentWebRunner extends ResidentRunner {
|
||||
@@ -47,7 +44,6 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
WebAssetServer _server;
|
||||
ProjectFileInvalidator projectFileInvalidator;
|
||||
DateTime _lastCompiled;
|
||||
WipConnection _connection;
|
||||
final FlutterProject flutterProject;
|
||||
|
||||
@override
|
||||
@@ -62,16 +58,12 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> cleanupAfterSignal() async {
|
||||
await _connection.sendCommand('Browser.close');
|
||||
_connection = null;
|
||||
Future<void> cleanupAfterSignal() {
|
||||
return _server?.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> cleanupAtFinish() async {
|
||||
await _connection?.sendCommand('Browser.close');
|
||||
_connection = null;
|
||||
Future<void> cleanupAtFinish() {
|
||||
return _server?.dispose();
|
||||
}
|
||||
|
||||
@@ -136,15 +128,7 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
await _server.initialize();
|
||||
|
||||
// Step 3: Spawn an instance of Chrome and direct it to the created server.
|
||||
final String url = 'http://localhost:${_server.port}';
|
||||
final Chrome chrome = await chromeLauncher.launch(url);
|
||||
final ChromeTab chromeTab = await chrome.chromeConnection.getTab((ChromeTab chromeTab) {
|
||||
return chromeTab.url.contains(url); // we don't care about trailing slashes or #
|
||||
});
|
||||
_connection = await chromeTab.connect();
|
||||
_connection.onClose.listen((WipConnection connection) {
|
||||
appFinished();
|
||||
});
|
||||
await chromeLauncher.launch('http:localhost:${_server.port}');
|
||||
|
||||
// We don't support the debugging proxy yet.
|
||||
appStartedCompleter?.complete();
|
||||
@@ -155,39 +139,23 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<OperationResult> restart({
|
||||
bool fullRestart = false,
|
||||
bool pauseAfterRestart = false,
|
||||
String reason,
|
||||
bool benchmarkMode = false,
|
||||
}) async {
|
||||
final Stopwatch timer = Stopwatch()..start();
|
||||
final Status status = logger.startProgress(
|
||||
'Performing hot restart...',
|
||||
timeout: timeoutConfiguration.fastOperation,
|
||||
progressId: 'hot.restart',
|
||||
Future<OperationResult> restart(
|
||||
{bool fullRestart = false,
|
||||
bool pauseAfterRestart = false,
|
||||
String reason,
|
||||
bool benchmarkMode = false}) async {
|
||||
final List<Uri> invalidatedSources = ProjectFileInvalidator.findInvalidated(
|
||||
lastCompiled: _lastCompiled,
|
||||
urisToMonitor: <Uri>[
|
||||
for (FileSystemEntity entity in flutterProject.directory
|
||||
.childDirectory('lib')
|
||||
.listSync(recursive: true))
|
||||
if (entity is File && entity.path.endsWith('.dart')) entity.uri
|
||||
], // Add new class to track this for web.
|
||||
packagesPath: PackageMap.globalPackagesPath,
|
||||
);
|
||||
OperationResult result = OperationResult.ok;
|
||||
try {
|
||||
final List<Uri> invalidatedSources = ProjectFileInvalidator.findInvalidated(
|
||||
lastCompiled: _lastCompiled,
|
||||
urisToMonitor: <Uri>[
|
||||
for (FileSystemEntity entity in flutterProject.directory
|
||||
.childDirectory('lib')
|
||||
.listSync(recursive: true))
|
||||
if (entity is File && entity.path.endsWith('.dart')) entity.uri
|
||||
], // Add new class to track this for web.
|
||||
packagesPath: PackageMap.globalPackagesPath,
|
||||
);
|
||||
await webCompilationProxy.invalidate(inputs: invalidatedSources);
|
||||
await _connection.sendCommand('Page.reload');
|
||||
await Future<void>.delayed(const Duration(milliseconds: 150));
|
||||
} catch (err) {
|
||||
result = OperationResult(1, err.toString());
|
||||
} finally {
|
||||
printStatus('Restarted application in ${getElapsedAsMilliseconds(timer.elapsed)}.');
|
||||
status.cancel();
|
||||
}
|
||||
return result;
|
||||
await webCompilationProxy.invalidate(inputs: invalidatedSources);
|
||||
printStatus('Sources updated, refresh browser');
|
||||
return OperationResult.ok;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@ class WebAssetServer {
|
||||
|
||||
Future<void> _completeRequest(HttpRequest request, File file,
|
||||
[String contentType = 'text']) async {
|
||||
printTrace('looking for ${request.uri} at ${file.path}');
|
||||
if (!file.existsSync()) {
|
||||
request.response.statusCode = HttpStatus.notFound;
|
||||
await request.response.close();
|
||||
|
||||
@@ -1,173 +0,0 @@
|
||||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
|
||||
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/os.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process_manager.dart';
|
||||
import '../convert.dart';
|
||||
|
||||
/// The [ChromeLauncher] instance.
|
||||
ChromeLauncher get chromeLauncher => context.get<ChromeLauncher>();
|
||||
|
||||
const String _kChromeEnvironment = 'CHROME_EXECUTABLE';
|
||||
const String _kLinuxExecutable = 'google-chrome';
|
||||
const String _kMacOSExecutable =
|
||||
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
const String _kWindowsExecutable = r'Google\Chrome\Application\chrome.exe';
|
||||
final List<String> _kWindowsPrefixes = <String>[
|
||||
platform.environment['LOCALAPPDATA'],
|
||||
platform.environment['PROGRAMFILES'],
|
||||
platform.environment['PROGRAMFILES(X86)']
|
||||
];
|
||||
|
||||
// Responsible for launching chrome with devtools configured.
|
||||
class ChromeLauncher {
|
||||
const ChromeLauncher();
|
||||
|
||||
static final Completer<Chrome> _currentCompleter = Completer<Chrome>();
|
||||
|
||||
/// Launch the chrome browser to a particular `host` page.
|
||||
Future<Chrome> launch(String url) async {
|
||||
final String chromeExecutable = _findExecutable();
|
||||
final Directory dataDir = fs.systemTempDirectory.createTempSync();
|
||||
final int port = await os.findFreePort();
|
||||
final List<String> args = <String>[
|
||||
chromeExecutable,
|
||||
// Using a tmp directory ensures that a new instance of chrome launches
|
||||
// allowing for the remote debug port to be enabled.
|
||||
'--user-data-dir=${dataDir.path}',
|
||||
'--remote-debugging-port=$port',
|
||||
// When the DevTools has focus we don't want to slow down the application.
|
||||
'--disable-background-timer-throttling',
|
||||
// Since we are using a temp profile, disable features that slow the
|
||||
// Chrome launch.
|
||||
'--disable-extensions',
|
||||
'--disable-popup-blocking',
|
||||
'--bwsi',
|
||||
'--no-first-run',
|
||||
'--no-default-browser-check',
|
||||
'--disable-default-apps',
|
||||
'--disable-translate',
|
||||
url,
|
||||
];
|
||||
final Process process = await processManager.start(args);
|
||||
|
||||
// Wait until the DevTools are listening before trying to connect.
|
||||
await process.stderr
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.firstWhere((String line) => line.startsWith('DevTools listening'))
|
||||
.timeout(const Duration(seconds: 60), onTimeout: () {
|
||||
throwToolExit('Unable to connect to Chrome DevTools.');
|
||||
return null;
|
||||
});
|
||||
|
||||
return _connect(Chrome._(
|
||||
port,
|
||||
ChromeConnection('localhost', port),
|
||||
process: process,
|
||||
dataDir: dataDir,
|
||||
));
|
||||
}
|
||||
|
||||
static Future<Chrome> _connect(Chrome chrome) async {
|
||||
if (_currentCompleter.isCompleted) {
|
||||
throwToolExit('Only one instance of chrome can be started.');
|
||||
}
|
||||
// The connection is lazy. Try a simple call to make sure the provided
|
||||
// connection is valid.
|
||||
try {
|
||||
await chrome.chromeConnection.getTabs();
|
||||
} catch (e) {
|
||||
await chrome.close();
|
||||
throwToolExit(
|
||||
'Unable to connect to Chrome debug port: ${chrome.debugPort}\n $e');
|
||||
}
|
||||
_currentCompleter.complete(chrome);
|
||||
return chrome;
|
||||
}
|
||||
|
||||
/// Connects to an instance of Chrome with an open debug port.
|
||||
static Future<Chrome> fromExisting(int port) async =>
|
||||
_connect(Chrome._(port, ChromeConnection('localhost', port)));
|
||||
|
||||
static Future<Chrome> get connectedInstance => _currentCompleter.future;
|
||||
|
||||
static String _findExecutable() {
|
||||
if (platform.environment.containsKey(_kChromeEnvironment)) {
|
||||
return platform.environment[_kChromeEnvironment];
|
||||
}
|
||||
if (platform.isLinux) {
|
||||
// Don't check if this exists, it isn't a file.
|
||||
return _kLinuxExecutable;
|
||||
}
|
||||
if (platform.isMacOS) {
|
||||
if (!fs.file(_kMacOSExecutable).existsSync()) {
|
||||
throwToolExit('Chrome executable not found at $_kMacOSExecutable');
|
||||
}
|
||||
return _kMacOSExecutable;
|
||||
}
|
||||
if (platform.isWindows) {
|
||||
final String windowsPrefix = _kWindowsPrefixes.firstWhere((String prefix) {
|
||||
if (prefix == null) {
|
||||
return false;
|
||||
}
|
||||
final String path = fs.path.join(prefix, _kWindowsExecutable);
|
||||
return fs.file(path).existsSync();
|
||||
}, orElse: () => '.');
|
||||
final String path = fs.path.join(windowsPrefix, _kWindowsExecutable);
|
||||
if (!fs.file(path).existsSync()) {
|
||||
throwToolExit('Chrome executable not found at $path');
|
||||
}
|
||||
return path;
|
||||
}
|
||||
throwToolExit('Platform ${platform.operatingSystem} is not supported.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// A class for managing an instance of Chrome.
|
||||
class Chrome {
|
||||
const Chrome._(
|
||||
this.debugPort,
|
||||
this.chromeConnection, {
|
||||
Process process,
|
||||
Directory dataDir,
|
||||
}) : _process = process,
|
||||
_dataDir = dataDir;
|
||||
|
||||
final int debugPort;
|
||||
final Process _process;
|
||||
final Directory _dataDir;
|
||||
final ChromeConnection chromeConnection;
|
||||
|
||||
static Completer<Chrome> _currentCompleter = Completer<Chrome>();
|
||||
|
||||
Future<void> close() async {
|
||||
if (_currentCompleter.isCompleted) {
|
||||
_currentCompleter = Completer<Chrome>();
|
||||
}
|
||||
chromeConnection.close();
|
||||
_process?.kill(ProcessSignal.SIGKILL);
|
||||
await _process?.exitCode;
|
||||
try {
|
||||
// Chrome starts another process as soon as it dies that modifies the
|
||||
// profile information. Give it some time before attempting to delete
|
||||
// the directory.
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
await _dataDir?.delete(recursive: true);
|
||||
} catch (_) {
|
||||
// Silently fail if we can't clean up the profile information.
|
||||
// It is a system tmp directory so it should get cleaned up eventually.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@
|
||||
import '../application_package.dart';
|
||||
import '../asset.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/platform.dart';
|
||||
import '../base/process_manager.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart';
|
||||
import '../device.dart';
|
||||
@@ -16,7 +18,8 @@ import '../globals.dart';
|
||||
import '../project.dart';
|
||||
import '../version.dart';
|
||||
import '../web/compile.dart';
|
||||
import 'chrome.dart';
|
||||
|
||||
ChromeLauncher get chromeLauncher => context.get<ChromeLauncher>();
|
||||
|
||||
/// Only launch or display web devices if `FLUTTER_WEB`
|
||||
/// environment variable is set to true.
|
||||
@@ -199,3 +202,45 @@ class WebDevices extends PollingDeviceDiscovery {
|
||||
@override
|
||||
bool get supportsPlatform => flutterWebEnabled;
|
||||
}
|
||||
|
||||
const String _klinuxExecutable = 'google-chrome';
|
||||
const String _kMacOSExecutable = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
||||
const String _kWindowsExecutable = r'Google\Chrome\Application\chrome.exe';
|
||||
final List<String> _kWindowsPrefixes = <String>[
|
||||
platform.environment['LOCALAPPDATA'],
|
||||
platform.environment['PROGRAMFILES'],
|
||||
platform.environment['PROGRAMFILES(X86)'],
|
||||
];
|
||||
|
||||
// Responsible for launching chrome with devtools configured.
|
||||
class ChromeLauncher {
|
||||
const ChromeLauncher();
|
||||
|
||||
/// Launch the chrome browser to a particular `host` page.
|
||||
Future<Process> launch(String host) async {
|
||||
String executable;
|
||||
if (platform.isMacOS) {
|
||||
executable = _kMacOSExecutable;
|
||||
} else if (platform.isLinux) {
|
||||
executable = _klinuxExecutable;
|
||||
} else if (platform.isWindows) {
|
||||
final String filePath = _kWindowsPrefixes.firstWhere((String prefix) {
|
||||
if (prefix == null) {
|
||||
return false;
|
||||
}
|
||||
final String path = fs.path.join(prefix, _kWindowsExecutable);
|
||||
return fs.file(path).existsSync();
|
||||
}, orElse: () => '.');
|
||||
executable = filePath;
|
||||
} else {
|
||||
throwToolExit('Platform ${platform.operatingSystem} is not supported.');
|
||||
}
|
||||
if (!fs.file(executable).existsSync()) {
|
||||
throwToolExit('Chrome executable not found at $executable');
|
||||
}
|
||||
return processManager.start(<String>[
|
||||
executable,
|
||||
host,
|
||||
], mode: ProcessStartMode.detached);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ environment:
|
||||
dependencies:
|
||||
# To update these, use "flutter update-packages --force-upgrade".
|
||||
archive: 2.0.9
|
||||
args: 1.5.2
|
||||
args: 1.5.1
|
||||
bsdiff: 0.1.0
|
||||
completion: 0.2.1+1
|
||||
coverage: 0.12.4
|
||||
@@ -33,7 +33,6 @@ dependencies:
|
||||
usage: 3.4.1
|
||||
vm_service_client: 0.2.6+2
|
||||
web_socket_channel: 1.0.13
|
||||
webkit_inspection_protocol: 0.4.0
|
||||
xml: 3.5.0
|
||||
yaml: 2.1.15
|
||||
flutter_goldens_client:
|
||||
@@ -62,7 +61,7 @@ dependencies:
|
||||
build_config: 0.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
build_resolvers: 1.0.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
built_collection: 4.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
built_value: 6.6.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
built_value: 6.5.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
charcode: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
convert: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
csslib: 0.16.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -79,9 +78,6 @@ dependencies:
|
||||
kernel: 0.3.18 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
logging: 0.11.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
matcher: 0.12.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
mime: 0.9.6+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
package_resolver: 1.0.10 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
path: 1.6.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
pedantic: 1.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -92,8 +88,6 @@ dependencies:
|
||||
pubspec_parse: 0.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
scratch_space: 0.0.3+2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf: 0.7.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_web_socket: 0.2.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_map_stack_trace: 1.1.5 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
source_maps: 0.10.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -107,15 +101,21 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
collection: 1.14.11
|
||||
mockito: 4.1.0
|
||||
mockito: 4.0.0
|
||||
file_testing: 2.1.0
|
||||
vm_service_lib: 3.17.0+1
|
||||
vm_service_lib: 3.17.0
|
||||
build_runner: 1.4.0
|
||||
build_vm_compilers: 1.0.0
|
||||
build_test: 0.10.7+3
|
||||
|
||||
mime: 0.9.6+3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
multi_server_socket: 1.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
node_preamble: 1.4.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_packages_handler: 1.0.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
shelf_static: 0.2.8 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
dartdoc:
|
||||
# Exclude this package from the hosted API docs.
|
||||
nodoc: true
|
||||
|
||||
# PUBSPEC CHECKSUM: 25f1
|
||||
# PUBSPEC CHECKSUM: b34a
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/web/chrome.dart';
|
||||
import 'package:flutter_tools/src/web/compile.dart';
|
||||
import 'package:flutter_tools/src/web/web_device.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
|
||||
Reference in New Issue
Block a user