@@ -10,6 +10,7 @@ import 'package:collection/collection.dart';
10
10
import 'package:pub_semver/pub_semver.dart' ;
11
11
12
12
import '../model/hook.dart' ;
13
+ import '../model/resource_identifiers.dart' ;
13
14
import '../utils/map.dart' ;
14
15
import 'architecture.dart' ;
15
16
import 'asset.dart' ;
@@ -19,18 +20,28 @@ import 'hook_config.dart';
19
20
import 'ios_sdk.dart' ;
20
21
import 'link_mode_preference.dart' ;
21
22
import 'os.dart' ;
23
+ import 'resource.dart' ;
22
24
23
25
part '../model/link_config.dart' ;
24
26
25
27
/// The configuration for a link hook (`hook/link.dart` ) invocation.
26
28
///
27
29
/// It consists of a subset of the fields from the [BuildConfig] already passed
28
- /// to the build hook and the [assets] from the build step.
30
+ /// to the build hook, the [assets] from the build step, and the
31
+ /// [treeshakingInformation] generated during the kernel compilation.
29
32
abstract class LinkConfig implements HookConfig {
30
33
/// The list of assets to be linked. These are the assets generated by a
31
34
/// `build.dart` script destined for this packages `link.dart` .
32
35
Iterable <Asset > get assets;
33
36
37
+ /// A collection of methods annotated with `@ResourceIdentifier` , which are
38
+ /// called in the tree-shaken Dart code. This information can be used to
39
+ /// dispose unused [assets] .
40
+ ///
41
+ /// This is `null` in JIT mode, where no resources are collected, or in a dry
42
+ /// run.
43
+ Iterable <Resource >? get treeshakingInformation;
44
+
34
45
/// Generate the [LinkConfig] from the input arguments to the linking script.
35
46
factory LinkConfig .fromArguments (List <String > arguments) =>
36
47
LinkConfigImpl .fromArguments (arguments);
@@ -47,12 +58,14 @@ abstract class LinkConfig implements HookConfig {
47
58
List <String >? supportedAssetTypes,
48
59
int ? targetAndroidNdkApi,
49
60
required Iterable <Asset > assets,
61
+ Uri ? resourceIdentifierUri,
50
62
required LinkModePreference linkModePreference,
51
63
bool ? dryRun,
52
64
Version ? version,
53
65
}) =>
54
66
LinkConfigImpl (
55
67
assets: assets.cast (),
68
+ resourceIdentifierUri: resourceIdentifierUri,
56
69
outputDirectory: outputDirectory,
57
70
packageName: packageName,
58
71
packageRoot: packageRoot,
@@ -75,11 +88,13 @@ abstract class LinkConfig implements HookConfig {
75
88
required OS targetOS,
76
89
List <String >? supportedAssetTypes,
77
90
required Iterable <Asset > assets,
91
+ Uri ? resourceIdentifierUri,
78
92
required LinkModePreference linkModePreference,
79
93
Version ? version,
80
94
}) =>
81
95
LinkConfigImpl .dryRun (
82
96
assets: assets.cast (),
97
+ resourceIdentifierUri: resourceIdentifierUri,
83
98
outputDirectory: outputDirectory,
84
99
packageName: packageName,
85
100
packageRoot: packageRoot,
0 commit comments