Description
While discussing with @mosuem we realized that many asset types will have a build-time API and run-time API in the same package.
This is nice, because it means that the these APIs can point to each other:
// package:my_asset/declaration.dart
/// A declaration for my asset.
///
/// Use this asset at runtime via [MyAsset].
class MyAssetDeclaration {
}
// package:my_asset/my_asset.dart
/// My asset.
///
/// Declare assets in hooks via [MyAssetDeclaration].
class MyAsset {
}
This is nice because the runtime API is version locked with the declaration API. So for assets built on top of data assets the serialization to JSON/bytes/... in the build hook and deserialization at runtime does not have to deal with version skew.
(CodeAsset
s are weird because they use @Native
as runtime API. DataAsset
s are somewhat special because the implementation is in the SDK, but the public API is still in a package: currently package:assets
. This should most likely be moved to be together with package:data_assets
which should also contain the declaration.)
The API used at runtime and build-time should be disjoint, which calls for having two libraries which can be imported separately:
package:my_asset/declaration.dart
for use in hooks.package:my_asset/my_asset.dart
for use at runtime.
Now, we have a questions about naming.
- How do we name the class used at build-time and the one named at run-time? (They could both be named
MyAsset
since they're available under different import paths, but that's likely going to be very confusing.)- build-time:
DataAssetDeclaration
,DataAssetDefinition
,BuildDataAsset
, ... - runtime:
DataAsset
- build-time:
- How do we name the libraries?
- build-time:
package:data_assets/for_hooks.dart
,package:data_assets/declaration.dart
, ... - runtime:
package:data_assets/data_assets.dart
,package:data_assets/runtime.dart
,package:data_assets/use.dart
, ...
- build-time:
Metadata
Metadata
Assignees
Type
Projects
Status