Switched to SimplePlugin plugin loader #16

Merged
ChiaraBm merged 1 commits from feat/SwitchPluginLoader into v2.1 2026-02-18 12:57:22 +00:00
12 changed files with 36 additions and 37 deletions
Showing only changes of commit 1fc33ebf03 - Show all commits

View File

@@ -1,10 +0,0 @@
using MoonCore.PluginFramework;
using Moonlight.Api.Startup;
namespace Moonlight.Api.Host;
[PluginLoader]
public partial class AppStartupLoader : IAppStartup
{
}

View File

@@ -7,8 +7,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.9"/>
<PackageReference Include="MoonCore.PluginFramework.Generator" Version="1.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.1"/>
@@ -16,6 +14,9 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SimplePlugin" Version="1.0.2" />
<PackageReference Include="SimplePlugin.Abstractions" Version="1.0.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,17 +1,22 @@
using Moonlight.Api.Host;
using Moonlight.Api.Startup;
using SimplePlugin.Generated;
var appLoader = new AppStartupLoader();
appLoader.Initialize();
var modules = PluginRegistry.Modules
.OfType<IAppStartup>()
.ToArray();
var builder = WebApplication.CreateBuilder(args);
appLoader.PreBuild(builder);
foreach (var startup in modules)
startup.PreBuild(builder);
var app = builder.Build();
appLoader.PostBuild(app);
foreach (var startup in modules)
startup.PostBuild(app);
appLoader.PostMiddleware(app);
foreach (var startup in modules)
startup.PostMiddleware(app);
if (app.Environment.IsDevelopment())
app.UseWebAssemblyDebugging();

View File

@@ -1,10 +0,0 @@
using MoonCore.PluginFramework;
using Moonlight.Frontend.Startup;
namespace Moonlight.Frontend.Host;
[PluginLoader]
public partial class AppStartupLoader : IAppStartup
{
}

View File

@@ -14,8 +14,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.1"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.1" PrivateAssets="all"/>
<PackageReference Include="MoonCore.PluginFramework" Version="1.0.9"/>
<PackageReference Include="MoonCore.PluginFramework.Generator" Version="1.0.3"/>
<PackageReference Include="SimplePlugin" Version="1.0.2" />
<PackageReference Include="SimplePlugin.Abstractions" Version="1.0.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,15 +1,20 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Moonlight.Frontend.Host;
using Moonlight.Frontend.Startup;
using SimplePlugin.Generated;
var appLoader = new AppStartupLoader();
appLoader.Initialize();
var modules = PluginRegistry
.Modules
.OfType<IAppStartup>()
.ToArray();
var builder = WebAssemblyHostBuilder.CreateDefault(args);
appLoader.PreBuild(builder);
foreach (var startup in modules)
startup.PreBuild(builder);
var app = builder.Build();
appLoader.PostBuild(app);
foreach(var startup in modules)
startup.PostBuild(app);
await app.RunAsync();

View File

@@ -30,6 +30,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="10.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0"/>
<PackageReference Include="Riok.Mapperly" Version="4.3.1-next.0"/>
<PackageReference Include="SimplePlugin.Abstractions" Version="1.0.2" />
<PackageReference Include="VYaml" Version="1.2.0" />
</ItemGroup>

View File

@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Builder;
using SimplePlugin.Abstractions;
namespace Moonlight.Api.Startup;
public interface IAppStartup
public interface IAppStartup : IPluginModule
{
public void PreBuild(WebApplicationBuilder builder);
public void PostBuild(WebApplication application);

View File

@@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Builder;
using SimplePlugin.Abstractions;
namespace Moonlight.Api.Startup;
[PluginModule]
public partial class Startup : IAppStartup
{
public void PreBuild(WebApplicationBuilder builder)

View File

@@ -26,6 +26,7 @@
<PackageReference Include="Riok.Mapperly" Version="4.3.1-next.0"/>
<PackageReference Include="ShadcnBlazor" Version="1.0.11" />
<PackageReference Include="ShadcnBlazor.Extras" Version="1.0.11" />
<PackageReference Include="SimplePlugin.Abstractions" Version="1.0.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SimplePlugin.Abstractions;
namespace Moonlight.Frontend.Startup;
public interface IAppStartup
public interface IAppStartup : IPluginModule
{
public void PreBuild(WebAssemblyHostBuilder builder);
public void PostBuild(WebAssemblyHost application);

View File

@@ -1,7 +1,9 @@
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using SimplePlugin.Abstractions;
namespace Moonlight.Frontend.Startup;
[PluginModule]
public partial class Startup : IAppStartup
{
public void PreBuild(WebAssemblyHostBuilder builder)