diff --git a/src/Bit.CI.Release.slnx b/src/Bit.CI.Release.slnx index a29293e919..7424f31a00 100644 --- a/src/Bit.CI.Release.slnx +++ b/src/Bit.CI.Release.slnx @@ -50,9 +50,9 @@ - - - + + + diff --git a/src/Bit.slnx b/src/Bit.slnx index eb506164d0..c6934a20b3 100644 --- a/src/Bit.slnx +++ b/src/Bit.slnx @@ -81,12 +81,12 @@ - - - + + + - + diff --git a/src/Brouter/Bit.Brouter.Web.slnf b/src/Brouter/Bit.Brouter.Web.slnf deleted file mode 100644 index d79d26b9dd..0000000000 --- a/src/Brouter/Bit.Brouter.Web.slnf +++ /dev/null @@ -1,10 +0,0 @@ -{ - "solution": { - "path": "Bit.Brouter.slnx", - "projects": [ - "Bit.Brouter\\Bit.Brouter.csproj", - "Demo\\Bit.Brouter.Demo.Core\\Bit.Brouter.Demo.Core.csproj", - "Demo\\Bit.Brouter.Demo.Web\\Bit.Brouter.Demo.Web.csproj" - ] - } -} diff --git a/src/Brouter/Bit.Brouter.slnx b/src/Brouter/Bit.Brouter.slnx index d8cf2e4f43..02b10d1206 100644 --- a/src/Brouter/Bit.Brouter.slnx +++ b/src/Brouter/Bit.Brouter.slnx @@ -6,12 +6,19 @@ - - - - - - + + + + + + + + + + + + + diff --git a/src/Brouter/Bit.Brouter/Brouter.cs b/src/Brouter/Bit.Brouter/Brouter.cs index 40f9c474ac..aec85fcffb 100644 --- a/src/Brouter/Bit.Brouter/Brouter.cs +++ b/src/Brouter/Bit.Brouter/Brouter.cs @@ -118,18 +118,45 @@ protected override void OnInitialized() CurrentLocation = ComputeLocation(); } + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + // Yield once so ComponentBase performs the initial synchronous render of our + // ChildContent. That first render is what causes the declared children to + // register themselves with us (each one calls RegisterRoute from its own OnInitialized). + // Until they've registered there is nothing to match against, which is why the initial + // match cannot run any earlier than this. + // + // Doing the initial match here - rather than in OnAfterRenderAsync - is what enables + // static server prerendering. OnAfterRenderAsync never runs during prerender, so the old + // placement left the prerendered HTML empty (no route was ever matched server-side). + // OnInitializedAsync, by contrast, runs during prerender and the renderer awaits it - and + // the StateHasChanged it triggers - before serializing the HTML, so the matched route is + // included in the prerendered output. When the component later becomes interactive its + // lifecycle runs again and the match re-runs naturally. + await Task.Yield(); + + // Initial render: the From is Empty (we just mounted), the To is the URL we're at now. + await ProcessNavigationAsync(BrouterLocation.Empty, CurrentLocation); + } + protected override async Task OnAfterRenderAsync(bool firstRender) { await base.OnAfterRenderAsync(firstRender); if (firstRender is false) return; - // Enabling navigation interception is best-effort: under prerender, on a disconnected - // circuit, or on an interop failure it can throw, but the navigation pipeline itself - // (and any subsequent reconnects / interactivity handoff) does not depend on it - // succeeding right now. Mirror the defensive style used in BrouterLink and - // BrouterService.BackAsync so a transient failure here can't kill the whole first - // navigation. Once the circuit/runtime is fully ready, Blazor will retry interception + // Enabling navigation interception genuinely requires an interactive runtime, so it stays + // in OnAfterRenderAsync, which only runs once interactivity is established. Under prerender + // this method doesn't run at all - that's fine: the initial match already happened in + // OnInitializedAsync, and interception is enabled here once the component goes interactive. + // + // Enabling navigation interception is best-effort: on a disconnected circuit or an interop + // failure it can throw, but the navigation pipeline itself (and any subsequent reconnects / + // interactivity handoff) does not depend on it succeeding right now. Mirror the defensive + // style used in BrouterLink and BrouterService.BackAsync so a transient failure here can't + // kill navigation. Once the circuit/runtime is fully ready, Blazor will retry interception // attachment naturally on the next user click via NavigationManager fallback paths. try { @@ -139,9 +166,6 @@ protected override async Task OnAfterRenderAsync(bool firstRender) catch (JSException) { /* JS interop failure; non-fatal */ } catch (InvalidOperationException) { /* interop unavailable during prerender */ } catch (TaskCanceledException) { /* component disposed mid-call */ } - - // Initial render: the From is Empty (we just mounted), the To is the URL we're at now. - await ProcessNavigationAsync(BrouterLocation.Empty, CurrentLocation); } protected override void BuildRenderTree(RenderTreeBuilder builder) @@ -551,6 +575,16 @@ private async ValueTask ProcessNavigationAsync(BrouterLocation from, BrouterLoca { return; } + catch (NavigationException) + { + // During static server rendering / prerender, NavigationManager.NavigateTo + // throws NavigationException as the framework's redirect signal (a loader may + // redirect, e.g. an auth gate). It must unwind out of OnInitializedAsync so the + // endpoint can issue the HTTP redirect; swallowing it into OnError would drop + // the redirect entirely. Interactive NavigateTo never throws, so this is inert + // outside SSR. + throw; + } catch (Exception ex) { await service.InvokeOnError(ctx, ex); @@ -583,6 +617,13 @@ private async ValueTask ProcessNavigationAsync(BrouterLocation from, BrouterLoca { // navigation was superseded; nothing to do } + catch (NavigationException) + { + // SSR/prerender redirect signal (see the loader catch above). Let it propagate out of + // OnInitializedAsync so the framework can turn it into an HTTP redirect. A guard or + // OnNavigating handler that redirects via NavigationManager during prerender lands here. + throw; + } catch (Exception ex) { await service.InvokeOnError(ctx, ex); diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml deleted file mode 100644 index 749a854d81..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml.cs deleted file mode 100644 index 0095bdf3e1..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/App.xaml.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Bit.Brouter.Demo.Maui; - -public partial class App : Application -{ - public App() - { - InitializeComponent(); - - MainPage = new MainPage(); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Bit.Brouter.Demo.Maui.csproj b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Bit.Brouter.Demo.Maui.csproj deleted file mode 100644 index 45bafa9c64..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Bit.Brouter.Demo.Maui.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net10.0-android;net10.0-ios;net10.0-maccatalyst - $(TargetFrameworks);net10.0-windows10.0.19041.0 - net10.0-android - - - Exe - true - true - enable - false - - - Brouter Demo - - - com.bitplatform.brouter.demo - - - 1.0.0 - 1 - - - True - - $(NoWarn);ClassWithoutModifierAnalyzer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Extensions/IServiceCollectionExtensions.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Extensions/IServiceCollectionExtensions.cs deleted file mode 100644 index e748a80620..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Extensions/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Microsoft.Extensions.DependencyInjection; - -public static class IServiceCollectionExtensions -{ - public static IServiceCollection AddMauiServices(this IServiceCollection services) - { - ArgumentNullException.ThrowIfNull(services); - - // Services registered in this class can be injected in Android, iOS, Windows, and macOS. - services.AddCoreServices(); - - return services; - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml deleted file mode 100644 index 8d0f1d6ca6..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml.cs deleted file mode 100644 index fcc3270bdf..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MainPage.xaml.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Bit.Brouter.Demo.Maui; - -public partial class MainPage -{ - public MainPage() - { - InitializeComponent(); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MauiProgram.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MauiProgram.cs deleted file mode 100644 index d01bb205a8..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/MauiProgram.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Extensions.Logging; - -namespace Bit.Brouter.Demo.Maui; -public static class MauiProgram -{ - public static MauiApp CreateMauiApp() - { - var builder = MauiApp.CreateBuilder(); - builder.UseMauiApp(); - - builder.Services.AddMauiBlazorWebView(); - -#if DEBUG - builder.Services.AddBlazorWebViewDeveloperTools(); - builder.Logging.AddDebug(); -#endif - - builder.Services.AddMauiServices(); - - return builder.Build(); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/AndroidManifest.xml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/AndroidManifest.xml deleted file mode 100644 index 37c84642ba..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/AndroidManifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainActivity.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainActivity.cs deleted file mode 100644 index 985d4d0285..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainActivity.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Android.App; -using Android.Content.PM; -using Android.OS; - -namespace Bit.Brouter.Demo.Maui; -[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] -public class MainActivity : MauiAppCompatActivity -{ -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainApplication.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainApplication.cs deleted file mode 100644 index 19c5cfaa07..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/MainApplication.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Android.App; -using Android.Runtime; - -namespace Bit.Brouter.Demo.Maui; -[Application] -public class MainApplication : MauiApplication -{ - public MainApplication(IntPtr handle, JniHandleOwnership ownership) - : base(handle, ownership) - { - } - - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/Resources/values/colors.xml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/Resources/values/colors.xml deleted file mode 100644 index bac402e4d3..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Android/Resources/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #0065EF - #0065EF - #0065EF - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/AppDelegate.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/AppDelegate.cs deleted file mode 100644 index 628e637c75..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/AppDelegate.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Foundation; - -namespace Bit.Brouter.Demo.Maui; -[Register("AppDelegate")] -public class AppDelegate : MauiUIApplicationDelegate -{ - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Entitlements.plist b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Entitlements.plist deleted file mode 100644 index d87da40f14..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Entitlements.plist +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - com.apple.security.app-sandbox - - - com.apple.security.network.client - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Info.plist b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Info.plist deleted file mode 100644 index 6fd53ea22d..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Info.plist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - UIDeviceFamily - - 2 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - XSAppIconAssets - Assets.xcassets/appicon.appiconset - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Program.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Program.cs deleted file mode 100644 index c0a60264f2..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/MacCatalyst/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using ObjCRuntime; -using UIKit; - -namespace Bit.Brouter.Demo.Maui; -public class Program -{ - // This is the main entry point of the application. - static void Main(string[] args) - { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, null, typeof(AppDelegate)); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/Main.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/Main.cs deleted file mode 100644 index 947332c64e..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/Main.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Microsoft.Maui; -using Microsoft.Maui.Hosting; - -namespace Bit.Brouter.Demo.Maui; - -internal class Program : MauiApplication -{ - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); - - static void Main(string[] args) - { - var app = new Program(); - app.Run(args); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/tizen-manifest.xml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/tizen-manifest.xml deleted file mode 100644 index 8449966265..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Tizen/tizen-manifest.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - maui-appicon-placeholder - - - - - http://tizen.org/privilege/internet - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml deleted file mode 100644 index c0606d11f9..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml.cs deleted file mode 100644 index 6747f04630..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/App.xaml.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.UI.Xaml; - -// To learn more about WinUI, the WinUI project structure, -// and more about our project templates, see: http://aka.ms/winui-project-info. - -namespace Bit.Brouter.Demo.Maui.WinUI; -/// -/// Provides application-specific behavior to supplement the default Application class. -/// -public partial class App : MauiWinUIApplication -{ - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - } - - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/Package.appxmanifest b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/Package.appxmanifest deleted file mode 100644 index b447c8609e..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/Package.appxmanifest +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - $placeholder$ - User Name - $placeholder$.png - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/app.manifest b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/app.manifest deleted file mode 100644 index bfccd4cde2..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/Windows/app.manifest +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - true/PM - PerMonitorV2, PerMonitor - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/AppDelegate.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/AppDelegate.cs deleted file mode 100644 index 628e637c75..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/AppDelegate.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Foundation; - -namespace Bit.Brouter.Demo.Maui; -[Register("AppDelegate")] -public class AppDelegate : MauiUIApplicationDelegate -{ - protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Info.plist b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Info.plist deleted file mode 100644 index ecb7f719bd..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Info.plist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - LSRequiresIPhoneOS - - UIDeviceFamily - - 1 - 2 - - UIRequiredDeviceCapabilities - - arm64 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - XSAppIconAssets - Assets.xcassets/appicon.appiconset - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Program.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Program.cs deleted file mode 100644 index c0a60264f2..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Platforms/iOS/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using ObjCRuntime; -using UIKit; - -namespace Bit.Brouter.Demo.Maui; -public class Program -{ - // This is the main entry point of the application. - static void Main(string[] args) - { - // if you want to use a different Application Delegate class from "AppDelegate" - // you can specify it here. - UIApplication.Main(args, null, typeof(AppDelegate)); - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Properties/launchSettings.json b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Properties/launchSettings.json deleted file mode 100644 index bc20df0c32..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "Windows Machine": { - "commandName": "MsixPackage", - "nativeDebugging": false - } - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appicon.svg b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appicon.svg deleted file mode 100644 index 184f4df738..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appicon.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appiconfg.svg b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appiconfg.svg deleted file mode 100644 index 4f2de530df..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/AppIcon/appiconfg.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - Br - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/Splash/splash.svg b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/Splash/splash.svg deleted file mode 100644 index 246e0a2f6c..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/Resources/Splash/splash.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - Br - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/wwwroot/index.html b/src/Brouter/Demo/Bit.Brouter.Demo.Maui/wwwroot/index.html deleted file mode 100644 index c2ea20817a..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Maui/wwwroot/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Bit.Brouter.Demo - - - - - - -
- - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Extensions/IServiceCollectionExtensions.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Web/Extensions/IServiceCollectionExtensions.cs deleted file mode 100644 index 4c9e2a366a..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Extensions/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Microsoft.Extensions.DependencyInjection; - -public static class IServiceCollectionExtensions -{ - public static IServiceCollection AddWebServices(this IServiceCollection services) - { - ArgumentNullException.ThrowIfNull(services); - - // Services being registered here can get injected in web (blazor web assembly & blazor server) - services.AddCoreServices(); - - return services; - } -} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Program.cs b/src/Brouter/Demo/Bit.Brouter.Demo.Web/Program.cs deleted file mode 100644 index c8c03af273..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Bit.Brouter.Demo.Core; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; - -var builder = WebAssemblyHostBuilder.CreateDefault(args); - -builder.Services.AddWebServices(); - -builder.RootComponents.Add("#app"); -builder.RootComponents.Add("head::after"); - -await builder.Build().RunAsync(); diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/index.html b/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/index.html deleted file mode 100644 index c9300ab7e2..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - Bit.Brouter.Demo - - - - - - -
- - - - - - diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/sw.js b/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/sw.js deleted file mode 100644 index 9ee1e923e4..0000000000 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/wwwroot/sw.js +++ /dev/null @@ -1,14 +0,0 @@ -self.addEventListener('install', e => { - console.log('sw install'); - // Tell the browser to keep this worker alive until install work is done. - // Calling skipWaiting inside waitUntil makes the new worker activate as - // soon as install completes, without waiting for existing clients to close. - e.waitUntil(self.skipWaiting()); -}); - -self.addEventListener('activate', e => { - console.log('sw activate'); - // Take control of any already-open clients (tabs) so they start using this - // new worker immediately, without requiring a reload. - e.waitUntil(self.clients.claim()); -}); diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Bit.Brouter.Demo.Web.csproj b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Bit.Brouter.Demos.Auto.Client.csproj similarity index 54% rename from src/Brouter/Demo/Bit.Brouter.Demo.Web/Bit.Brouter.Demo.Web.csproj rename to src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Bit.Brouter.Demos.Auto.Client.csproj index 59a60e0ff0..9c1c394755 100644 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Bit.Brouter.Demo.Web.csproj +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Bit.Brouter.Demos.Auto.Client.csproj @@ -2,17 +2,16 @@ net10.0 - enable enable + enable + true + Default + true - - - - - +
diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/Pages/Host.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/Pages/Host.razor new file mode 100644 index 0000000000..341809c965 --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/Pages/Host.razor @@ -0,0 +1,8 @@ +@page "/" +@page "/{*path}" + + + +@code { + [Parameter] public string? Path { get; set; } +} diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/_Imports.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/_Imports.razor new file mode 100644 index 0000000000..ca38b1d741 --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Components/_Imports.razor @@ -0,0 +1,14 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared +@using Bit.Brouter.Demos.Auto.Client.Components +@using Bit.Brouter.Demos.Auto.Client.Components.Pages diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Program.cs b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Program.cs new file mode 100644 index 0000000000..59f28a9c5a --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/Program.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); + +builder.Services.AddCoreServices(); + +await builder.Build().RunAsync(); diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/_Imports.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/_Imports.razor new file mode 100644 index 0000000000..8401f6aae6 --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto.Client/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Bit.Brouter.Demos.Auto.csproj b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Bit.Brouter.Demos.Auto.csproj new file mode 100644 index 0000000000..376ef8ca7d --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Bit.Brouter.Demos.Auto.csproj @@ -0,0 +1,16 @@ + + + + net10.0 + enable + enable + true + + + + + + + + + diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/App.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/App.razor new file mode 100644 index 0000000000..0fd68e2374 --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/App.razor @@ -0,0 +1,19 @@ + + + + + + + + Bit.Brouter - Auto demo (prerendering) + + + + + + + + + + + diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/Pages/Error.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/Pages/Error.razor new file mode 100644 index 0000000000..dc277451aa --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/Pages/Error.razor @@ -0,0 +1,23 @@ +@page "/Error" +@using System.Diagnostics + +
+

Error

+

An error occurred while processing your request.

+ + @if (string.IsNullOrEmpty(RequestId) is false) + { +

Request ID: @RequestId

+ } + + Back to home +
+ +@code { + [CascadingParameter] private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/_Imports.razor b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/_Imports.razor new file mode 100644 index 0000000000..62caad6ade --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Components/_Imports.razor @@ -0,0 +1,13 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared +@using Bit.Brouter.Demos.Auto.Client.Components diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Program.cs b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Program.cs new file mode 100644 index 0000000000..e97e61764f --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Program.cs @@ -0,0 +1,33 @@ +using Bit.Brouter.Demos.Auto.Components; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents() + .AddInteractiveWebAssemblyComponents(); + +builder.Services.AddCoreServices(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.UseWebAssemblyDebugging(); +} +else +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseHttpsRedirection(); +app.UseAntiforgery(); + +app.MapStaticAssets(); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode() + .AddInteractiveWebAssemblyRenderMode() + .AddAdditionalAssemblies(typeof(Bit.Brouter.Demos.Auto.Client._Imports).Assembly); + +app.Run(); diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Properties/launchSettings.json b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Properties/launchSettings.json similarity index 76% rename from src/Brouter/Demo/Bit.Brouter.Demo.Web/Properties/launchSettings.json rename to src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Properties/launchSettings.json index eeebd1ea15..1bca23d48b 100644 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Web/Properties/launchSettings.json +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/Properties/launchSettings.json @@ -1,11 +1,11 @@ { "profiles": { - "Bit.Brouter.Demo.Web": { + "Bit.Brouter.Demos.Auto": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "http://localhost:5050;https://localhost:5051", + "applicationUrl": "https://localhost:7183;http://localhost:5183", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/appsettings.json b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/src/Brouter/InteralDemos/Auto/Bit.Brouter.Demos.Auto/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/AppRouter.razor b/src/Brouter/InteralDemos/Core/AppRouter.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/AppRouter.razor rename to src/Brouter/InteralDemos/Core/AppRouter.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Bit.Brouter.Demo.Core.csproj b/src/Brouter/InteralDemos/Core/Bit.Brouter.Demos.Core.csproj similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Bit.Brouter.Demo.Core.csproj rename to src/Brouter/InteralDemos/Core/Bit.Brouter.Demos.Core.csproj diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Extensions/IServiceCollectionExtensions.cs b/src/Brouter/InteralDemos/Core/Extensions/IServiceCollectionExtensions.cs similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Extensions/IServiceCollectionExtensions.cs rename to src/Brouter/InteralDemos/Core/Extensions/IServiceCollectionExtensions.cs diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/CounterPage.razor b/src/Brouter/InteralDemos/Core/Pages/CounterPage.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/CounterPage.razor rename to src/Brouter/InteralDemos/Core/Pages/CounterPage.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/FetchDataPage.razor b/src/Brouter/InteralDemos/Core/Pages/FetchDataPage.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/FetchDataPage.razor rename to src/Brouter/InteralDemos/Core/Pages/FetchDataPage.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/HomePage.razor b/src/Brouter/InteralDemos/Core/Pages/HomePage.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/HomePage.razor rename to src/Brouter/InteralDemos/Core/Pages/HomePage.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/Nested.razor b/src/Brouter/InteralDemos/Core/Pages/Nested.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/Nested.razor rename to src/Brouter/InteralDemos/Core/Pages/Nested.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/Nested2.razor b/src/Brouter/InteralDemos/Core/Pages/Nested2.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/Nested2.razor rename to src/Brouter/InteralDemos/Core/Pages/Nested2.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/PostPage.razor b/src/Brouter/InteralDemos/Core/Pages/PostPage.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/PostPage.razor rename to src/Brouter/InteralDemos/Core/Pages/PostPage.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/ProfilePage.razor b/src/Brouter/InteralDemos/Core/Pages/ProfilePage.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Pages/ProfilePage.razor rename to src/Brouter/InteralDemos/Core/Pages/ProfilePage.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Routes.razor b/src/Brouter/InteralDemos/Core/Routes.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Routes.razor rename to src/Brouter/InteralDemos/Core/Routes.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/Header.razor b/src/Brouter/InteralDemos/Core/Shared/Header.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/Header.razor rename to src/Brouter/InteralDemos/Core/Shared/Header.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/Header.razor.css b/src/Brouter/InteralDemos/Core/Shared/Header.razor.css similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/Header.razor.css rename to src/Brouter/InteralDemos/Core/Shared/Header.razor.css diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/MainLayout.razor b/src/Brouter/InteralDemos/Core/Shared/MainLayout.razor similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/MainLayout.razor rename to src/Brouter/InteralDemos/Core/Shared/MainLayout.razor diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/MainLayout.razor.css b/src/Brouter/InteralDemos/Core/Shared/MainLayout.razor.css similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/Shared/MainLayout.razor.css rename to src/Brouter/InteralDemos/Core/Shared/MainLayout.razor.css diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/_Imports.razor b/src/Brouter/InteralDemos/Core/_Imports.razor similarity index 79% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/_Imports.razor rename to src/Brouter/InteralDemos/Core/_Imports.razor index 0d455ed585..e4e461d2ae 100644 --- a/src/Brouter/Demo/Bit.Brouter.Demo.Core/_Imports.razor +++ b/src/Brouter/InteralDemos/Core/_Imports.razor @@ -10,6 +10,6 @@ @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Web.Virtualization @using Bit.Brouter -@using Bit.Brouter.Demo.Core -@using Bit.Brouter.Demo.Core.Pages -@using Bit.Brouter.Demo.Core.Shared +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared diff --git a/src/Brouter/Demo/Bit.Brouter.Demo.Core/wwwroot/app.css b/src/Brouter/InteralDemos/Core/wwwroot/app.css similarity index 100% rename from src/Brouter/Demo/Bit.Brouter.Demo.Core/wwwroot/app.css rename to src/Brouter/InteralDemos/Core/wwwroot/app.css diff --git a/src/Brouter/InteralDemos/Server/Bit.Brouter.Demos.Server.csproj b/src/Brouter/InteralDemos/Server/Bit.Brouter.Demos.Server.csproj new file mode 100644 index 0000000000..7f7a03c056 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Bit.Brouter.Demos.Server.csproj @@ -0,0 +1,14 @@ + + + + net10.0 + enable + enable + true + + + + + + + diff --git a/src/Brouter/InteralDemos/Server/Components/App.razor b/src/Brouter/InteralDemos/Server/Components/App.razor new file mode 100644 index 0000000000..d406a50375 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Components/App.razor @@ -0,0 +1,19 @@ + + + + + + + + Bit.Brouter - Server demo (prerendering) + + + + + + + + + + + diff --git a/src/Brouter/InteralDemos/Server/Components/Pages/Error.razor b/src/Brouter/InteralDemos/Server/Components/Pages/Error.razor new file mode 100644 index 0000000000..dc277451aa --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Components/Pages/Error.razor @@ -0,0 +1,23 @@ +@page "/Error" +@using System.Diagnostics + +
+

Error

+

An error occurred while processing your request.

+ + @if (string.IsNullOrEmpty(RequestId) is false) + { +

Request ID: @RequestId

+ } + + Back to home +
+ +@code { + [CascadingParameter] private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/src/Brouter/InteralDemos/Server/Components/Pages/Host.razor b/src/Brouter/InteralDemos/Server/Components/Pages/Host.razor new file mode 100644 index 0000000000..8d4e809c05 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Components/Pages/Host.razor @@ -0,0 +1,13 @@ +@* + Catch-all host page. The Blazor router maps EVERY url to this single page; from here on + Bit.Brouter's takes over and matches the real route. Brouter matches during + OnInitializedAsync so the matched page's HTML is in the initial prerendered response. +*@ +@page "/" +@page "/{*path}" + + + +@code { + [Parameter] public string? Path { get; set; } +} diff --git a/src/Brouter/InteralDemos/Server/Components/_Imports.razor b/src/Brouter/InteralDemos/Server/Components/_Imports.razor new file mode 100644 index 0000000000..db2980d8f9 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Components/_Imports.razor @@ -0,0 +1,15 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared +@using Bit.Brouter.Demos.Server +@using Bit.Brouter.Demos.Server.Components +@using Bit.Brouter.Demos.Server.Components.Pages diff --git a/src/Brouter/InteralDemos/Server/Program.cs b/src/Brouter/InteralDemos/Server/Program.cs new file mode 100644 index 0000000000..e1419c35c2 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Program.cs @@ -0,0 +1,26 @@ +using Bit.Brouter.Demos.Server.Components; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +builder.Services.AddCoreServices(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment() is false) +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseHttpsRedirection(); +app.UseAntiforgery(); + +app.MapStaticAssets(); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + +app.Run(); diff --git a/src/Brouter/InteralDemos/Server/Properties/launchSettings.json b/src/Brouter/InteralDemos/Server/Properties/launchSettings.json new file mode 100644 index 0000000000..76f6d415e6 --- /dev/null +++ b/src/Brouter/InteralDemos/Server/Properties/launchSettings.json @@ -0,0 +1,13 @@ +{ + "profiles": { + "Bit.Brouter.Demos.Server": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7181;http://localhost:5181", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Brouter/InteralDemos/Server/appsettings.json b/src/Brouter/InteralDemos/Server/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/src/Brouter/InteralDemos/Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Bit.Brouter.Demos.Wasm.Client.csproj b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Bit.Brouter.Demos.Wasm.Client.csproj new file mode 100644 index 0000000000..9c1c394755 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Bit.Brouter.Demos.Wasm.Client.csproj @@ -0,0 +1,17 @@ + + + + net10.0 + enable + enable + true + Default + true + + + + + + + + diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/Pages/Host.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/Pages/Host.razor new file mode 100644 index 0000000000..341809c965 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/Pages/Host.razor @@ -0,0 +1,8 @@ +@page "/" +@page "/{*path}" + + + +@code { + [Parameter] public string? Path { get; set; } +} diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/_Imports.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/_Imports.razor new file mode 100644 index 0000000000..de7d38b47b --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Components/_Imports.razor @@ -0,0 +1,14 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared +@using Bit.Brouter.Demos.Wasm.Client.Components +@using Bit.Brouter.Demos.Wasm.Client.Components.Pages diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Program.cs b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Program.cs new file mode 100644 index 0000000000..59f28a9c5a --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/Program.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); + +builder.Services.AddCoreServices(); + +await builder.Build().RunAsync(); diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/_Imports.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/_Imports.razor new file mode 100644 index 0000000000..8401f6aae6 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm.Client/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Bit.Brouter.Demos.Wasm.csproj b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Bit.Brouter.Demos.Wasm.csproj new file mode 100644 index 0000000000..c943775470 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Bit.Brouter.Demos.Wasm.csproj @@ -0,0 +1,16 @@ + + + + net10.0 + enable + enable + true + + + + + + + + + diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/App.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/App.razor new file mode 100644 index 0000000000..8279f7d823 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/App.razor @@ -0,0 +1,19 @@ + + + + + + + + Bit.Brouter - WebAssembly demo (prerendering) + + + + + + + + + + + diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/Pages/Error.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/Pages/Error.razor new file mode 100644 index 0000000000..dc277451aa --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/Pages/Error.razor @@ -0,0 +1,23 @@ +@page "/Error" +@using System.Diagnostics + +
+

Error

+

An error occurred while processing your request.

+ + @if (string.IsNullOrEmpty(RequestId) is false) + { +

Request ID: @RequestId

+ } + + Back to home +
+ +@code { + [CascadingParameter] private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/_Imports.razor b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/_Imports.razor new file mode 100644 index 0000000000..46bfc74d8b --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Components/_Imports.razor @@ -0,0 +1,13 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using Bit.Brouter +@using Bit.Brouter.Demos.Core +@using Bit.Brouter.Demos.Core.Pages +@using Bit.Brouter.Demos.Core.Shared +@using Bit.Brouter.Demos.Wasm.Client.Components diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Program.cs b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Program.cs new file mode 100644 index 0000000000..43ec7e2499 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Program.cs @@ -0,0 +1,32 @@ +using Bit.Brouter.Demos.Wasm.Components; +using Bit.Brouter.Demos.Wasm.Client; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddRazorComponents() + .AddInteractiveWebAssemblyComponents(); + +builder.Services.AddCoreServices(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.UseWebAssemblyDebugging(); +} +else +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + app.UseHsts(); +} + +app.UseHttpsRedirection(); +app.UseAntiforgery(); + +app.MapStaticAssets(); + +app.MapRazorComponents() + .AddInteractiveWebAssemblyRenderMode() + .AddAdditionalAssemblies(typeof(Bit.Brouter.Demos.Wasm.Client._Imports).Assembly); + +app.Run(); diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Properties/launchSettings.json b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Properties/launchSettings.json new file mode 100644 index 0000000000..2fb501c404 --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/Properties/launchSettings.json @@ -0,0 +1,14 @@ +{ + "profiles": { + "Bit.Brouter.Demos.Wasm": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7182;http://localhost:5182", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/appsettings.json b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/appsettings.json new file mode 100644 index 0000000000..10f68b8c8b --- /dev/null +++ b/src/Brouter/InteralDemos/Wasm/Bit.Brouter.Demos.Wasm/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}