diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 78de689..1c033f4 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,17 +10,17 @@ jobs: runs-on: ubuntu-latest steps: # Checkout the code - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - # Install .NET Core SDK - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + # Install .NET SDK + - name: Setup .NET SDK + uses: actions/setup-dotnet@v2 with: - dotnet-version: 5.0.401 + dotnet-version: 8.0.x # Publish the site - name: Publish - run: dotnet publish SampleSites/Client/SampleSite.Client.csproj -c:Release -o:public -p:GHPages=true -f:net5.0 + run: dotnet publish SampleSites/Client/SampleSite.Client.csproj -c:Release -o:public -p:GHPages=true -f:net8.0 # Deploy the site - name: Deploy diff --git a/SampleSites/Client/Program.cs b/SampleSites/Client/Program.cs index b740fbf..5fec7f4 100644 --- a/SampleSites/Client/Program.cs +++ b/SampleSites/Client/Program.cs @@ -1,30 +1,17 @@ -using System.Threading.Tasks; +using SampleSite.Components; +using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using Microsoft.Extensions.DependencyInjection; -using SampleSite.Components; using Toolbelt.Blazor.Extensions.DependencyInjection; -namespace SampleSite.Client -{ - public class Program - { - public static async Task Main(string[] args) - { - var builder = WebAssemblyHostBuilder.CreateDefault(args); - builder.RootComponents.Add("#app"); - - ConfigureServices(builder.Services); +var builder = WebAssemblyHostBuilder.CreateDefault(args); +builder.RootComponents.Add("#app"); +builder.RootComponents.Add("head::after"); - await builder.Build().RunAsync(); - } +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +builder.Services.AddHeadElementHelper(); +builder.Services.AddGamepadList(options => +{ + //options.DisableClientScriptAutoInjection = true; +}); - private static void ConfigureServices(IServiceCollection services) - { - services.AddHeadElementHelper(); - services.AddGamepadList(options => - { - //options.DisableClientScriptAutoInjection = true; - }); - } - } -} +await builder.Build().RunAsync(); diff --git a/SampleSites/Client/Properties/launchSettings.json b/SampleSites/Client/Properties/launchSettings.json index 3cd43be..cda54ec 100644 --- a/SampleSites/Client/Properties/launchSettings.json +++ b/SampleSites/Client/Properties/launchSettings.json @@ -4,24 +4,37 @@ "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:59481/", - "sslPort": 0 + "sslPort": 59480 } }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", + "http": { + "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:59482", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, - "SampleSite.Client": { + "https": { "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:59483;http://localhost:59482", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:59482/" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } } } } \ No newline at end of file diff --git a/SampleSites/Client/SampleSite.Client.csproj b/SampleSites/Client/SampleSite.Client.csproj index 4ec16e0..3679783 100644 --- a/SampleSites/Client/SampleSite.Client.csproj +++ b/SampleSites/Client/SampleSite.Client.csproj @@ -1,20 +1,32 @@  - net5.0 + net6.0;net7.0;net8.0 + enable + enable + + + + + + + + + + + + + - - - - - - - + + + + diff --git a/SampleSites/Client/wwwroot/css/blazor-ui.css b/SampleSites/Client/wwwroot/css/blazor-ui.css new file mode 100644 index 0000000..4620e29 --- /dev/null +++ b/SampleSites/Client/wwwroot/css/blazor-ui.css @@ -0,0 +1,61 @@ +#blazor-error-ui { + background: #ffffe0; + bottom: 0; + box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); + display: none; + left: 0; + padding: .6rem 1.25rem .7rem 1.25rem; + position: fixed; + right: 0; + z-index: 1000 +} + +#blazor-error-ui .dismiss { + cursor: pointer; + position: absolute; + right: .75rem; + top: .5rem +} + +.blazor-error-boundary { + background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; + padding: 1rem 1rem 1rem 3.7rem; + color: white; +} + +.blazor-error-boundary::after { + content: "An error has occurred." +} + +.loading-progress { + position: relative; + display: block; + width: 8rem; + height: 8rem; + margin: 20vh auto 1rem auto; +} + +.loading-progress circle { + fill: none; + stroke: #e0e0e0; + stroke-width: 0.6rem; + transform-origin: 50% 50%; + transform: rotate(-90deg); +} + +.loading-progress circle:last-child { + stroke: #1b6ec2; + stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; + transition: stroke-dasharray 0.05s ease-in-out; +} + +.loading-progress-text { + position: absolute; + text-align: center; + font-weight: bold; + inset: calc(20vh + 3.25rem) 0 auto 0.2rem; +} + +.loading-progress-text:after { + content: var(--blazor-load-percentage-text, "Loading"); +} diff --git a/SampleSites/Client/wwwroot/index.html b/SampleSites/Client/wwwroot/index.html index 03ecc6b..9d0d6ae 100644 --- a/SampleSites/Client/wwwroot/index.html +++ b/SampleSites/Client/wwwroot/index.html @@ -9,15 +9,17 @@ - - +
-
Loading...
- + + + + +
diff --git a/SampleSites/Client31/Properties/launchSettings.json b/SampleSites/Client31/Properties/launchSettings.json deleted file mode 100644 index 3fc70e1..0000000 --- a/SampleSites/Client31/Properties/launchSettings.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:57064/", - "sslPort": 44367 - } - }, - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "SampleSite.Client.Net31": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/SampleSites/Client31/SampleSite.Client.Net31.csproj b/SampleSites/Client31/SampleSite.Client.Net31.csproj deleted file mode 100644 index 1217824..0000000 --- a/SampleSites/Client31/SampleSite.Client.Net31.csproj +++ /dev/null @@ -1,31 +0,0 @@ - - - - netstandard2.1 - 3.0 - SampleSite.Client - - - - - - - - - - - - - PreserveNewest - - - - - - - - - diff --git a/SampleSites/Client31/wwwroot/.gitkeep b/SampleSites/Client31/wwwroot/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/SampleSites/Components/About.razor b/SampleSites/Components/About.razor index acaba0c..0e26582 100644 --- a/SampleSites/Components/About.razor +++ b/SampleSites/Components/About.razor @@ -28,10 +28,10 @@ @code { - [CascadingParameter] Layout.HeaderLinkType headerLink { get; set; } + [CascadingParameter] Layout.HeaderLinkType? headerLink { get; set; } protected override void OnInitialized() { - headerLink.Update("", "", ""); + headerLink?.Update("", "", ""); } } \ No newline at end of file diff --git a/SampleSites/Components/Home.razor b/SampleSites/Components/Home.razor index f7e003c..771be94 100644 --- a/SampleSites/Components/Home.razor +++ b/SampleSites/Components/Home.razor @@ -55,13 +55,13 @@ @code { - [CascadingParameter] Layout.HeaderLinkType headerLink { get; set; } + [CascadingParameter] Layout.HeaderLinkType? headerLink { get; set; } - IEnumerable Gamepads = new Gamepad[0]; + private IEnumerable Gamepads = new Gamepad[0]; - Gamepad Gamepad; + private Gamepad? Gamepad; - System.Timers.Timer Timer = new System.Timers.Timer(50) { Enabled = true }; + private System.Timers.Timer Timer = new(interval: 50) { Enabled = true }; const double SpaceBoxSize = 320; const double SpaceShipSize = 30; @@ -85,12 +85,12 @@ protected override void OnInitialized() { - headerLink.Update("about", "📣", "About"); + headerLink?.Update("about", "📣", "About"); Timer.Elapsed += Timer_Elapsed; } - private async void Timer_Elapsed(object sender, EventArgs args) + private async void Timer_Elapsed(object? sender, EventArgs args) { try { diff --git a/SampleSites/Components/Layout.razor b/SampleSites/Components/Layout.razor index 4b42c8b..b7d260c 100644 --- a/SampleSites/Components/Layout.razor +++ b/SampleSites/Components/Layout.razor @@ -7,10 +7,10 @@
This is the demonstration site of the class library that provides gamepad API access for your Blazor apps.
- @if (this.HeaderLink.Url != "") + @if (this.HeaderLink?.Url != "") { - @this.HeaderLink.Emoji - @this.HeaderLink.Text + @this.HeaderLink?.Emoji + @this.HeaderLink?.Text }
@@ -33,7 +33,7 @@ @code { - System.Timers.Timer Timer = new System.Timers.Timer(1000) { Enabled = true }; + private System.Timers.Timer Timer = new(interval: 1000) { Enabled = true }; public class HeaderLinkType { @@ -52,7 +52,7 @@ } } - HeaderLinkType HeaderLink { get; set; } + private HeaderLinkType? HeaderLink { get; set; } protected override void OnInitialized() { @@ -60,7 +60,7 @@ Timer.Elapsed += Timer_Elapsed; } - private async void Timer_Elapsed(object sender, EventArgs args) + private async void Timer_Elapsed(object? sender, EventArgs args) { await this.InvokeAsync(() => this.StateHasChanged()); } diff --git a/SampleSites/Components/SampleSite.Components.csproj b/SampleSites/Components/SampleSite.Components.csproj index 30fd2ea..27aa651 100644 --- a/SampleSites/Components/SampleSite.Components.csproj +++ b/SampleSites/Components/SampleSite.Components.csproj @@ -1,16 +1,19 @@  - netstandard2.0;net5.0 - 3.0 + net6.0;net7.0;net8.0 + enable + enable - - + + - - - + + + + + diff --git a/SampleSites/Host/Program.cs b/SampleSites/Host/Program.cs index c3f377b..017148a 100644 --- a/SampleSites/Host/Program.cs +++ b/SampleSites/Host/Program.cs @@ -1,22 +1,34 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +var builder = WebApplication.CreateBuilder(args); -namespace SampleSite.Host +// Add services to the container. + +builder.Services.AddControllersWithViews(); +builder.Services.AddRazorPages(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) { - public class Program - { - public static void Main(string[] args) - { - BuildWebHost(args).Run(); - } - - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseConfiguration(new ConfigurationBuilder() - .AddCommandLine(args) - .Build()) - .UseStartup() - .Build(); - } + app.UseWebAssemblyDebugging(); } +else +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseBlazorFrameworkFiles(); +app.UseStaticFiles(); + +app.UseRouting(); + + +app.MapRazorPages(); +app.MapControllers(); +app.MapFallbackToFile("index.html"); + +app.Run(); diff --git a/SampleSites/Host/Properties/launchSettings.json b/SampleSites/Host/Properties/launchSettings.json index 6a197fd..28cf6de 100644 --- a/SampleSites/Host/Properties/launchSettings.json +++ b/SampleSites/Host/Properties/launchSettings.json @@ -4,24 +4,37 @@ "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:58511/", - "sslPort": 0 + "sslPort": 58510 } }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", + "http": { + "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:58512", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, - "SampleSite.Host": { + "https": { "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:58513;http://localhost:58512", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:58512/" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } } } } \ No newline at end of file diff --git a/SampleSites/Host/SampleSite.Host.csproj b/SampleSites/Host/SampleSite.Host.csproj index db4b58e..a062e38 100644 --- a/SampleSites/Host/SampleSite.Host.csproj +++ b/SampleSites/Host/SampleSite.Host.csproj @@ -1,22 +1,22 @@  - netcoreapp3.1;net5.0 + net6.0;net7.0;net8.0 + enable + enable - - + + - - - + + - - - + + - + diff --git a/SampleSites/Host/Startup.cs b/SampleSites/Host/Startup.cs deleted file mode 100644 index 9509192..0000000 --- a/SampleSites/Host/Startup.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace SampleSite.Host -{ - public class Startup - { - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - app.UseWebAssemblyDebugging(); - } - - app.UseBlazorFrameworkFiles(); - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapFallbackToFile("index.html"); - }); - } - } -} diff --git a/SampleSites/Server/Program.cs b/SampleSites/Server/Program.cs index 17a0316..d03dd95 100644 --- a/SampleSites/Server/Program.cs +++ b/SampleSites/Server/Program.cs @@ -1,20 +1,32 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; +using Toolbelt.Blazor.Extensions.DependencyInjection; -namespace SampleSite.Server +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor(); +builder.Services.AddHeadElementHelper(); +builder.Services.AddGamepadList(options => +{ + //options.DisableClientScriptAutoInjection = true; +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + app.UseExceptionHandler("/Error"); + + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); } + +app.UseHttpsRedirection(); +app.UseStaticFiles(); +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); diff --git a/SampleSites/Server/Properties/launchSettings.json b/SampleSites/Server/Properties/launchSettings.json index 7ba2a3b..8a391a7 100644 --- a/SampleSites/Server/Properties/launchSettings.json +++ b/SampleSites/Server/Properties/launchSettings.json @@ -3,25 +3,35 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:10636", - "sslPort": 44307 + "applicationUrl": "http://localhost:58151/", + "sslPort": 58150 } }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", + "http": { + "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, + "applicationUrl": "http://localhost:58152", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, - "SampleSite.Server": { + "https": { "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:58153;http://localhost:58152", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", "launchBrowser": true, - "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } } } -} +} \ No newline at end of file diff --git a/SampleSites/Server/SampleSite.Server.csproj b/SampleSites/Server/SampleSite.Server.csproj index a1e8275..53dffcb 100644 --- a/SampleSites/Server/SampleSite.Server.csproj +++ b/SampleSites/Server/SampleSite.Server.csproj @@ -1,7 +1,8 @@  - netcoreapp3.1;net5.0 + net6.0;net7.0;net8.0 + enable diff --git a/SampleSites/Server/Startup.cs b/SampleSites/Server/Startup.cs deleted file mode 100644 index 94e4a1c..0000000 --- a/SampleSites/Server/Startup.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Toolbelt.Blazor.Extensions.DependencyInjection; - -namespace SampleSite.Server -{ - public class Startup - { - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 - public void ConfigureServices(IServiceCollection services) - { - services.AddGamepadList(options => - { - //options.DisableClientScriptAutoInjection = true; - }); - - services.AddRazorPages(); - services.AddServerSideBlazor(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - app.UseHsts(); - } - - app.UseHttpsRedirection(); - app.UseStaticFiles(); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapBlazorHub(); - endpoints.MapFallbackToPage("/_Host"); - }); - } - } -} diff --git a/Toolbelt.Blazor.Gamepad.sln b/Toolbelt.Blazor.Gamepad.sln index ce68922..4c825c5 100644 --- a/Toolbelt.Blazor.Gamepad.sln +++ b/Toolbelt.Blazor.Gamepad.sln @@ -21,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Host", "SampleSi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Server", "SampleSites\Server\SampleSite.Server.csproj", "{C2E8DC92-E36D-4272-93A4-B006F2AD02F2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleSite.Client.Net31", "SampleSites\Client31\SampleSite.Client.Net31.csproj", "{6ECA5925-0605-417D-A73D-E9FCE848256A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Actions", "GitHub Actions", "{7D027525-8AFB-48D9-B79B-91E34B8F3F76}" ProjectSection(SolutionItems) = preProject .github\workflows\gh-pages.yml = .github\workflows\gh-pages.yml @@ -54,10 +52,6 @@ Global {C2E8DC92-E36D-4272-93A4-B006F2AD02F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2E8DC92-E36D-4272-93A4-B006F2AD02F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {C2E8DC92-E36D-4272-93A4-B006F2AD02F2}.Release|Any CPU.Build.0 = Release|Any CPU - {6ECA5925-0605-417D-A73D-E9FCE848256A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6ECA5925-0605-417D-A73D-E9FCE848256A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6ECA5925-0605-417D-A73D-E9FCE848256A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6ECA5925-0605-417D-A73D-E9FCE848256A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,7 +61,6 @@ Global {097644C8-640F-4FB6-9AD5-53A44A4BFD0C} = {2F68DF90-123D-4252-AA47-0AD9CA7E247F} {F5083603-64A6-4501-83BE-5E69B3D60205} = {2F68DF90-123D-4252-AA47-0AD9CA7E247F} {C2E8DC92-E36D-4272-93A4-B006F2AD02F2} = {2F68DF90-123D-4252-AA47-0AD9CA7E247F} - {6ECA5925-0605-417D-A73D-E9FCE848256A} = {2F68DF90-123D-4252-AA47-0AD9CA7E247F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {62E30C2E-4DE2-4F3F-8344-05ACD9C5C6C2} diff --git a/Toolbelt.Blazor.Gamepad/Gamepad.cs b/Toolbelt.Blazor.Gamepad/Gamepad.cs index 67e4694..1bb7fd5 100644 --- a/Toolbelt.Blazor.Gamepad/Gamepad.cs +++ b/Toolbelt.Blazor.Gamepad/Gamepad.cs @@ -1,10 +1,5 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Threading.Tasks; +using System.ComponentModel; using Microsoft.JSInterop; -#if !ENABLE_JSMODULE -using JSInvoker = Microsoft.JSInterop.IJSRuntime; -#endif namespace Toolbelt.Blazor.Gamepad { diff --git a/Toolbelt.Blazor.Gamepad/GamepadExtensions.cs b/Toolbelt.Blazor.Gamepad/GamepadExtensions.cs index ea0d7cd..dac9395 100644 --- a/Toolbelt.Blazor.Gamepad/GamepadExtensions.cs +++ b/Toolbelt.Blazor.Gamepad/GamepadExtensions.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.JSInterop; using Toolbelt.Blazor.Gamepad; diff --git a/Toolbelt.Blazor.Gamepad/GamepadList.cs b/Toolbelt.Blazor.Gamepad/GamepadList.cs index 8c4719d..2fb54e4 100644 --- a/Toolbelt.Blazor.Gamepad/GamepadList.cs +++ b/Toolbelt.Blazor.Gamepad/GamepadList.cs @@ -1,23 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; +using System.Reflection; using Microsoft.JSInterop; -#if !ENABLE_JSMODULE -using JSInvoker = Microsoft.JSInterop.IJSRuntime; -#endif namespace Toolbelt.Blazor.Gamepad { /// /// Provides gamepad API access. /// - public class GamepadList -#if ENABLE_JSMODULE - : System.IAsyncDisposable -#endif + public class GamepadList : IAsyncDisposable { private readonly IJSRuntime JSRuntime; @@ -73,7 +62,6 @@ private async ValueTask GetJSInvokerAsync() if (this.JSInvoker != null) return this.JSInvoker; var version = this.GetVersionText(); -#if ENABLE_JSMODULE if (!this.Options.DisableClientScriptAutoInjection) { var scriptPath = $"./_content/Toolbelt.Blazor.Gamepad/script.module.min.js?v={version}"; @@ -85,15 +73,6 @@ private async ValueTask GetJSInvokerAsync() try { await this.JSRuntime.InvokeVoidAsync("Toolbelt.Blazor.Gamepad.ready"); } catch { } this.JSInvoker = new JSInvoker(this.JSRuntime, null); } -#else - if (!this.Options.DisableClientScriptAutoInjection) - { - const string scriptPath = "_content/Toolbelt.Blazor.Gamepad/script.min.js"; - await this.JSRuntime.InvokeVoidAsync("eval", "new Promise(r=>((d,t,s,v)=>(h=>h.querySelector(t+`[src^=\"${s}\"]`)?r():(e=>(e.src=(s+v),e.onload=r,h.appendChild(e)))(d.createElement(t)))(d.head))(document,'script','" + scriptPath + "','?v=" + version + "'))"); - } - try { await this.JSRuntime.InvokeVoidAsync("Toolbelt.Blazor.Gamepad.ready"); } catch { } - this.JSInvoker = this.JSRuntime; -#endif } catch (Exception) { } finally { this.Syncer.Release(); } @@ -110,13 +89,11 @@ private string GetVersionText() return version; } -#if ENABLE_JSMODULE private IJSObjectReference JSModule; public async ValueTask DisposeAsync() { if (this.JSModule != null) await this.JSModule.DisposeAsync(); } -#endif } } diff --git a/Toolbelt.Blazor.Gamepad/JSInvoker.cs b/Toolbelt.Blazor.Gamepad/JSInvoker.cs index 816ef90..f6cfd7b 100644 --- a/Toolbelt.Blazor.Gamepad/JSInvoker.cs +++ b/Toolbelt.Blazor.Gamepad/JSInvoker.cs @@ -1,6 +1,4 @@ -#if ENABLE_JSMODULE -#nullable enable -using System.Threading.Tasks; +#nullable enable using Microsoft.JSInterop; namespace Toolbelt.Blazor.Gamepad @@ -26,4 +24,3 @@ public ValueTask InvokeAsync(string identifier, params object[]? args) } } } -#endif diff --git a/Toolbelt.Blazor.Gamepad/Toolbelt.Blazor.Gamepad.csproj b/Toolbelt.Blazor.Gamepad/Toolbelt.Blazor.Gamepad.csproj index 571cca3..96b72cd 100644 --- a/Toolbelt.Blazor.Gamepad/Toolbelt.Blazor.Gamepad.csproj +++ b/Toolbelt.Blazor.Gamepad/Toolbelt.Blazor.Gamepad.csproj @@ -1,19 +1,18 @@  - netstandard2.0;net5.0 + net6.0;net7.0;net8.0 true - 8.0 - 3.0 - true + enable + $(WarningsAsErrors);nullable 3.0 true bin\$(Configuration)\$(TargetFramework)\$(MSBuildProjectName).xml $(NoWarn);1591 true - Copyright © 2018-2021 J.Sakamoto, Mozilla Public License 2.0 + Copyright © 2018-2023 J.Sakamoto, Mozilla Public License 2.0 J.Sakamoto - 8.0.0.1 + 9.0.0-preview.1 MPL-2.0 https://github.com/jsakamoto/Toolbelt.Blazor.Gamepad/ @@ -23,17 +22,21 @@ ..\_dist\ nupkg-icon.png README.md - $(DefineConstants);ENABLE_JSMODULE - - - + + + + + + + + - - - + + + diff --git a/global.json b/global.json index f382615..2ddda36 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { - "version": "5.0.0", + "version": "8.0.0", "rollForward": "latestMinor", - "allowPrerelease": true + "allowPrerelease": false } } \ No newline at end of file