Improved asset service. Removed now unused plugin asset streaming endpoint

This commit is contained in:
2024-12-01 20:04:29 +01:00
parent 0a76e64d2f
commit 62fe6089f7
6 changed files with 83 additions and 54 deletions

View File

@@ -62,7 +62,6 @@ public class Startup
await BuildWebAssemblyHost();
await LoadPluginAssets();
await LoadAssets();
await WebAssemblyHost.RunAsync();
@@ -176,7 +175,7 @@ public class Startup
);
// Build source from the retrieved data
var pluginsStreamUrl = $"{WebAssemblyHostBuilder.HostEnvironment.BaseAddress}api/pluginsStream";
var pluginsStreamUrl = $"{WebAssemblyHostBuilder.HostEnvironment.BaseAddress}api/assets/plugins";
PluginLoaderService.AddHttpHostedSource(pluginsStreamUrl);
// Perform assembly loading
@@ -188,20 +187,6 @@ public class Startup
WebAssemblyHostBuilder.Services.AddSingleton(ApplicationAssemblyService);
}
private async Task LoadPluginAssets()
{
var apiClient = WebAssemblyHost.Services.GetRequiredService<HttpApiClient>();
var assetManifest = await apiClient.GetJson<PluginsAssetManifest>("api/pluginsStream/assets");
var jsRuntime = WebAssemblyHost.Services.GetRequiredService<IJSRuntime>();
foreach (var cssFile in assetManifest.CssFiles)
await jsRuntime.InvokeVoidAsync("moonlight.assets.loadCss", cssFile);
foreach (var javascriptFile in assetManifest.JavascriptFiles)
await jsRuntime.InvokeVoidAsync("moonlight.assets.loadJavascript", javascriptFile);
}
#endregion
#region Logging