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
392e825b
Unverified
Commit
392e825b
authored
Jun 10, 2019
by
Jonah Williams
Committed by
GitHub
Jun 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use product define for flutter web and remove extra asset server (#34159)
parent
d9179780
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
60 deletions
+8
-60
web_compilation_delegate.dart
..._tools/lib/src/build_runner/web_compilation_delegate.dart
+1
-0
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+2
-2
resident_web_runner.dart
packages/flutter_tools/lib/src/resident_web_runner.dart
+3
-5
web_device.dart
packages/flutter_tools/lib/src/web/web_device.dart
+2
-53
No files found.
packages/flutter_tools/lib/src/build_runner/web_compilation_delegate.dart
View file @
392e825b
...
@@ -608,6 +608,7 @@ Future<void> bootstrapDart2Js(BuildStep buildStep) async {
...
@@ -608,6 +608,7 @@ Future<void> bootstrapDart2Js(BuildStep buildStep) async {
'
-
o
',
'
-
o
',
'
$jsOutputPath
',
'
$jsOutputPath
',
'
--
packages
=
"
$packageFile
"',
'
--
packages
=
"
$packageFile
"',
'
-
Ddart
.
vm
.
product
=
true
',
dartPath,
dartPath,
];
];
final Dart2JsBatchWorkerPool dart2js = await buildStep.fetchResource(dart2JsWorkerResource);
final Dart2JsBatchWorkerPool dart2js = await buildStep.fetchResource(dart2JsWorkerResource);
...
...
packages/flutter_tools/lib/src/commands/run.dart
View file @
392e825b
...
@@ -411,8 +411,7 @@ class RunCommand extends RunCommandBase {
...
@@ -411,8 +411,7 @@ class RunCommand extends RunCommandBase {
// in a "hot mode".
// in a "hot mode".
final
bool
webMode
=
!
FlutterVersion
.
instance
.
isStable
final
bool
webMode
=
!
FlutterVersion
.
instance
.
isStable
&&
devices
.
length
==
1
&&
devices
.
length
==
1
&&
await
devices
.
single
.
targetPlatform
==
TargetPlatform
.
web_javascript
&&
await
devices
.
single
.
targetPlatform
==
TargetPlatform
.
web_javascript
;
&&
hotMode
;
ResidentRunner
runner
;
ResidentRunner
runner
;
final
String
applicationBinaryPath
=
argResults
[
'use-application-binary'
];
final
String
applicationBinaryPath
=
argResults
[
'use-application-binary'
];
...
@@ -438,6 +437,7 @@ class RunCommand extends RunCommandBase {
...
@@ -438,6 +437,7 @@ class RunCommand extends RunCommandBase {
target:
targetFile
,
target:
targetFile
,
flutterProject:
flutterProject
,
flutterProject:
flutterProject
,
ipv6:
ipv6
,
ipv6:
ipv6
,
debuggingOptions:
_createDebuggingOptions
(),
);
);
}
else
{
}
else
{
runner
=
ColdRunner
(
runner
=
ColdRunner
(
...
...
packages/flutter_tools/lib/src/resident_web_runner.dart
View file @
392e825b
...
@@ -32,15 +32,14 @@ class ResidentWebRunner extends ResidentRunner {
...
@@ -32,15 +32,14 @@ class ResidentWebRunner extends ResidentRunner {
String
target
,
String
target
,
@required
this
.
flutterProject
,
@required
this
.
flutterProject
,
@required
bool
ipv6
,
@required
bool
ipv6
,
@required
DebuggingOptions
debuggingOptions
,
})
:
super
(
})
:
super
(
flutterDevices
,
flutterDevices
,
target:
target
,
target:
target
,
usesTerminalUI:
true
,
usesTerminalUI:
true
,
stayResident:
true
,
stayResident:
true
,
saveCompilationTrace:
false
,
saveCompilationTrace:
false
,
debuggingOptions:
DebuggingOptions
.
enabled
(
debuggingOptions:
debuggingOptions
,
const
BuildInfo
(
BuildMode
.
debug
,
''
),
),
ipv6:
ipv6
,
ipv6:
ipv6
,
);
);
...
@@ -134,8 +133,7 @@ class ResidentWebRunner extends ResidentRunner {
...
@@ -134,8 +133,7 @@ class ResidentWebRunner extends ResidentRunner {
if
(
build
!=
0
)
{
if
(
build
!=
0
)
{
throwToolExit
(
'Error: Failed to build asset bundle'
);
throwToolExit
(
'Error: Failed to build asset bundle'
);
}
}
await
writeBundle
(
await
writeBundle
(
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
fs
.
directory
(
getAssetBuildDirectory
()),
assetBundle
.
entries
);
// Step 2: Start an HTTP server
// Step 2: Start an HTTP server
_server
=
WebAssetServer
(
flutterProject
,
target
,
ipv6
);
_server
=
WebAssetServer
(
flutterProject
,
target
,
ipv6
);
...
...
packages/flutter_tools/lib/src/web/web_device.dart
View file @
392e825b
...
@@ -11,9 +11,7 @@ import '../base/platform.dart';
...
@@ -11,9 +11,7 @@ import '../base/platform.dart';
import
'../base/process_manager.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
import
'../build_info.dart'
;
import
'../device.dart'
;
import
'../device.dart'
;
import
'../globals.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'../web/compile.dart'
;
import
'../web/workflow.dart'
;
import
'../web/workflow.dart'
;
import
'chrome.dart'
;
import
'chrome.dart'
;
...
@@ -32,9 +30,6 @@ class WebApplicationPackage extends ApplicationPackage {
...
@@ -32,9 +30,6 @@ class WebApplicationPackage extends ApplicationPackage {
class
WebDevice
extends
Device
{
class
WebDevice
extends
Device
{
WebDevice
()
:
super
(
'web'
);
WebDevice
()
:
super
(
'web'
);
HttpServer
_server
;
WebApplicationPackage
_package
;
@override
@override
bool
get
supportsHotReload
=>
true
;
bool
get
supportsHotReload
=>
true
;
...
@@ -120,26 +115,13 @@ class WebDevice extends Device {
...
@@ -120,26 +115,13 @@ class WebDevice extends Device {
bool
usesTerminalUi
=
true
,
bool
usesTerminalUi
=
true
,
bool
ipv6
=
false
,
bool
ipv6
=
false
,
})
async
{
})
async
{
await
buildWeb
(
// See [ResidentWebRunner.run] in flutter_tools/lib/src/resident_web_runner.dart
package
.
flutterProject
,
// for the web initialization and server logic.
fs
.
path
.
relative
(
mainPath
,
from:
package
.
flutterProject
.
directory
.
path
),
debuggingOptions
.
buildInfo
,
);
_package
=
package
;
_server
=
await
HttpServer
.
bind
(
InternetAddress
.
loopbackIPv4
,
0
);
_server
.
listen
(
_basicAssetServer
);
printStatus
(
'Serving assets from http:localhost:
${_server.port}
'
);
await
chromeLauncher
.
launch
(
'http://localhost:
${_server.port}
'
);
return
LaunchResult
.
succeeded
(
observatoryUri:
null
);
return
LaunchResult
.
succeeded
(
observatoryUri:
null
);
}
}
// Note: we don't currently have a way to track which chrome processes
// belong to the flutter tool, so we'll err on the side of caution by
// keeping these open.
@override
@override
Future
<
bool
>
stopApp
(
ApplicationPackage
app
)
async
{
Future
<
bool
>
stopApp
(
ApplicationPackage
app
)
async
{
await
_server
?.
close
();
_server
=
null
;
return
true
;
return
true
;
}
}
...
@@ -149,39 +131,6 @@ class WebDevice extends Device {
...
@@ -149,39 +131,6 @@ class WebDevice extends Device {
@override
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
Future
<
void
>
_basicAssetServer
(
HttpRequest
request
)
async
{
if
(
request
.
method
!=
'GET'
)
{
request
.
response
.
statusCode
=
HttpStatus
.
forbidden
;
await
request
.
response
.
close
();
return
;
}
// Resolve all get requests to the build/web/ or build/flutter_assets directory.
final
Uri
uri
=
request
.
uri
;
File
file
;
String
contentType
;
if
(
uri
.
path
==
'/'
)
{
file
=
_package
.
webSourcePath
.
childFile
(
'index.html'
);
contentType
=
'text/html'
;
}
else
if
(
uri
.
path
==
'/main.dart.js'
)
{
file
=
fs
.
file
(
fs
.
path
.
join
(
getWebBuildDirectory
(),
'main.dart.js'
));
contentType
=
'text/javascript'
;
}
else
{
file
=
fs
.
file
(
fs
.
path
.
join
(
getAssetBuildDirectory
(),
uri
.
path
.
replaceFirst
(
'/assets/'
,
''
)));
}
if
(!
file
.
existsSync
())
{
request
.
response
.
statusCode
=
HttpStatus
.
notFound
;
await
request
.
response
.
close
();
return
;
}
request
.
response
.
statusCode
=
HttpStatus
.
ok
;
if
(
contentType
!=
null
)
{
request
.
response
.
headers
.
add
(
HttpHeaders
.
contentTypeHeader
,
contentType
);
}
await
request
.
response
.
addStream
(
file
.
openRead
());
await
request
.
response
.
close
();
}
@override
@override
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
bool
isSupportedForProject
(
FlutterProject
flutterProject
)
{
return
flutterProject
.
web
.
existsSync
();
return
flutterProject
.
web
.
existsSync
();
...
...
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