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
2f057519
Unverified
Commit
2f057519
authored
Mar 24, 2021
by
Gary Qian
Committed by
GitHub
Mar 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record deferred components assets in AssetManifest.json (#78824)
parent
9f49181f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
5 deletions
+60
-5
asset.dart
packages/flutter_tools/lib/src/asset.dart
+23
-5
asset_bundle_test.dart
...s/flutter_tools/test/general.shard/asset_bundle_test.dart
+37
-0
No files found.
packages/flutter_tools/lib/src/asset.dart
View file @
2f057519
...
...
@@ -399,7 +399,7 @@ class ManifestAssetBundle implements AssetBundle {
_wildcardDirectories
[
uri
]
??=
_fileSystem
.
directory
(
uri
);
}
final
DevFSStringContent
assetManifest
=
_createAssetManifest
(
assetVariants
);
final
DevFSStringContent
assetManifest
=
_createAssetManifest
(
assetVariants
,
deferredComponentsAssetVariants
);
final
DevFSStringContent
fontManifest
=
DevFSStringContent
(
json
.
encode
(
fonts
));
final
LicenseResult
licenseResult
=
_licenseCollector
.
obtainLicenses
(
packageConfig
,
additionalLicenseFiles
);
if
(
licenseResult
.
errorMessages
.
isNotEmpty
)
{
...
...
@@ -524,16 +524,34 @@ class ManifestAssetBundle implements AssetBundle {
return
deferredComponentsAssetVariants
;
}
DevFSStringContent
_createAssetManifest
(
Map
<
_Asset
,
List
<
_Asset
>>
assetVariants
)
{
DevFSStringContent
_createAssetManifest
(
Map
<
_Asset
,
List
<
_Asset
>>
assetVariants
,
Map
<
String
,
Map
<
_Asset
,
List
<
_Asset
>>>
deferredComponentsAssetVariants
)
{
final
Map
<
String
,
List
<
String
>>
jsonObject
=
<
String
,
List
<
String
>>{};
final
List
<
_Asset
>
assets
=
assetVariants
.
keys
.
toList
()
..
sort
((
_Asset
left
,
_Asset
right
)
=>
left
.
entryUri
.
path
.
compareTo
(
right
.
entryUri
.
path
))
;
final
List
<
_Asset
>
assets
=
assetVariants
.
keys
.
toList
()
;
final
Map
<
_Asset
,
List
<
String
>>
jsonEntries
=
<
_Asset
,
List
<
String
>>{}
;
for
(
final
_Asset
main
in
assets
)
{
json
Object
[
main
.
entryUri
.
path
]
=
<
String
>[
json
Entries
[
main
]
=
<
String
>[
for
(
final
_Asset
variant
in
assetVariants
[
main
])
variant
.
entryUri
.
path
,
];
}
if
(
deferredComponentsAssetVariants
!=
null
)
{
for
(
final
Map
<
_Asset
,
List
<
_Asset
>>
componentAssets
in
deferredComponentsAssetVariants
.
values
)
{
for
(
final
_Asset
main
in
componentAssets
.
keys
)
{
jsonEntries
[
main
]
=
<
String
>[
for
(
final
_Asset
variant
in
componentAssets
[
main
])
variant
.
entryUri
.
path
,
];
}
}
}
final
List
<
_Asset
>
sortedKeys
=
jsonEntries
.
keys
.
toList
()
..
sort
((
_Asset
left
,
_Asset
right
)
=>
left
.
entryUri
.
path
.
compareTo
(
right
.
entryUri
.
path
));
for
(
final
_Asset
main
in
sortedKeys
)
{
jsonObject
[
main
.
entryUri
.
path
]
=
jsonEntries
[
main
];
}
return
DevFSStringContent
(
json
.
encode
(
jsonObject
));
}
...
...
packages/flutter_tools/test/general.shard/asset_bundle_test.dart
View file @
2f057519
...
...
@@ -591,4 +591,41 @@ flutter:
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
),
});
testUsingContext
(
'deferred and regular assets are included in manifest alphabetically'
,
()
async
{
globals
.
fs
.
file
(
'.packages'
).
writeAsStringSync
(
r''
'
example:lib/
'''
);
globals
.
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
name: example
flutter:
assets:
- assets/zebra.jpg
- assets/foo.jpg
deferred-components:
- name: component1
assets:
- assets/bar.jpg
- assets/apple.jpg
'''
);
globals
.
fs
.
file
(
'assets/foo.jpg'
).
createSync
(
recursive:
true
);
globals
.
fs
.
file
(
'assets/bar.jpg'
).
createSync
();
globals
.
fs
.
file
(
'assets/apple.jpg'
).
createSync
();
globals
.
fs
.
file
(
'assets/zebra.jpg'
).
createSync
();
final
AssetBundle
bundle
=
AssetBundleFactory
.
instance
.
createBundle
();
expect
(
await
bundle
.
build
(
manifestPath:
'pubspec.yaml'
,
packagesPath:
'.packages'
),
0
);
expect
((
bundle
.
entries
[
'FontManifest.json'
]
as
DevFSStringContent
).
string
,
'[]'
);
// The assets from deferred components and regular assets
// are both included in alphabetical order
expect
((
bundle
.
entries
[
'AssetManifest.json'
]
as
DevFSStringContent
).
string
,
'{"assets/apple.jpg":["assets/apple.jpg"],"assets/bar.jpg":["assets/bar.jpg"],"assets/foo.jpg":["assets/foo.jpg"],"assets/zebra.jpg":["assets/zebra.jpg"]}'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
),
});
}
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