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
f1186b07
Unverified
Commit
f1186b07
authored
Nov 02, 2019
by
Jonah Williams
Committed by
GitHub
Nov 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asset server fix for sourcemaps (#44017)
parent
ade8dfac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
12 deletions
+55
-12
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+24
-12
asset_server_test.dart
...utter_tools/test/general.shard/web/asset_server_test.dart
+31
-0
No files found.
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
f1186b07
...
...
@@ -442,37 +442,49 @@ class DebugAssetServer extends AssetServer {
return
Response
.
ok
(
file
.
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/javascript'
,
});
}
else
if
(
request
.
url
.
path
.
endsWith
(
'dart_sdk.js'
))
{
}
else
if
(
request
.
url
.
path
.
endsWith
(
'dart_sdk.js
.map
'
))
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
),
'kernel'
,
'amd'
,
'dart_sdk.js'
,
'dart_sdk.js
.map
'
,
));
return
Response
.
ok
(
file
.
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/javascript'
,
});
}
else
if
(
request
.
url
.
path
.
endsWith
(
'dart_sdk.js.map'
))
{
return
Response
.
ok
(
file
.
readAsBytesSync
());
}
else
if
(
request
.
url
.
path
.
endsWith
(
'dart_sdk.js'
))
{
final
File
file
=
fs
.
file
(
fs
.
path
.
join
(
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
),
'kernel'
,
'amd'
,
'dart_sdk.js
.map
'
,
'dart_sdk.js'
,
));
return
Response
.
ok
(
file
.
readAsBytesSync
());
return
Response
.
ok
(
file
.
readAsBytesSync
(),
headers:
<
String
,
String
>{
'Content-Type'
:
'text/javascript'
,
});
}
else
if
(
request
.
url
.
path
.
endsWith
(
'.dart'
))
{
// This is likely a sourcemap request. The first segment is the
// package name, and the rest is the path to the file relative to
// the package uri. For example, `foo/bar.dart` would represent a
// file at a path like `foo/lib/bar.dart`. If there is no leading
// segment, then we assume it is from the current package.
String
basePath
=
request
.
url
.
path
;
basePath
=
basePath
.
replaceFirst
(
'packages/build_web_compilers/'
,
''
);
basePath
=
basePath
.
replaceFirst
(
'packages/'
,
''
);
// Handle sdk requests that have mangled urls from engine build.
if
(
request
.
url
.
path
.
contains
(
'
flutter_web_
sdk'
))
{
if
(
request
.
url
.
path
.
contains
(
'
dart-
sdk'
))
{
// Note: the request is a uri and not a file path, so they always use `/`.
final
String
sdkPath
=
fs
.
path
.
joinAll
(
request
.
url
.
path
.
split
(
'flutter_web_sdk/'
).
last
.
split
(
'/'
));
final
String
webSdkPath
=
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
);
return
Response
.
ok
(
fs
.
file
(
fs
.
path
.
join
(
webSdkPath
,
sdkPath
)).
readAsBytesSync
());
final
String
sdkPath
=
fs
.
path
.
joinAll
(
request
.
url
.
path
.
split
(
'dart-sdk/'
).
last
.
split
(
'/'
));
final
String
dartSdkPath
=
artifacts
.
getArtifactPath
(
Artifact
.
engineDartSdkPath
);
final
File
candidateFile
=
fs
.
file
(
fs
.
path
.
join
(
dartSdkPath
,
sdkPath
));
return
Response
.
ok
(
candidateFile
.
readAsBytesSync
());
}
// See if it is a flutter sdk path.
final
String
webSdkPath
=
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
);
final
File
candidateFile
=
fs
.
file
(
fs
.
path
.
join
(
webSdkPath
,
basePath
.
split
(
'/'
).
join
(
platform
.
pathSeparator
)));
if
(
candidateFile
.
existsSync
())
{
return
Response
.
ok
(
candidateFile
.
readAsBytesSync
());
}
final
String
packageName
=
request
.
url
.
pathSegments
.
length
==
1
...
...
packages/flutter_tools/test/general.shard/web/asset_server_test.dart
View file @
f1186b07
...
...
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/build_runner/web_fs.dart'
;
import
'package:flutter_tools/src/globals.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:shelf/shelf.dart'
;
...
...
@@ -52,6 +54,35 @@ void main() {
expect
(
await
response
.
readAsString
(),
'hello'
);
}));
test
(
'can serve a sourcemap from dart:ui'
,
()
=>
testbed
.
run
(()
async
{
final
String
flutterWebSdkPath
=
artifacts
.
getArtifactPath
(
Artifact
.
flutterWebSdk
);
final
File
windowSourceFile
=
fs
.
file
(
fs
.
path
.
join
(
flutterWebSdkPath
,
'lib'
,
'ui'
,
'src'
,
'ui'
,
'window.dart'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'test'
);
final
Response
response
=
await
assetServer
.
handle
(
Request
(
'GET'
,
Uri
.
parse
(
'http://localhost:8080/packages/build_web_compilers/lib/ui/src/ui/window.dart'
)));
expect
(
response
.
headers
,
<
String
,
String
>{
'content-length'
:
windowSourceFile
.
lengthSync
().
toString
(),
});
expect
(
await
response
.
readAsString
(),
'test'
);
}));
test
(
'can serve a sourcemap from the dart:sdk'
,
()
=>
testbed
.
run
(()
async
{
final
String
dartSdkPath
=
artifacts
.
getArtifactPath
(
Artifact
.
engineDartSdkPath
);
final
File
listSourceFile
=
fs
.
file
(
fs
.
path
.
join
(
dartSdkPath
,
'lib'
,
'core'
,
'list.dart'
))
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
'test'
);
final
Response
response
=
await
assetServer
.
handle
(
Request
(
'GET'
,
Uri
.
parse
(
'http://localhost:8080/packages/dart-sdk/lib/core/list.dart'
)));
expect
(
response
.
headers
,
<
String
,
String
>{
'content-length'
:
listSourceFile
.
lengthSync
().
toString
(),
});
expect
(
await
response
.
readAsString
(),
'test'
);
}));
test
(
'can serve an asset with a png content type'
,
()
=>
testbed
.
run
(()
async
{
final
Response
response
=
await
assetServer
.
handle
(
Request
(
'GET'
,
Uri
.
parse
(
'http://localhost:8080/assets/foo.png'
)));
...
...
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