Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
d39d4505
Unverified
Commit
d39d4505
authored
Mar 08, 2021
by
Jonah Williams
Committed by
GitHub
Mar 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove most globals from resident web runner (#77432)
parent
85e2c52b
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
265 additions
and
263 deletions
+265
-263
file_system.dart
packages/flutter_tools/lib/src/base/file_system.dart
+7
-7
logger.dart
packages/flutter_tools/lib/src/base/logger.dart
+21
-23
daemon.dart
packages/flutter_tools/lib/src/commands/daemon.dart
+4
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+4
-0
web_driver_service.dart
packages/flutter_tools/lib/src/drive/web_driver_service.dart
+4
-0
resident_web_runner.dart
...s/flutter_tools/lib/src/isolated/resident_web_runner.dart
+73
-70
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+2
-2
web_runner.dart
packages/flutter_tools/lib/src/web/web_runner.dart
+8
-0
attach_test.dart
...utter_tools/test/commands.shard/hermetic/attach_test.dart
+3
-0
resident_web_runner_cold_test.dart
...ols/test/general.shard/resident_web_runner_cold_test.dart
+7
-2
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+132
-159
No files found.
packages/flutter_tools/lib/src/base/file_system.dart
View file @
d39d4505
...
...
@@ -73,13 +73,6 @@ class FileSystemUtils {
}
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
getDisplayPath
(
String
fullPath
)
{
final
String
cwd
=
_fileSystem
.
currentDirectory
.
path
+
_fileSystem
.
path
.
separator
;
return
fullPath
.
startsWith
(
cwd
)
?
fullPath
.
substring
(
cwd
.
length
)
:
fullPath
;
}
/// Escapes [path].
///
/// On Windows it replaces all '\' with '\\'. On other platforms, it returns the
...
...
@@ -115,6 +108,13 @@ class FileSystemUtils {
}
}
/// Return a relative path if [fullPath] is contained by the cwd, else return an
/// absolute path.
String
getDisplayPath
(
String
fullPath
,
FileSystem
fileSystem
)
{
final
String
cwd
=
fileSystem
.
currentDirectory
.
path
+
fileSystem
.
path
.
separator
;
return
fullPath
.
startsWith
(
cwd
)
?
fullPath
.
substring
(
cwd
.
length
)
:
fullPath
;
}
/// Creates `destDir` if needed, then recursively copies `srcDir` to
/// `destDir`, invoking [onFileCopied], if specified, for each
/// source/destination file pair.
...
...
packages/flutter_tools/lib/src/base/logger.dart
View file @
d39d4505
...
...
@@ -11,7 +11,7 @@ import 'package:meta/meta.dart';
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'io.dart'
;
import
'terminal.dart'
show
AnsiTerminal
,
Terminal
,
TerminalColor
,
OutputPreferences
;
import
'terminal.dart'
show
Terminal
,
TerminalColor
,
OutputPreferences
;
import
'utils.dart'
;
const
int
kDefaultStatusPadding
=
59
;
...
...
@@ -36,7 +36,7 @@ abstract class Logger {
bool
get
hasTerminal
;
Terminal
get
_
terminal
;
Terminal
get
terminal
;
OutputPreferences
get
_outputPreferences
;
...
...
@@ -162,7 +162,7 @@ class DelegatingLogger implements Logger {
bool
get
hasTerminal
=>
_delegate
.
hasTerminal
;
@override
Terminal
get
_terminal
=>
_delegate
.
_
terminal
;
Terminal
get
terminal
=>
_delegate
.
terminal
;
@override
OutputPreferences
get
_outputPreferences
=>
_delegate
.
_outputPreferences
;
...
...
@@ -241,18 +241,17 @@ T asLogger<T extends Logger>(Logger logger) {
class
StdoutLogger
extends
Logger
{
StdoutLogger
({
@required
Terminal
terminal
,
@required
this
.
terminal
,
@required
Stdio
stdio
,
@required
OutputPreferences
outputPreferences
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_stdio
=
stdio
,
_terminal
=
terminal
,
_outputPreferences
=
outputPreferences
,
_stopwatchFactory
=
stopwatchFactory
;
@override
final
Terminal
_
terminal
;
final
Terminal
terminal
;
@override
final
OutputPreferences
_outputPreferences
;
final
Stdio
_stdio
;
...
...
@@ -264,7 +263,7 @@ class StdoutLogger extends Logger {
bool
get
isVerbose
=>
false
;
@override
bool
get
supportsColor
=>
_
terminal
.
supportsColor
;
bool
get
supportsColor
=>
terminal
.
supportsColor
;
@override
bool
get
hasTerminal
=>
_stdio
.
stdinHasTerminal
;
...
...
@@ -288,9 +287,9 @@ class StdoutLogger extends Logger {
columnWidth:
_outputPreferences
.
wrapColumn
,
);
if
(
emphasis
==
true
)
{
message
=
_
terminal
.
bolden
(
message
);
message
=
terminal
.
bolden
(
message
);
}
message
=
_
terminal
.
color
(
message
,
color
??
TerminalColor
.
red
);
message
=
terminal
.
color
(
message
,
color
??
TerminalColor
.
red
);
writeToStdErr
(
'
$message
\n
'
);
if
(
stackTrace
!=
null
)
{
writeToStdErr
(
'
$stackTrace
\n
'
);
...
...
@@ -317,10 +316,10 @@ class StdoutLogger extends Logger {
columnWidth:
_outputPreferences
.
wrapColumn
,
);
if
(
emphasis
==
true
)
{
message
=
_
terminal
.
bolden
(
message
);
message
=
terminal
.
bolden
(
message
);
}
if
(
color
!=
null
)
{
message
=
_
terminal
.
color
(
message
,
color
);
message
=
terminal
.
color
(
message
,
color
);
}
if
(
newline
!=
false
)
{
message
=
'
$message
\n
'
;
...
...
@@ -361,7 +360,7 @@ class StdoutLogger extends Logger {
onFinish:
_clearStatus
,
stdio:
_stdio
,
stopwatch:
_stopwatchFactory
.
createStopwatch
(),
terminal:
_
terminal
,
terminal:
terminal
,
)..
start
();
}
else
{
_status
=
SummaryStatus
(
...
...
@@ -385,7 +384,7 @@ class StdoutLogger extends Logger {
@override
void
clear
()
{
_status
?.
pause
();
writeToStdOut
(
_
terminal
.
clearScreen
()
+
'
\n
'
);
writeToStdOut
(
terminal
.
clearScreen
()
+
'
\n
'
);
_status
?.
resume
();
}
}
...
...
@@ -413,7 +412,7 @@ class WindowsStdoutLogger extends StdoutLogger {
@override
void
writeToStdOut
(
String
message
)
{
final
String
windowsMessage
=
_
terminal
.
supportsEmoji
final
String
windowsMessage
=
terminal
.
supportsEmoji
?
message
:
message
.
replaceAll
(
'🔥'
,
''
)
.
replaceAll
(
'🖼️'
,
''
)
...
...
@@ -428,18 +427,17 @@ class WindowsStdoutLogger extends StdoutLogger {
class
BufferLogger
extends
Logger
{
BufferLogger
({
@required
AnsiTerminal
terminal
,
@required
this
.
terminal
,
@required
OutputPreferences
outputPreferences
,
StopwatchFactory
stopwatchFactory
=
const
StopwatchFactory
(),
})
:
_outputPreferences
=
outputPreferences
,
_terminal
=
terminal
,
_stopwatchFactory
=
stopwatchFactory
;
/// Create a [BufferLogger] with test preferences.
BufferLogger
.
test
({
Terminal
terminal
,
OutputPreferences
outputPreferences
,
})
:
_
terminal
=
terminal
??
Terminal
.
test
(),
})
:
terminal
=
terminal
??
Terminal
.
test
(),
_outputPreferences
=
outputPreferences
??
OutputPreferences
.
test
(),
_stopwatchFactory
=
const
StopwatchFactory
();
...
...
@@ -448,7 +446,7 @@ class BufferLogger extends Logger {
final
OutputPreferences
_outputPreferences
;
@override
final
Terminal
_
terminal
;
final
Terminal
terminal
;
final
StopwatchFactory
_stopwatchFactory
;
...
...
@@ -456,7 +454,7 @@ class BufferLogger extends Logger {
bool
get
isVerbose
=>
false
;
@override
bool
get
supportsColor
=>
_
terminal
.
supportsColor
;
bool
get
supportsColor
=>
terminal
.
supportsColor
;
final
StringBuffer
_error
=
StringBuffer
();
final
StringBuffer
_status
=
StringBuffer
();
...
...
@@ -481,7 +479,7 @@ class BufferLogger extends Logger {
int
hangingIndent
,
bool
wrap
,
})
{
_error
.
writeln
(
_
terminal
.
color
(
_error
.
writeln
(
terminal
.
color
(
wrapText
(
message
,
indent:
indent
,
hangingIndent:
hangingIndent
,
...
...
@@ -654,7 +652,7 @@ class VerboseLogger extends DelegatingLogger {
}
else
{
prefix
=
'+
$millis
ms'
.
padLeft
(
prefixWidth
);
if
(
millis
>=
100
)
{
prefix
=
_
terminal
.
bolden
(
prefix
);
prefix
=
terminal
.
bolden
(
prefix
);
}
}
prefix
=
'[
$prefix
] '
;
...
...
@@ -663,12 +661,12 @@ class VerboseLogger extends DelegatingLogger {
final
String
indentMessage
=
message
.
replaceAll
(
'
\n
'
,
'
\n
$indent
'
);
if
(
type
==
_LogType
.
error
)
{
super
.
printError
(
prefix
+
_
terminal
.
bolden
(
indentMessage
));
super
.
printError
(
prefix
+
terminal
.
bolden
(
indentMessage
));
if
(
stackTrace
!=
null
)
{
super
.
printError
(
indent
+
stackTrace
.
toString
().
replaceAll
(
'
\n
'
,
'
\n
$indent
'
));
}
}
else
if
(
type
==
_LogType
.
status
)
{
super
.
printStatus
(
prefix
+
_
terminal
.
bolden
(
indentMessage
));
super
.
printStatus
(
prefix
+
terminal
.
bolden
(
indentMessage
));
}
else
{
super
.
printStatus
(
prefix
+
indentMessage
);
}
...
...
packages/flutter_tools/lib/src/commands/daemon.dart
View file @
d39d4505
...
...
@@ -484,6 +484,10 @@ class AppDomain extends Domain {
stayResident:
true
,
urlTunneller:
options
.
webEnableExposeUrl
?
daemon
.
daemonDomain
.
exposeUrl
:
null
,
machine:
machine
,
usage:
globals
.
flutterUsage
,
systemClock:
globals
.
systemClock
,
logger:
globals
.
logger
,
fileSystem:
globals
.
fs
,
);
}
else
if
(
enableHotReload
)
{
runner
=
HotRunner
(
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
d39d4505
...
...
@@ -495,6 +495,10 @@ class RunCommand extends RunCommandBase {
debuggingOptions:
await
createDebuggingOptions
(
webMode
),
stayResident:
stayResident
,
urlTunneller:
null
,
fileSystem:
globals
.
fs
,
usage:
globals
.
flutterUsage
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
);
}
return
ColdRunner
(
...
...
packages/flutter_tools/lib/src/drive/web_driver_service.dart
View file @
d39d4505
...
...
@@ -72,6 +72,10 @@ class WebDriverService extends DriverService {
stayResident:
false
,
urlTunneller:
null
,
flutterProject:
FlutterProject
.
current
(),
fileSystem:
globals
.
fs
,
usage:
globals
.
flutterUsage
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
);
final
Completer
<
void
>
appStartedCompleter
=
Completer
<
void
>.
sync
();
final
int
result
=
await
_residentRunner
.
run
(
...
...
packages/flutter_tools/lib/src/isolated/resident_web_runner.dart
View file @
d39d4505
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/resident_runner.dart
View file @
d39d4505
...
...
@@ -565,7 +565,7 @@ class FlutterDevice {
final
bool
prebuiltMode
=
hotRunner
.
applicationBinary
!=
null
;
final
String
modeName
=
hotRunner
.
debuggingOptions
.
buildInfo
.
friendlyModeName
;
globals
.
printStatus
(
'Launching
${g
lobals.fsUtils.getDisplayPath(hotRunner.mainPath
)}
'
'Launching
${g
etDisplayPath(hotRunner.mainPath, globals.fs
)}
'
'on
${device.name}
in
$modeName
mode...'
,
);
...
...
@@ -645,7 +645,7 @@ class FlutterDevice {
);
}
else
{
globals
.
printStatus
(
'Launching
${g
lobals.fsUtils.getDisplayPath(coldRunner.mainPath
)}
'
'Launching
${g
etDisplayPath(coldRunner.mainPath, globals.fs
)}
'
'on
${device.name}
in
$modeName
mode...'
,
);
}
...
...
packages/flutter_tools/lib/src/web/web_runner.dart
View file @
d39d4505
...
...
@@ -7,9 +7,13 @@
import
'package:meta/meta.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/logger.dart'
;
import
'../base/net.dart'
;
import
'../base/time.dart'
;
import
'../device.dart'
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../resident_runner.dart'
;
WebRunnerFactory
get
webRunnerFactory
=>
context
.
get
<
WebRunnerFactory
>();
...
...
@@ -27,6 +31,10 @@ abstract class WebRunnerFactory {
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
@required
UrlTunneller
urlTunneller
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
SystemClock
systemClock
,
@required
Usage
usage
,
bool
machine
=
false
,
});
}
packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
View file @
d39d4505
...
...
@@ -799,6 +799,9 @@ class StreamLogger extends Logger {
@override
void
clear
()
=>
_log
(
'[stdout]
${globals.terminal.clearScreen()}
\n
'
);
@override
Terminal
get
terminal
=>
Terminal
.
test
();
}
class
LoggerInterrupted
implements
Exception
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
View file @
d39d4505
...
...
@@ -48,14 +48,19 @@ void main() {
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
)).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'web'
,
'index.html'
)).
createSync
(
recursive:
true
);
final
FlutterProject
project
=
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
);
residentWebRunner
=
DwdsWebRunnerFactory
().
create
WebRunner
(
residentWebRunner
=
Resident
WebRunner
(
mockFlutterDevice
,
flutterProject:
project
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
ipv6:
true
,
stayResident:
true
,
urlTunneller:
null
,
)
as
ResidentWebRunner
;
featureFlags:
TestFeatureFlags
(),
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
systemClock:
globals
.
systemClock
,
usage:
globals
.
flutterUsage
,
);
}
testUsingContext
(
'Can successfully run and connect without vmservice'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
d39d4505
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment