Skip to content

[Components] Prerrendering startup experience #7770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Components.Server;

namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extensions for <see cref="IEndpointConventionBuilder"/>.
/// </summary>
public static class ComponentEndpointConventionBuilderExtensions
{
/// <summary>
/// Adds <typeparamref name="TComponent"/> to the list of components registered with this <see cref="ComponentHub"/> instance.
/// </summary>
/// <typeparam name="TComponent">The component type.</typeparam>
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
/// <param name="selector">A CSS selector that identifies the DOM element into which the <typeparamref name="TComponent"/> will be placed.</param>
/// <returns>The <paramref name="builder"/>.</returns>
public static IEndpointConventionBuilder AddComponent<TComponent>(this IEndpointConventionBuilder builder, string selector)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}

if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
}

return AddComponent(builder, typeof(TComponent), selector);
}

/// <summary>
/// Adds <paramref name="componentType"/> to the list of components registered with this <see cref="ComponentHub"/> instance.
/// The selector will default to the component name in lowercase.
/// </summary>
/// <param name="builder">The <see cref="IEndpointConventionBuilder"/>.</param>
/// <param name="componentType">The component type.</param>
/// <param name="selector">The component selector in the DOM for the <paramref name="componentType"/>.</param>
/// <returns>The <paramref name="builder"/>.</returns>
public static IEndpointConventionBuilder AddComponent(this IEndpointConventionBuilder builder, Type componentType, string selector)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}

if (componentType == null)
{
throw new ArgumentNullException(nameof(componentType));
}

if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
}

builder.Add(endpointBuilder => AddComponent(endpointBuilder.Metadata, componentType, selector));
return builder;
}

private static void AddComponent(IList<object> metadata, Type type, string selector)
{
metadata.Add(new ComponentDescriptor
{
ComponentType = type,
Selector = selector
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Routing;

namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Extensions for <see cref="IEndpointRouteBuilder"/>.
/// </summary>
public static class ComponentEndpointRouteBuilderExtensions
{
/// <summary>
/// Maps the SignalR <see cref="ComponentHub"/> to the path <paramref name="path"/> and associates
/// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
/// </summary>
/// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub"/>.</typeparam>
/// <param name="routes">The <see cref="RouteBuilder"/>.</param>
/// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
/// <returns>The <see cref="IEndpointConventionBuilder"/>.</returns>
public static IEndpointConventionBuilder MapComponentHub<TComponent>(
this IEndpointRouteBuilder routes,
string selector)
{
if (routes == null)
{
throw new ArgumentNullException(nameof(routes));
}

if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
}

return routes.MapComponentHub(typeof(TComponent), selector, ComponentHub.DefaultPath);
}

/// <summary>
/// Maps the SignalR <see cref="ComponentHub"/> to the path <paramref name="path"/> and associates
/// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
/// </summary>
/// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub"/>.</typeparam>
/// <param name="routes">The <see cref="RouteBuilder"/>.</param>
/// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
/// <param name="path">The path to map to which the <see cref="ComponentHub"/> will be mapped.</param>
/// <returns>The <see cref="IEndpointConventionBuilder"/>.</returns>
public static IEndpointConventionBuilder MapComponentHub<TComponent>(
this IEndpointRouteBuilder routes,
string selector,
string path)
{
if (routes == null)
{
throw new ArgumentNullException(nameof(routes));
}

if (path == null)
{
throw new ArgumentNullException(nameof(path));
}

if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
}

return routes.MapComponentHub(typeof(TComponent), selector, path);
}

/// <summary>
/// Maps the SignalR <see cref="ComponentHub"/> to the path <paramref name="path"/> and associates
/// the component <paramref name="componentType"/> to this hub instance as the given DOM <paramref name="selector"/>.
/// </summary>
/// <param name="routes">The <see cref="RouteBuilder"/>.</param>
/// <param name="componentType">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub"/>.</param>
/// <param name="selector">The selector for the <paramref name="componentType"/>.</param>
/// <param name="path">The path to map to which the <see cref="ComponentHub"/> will be mapped.</param>
/// <returns>The <see cref="IEndpointConventionBuilder"/>.</returns>
public static IEndpointConventionBuilder MapComponentHub(
this IEndpointRouteBuilder routes,
Type componentType,
string selector,
string path)
{
if (routes == null)
{
throw new ArgumentNullException(nameof(routes));
}

if (path == null)
{
throw new ArgumentNullException(nameof(path));
}

if (componentType == null)
{
throw new ArgumentNullException(nameof(componentType));
}

if (selector == null)
{
throw new ArgumentNullException(nameof(selector));
}

return routes.MapHub<ComponentHub>(path).AddComponent(componentType, selector);
}
}
}

This file was deleted.

23 changes: 0 additions & 23 deletions src/Components/Server/src/Builder/RazorComponentsOptions.cs

This file was deleted.

This file was deleted.

6 changes: 5 additions & 1 deletion src/Components/Server/src/Circuits/CircuitFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits
{
internal abstract class CircuitFactory
{
public abstract CircuitHost CreateCircuitHost(HttpContext httpContext, IClientProxy client);
public abstract CircuitHost CreateCircuitHost(
HttpContext httpContext,
IClientProxy client,
string uriAbsolute,
string baseUriAbsolute);
}
}
Loading