using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.Authorization; using NexusReader.Application.Abstractions.Services; using NexusReader.Web.Client.Services; using NexusReader.UI.Shared.Services; using NexusReader.Application; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.AI; using NexusReader.Data.Persistence; var builder = WebAssemblyHostBuilder.CreateDefault(args); // Platform & UI Services builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); // Identity & Auth Services builder.Services.AddOptions(); builder.Services.AddAuthorizationCore(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(sp => sp.GetRequiredService()); builder.Services.AddCascadingAuthenticationState(); // AI & Content Services builder.Services.AddScoped(); builder.Services.AddTransient(); builder.Services.AddHttpClient("NexusAPI", client => { client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress); }).AddHttpMessageHandler(); builder.Services.AddScoped(sp => sp.GetRequiredService().CreateClient("NexusAPI")); // Dummy registrations for server-only handlers to satisfy DI validation builder.Services.AddSingleton>(new ThrowingDbContextFactory()); builder.Services.AddSingleton>>(new ThrowingEmbeddingGenerator()); builder.Services.AddApplication(); builder.Services.AddScoped(); builder.Services.AddScoped(); await builder.Build().RunAsync(); public class ThrowingDbContextFactory : IDbContextFactory { public AppDbContext CreateDbContext() => throw new NotSupportedException("DbContext cannot be used in WASM client."); } public class ThrowingEmbeddingGenerator : IEmbeddingGenerator> { public void Dispose() { } public Task>> GenerateAsync(IEnumerable values, EmbeddingGenerationOptions? options = null, CancellationToken cancellationToken = default) => throw new NotSupportedException("Embedding generation cannot be used in WASM client."); public object? GetService(Type serviceType, object? serviceKey = null) => null; }