-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
[Static Web Assets] Runtime APIs to consume the generated endpoint manifest from the SDK #54875
Comments
Static assets compression API reviewUsage// This is it, its equivalent to UseStaticFiles but endpoint aware. The vast majority of the functionality on static files is not needed for most web apps (and you can still reach for it if you need it) and this optimizes serving the known assets at compile/publish time from your app, which is the most common scenario for web apps by far. app.MapStaticAssetEndpoints() // You might want to specify a path to the manifest, this is useful for testing scenarios and for scenarios like web assembly, which is "its own app" hosted inside an asp.net core process. app.MapStaticAssetEndpoints("MyWebAssemblyApp.staticwebassets.endpoints.json"); // Used to indicate webassembly the path to the manifest where its files live. It's only ever set in the case you might have more than one webassembly application. app.MapStaticWebAssetEndpoints("<<manifest-path>>");
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode(options => options.AssetsManifestPath = "<<manifest-path>>") Common APIs users interact withnamespace Microsoft.AspNetCore.Builder;
+public static class StaticAssetsEndpointRouteBuilderExtensions
+{
+ public static StaticAssetsEndpointConventionBuilder MapStaticAssetEndpoints(this IEndpointRouteBuilder endpoints, string? staticAssetsManifestPath = null);
+} public sealed class WebAssemblyComponentsEndpointOptions
{
+ public string? AssetsManifestPath { get; set; }
} Other APIs that are public because of layering and other aspectsMetadata added to an endpoint to indicate is compressed. +namespace Microsoft.AspNetCore.Routing.Matching;
+public class ContentEncodingMetadata(string value, double quality)
+{
+ public string Value { get; } = value;
+ public double Quality { get; } = quality;
+} Plumbingpublic static class ComponentEndpointConventionBuilderHelper
{
+ public static IEndpointRouteBuilder GetEndpointRouteBuilder(RazorComponentsEndpointConventionBuilder builder)
} namespace Microsoft.AspNetCore.Builder;
+public static class StaticAssetsEndpointRouteBuilderExtensions
+{
+ public static StaticAssetsEndpointConventionBuilder MapStaticAssetEndpoints(this IEndpointRouteBuilder endpoints, string? staticAssetsManifestPath = null);
+} +namespace Microsoft.AspNetCore.StaticAssets;
+public class StaticAssetsEndpointConventionBuilder : IEndpointConventionBuilder
+{
+ public void Add(Action<EndpointBuilder> convention);
+ public void Finally(Action<EndpointBuilder> convention);
+} +namespace Microsoft.AspNetCore.StaticAssets
+public class StaticAssetsEndpointDataSource : EndpointDataSource
+{
+ public string ManifestPath { get; }
+ public StaticAssetsEndpointConventionBuilder DefaultBuilder { get; }
// From Endpoint data source
+ public override IReadOnlyList<Endpoint> Endpoints { get; }
+ public override IChangeToken GetChangeToken()
+} |
API Review Notes:
API Approved! +// Microsoft.AspNetCore.StaticAssets.dll
namespace Microsoft.AspNetCore.Builder;
+public static class StaticAssetsEndpointRouteBuilderExtensions
+{
+ public static StaticAssetsEndpointConventionBuilder MapStaticAssets(this IEndpointRouteBuilder endpoints, string? staticAssetsManifestPath = null);
+}
// Microsoft.AspNetCore.Components.WebAssembly.Server.dll
namespace Microsoft.AspNetCore.Components.WebAssembly.Server;
public sealed class WebAssemblyComponentsEndpointOptions
{
+ public string? StaticAssetsManifestPath { get; set; }
}
// Microsoft.AspNetCore.Routing.dll
+namespace Microsoft.AspNetCore.Routing;
+public sealed class ContentEncodingMetadata(string value, double quality)
+{
+ public string Value { get; } = value;
+ public double Quality { get; } = quality;
+}
// Microsoft.AspNetCore.Components.Endpoints.dll
namespace Microsoft.AspNetCore.Components.Endpoints.Infrastructure;
public static class ComponentEndpointConventionBuilderHelper
{
+ public static IEndpointRouteBuilder GetEndpointRouteBuilder(RazorComponentsEndpointConventionBuilder builder)
}
+// Microsoft.AspNetCore.StaticAssets.dll
+namespace Microsoft.AspNetCore.StaticAssets;
+public sealed class StaticAssetsEndpointConventionBuilder : IEndpointConventionBuilder
+{
+ public void Add(Action<EndpointBuilder> convention);
+ public void Finally(Action<EndpointBuilder> convention);
+}
+public sealed class StaticAssetsEndpointDataSource : EndpointDataSource
+{
+ public string ManifestPath { get; }
// From Endpoint data source
+ public override IReadOnlyList<Endpoint> Endpoints { get; }
+ public override IChangeToken GetChangeToken()
+} |
We need a few runtime APIs to consume the static web asset endpoints manifest in different locations:
API to find the fingerprinted route for an asset given their "canonical" name.UpdateUrl
tag helper to automatically apply fingerprinted versions where possible.Razor component to use the fingerprinted version of an asset.The text was updated successfully, but these errors were encountered: