Skip to content

Commit 93c6972

Browse files
authored
[hooks] [code_assets] Surface input.packageRoot in more places (#2733)
1 parent 70969fa commit 93c6972

File tree

19 files changed

+163
-51
lines changed

19 files changed

+163
-51
lines changed

pkgs/code_assets/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.19.10
2+
3+
- Document `input.packageRoot` in more places.
4+
15
## 0.19.9
26

37
- Document that asset file paths must be absolute.

pkgs/code_assets/README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@ import 'package:hooks/hooks.dart';
2424
2525
void main(List<String> args) async {
2626
await build(args, (input, output) async {
27-
final packageName = input.packageName;
28-
final assetPath = input.outputDirectory.resolve('...');
29-
30-
output.assets.code.add(
31-
CodeAsset(
32-
package: packageName,
33-
name: '...',
34-
linkMode: DynamicLoadingBundled(),
35-
file: assetPath,
36-
),
37-
);
27+
if (input.config.buildCodeAssets) {
28+
final packageName = input.packageName;
29+
final assetPathInPackage = input.packageRoot.resolve('...');
30+
final assetPathDownload = input.outputDirectoryShared.resolve('...');
31+
32+
output.assets.code.add(
33+
CodeAsset(
34+
package: packageName,
35+
name: '...',
36+
linkMode: DynamicLoadingBundled(),
37+
file: assetPathInPackage,
38+
),
39+
);
40+
}
3841
});
3942
}
4043
```

pkgs/code_assets/example/api/code_assets_snippet.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,30 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// ignore_for_file: unused_local_variable
6+
7+
// dart format width=76
8+
59
// snippet-start
610
import 'package:code_assets/code_assets.dart';
711
import 'package:hooks/hooks.dart';
812

913
void main(List<String> args) async {
1014
await build(args, (input, output) async {
11-
final packageName = input.packageName;
12-
final assetPath = input.outputDirectory.resolve('...');
15+
if (input.config.buildCodeAssets) {
16+
final packageName = input.packageName;
17+
final assetPathInPackage = input.packageRoot.resolve('...');
18+
final assetPathDownload = input.outputDirectoryShared.resolve('...');
1319

14-
output.assets.code.add(
15-
CodeAsset(
16-
package: packageName,
17-
name: '...',
18-
linkMode: DynamicLoadingBundled(),
19-
file: assetPath,
20-
),
21-
);
20+
output.assets.code.add(
21+
CodeAsset(
22+
package: packageName,
23+
name: '...',
24+
linkMode: DynamicLoadingBundled(),
25+
file: assetPathInPackage,
26+
),
27+
);
28+
}
2229
});
2330
}
2431

pkgs/code_assets/lib/code_assets.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@
2828
///
2929
/// void main(List<String> args) async {
3030
/// await build(args, (input, output) async {
31-
/// final packageName = input.packageName;
32-
/// final assetPath = input.outputDirectory.resolve('...');
31+
/// if (input.config.buildCodeAssets) {
32+
/// final packageName = input.packageName;
33+
/// final assetPathInPackage = input.packageRoot.resolve('...');
34+
/// final assetPathDownload = input.outputDirectoryShared.resolve('...');
3335
///
34-
/// output.assets.code.add(
35-
/// CodeAsset(
36-
/// package: packageName,
37-
/// name: '...',
38-
/// linkMode: DynamicLoadingBundled(),
39-
/// file: assetPath,
40-
/// ),
41-
/// );
36+
/// output.assets.code.add(
37+
/// CodeAsset(
38+
/// package: packageName,
39+
/// name: '...',
40+
/// linkMode: DynamicLoadingBundled(),
41+
/// file: assetPathInPackage,
42+
/// ),
43+
/// );
44+
/// }
4245
/// });
4346
/// }
4447
/// ```

pkgs/code_assets/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >-
33
This library contains the hook protocol specification for bundling native code
44
with Dart packages.
55
6-
version: 0.19.9
6+
version: 0.19.10
77

88
repository: https://github.com/dart-lang/native/tree/main/pkgs/code_assets
99

pkgs/data_assets/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.19.5
2+
3+
- Document `input.packageRoot` in more places.
4+
15
## 0.19.4
26

37
- Document that asset file paths must be absolute.

pkgs/data_assets/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ import 'package:hooks/hooks.dart';
1818
1919
void main(List<String> args) async {
2020
await build(args, (input, output) async {
21-
final packageName = input.packageName;
22-
final assetPath = input.outputDirectory.resolve('...');
23-
24-
output.assets.data.add(
25-
DataAsset(package: packageName, name: '...', file: assetPath),
26-
);
21+
if (input.config.buildDataAssets) {
22+
final packageName = input.packageName;
23+
final assetPathInPackage = input.packageRoot.resolve('...');
24+
final assetPathDownload = input.outputDirectoryShared.resolve('...');
25+
26+
output.assets.data.add(
27+
DataAsset(
28+
package: packageName,
29+
name: '...',
30+
file: assetPathInPackage,
31+
),
32+
);
33+
}
2734
});
2835
}
2936
```

pkgs/data_assets/example/api/data_assets_snippet.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,27 @@
44

55
// dart format width=76
66

7+
// ignore_for_file: unused_local_variable
8+
79
// snippet-start
810
import 'package:data_assets/data_assets.dart';
911
import 'package:hooks/hooks.dart';
1012

1113
void main(List<String> args) async {
1214
await build(args, (input, output) async {
13-
final packageName = input.packageName;
14-
final assetPath = input.outputDirectory.resolve('...');
15+
if (input.config.buildDataAssets) {
16+
final packageName = input.packageName;
17+
final assetPathInPackage = input.packageRoot.resolve('...');
18+
final assetPathDownload = input.outputDirectoryShared.resolve('...');
1519

16-
output.assets.data.add(
17-
DataAsset(package: packageName, name: '...', file: assetPath),
18-
);
20+
output.assets.data.add(
21+
DataAsset(
22+
package: packageName,
23+
name: '...',
24+
file: assetPathInPackage,
25+
),
26+
);
27+
}
1928
});
2029
}
2130

pkgs/data_assets/lib/data_assets.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@
1919
///
2020
/// void main(List<String> args) async {
2121
/// await build(args, (input, output) async {
22-
/// final packageName = input.packageName;
23-
/// final assetPath = input.outputDirectory.resolve('...');
22+
/// if (input.config.buildDataAssets) {
23+
/// final packageName = input.packageName;
24+
/// final assetPathInPackage = input.packageRoot.resolve('...');
25+
/// final assetPathDownload = input.outputDirectoryShared.resolve('...');
2426
///
25-
/// output.assets.data.add(
26-
/// DataAsset(package: packageName, name: '...', file: assetPath),
27-
/// );
27+
/// output.assets.data.add(
28+
/// DataAsset(
29+
/// package: packageName,
30+
/// name: '...',
31+
/// file: assetPathInPackage,
32+
/// ),
33+
/// );
34+
/// }
2835
/// });
2936
/// }
3037
/// ```

pkgs/data_assets/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >-
33
This library contains the hook protocol specification for bundling data assets
44
with Dart packages.
55
6-
version: 0.19.4
6+
version: 0.19.5
77

88
repository: https://github.com/dart-lang/native/tree/main/pkgs/data_assets
99

0 commit comments

Comments
 (0)