diff --git a/src/Wolder.Core/Workspace/Events/WorkspaceStateDelegateDispatcher.cs b/src/Wolder.Core/Workspace/Events/WorkspaceStateDelegateDispatcher.cs index d64cc9d..5e5fa45 100644 --- a/src/Wolder.Core/Workspace/Events/WorkspaceStateDelegateDispatcher.cs +++ b/src/Wolder.Core/Workspace/Events/WorkspaceStateDelegateDispatcher.cs @@ -12,6 +12,9 @@ public WorkspaceStateEventDispatcher() WorkspaceInitializedAsync = async () => await Task.WhenAll(Delegates.Select(d => d.WorkspaceInitializedAsync())), + WorkspaceRunEndAsync = async () => + await Task.WhenAll(Delegates.Select(d => + d.WorkspaceRunEndAsync())), InvocationBeginAsync = async (c) => await Task.WhenAll(Delegates.Select(d => d.InvocationBeginAsync(c))), diff --git a/src/Wolder.Core/Workspace/Events/WorkspaceStateEvents.cs b/src/Wolder.Core/Workspace/Events/WorkspaceStateEvents.cs index 8624889..9a20864 100644 --- a/src/Wolder.Core/Workspace/Events/WorkspaceStateEvents.cs +++ b/src/Wolder.Core/Workspace/Events/WorkspaceStateEvents.cs @@ -3,6 +3,7 @@ public class WorkspaceStateEvents { public Func WorkspaceInitializedAsync { get; set; } = () => Task.CompletedTask; + public Func WorkspaceRunEndAsync { get; set; } = () => Task.CompletedTask; public Func InvocationBeginAsync { get; set; } = (c) => Task.CompletedTask; public Func InvocationEndAsync { get; set; } = (c) => Task.CompletedTask; } \ No newline at end of file diff --git a/src/Wolder.Core/Workspace/GeneratorWorkspaceBuilder.cs b/src/Wolder.Core/Workspace/GeneratorWorkspaceBuilder.cs index 6f70f90..b12f57f 100644 --- a/src/Wolder.Core/Workspace/GeneratorWorkspaceBuilder.cs +++ b/src/Wolder.Core/Workspace/GeneratorWorkspaceBuilder.cs @@ -51,5 +51,6 @@ public async Task BuildWorkspaceAndRunAsync(string rootPath) await EventDispatcher.Events.WorkspaceInitializedAsync(); var invokeRootAction = serviceProvider.GetRequiredService(); await invokeRootAction.InvokeVoidAsync(); + await EventDispatcher.Events.WorkspaceRunEndAsync(); } } \ No newline at end of file diff --git a/src/Wolder.Interactive.Web/Components/Index.razor b/src/Wolder.Interactive.Web/Components/Index.razor index f1b858e..2846f95 100644 --- a/src/Wolder.Interactive.Web/Components/Index.razor +++ b/src/Wolder.Interactive.Web/Components/Index.razor @@ -1,6 +1,18 @@ @page "/" +@using Wolder.Interactive.Web.Services + +@inject WorkspaceStateManager WorkspaceStateManager; + +@rendermode InteractiveServer +

Wolder Interactive

+
+ + + +
+ @code { } \ No newline at end of file diff --git a/src/Wolder.Interactive.Web/Components/Layout/MainLayout.razor.css b/src/Wolder.Interactive.Web/Components/Layout/MainLayout.razor.css index 9784e0d..6da5db3 100644 --- a/src/Wolder.Interactive.Web/Components/Layout/MainLayout.razor.css +++ b/src/Wolder.Interactive.Web/Components/Layout/MainLayout.razor.css @@ -1,4 +1,5 @@  main { font-family: monospace; + text-align: center; } \ No newline at end of file diff --git a/src/Wolder.Interactive.Web/Services/WorkspaceStateManager.cs b/src/Wolder.Interactive.Web/Services/WorkspaceStateManager.cs index d95330b..6da73a8 100644 --- a/src/Wolder.Interactive.Web/Services/WorkspaceStateManager.cs +++ b/src/Wolder.Interactive.Web/Services/WorkspaceStateManager.cs @@ -12,6 +12,7 @@ public WorkspaceStateManager() Events = new() { WorkspaceInitializedAsync = WorkspaceInitializedAsync, + WorkspaceRunEndAsync = WorkspaceRunEndAsync, InvocationBeginAsync = InvocationBeginAsync, InvocationEndAsync = InvocationEndAsync, }; @@ -50,6 +51,12 @@ private async Task InvocationBeginAsync(InvocationBeginContext c) InvocationBegin?.Invoke(new InvocationDetail(c.Invokable.GetType().Name)); await _proceedWhenUnpaused.Task; } + + private async Task WorkspaceRunEndAsync() + { + Pause(); + await _proceedWhenUnpaused.Task; + } private Task InvocationEndAsync(InvocationEndContext c) { diff --git a/src/Wolder.Interactive.Web/SetupExtensions.cs b/src/Wolder.Interactive.Web/SetupExtensions.cs index 6b4aee0..49fbb84 100644 --- a/src/Wolder.Interactive.Web/SetupExtensions.cs +++ b/src/Wolder.Interactive.Web/SetupExtensions.cs @@ -9,7 +9,7 @@ public static GeneratorWorkspaceBuilder AddInteractiveWebServer(this GeneratorWo { var server = new WorkspaceInteractiveWebHost(); builder.Services.AddSingleton(server); - builder.EventDispatcher.Delegates.Add(server.WorkspaceStateNotifications.Events); + builder.EventDispatcher.Delegates.Add(server.WorkspaceStateManager.Events); return builder; } } \ No newline at end of file diff --git a/src/Wolder.Interactive.Web/WorkspaceInteractiveWebHost.cs b/src/Wolder.Interactive.Web/WorkspaceInteractiveWebHost.cs index 5385b53..f6d14d3 100644 --- a/src/Wolder.Interactive.Web/WorkspaceInteractiveWebHost.cs +++ b/src/Wolder.Interactive.Web/WorkspaceInteractiveWebHost.cs @@ -11,13 +11,13 @@ public class WorkspaceInteractiveWebHost public WorkspaceInteractiveWebHost() { - WorkspaceStateNotifications.WorkspaceInitialized += () => + WorkspaceStateManager.WorkspaceInitialized += () => { _serverInitializeTask = StartAsync(); }; } - public WorkspaceStateManager WorkspaceStateNotifications { get; } = new(); + public WorkspaceStateManager WorkspaceStateManager { get; } = new(); private async Task StartAsync() { @@ -32,6 +32,8 @@ private async Task StartAsync() ApplicationName = "Wolder.Interactive.Web" }); + webBuilder.Services.AddSingleton(WorkspaceStateManager); + // Add services to the container. webBuilder.Services.AddRazorComponents() .AddInteractiveServerComponents();