-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[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
mkArtakMSFT
merged 19 commits into
release/3.0-preview3
from
javiercn/prerrenderer-startup-experience
Feb 22, 2019
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ec839ca
[Components] Prerrendering startup experience
javiercn edd5687
Address feedback
javiercn 628ec49
Prerrender -> Prerender, remove selectorless overloads from MapCompon…
javiercn 2fbe11b
Get rid of ComponentEndpointBuilder alltogether
javiercn ae9b7f3
Fix compilation
javiercn 5dd078e
Update project template
javiercn 4d49c3a
Cleanup
javiercn d637117
Update JSRuntime comment
javiercn 860ceb8
Cleanups
javiercn 7a6f848
Remove the JSRuntimeAccessor
javiercn de5750d
More cleanups
javiercn 96f9a13
Map hub manually
javiercn 8971921
Update startup project template
javiercn 7e6f384
Addressed feedback from @pranavkm
javiercn c380e55
Last template touch-ups
javiercn 9ac11bd
Final cleanups
javiercn bbd0ce6
Last cleanups for realz
javiercn 83f8627
Make static file options configuration internal
javiercn 9524dd6
Fix broken test
javiercn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/Components/Server/src/Builder/ComponentEndpointConventionBuilderExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
} | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
src/Components/Server/src/Builder/ComponentEndpointRouteBuilderExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
src/Components/Server/src/Builder/RazorComponentsApplicationBuilderExtensions.cs
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/Components/Server/src/Builder/RazorComponentsOptions.cs
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
src/Components/Server/src/Builder/ServerSideComponentsApplicationBuilder.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.