Implementing plugin loading for api server and client
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<PackageReference Include="Blazor-ApexCharts" Version="3.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.10"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.10" PrivateAssets="all"/>
|
||||
<PackageReference Include="MoonCore" Version="1.7.4" />
|
||||
<PackageReference Include="MoonCore" Version="1.7.8" />
|
||||
<PackageReference Include="MoonCore.Blazor" Version="1.2.7" />
|
||||
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.4" />
|
||||
<PackageReference Include="MoonCore.Blazor.Tailwind" Version="1.1.2" />
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
using Moonlight.Client;
|
||||
|
||||
await Startup.Run(args, []);
|
||||
@@ -9,6 +9,7 @@ using MoonCore.Blazor.Tailwind.Forms.Components;
|
||||
using MoonCore.Extensions;
|
||||
using MoonCore.Helpers;
|
||||
using MoonCore.PluginFramework.Extensions;
|
||||
using MoonCore.Plugins;
|
||||
using Moonlight.Client.Interfaces;
|
||||
using Moonlight.Client.Services;
|
||||
using Moonlight.Client.UI;
|
||||
@@ -18,6 +19,9 @@ namespace Moonlight.Client;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
=> await Run(args, []);
|
||||
|
||||
public static async Task Run(string[] args, Assembly[] assemblies)
|
||||
{
|
||||
// Build pre run logger
|
||||
@@ -49,6 +53,16 @@ public class Startup
|
||||
|
||||
// Building app
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
|
||||
// Load plugins
|
||||
var pluginLoader = new PluginLoaderService(
|
||||
loggerFactory.CreateLogger<PluginLoaderService>()
|
||||
);
|
||||
|
||||
pluginLoader.AddHttpHostedSource($"{builder.HostEnvironment.BaseAddress}api/pluginsStream");
|
||||
await pluginLoader.Load();
|
||||
|
||||
builder.Services.AddSingleton(pluginLoader);
|
||||
|
||||
// Configure application logging
|
||||
builder.Logging.ClearProviders();
|
||||
@@ -61,7 +75,7 @@ public class Startup
|
||||
|
||||
builder.AddTokenAuthentication();
|
||||
builder.AddOAuth2();
|
||||
|
||||
|
||||
builder.Services.AddMoonCoreBlazorTailwind();
|
||||
builder.Services.AddScoped<WindowService>();
|
||||
builder.Services.AddScoped<LocalStorageService>();
|
||||
@@ -76,7 +90,10 @@ public class Startup
|
||||
builder.Services.AddPlugins(configuration =>
|
||||
{
|
||||
configuration.AddAssembly(typeof(Startup).Assembly);
|
||||
|
||||
configuration.AddAssemblies(assemblies);
|
||||
|
||||
configuration.AddAssemblies(pluginLoader.PluginAssemblies);
|
||||
|
||||
configuration.AddInterface<IAppLoader>();
|
||||
configuration.AddInterface<IAppScreen>();
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
@using Moonlight.Client.UI.Layouts
|
||||
@using MoonCore.Blazor.Components
|
||||
@using MoonCore.Plugins
|
||||
|
||||
@inject PluginLoaderService PluginLoaderService
|
||||
|
||||
<ErrorLogger>
|
||||
<OAuth2AuthenticationHandler>
|
||||
<Router AppAssembly="@typeof(App).Assembly">
|
||||
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="PluginLoaderService.PluginAssemblies">
|
||||
<Found Context="routeData">
|
||||
<CascadingValue Name="TargetPageType" Value="routeData.PageType">
|
||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
||||
|
||||
Reference in New Issue
Block a user