-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[native_assets_cli] NativeCodeAsset
and DataAsset
should accept an assetId
instead of package
and name
.
#1410
Comments
This was changed in #946 based on feedback from @mosuem that having the If I remember correctly, the wish was to have the package name be automatic. But since the assets are data classes, and we have a single add method for assets rather than a new add method for I also don't mind having We could have an extension type |
Users of this system will write And using |
I disagree. Using a "non-typed" API by requiring a string in a certain format is (IMO much) worse than making the format explicit.
Agree there.
Yes, I think it is weird to ask the user to supply information we already have. The user should just choose the name, then the point about non-package uris would also be moot. |
(it has colons, quotes, commas spaces) than It doesn't prevent errors either, because I may supply the wrong package or names values. The only thing it really does is it adds a If we have an invariant that any asset ID must start with I understand the urge to model things very detailed with Dart classes, but it often leads to over engineered and hard to use APIs. (Tangential example: We used to have a
The "format" is a ID for which a The fact that currently the system restricts it to be
This asymmetric API is super confusing and I'm strongly opposed to this (me as a user of this have made mistakes due to this asymmetry several times). We should have (Strongly in favor of KISS design principle - keep things simple, not over-engineer APIs, ...) |
Agree.
Also agree - my problem is that I am always unsure what to type in
I agree that one has to be careful with this. In this case, we are talking about two components, so it's fine to model things in a more detailed way.
Maybe that is the issue to tackle here first before deciding on the API. If we do want this restriction, we should auto-fill that information when adding assets, and have a named argument |
Hm, that's interesting. But that would break the symmetry omitting Build hooks may only report assets that start with Since the reporting is restrictive in the build hook but not in the link hook and not in uses, and if we do want symmetry in reporting and using, we redundantly have to repeat
That's not allowed currently. Maybe we should? Or maybe we should clamp down our design and say we're never going to allow other schemes than |
One can make this just fine. Because this is passed to a high-level API which is implemented in terms of a lower-level one, this implementation has to eventually bottom out on a data asset and use it's naming convention. You can see an example in my recently sent out CLs pkg/asset/lib/hook.dart & pkg/asset/lib/asset.dart which re-writes asset names from higher level names to lower level ones. I think one would want to have it like this because a
Thereby ensuring that if you have a higher-level asset (intl, shader, ...) you can only load it using those higher-level apis (intl api, shader api) and you'll get the tree shaking as you're supposed to. => Want to effectively have a different ID namespace for every higher level, tree shakeable abstraction. |
NativeCodeAsset
and DataAsset
should accept an assetId
instead of package
and name
.NativeCodeAsset
and DataAsset
should accept an assetId
instead of package
and name
.
Notes from discussion today. The majority prefers having separate arguments/getters over exposing the assetID string. And we should ensure that we then do the same everywhere. A hopefully exhaustive list:
I've cooked up some CLs to change the API in this package: |
We should set us up for a future, where on the lowest level, we support various kind of asset types. Those asset types may be extensions to the basic build/hook protocol. None of the asset kinds are any more special than others, they should all be on same footing. Because of this, I think we should decouple (Imagine a => So the first step I think is to decouple the We may not want to model this as a (It could possibly be Then the next step is to decide for all asset kinds individually what the best hook API and runtime API looks like - it may choose a different way for code assets and data assets. But I think for a specific asset kind the hook API and the runtime API should refer to them the same way (i.e. symmetric API) to make it easy for users to understand the connection between their There are considerations that may lead to different outcomes for the code & data assets:
(Apologies for the long comment) |
Yes. We can rename files and rewrite dynamic linker imports for iOS/MacOS, but not for Linux. #1425
How do you envision the default asset ids to work in this scenario if we don't default to library URI.
Before we end up doing that rewrite, should we land any of the 3 PRs, if not I'll just close them and leave it beautifully asymmetric until we get to that rewrite. As discussed offline, the rewrite of the Dart API is less urgent than getting the JSON protocol correct. |
Currently there is asymmetry between hooks and runtime
NativeCodeAsset(package: ..., name: ...)
@Native<Void Function()>(assetId: '...')
we should remove this asymmetry by only requiring an
assetId
everywhere.The text was updated successfully, but these errors were encountered: