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
c141a53f
Unverified
Commit
c141a53f
authored
Apr 15, 2020
by
Jonah Williams
Committed by
GitHub
Apr 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] support any as a special web-hostname (#54715)
parent
2f23476c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
5 deletions
+63
-5
devfs_web.dart
packages/flutter_tools/lib/src/build_runner/devfs_web.dart
+12
-2
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+5
-1
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+46
-2
No files found.
packages/flutter_tools/lib/src/build_runner/devfs_web.dart
View file @
c141a53f
...
@@ -136,7 +136,12 @@ class WebAssetServer implements AssetReader {
...
@@ -136,7 +136,12 @@ class WebAssetServer implements AssetReader {
DwdsLauncher
dwdsLauncher
=
Dwds
.
start
,
DwdsLauncher
dwdsLauncher
=
Dwds
.
start
,
})
async
{
})
async
{
try
{
try
{
final
InternetAddress
address
=
(
await
InternetAddress
.
lookup
(
hostname
)).
first
;
InternetAddress
address
;
if
(
hostname
==
'any'
)
{
address
=
InternetAddress
.
anyIPv4
;
}
else
{
address
=
(
await
InternetAddress
.
lookup
(
hostname
)).
first
;
}
final
HttpServer
httpServer
=
await
HttpServer
.
bind
(
address
,
port
);
final
HttpServer
httpServer
=
await
HttpServer
.
bind
(
address
,
port
);
final
PackageConfig
packageConfig
=
await
loadPackageConfigUri
(
final
PackageConfig
packageConfig
=
await
loadPackageConfigUri
(
globals
.
fs
.
file
(
PackageMap
.
globalPackagesPath
).
absolute
.
uri
,
globals
.
fs
.
file
(
PackageMap
.
globalPackagesPath
).
absolute
.
uri
,
...
@@ -211,6 +216,7 @@ class WebAssetServer implements AssetReader {
...
@@ -211,6 +216,7 @@ class WebAssetServer implements AssetReader {
final
Chrome
chrome
=
await
ChromeLauncher
.
connectedInstance
;
final
Chrome
chrome
=
await
ChromeLauncher
.
connectedInstance
;
return
chrome
.
chromeConnection
;
return
chrome
.
chromeConnection
;
},
},
hostname:
hostname
,
urlEncoder:
urlTunneller
,
urlEncoder:
urlTunneller
,
enableDebugging:
true
,
enableDebugging:
true
,
useSseForDebugProxy:
useSseForDebugProxy
,
useSseForDebugProxy:
useSseForDebugProxy
,
...
@@ -634,7 +640,11 @@ class WebDevFS implements DevFS {
...
@@ -634,7 +640,11 @@ class WebDevFS implements DevFS {
expressionCompiler
,
expressionCompiler
,
testMode:
testMode
,
testMode:
testMode
,
);
);
_baseUri
=
Uri
.
parse
(
'http://
$hostname
:
$port
'
);
if
(
hostname
==
'any'
)
{
_baseUri
=
Uri
.
http
(
'localhost:
$port
'
,
''
);
}
else
{
_baseUri
=
Uri
.
http
(
'
$hostname
:
$port
'
,
''
);
}
return
_baseUri
;
return
_baseUri
;
}
}
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
c141a53f
...
@@ -159,7 +159,11 @@ abstract class FlutterCommand extends Command<void> {
...
@@ -159,7 +159,11 @@ abstract class FlutterCommand extends Command<void> {
void
usesWebOptions
({
bool
hide
=
true
})
{
void
usesWebOptions
({
bool
hide
=
true
})
{
argParser
.
addOption
(
'web-hostname'
,
argParser
.
addOption
(
'web-hostname'
,
defaultsTo:
'localhost'
,
defaultsTo:
'localhost'
,
help:
'The hostname to serve web application on.'
,
help:
'The hostname that the web sever will use to resolve an IP to serve '
'from. The unresolved hostname is used to launch Chrome when using '
'the chrome Device. The name "any" may also be used to serve on any '
'IPV4 for either the Chrome or web-server device.'
,
hide:
hide
,
hide:
hide
,
);
);
argParser
.
addOption
(
'web-port'
,
argParser
.
addOption
(
'web-port'
,
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
c141a53f
...
@@ -380,7 +380,7 @@ void main() {
...
@@ -380,7 +380,7 @@ void main() {
webDevFS
.
requireJS
.
createSync
(
recursive:
true
);
webDevFS
.
requireJS
.
createSync
(
recursive:
true
);
webDevFS
.
stackTraceMapper
.
createSync
(
recursive:
true
);
webDevFS
.
stackTraceMapper
.
createSync
(
recursive:
true
);
await
webDevFS
.
create
();
final
Uri
uri
=
await
webDevFS
.
create
();
webDevFS
.
webAssetServer
.
entrypointCacheDirectory
=
globals
.
fs
.
currentDirectory
;
webDevFS
.
webAssetServer
.
entrypointCacheDirectory
=
globals
.
fs
.
currentDirectory
;
globals
.
fs
.
currentDirectory
globals
.
fs
.
currentDirectory
.
childDirectory
(
'lib'
)
.
childDirectory
(
'lib'
)
...
@@ -432,13 +432,56 @@ void main() {
...
@@ -432,13 +432,56 @@ void main() {
expect
(
await
webDevFS
.
webAssetServer
.
dartSourceContents
(
'web_entrypoint.dart'
),
expect
(
await
webDevFS
.
webAssetServer
.
dartSourceContents
(
'web_entrypoint.dart'
),
contains
(
'GENERATED'
));
contains
(
'GENERATED'
));
// served on localhost
expect
(
uri
,
Uri
.
http
(
'localhost:0'
,
''
));
await
webDevFS
.
destroy
();
}));
test
(
'Can start web server with hostname any'
,
()
=>
testbed
.
run
(()
async
{
globals
.
fs
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
final
File
outputFile
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'lib'
,
'main.dart'
))
..
createSync
(
recursive:
true
);
outputFile
.
parent
.
childFile
(
'a.sources'
).
writeAsStringSync
(
''
);
outputFile
.
parent
.
childFile
(
'a.json'
).
writeAsStringSync
(
'{}'
);
outputFile
.
parent
.
childFile
(
'a.map'
).
writeAsStringSync
(
'{}'
);
outputFile
.
parent
.
childFile
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
final
ResidentCompiler
residentCompiler
=
MockResidentCompiler
();
when
(
residentCompiler
.
recompile
(
any
,
any
,
outputPath:
anyNamed
(
'outputPath'
),
packagesFilePath:
anyNamed
(
'packagesFilePath'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
const
CompilerOutput
(
'a'
,
0
,
<
Uri
>[]);
});
final
WebDevFS
webDevFS
=
WebDevFS
(
hostname:
'any'
,
port:
0
,
packagesFilePath:
'.packages'
,
urlTunneller:
null
,
useSseForDebugProxy:
true
,
buildMode:
BuildMode
.
debug
,
enableDwds:
false
,
entrypoint:
Uri
.
base
,
testMode:
true
,
expressionCompiler:
null
,
);
webDevFS
.
requireJS
.
createSync
(
recursive:
true
);
webDevFS
.
stackTraceMapper
.
createSync
(
recursive:
true
);
final
Uri
uri
=
await
webDevFS
.
create
();
expect
(
uri
,
Uri
.
http
(
'localhost:0'
,
''
));
await
webDevFS
.
destroy
();
await
webDevFS
.
destroy
();
}));
}));
test
(
'Launches DWDS with the correct arguments'
,
()
=>
testbed
.
run
(()
async
{
test
(
'Launches DWDS with the correct arguments'
,
()
=>
testbed
.
run
(()
async
{
globals
.
fs
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
globals
.
fs
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
final
WebAssetServer
server
=
await
WebAssetServer
.
start
(
final
WebAssetServer
server
=
await
WebAssetServer
.
start
(
'
localhost
'
,
'
any
'
,
8123
,
8123
,
(
String
url
)
=>
null
,
(
String
url
)
=>
null
,
true
,
true
,
...
@@ -466,6 +509,7 @@ void main() {
...
@@ -466,6 +509,7 @@ void main() {
expect
(
enableDebugging
,
true
);
expect
(
enableDebugging
,
true
);
expect
(
enableDebugExtension
,
true
);
expect
(
enableDebugExtension
,
true
);
expect
(
useSseForDebugProxy
,
true
);
expect
(
useSseForDebugProxy
,
true
);
expect
(
hostname
,
'any'
);
return
MockDwds
();
return
MockDwds
();
});
});
...
...
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