Added AssetService. Added command line handling for assets. Added asset streaming on the client

This commit is contained in:
2024-12-01 18:34:08 +01:00
parent 2e98d166ec
commit 0a76e64d2f
5 changed files with 134 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ using Moonlight.Client.Interfaces;
using Moonlight.Client.Services;
using Moonlight.Client.UI;
using Moonlight.Client.UI.Forms;
using Moonlight.Shared.Http.Responses.Assets;
using Moonlight.Shared.Http.Responses.PluginsStream;
namespace Moonlight.Client;
@@ -50,7 +51,7 @@ public class Startup
await SetupLogging();
await CreateWebAssemblyHostBuilder();
await LoadPlugins();
await RegisterLogging();
@@ -62,6 +63,7 @@ public class Startup
await BuildWebAssemblyHost();
await LoadPluginAssets();
await LoadAssets();
await WebAssemblyHost.RunAsync();
}
@@ -124,6 +126,24 @@ public class Startup
return Task.CompletedTask;
}
#region Asset Loading
private async Task LoadAssets()
{
var apiClient = WebAssemblyHost.Services.GetRequiredService<HttpApiClient>();
var assetManifest = await apiClient.GetJson<FrontendAssetResponse>("api/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 Interfaces
private Task RegisterInterfaces()