Obsolete Microsoft.AspNetCore.SpaServices and Microsoft.AspNetCore.No… (#12892)

Obsolete Microsoft.AspNetCore.SpaServices and Microsoft.AspNetCore.NodeServices
This commit is contained in:
Ryan Brandenburg 2019-08-09 13:47:51 -07:00 committed by GitHub
parent 3ab8ebff42
commit 14f17fa7cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 324 additions and 618 deletions

View File

@ -255,8 +255,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.NodeSe
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SpaServices", "SpaServices", "{D6FA4ABE-E685-4EDD-8B06-D8777E76B472}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Webpack", "SpaServices\samples\Webpack\Webpack.csproj", "{121DFA13-E965-4C91-A175-19EF20DFD5AC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices", "SpaServices\src\Microsoft.AspNetCore.SpaServices.csproj", "{D9D02772-1D53-45C3-B2CC-888F9978958C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices.Extensions", "SpaServices.Extensions\src\Microsoft.AspNetCore.SpaServices.Extensions.csproj", "{5D5B7E54-9323-498A-8983-E9BDFA3B2D07}"
@ -297,6 +295,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestOrigin", "CORS\test\tes
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore", "..\DefaultBuilder\src\Microsoft.AspNetCore.csproj", "{46B4FE62-06A1-4D54-B3E8-D8B4B3560075}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IntegrationTesting.IIS", "..\Servers\IIS\IntegrationTesting.IIS\src\Microsoft.AspNetCore.Server.IntegrationTesting.IIS.csproj", "{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SpaServices.Extensions.Tests", "SpaServices.Extensions\test\Microsoft.AspNetCore.SpaServices.Extensions.Tests.csproj", "{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1423,18 +1425,6 @@ Global
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x64.Build.0 = Release|Any CPU
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.ActiveCfg = Release|Any CPU
{40951683-DBC4-437A-BBAB-2FA7147E11EA}.Release|x86.Build.0 = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.ActiveCfg = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x64.Build.0 = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.ActiveCfg = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Debug|x86.Build.0 = Debug|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|Any CPU.Build.0 = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.ActiveCfg = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x64.Build.0 = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.ActiveCfg = Release|Any CPU
{121DFA13-E965-4C91-A175-19EF20DFD5AC}.Release|x86.Build.0 = Release|Any CPU
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9D02772-1D53-45C3-B2CC-888F9978958C}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -1627,6 +1617,30 @@ Global
{46B4FE62-06A1-4D54-B3E8-D8B4B3560075}.Release|x64.Build.0 = Release|Any CPU
{46B4FE62-06A1-4D54-B3E8-D8B4B3560075}.Release|x86.ActiveCfg = Release|Any CPU
{46B4FE62-06A1-4D54-B3E8-D8B4B3560075}.Release|x86.Build.0 = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|x64.ActiveCfg = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|x64.Build.0 = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|x86.ActiveCfg = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Debug|x86.Build.0 = Debug|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|Any CPU.Build.0 = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|x64.ActiveCfg = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|x64.Build.0 = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|x86.ActiveCfg = Release|Any CPU
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0}.Release|x86.Build.0 = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|x64.ActiveCfg = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|x64.Build.0 = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|x86.ActiveCfg = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Debug|x86.Build.0 = Debug|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|Any CPU.Build.0 = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|x64.ActiveCfg = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|x64.Build.0 = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|x86.ActiveCfg = Release|Any CPU
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1736,7 +1750,6 @@ Global
{47B6636D-09A3-47AE-9303-9F5D15EEE9D8} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
{C801B6A3-906F-406F-BA25-EAE0B4BCE5C9} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5}
{40951683-DBC4-437A-BBAB-2FA7147E11EA} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5}
{121DFA13-E965-4C91-A175-19EF20DFD5AC} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
{D9D02772-1D53-45C3-B2CC-888F9978958C} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
{5D5B7E54-9323-498A-8983-E9BDFA3B2D07} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
{B04E9CB6-0D1C-4C21-B626-89B6926A491F} = {17B409B3-7EC6-49D8-847E-CFAA319E01B5}
@ -1755,6 +1768,8 @@ Global
{DFEB537A-2D35-4C62-8A13-42798DF66A80} = {BD7B3AD8-0BA6-405F-8CF6-24B9464D4B5B}
{E0521105-3A7B-480B-B962-0BFC2838D919} = {BD7B3AD8-0BA6-405F-8CF6-24B9464D4B5B}
{46B4FE62-06A1-4D54-B3E8-D8B4B3560075} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
{92E11EBB-759E-4DA8-AB61-A9977D9F97D0} = {ACA6DDB9-7592-47CE-A740-D15BF307E9E0}
{D0CB733B-4CE8-4F6C-BBB9-548EA1A96966} = {D6FA4ABE-E685-4EDD-8B06-D8777E76B472}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {83786312-A93B-4BB4-AB06-7C6913A59AFA}

View File

@ -3,10 +3,13 @@
namespace Microsoft.AspNetCore.NodeServices
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class EmbeddedResourceReader
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static string Read(System.Type assemblyContainingType, string path) { throw null; }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial interface INodeServices : System.IDisposable
{
System.Threading.Tasks.Task<T> InvokeAsync<T>(string moduleName, params object[] args);
@ -14,10 +17,13 @@ namespace Microsoft.AspNetCore.NodeServices
System.Threading.Tasks.Task<T> InvokeExportAsync<T>(string moduleName, string exportedFunctionName, params object[] args);
System.Threading.Tasks.Task<T> InvokeExportAsync<T>(System.Threading.CancellationToken cancellationToken, string moduleName, string exportedFunctionName, params object[] args);
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class NodeServicesFactory
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static Microsoft.AspNetCore.NodeServices.INodeServices CreateNodeServices(Microsoft.AspNetCore.NodeServices.NodeServicesOptions options) { throw null; }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class NodeServicesOptions
{
public NodeServicesOptions(System.IServiceProvider serviceProvider) { }
@ -31,6 +37,7 @@ namespace Microsoft.AspNetCore.NodeServices
public string ProjectPath { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string[] WatchFileExtensions { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public sealed partial class StringAsTempFile : System.IDisposable
{
public StringAsTempFile(string content, System.Threading.CancellationToken applicationStoppingToken) { }
@ -41,10 +48,12 @@ namespace Microsoft.AspNetCore.NodeServices
}
namespace Microsoft.AspNetCore.NodeServices.HostingModels
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial interface INodeInstance : System.IDisposable
{
System.Threading.Tasks.Task<T> InvokeExportAsync<T>(System.Threading.CancellationToken cancellationToken, string moduleName, string exportNameOrNull, params object[] args);
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class NodeInvocationException : System.Exception
{
public NodeInvocationException(string message, string details) { }
@ -52,6 +61,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
public bool AllowConnectionDraining { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public bool NodeInstanceUnavailable { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class NodeInvocationInfo
{
public NodeInvocationInfo() { }
@ -59,10 +69,13 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
public string ExportedFunctionName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string ModuleName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class NodeServicesOptionsExtensions
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void UseHttpHosting(this Microsoft.AspNetCore.NodeServices.NodeServicesOptions options) { }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public abstract partial class OutOfProcessNodeInstance : Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance, System.IDisposable
{
protected readonly Microsoft.Extensions.Logging.ILogger OutputLogger;
@ -80,9 +93,12 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
}
namespace Microsoft.Extensions.DependencyInjection
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class NodeServicesServiceCollectionExtensions
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddNodeServices(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection) { }
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddNodeServices(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection, System.Action<Microsoft.AspNetCore.NodeServices.NodeServicesOptions> setupAction) { }
}
}

View File

@ -1,7 +1,9 @@
// 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.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.NodeServices;
using Microsoft.AspNetCore.SpaServices.Prerendering;
namespace NodeServicesExamples.Controllers
{
@ -17,7 +19,9 @@ namespace NodeServicesExamples.Controllers
return View();
}
#pragma warning disable 0618
public async Task<IActionResult> Chart([FromServices] INodeServices nodeServices)
#pragma warning restore 0618
{
var options = new { width = 400, height = 200, showArea = true, showPoint = true, fullWidth = true };
var data = new
@ -35,20 +39,6 @@ namespace NodeServicesExamples.Controllers
return View();
}
public async Task<IActionResult> Prerendering([FromServices] ISpaPrerenderer prerenderer)
{
var result = await prerenderer.RenderToString("./Node/prerenderPage");
if (!string.IsNullOrEmpty(result.RedirectUrl))
{
return Redirect(result.RedirectUrl);
}
ViewData["PrerenderedHtml"] = result.Html;
ViewData["PrerenderedGlobals"] = result.CreateGlobalsAssignmentScript();
return View();
}
public IActionResult Error()
{
return View("~/Views/Shared/Error.cshtml");

View File

@ -7,14 +7,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.SpaServices" />
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
<Reference Include="Microsoft.AspNetCore.Hosting" />
<Reference Include="Microsoft.AspNetCore.NodeServices" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
<Reference Include="Microsoft.Extensions.Logging.Debug" />
<Reference Include="Microsoft.Extensions.Logging.Console" />
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">

View File

@ -1,15 +1,20 @@
// 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.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.NodeServices;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.IO;
namespace NodeServicesExamples
{
public class Startup
{
#pragma warning disable 0618
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
@ -17,7 +22,6 @@ namespace NodeServicesExamples
// Enable Node Services
services.AddNodeServices();
services.AddSpaPrerenderer();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -26,11 +30,14 @@ namespace NodeServicesExamples
app.UseDeveloperExceptionPage();
// Dynamically transpile any .js files under the '/js/' directory
app.Use(next => async context => {
app.Use(next => async context =>
{
var requestPath = context.Request.Path.Value;
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) {
if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js"))
{
var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath);
if (fileInfo.Exists) {
if (fileInfo.Exists)
{
var transpiled = await nodeServices.InvokeAsync<string>("./Node/transpilation.js", fileInfo.PhysicalPath, requestPath);
await context.Response.WriteAsync(transpiled);
return;
@ -49,6 +56,7 @@ namespace NodeServicesExamples
endpoints.MapDefaultControllerRoute();
});
}
#pragma warning restore 0618
public static void Main(string[] args)
{

View File

@ -1,3 +1,6 @@
// 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;
namespace Microsoft.AspNetCore.NodeServices
@ -5,6 +8,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// <summary>
/// Supplies INodeServices instances.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class NodeServicesFactory
{
/// <summary>
@ -12,6 +16,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// </summary>
/// <param name="options">Options for creating the <see cref="INodeServices"/> instance.</param>
/// <returns>An <see cref="INodeServices"/> instance.</returns>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static INodeServices CreateNodeServices(NodeServicesOptions options)
{
if (options == null)
@ -22,4 +27,4 @@ namespace Microsoft.AspNetCore.NodeServices
return new NodeServicesImpl(options.NodeInstanceFactory);
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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 System.IO;
@ -14,6 +17,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// <summary>
/// Describes options used to configure an <see cref="INodeServices"/> instance.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class NodeServicesOptions
{
internal const string TimeoutConfigPropertyName = nameof(InvocationTimeoutMilliseconds);

View File

@ -1,3 +1,6 @@
// 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.NodeServices;
@ -6,12 +9,14 @@ namespace Microsoft.Extensions.DependencyInjection
/// <summary>
/// Extension methods for setting up NodeServices in an <see cref="IServiceCollection" />.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class NodeServicesServiceCollectionExtensions
{
/// <summary>
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
/// </summary>
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddNodeServices(this IServiceCollection serviceCollection)
=> AddNodeServices(serviceCollection, _ => {});
@ -20,6 +25,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
/// <param name="setupAction">A callback that will be invoked to populate the <see cref="NodeServicesOptions"/>.</param>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddNodeServices(this IServiceCollection serviceCollection, Action<NodeServicesOptions> setupAction)
{
if (setupAction == null)

View File

@ -1,3 +1,6 @@
// 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.IO;
using System.Net.Http;
@ -19,6 +22,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
/// accept RPC invocations.
/// </summary>
/// <seealso cref="Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance" />
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class HttpNodeInstance : OutOfProcessNodeInstance
{
private static readonly Regex EndpointMessageRegex =

View File

@ -1,3 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
@ -7,6 +10,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
/// <summary>
/// Represents an instance of Node.js to which Remote Procedure Calls (RPC) may be sent.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public interface INodeInstance : IDisposable
{
/// <summary>
@ -20,4 +24,4 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
Task<T> InvokeExportAsync<T>(CancellationToken cancellationToken, string moduleName, string exportNameOrNull, params object[] args);
}
}
}

View File

@ -1,3 +1,6 @@
// 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;
namespace Microsoft.AspNetCore.NodeServices.HostingModels
@ -5,6 +8,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
/// <summary>
/// Represents an exception caused by invoking Node.js code.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class NodeInvocationException : Exception
{
/// <summary>
@ -52,4 +56,4 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
AllowConnectionDraining = allowConnectionDraining;
}
}
}
}

View File

@ -1,8 +1,14 @@
// 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;
namespace Microsoft.AspNetCore.NodeServices.HostingModels
{
/// <summary>
/// Describes an RPC call sent from .NET code to Node.js code.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class NodeInvocationInfo
{
/// <summary>

View File

@ -1,17 +1,24 @@
// 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;
namespace Microsoft.AspNetCore.NodeServices.HostingModels
{
/// <summary>
/// Extension methods that help with populating a <see cref="NodeServicesOptions"/> object.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class NodeServicesOptionsExtensions
{
/// <summary>
/// Configures the <see cref="INodeServices"/> service so that it will use out-of-process
/// Node.js instances and perform RPC calls over HTTP.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void UseHttpHosting(this NodeServicesOptions options)
{
options.NodeInstanceFactory = () => new HttpNodeInstance(options);
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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 System.Diagnostics;
@ -19,6 +22,7 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
/// protocol, or any other RPC-type mechanism).
/// </summary>
/// <seealso cref="Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance" />
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public abstract class OutOfProcessNodeInstance : INodeInstance
{
/// <summary>
@ -472,4 +476,4 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
Dispose(false);
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
@ -9,6 +12,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// might change over time (e.g., the process might be restarted), the <see cref="INodeServices"/> instance
/// will remain constant.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public interface INodeServices : IDisposable
{
/// <summary>
@ -51,4 +55,4 @@ namespace Microsoft.AspNetCore.NodeServices
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
Task<T> InvokeExportAsync<T>(CancellationToken cancellationToken, string moduleName, string exportedFunctionName, params object[] args);
}
}
}

View File

@ -1,3 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
@ -17,6 +20,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// analogous to the "connection draining" feature implemented by HTTP load balancers.
/// </summary>
/// <seealso cref="Microsoft.AspNetCore.NodeServices.INodeServices" />
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class NodeServicesImpl : INodeServices
{
private static TimeSpan ConnectionDrainingTimespan = TimeSpan.FromSeconds(15);
@ -162,4 +166,4 @@ namespace Microsoft.AspNetCore.NodeServices
return _nodeInstanceFactory();
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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.IO;
using System.Reflection;
@ -7,6 +10,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// <summary>
/// Contains methods for reading embedded resources.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class EmbeddedResourceReader
{
/// <summary>
@ -15,6 +19,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// <param name="assemblyContainingType">Any <see cref="Type"/> in the assembly whose resource is to be read.</param>
/// <param name="path">The path of the resource to be read.</param>
/// <returns>The contents of the resource.</returns>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static string Read(Type assemblyContainingType, string path)
{
var asm = assemblyContainingType.GetTypeInfo().Assembly;
@ -27,4 +32,4 @@ namespace Microsoft.AspNetCore.NodeServices
}
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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.IO;
using System.Threading;
@ -7,6 +10,7 @@ namespace Microsoft.AspNetCore.NodeServices
/// <summary>
/// Makes it easier to pass script files to Node in a way that's sure to clean up after the process exits.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public sealed class StringAsTempFile : IDisposable
{
private bool _disposedValue;
@ -79,4 +83,4 @@ namespace Microsoft.AspNetCore.NodeServices
DisposeImpl(false);
}
}
}
}

View File

@ -1,10 +1,16 @@
// 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.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.NodeServices
{
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal static class TaskExtensions
{
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static Task OrThrowOnCancellation(this Task task, CancellationToken cancellationToken)
{
return task.IsCompleted
@ -16,6 +22,7 @@ namespace Microsoft.AspNetCore.NodeServices
TaskScheduler.Default);
}
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static Task<T> OrThrowOnCancellation<T>(this Task<T> task, CancellationToken cancellationToken)
{
return task.IsCompleted
@ -27,4 +34,4 @@ namespace Microsoft.AspNetCore.NodeServices
TaskScheduler.Default);
}
}
}
}

View File

@ -1,15 +1,16 @@
// 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 Microsoft.AspNetCore.NodeServices.HostingModels;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.NodeServices.HostingModels;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace Microsoft.AspNetCore.NodeServices
{
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class NodeServicesTest : IDisposable
{
private readonly INodeServices _nodeServices;

View File

@ -7,10 +7,13 @@ namespace Microsoft.AspNetCore.Builder
{
public static void UseSpa(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action<Microsoft.AspNetCore.SpaServices.ISpaBuilder> configuration) { }
}
[System.ObsoleteAttribute("Prerendering is no longer supported out of box")]
public static partial class SpaPrerenderingExtensions
{
[System.ObsoleteAttribute("Prerendering is no longer supported out of box")]
public static void UseSpaPrerendering(this Microsoft.AspNetCore.SpaServices.ISpaBuilder spaBuilder, System.Action<Microsoft.AspNetCore.Builder.SpaPrerenderingOptions> configuration) { }
}
[System.ObsoleteAttribute("Prerendering is no longer supported out of box")]
public partial class SpaPrerenderingOptions
{
public SpaPrerenderingOptions() { }
@ -44,6 +47,7 @@ namespace Microsoft.AspNetCore.SpaServices
}
namespace Microsoft.AspNetCore.SpaServices.AngularCli
{
[System.ObsoleteAttribute("Prerendering is no longer supported out of box")]
public partial class AngularCliBuilder : Microsoft.AspNetCore.SpaServices.Prerendering.ISpaPrerendererBuilder
{
public AngularCliBuilder(string npmScript) { }
@ -57,6 +61,7 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
}
namespace Microsoft.AspNetCore.SpaServices.Prerendering
{
[System.ObsoleteAttribute("Prerendering is no longer supported out of box")]
public partial interface ISpaPrerendererBuilder
{
System.Threading.Tasks.Task Build(Microsoft.AspNetCore.SpaServices.ISpaBuilder spaBuilder);

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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 Microsoft.AspNetCore.Builder;
@ -17,6 +17,7 @@ namespace Microsoft.AspNetCore.SpaServices.AngularCli
/// Provides an implementation of <see cref="ISpaPrerendererBuilder"/> that can build
/// an Angular application by invoking the Angular CLI.
/// </summary>
[Obsolete("Prerendering is no longer supported out of box")]
public class AngularCliBuilder : ISpaPrerendererBuilder
{
private static TimeSpan RegexMatchTimeout = TimeSpan.FromSeconds(5); // This is a development-time only feature, so a very long timeout is fine

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Helpers for building single-page applications on ASP.NET MVC Core.</Description>
@ -13,4 +13,8 @@
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Microsoft.AspNetCode.SpaServices.Extensions.Tests" />
</ItemGroup>
</Project>

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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 Microsoft.AspNetCore.Builder;
using System;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.SpaServices.Prerendering
@ -11,6 +11,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// so that it can be prerendered. This is only intended to be used at development
/// time. In production, a SPA should already have been built during publishing.
/// </summary>
[Obsolete("Prerendering is no longer supported out of box")]
public interface ISpaPrerendererBuilder
{
/// <summary>

View File

@ -23,6 +23,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// Extension methods for configuring prerendering of a Single Page Application.
/// </summary>
[Obsolete("Prerendering is no longer supported out of box")]
public static class SpaPrerenderingExtensions
{
/// <summary>
@ -30,6 +31,7 @@ namespace Microsoft.AspNetCore.Builder
/// </summary>
/// <param name="spaBuilder">The <see cref="ISpaBuilder"/>.</param>
/// <param name="configuration">Supplies configuration for the prerendering middleware.</param>
[Obsolete("Prerendering is no longer supported out of box")]
public static void UseSpaPrerendering(
this ISpaBuilder spaBuilder,
Action<SpaPrerenderingOptions> configuration)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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 Microsoft.AspNetCore.Http;
@ -11,6 +11,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// Represents options for the SPA prerendering middleware.
/// </summary>
[Obsolete("Prerendering is no longer supported out of box")]
public class SpaPrerenderingOptions
{
/// <summary>

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TestDependsOnNode>true</TestDependsOnNode>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.SpaServices.Extensions" />
<Reference Include="Microsoft.AspNetCore.Hosting" />
<Reference Include="Microsoft.AspNetCore.TestHost" />
<Reference Include="Microsoft.Extensions.Hosting" />
<Reference Include="Microsoft.Extensions.Logging.Testing" />
<Content Include="js\**\*" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
// 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.Builder;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.SpaServices.Extensions.Tests
{
public class SpaServicesExtensionsTests
{
[Fact]
public void UseSpa_ThrowsInvalidOperationException_IfRootpathNotSet()
{
// Arrange
var applicationbuilder = GetApplicationBuilder(GetServiceProvider());
// Act & Assert
var exception = Assert.Throws<InvalidOperationException>(
() => applicationbuilder.UseSpa(rb => { }));
Assert.Equal("No RootPath was set on the SpaStaticFilesOptions.", exception.Message);
}
private IApplicationBuilder GetApplicationBuilder(IServiceProvider serviceProvider = null)
{
if(serviceProvider == null)
{
serviceProvider = new Mock<IServiceProvider>(MockBehavior.Strict).Object;
}
var applicationbuilderMock = new Mock<IApplicationBuilder>();
applicationbuilderMock
.Setup(s => s.ApplicationServices)
.Returns(serviceProvider);
return applicationbuilderMock.Object;
}
private IServiceProvider GetServiceProvider()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddSpaStaticFiles();
return services.BuildServiceProvider();
}
}
}

View File

@ -3,33 +3,41 @@
namespace Microsoft.AspNetCore.Builder
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class SpaRouteExtensions
{
public static void MapSpaFallbackRoute(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string name, object defaults, object constraints = null, object dataTokens = null) { }
public static void MapSpaFallbackRoute(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string name, string templatePrefix, object defaults, object constraints = null, object dataTokens = null) { }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class WebpackDevMiddleware
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void UseWebpackDevMiddleware(this Microsoft.AspNetCore.Builder.IApplicationBuilder appBuilder, Microsoft.AspNetCore.SpaServices.Webpack.WebpackDevMiddlewareOptions options = null) { }
}
}
namespace Microsoft.AspNetCore.SpaServices.Prerendering
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial interface ISpaPrerenderer
{
System.Threading.Tasks.Task<Microsoft.AspNetCore.SpaServices.Prerendering.RenderToStringResult> RenderToString(string moduleName, string exportName = null, object customDataParameter = null, int timeoutMilliseconds = 0);
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class JavaScriptModuleExport
{
public JavaScriptModuleExport(string moduleName) { }
public string ExportName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public string ModuleName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class Prerenderer
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static System.Threading.Tasks.Task<Microsoft.AspNetCore.SpaServices.Prerendering.RenderToStringResult> RenderToString(string applicationBasePath, Microsoft.AspNetCore.NodeServices.INodeServices nodeServices, System.Threading.CancellationToken applicationStoppingToken, Microsoft.AspNetCore.SpaServices.Prerendering.JavaScriptModuleExport bootModule, string requestAbsoluteUrl, string requestPathAndQuery, object customDataParameter, int timeoutMilliseconds, string requestPathBase) { throw null; }
}
[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute(Attributes="asp-prerender-module")]
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class PrerenderTagHelper : Microsoft.AspNetCore.Razor.TagHelpers.TagHelper
{
public PrerenderTagHelper(System.IServiceProvider serviceProvider) { }
@ -47,6 +55,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
[System.Diagnostics.DebuggerStepThroughAttribute]
public override System.Threading.Tasks.Task ProcessAsync(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context, Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output) { throw null; }
}
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class RenderToStringResult
{
public RenderToStringResult() { }
@ -59,6 +68,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
}
namespace Microsoft.AspNetCore.SpaServices.Webpack
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public partial class WebpackDevMiddlewareOptions
{
public WebpackDevMiddlewareOptions() { }
@ -75,8 +85,10 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
}
namespace Microsoft.Extensions.DependencyInjection
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static partial class PrerenderingServiceCollectionExtensions
{
[System.ObsoleteAttribute("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddSpaPrerenderer(this Microsoft.Extensions.DependencyInjection.IServiceCollection serviceCollection) { }
}
}

View File

@ -1,233 +0,0 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
yarn.lock
wwwroot/dist
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Microsoft Azure ApplicationInsights config file
ApplicationInsights.config
# Windows Store app package directory
AppPackages/
BundleArtifacts/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
# FAKE - F# Make
.fake/

View File

@ -1,52 +0,0 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.NodeServices;
using Microsoft.AspNetCore.SpaServices.Prerendering;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Webpack.ActionResults
{
// This is an example of how you could invoke the prerendering API from an ActionResult, so as to
// prerender a SPA component as the entire response page (instead of injecting the SPA component
// into a Razor view's output)
public class PrerenderResult : ActionResult
{
private JavaScriptModuleExport _moduleExport;
private object _dataToSupply;
public PrerenderResult(JavaScriptModuleExport moduleExport, object dataToSupply = null)
{
_moduleExport = moduleExport;
_dataToSupply = dataToSupply;
}
public override async Task ExecuteResultAsync(ActionContext context)
{
var nodeServices = context.HttpContext.RequestServices.GetRequiredService<INodeServices>();
var hostEnv = context.HttpContext.RequestServices.GetRequiredService<IWebHostEnvironment>();
var applicationLifetime = context.HttpContext.RequestServices.GetRequiredService<IHostApplicationLifetime>();
var applicationBasePath = hostEnv.ContentRootPath;
var request = context.HttpContext.Request;
var response = context.HttpContext.Response;
var prerenderedHtml = await Prerenderer.RenderToString(
applicationBasePath,
nodeServices,
applicationLifetime.ApplicationStopping,
_moduleExport,
request.GetEncodedUrl(),
request.Path + request.QueryString.Value,
_dataToSupply,
/* timeoutMilliseconds */ 30000,
/* requestPathBase */ "/"
);
response.ContentType = "text/html";
await response.WriteAsync(prerenderedHtml.Html);
}
}
}

View File

@ -1,13 +0,0 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SpaServices.Prerendering;
namespace Webpack.ActionResults
{
public static class PrerenderResultExtensions
{
public static PrerenderResult Prerender(this ControllerBase controller, JavaScriptModuleExport exportToPrerender, object dataToSupply = null)
{
return new PrerenderResult(exportToPrerender, dataToSupply);
}
}
}

View File

@ -1,4 +0,0 @@
import { HelloWorld } from './HelloWorld';
import './styles/main.less';
new HelloWorld().doIt();

View File

@ -1,5 +0,0 @@
export class HelloWorld {
public doIt() {
console.log('Hello from MyApp');
}
}

View File

@ -1,5 +0,0 @@
@headerColor: red;
h1 {
color: @headerColor;
}

View File

@ -1,16 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Webpack.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

View File

@ -1,59 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SpaServices.Webpack;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System.IO;
using Microsoft.AspNetCore.NodeServices;
namespace Webpack
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddNodeServices();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseDeveloperExceptionPage();
// For real apps, you should only use Webpack Dev Middleware at development time. For production,
// you'll get better performance and reliability if you precompile the webpack output and simply
// serve the resulting static files. For examples of setting up this automatic switch between
// development-style and production-style webpack usage, see the 'templates' dir in this repo.
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
app.UseStaticFiles();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});
}
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.ConfigureLogging(factory =>
{
factory.AddConsole();
factory.AddDebug();
})
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
}

View File

@ -1,10 +0,0 @@
@{
ViewData["Title"] = "Home Page";
}
<h1>Hello</h1>
Hi there. Enter some text: <input />
@section scripts {
<script src="dist/main.js"></script>
}

View File

@ -1,6 +0,0 @@
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

View File

@ -1,14 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>@ViewData["Title"]</title>
<environment names="Production">
<link rel="stylesheet" href="dist/my-styles.css" />
</environment>
</head>
<body>
@RenderBody()
@RenderSection("scripts", required: false)
</body>
</html>

View File

@ -1,2 +0,0 @@
@using Webpack
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"

View File

@ -1,3 +0,0 @@
@{
Layout = "_Layout";
}

View File

@ -1,25 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.SpaServices" />
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
<Reference Include="Microsoft.AspNetCore.Hosting" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
<Reference Include="Microsoft.Extensions.Logging.Debug" />
<Reference Include="Microsoft.Extensions.Logging.Console" />
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="npm install" />
</Target>
</Project>

View File

@ -1,10 +0,0 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -1,20 +0,0 @@
{
"name": "Webpack",
"version": "0.0.0",
"devDependencies": {
"css-loader": "^0.23.1",
"extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1",
"less": "^2.6.0",
"less-loader": "^2.2.2",
"style-loader": "^0.13.0",
"webpack-hot-middleware": "^2.7.1"
},
"dependencies": {
"aspnet-prerendering": "^1.0.4",
"aspnet-webpack": "^1.0.3",
"ts-loader": "^0.8.1",
"typescript": "^2.0.0",
"webpack": "^1.13.3"
}
}

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs",
"target": "es5",
"jsx": "preserve",
"sourceMap": true,
"lib": ["es6", "dom"]
},
"exclude": [
"node_modules"
]
}

View File

@ -1,8 +0,0 @@
module.exports = {
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.less$/, loader: 'style-loader!css-loader!less-loader' }
]
}
};

View File

@ -1,25 +0,0 @@
var path = require('path');
var merge = require('extendify')({ isDeep: true, arrays: 'concat' });
var devConfig = require('./webpack.config.dev');
var prodConfig = require('./webpack.config.prod');
var isDevelopment = process.env.ASPNETCORE_ENVIRONMENT === 'Development';
module.exports = merge({
resolve: {
extensions: [ '', '.js', '.jsx', '.ts', '.tsx' ]
},
module: {
loaders: [
{ test: /\.ts(x?)$/, exclude: /node_modules/, loader: 'ts-loader?silent' }
],
},
entry: {
main: ['./Clientside/App.ts']
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
filename: '[name].js',
publicPath: '/dist/'
},
plugins: []
}, isDevelopment ? devConfig : prodConfig);

View File

@ -1,15 +0,0 @@
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractLESS = new ExtractTextPlugin('my-styles.css');
module.exports = {
module: {
loaders: [
{ test: /\.less$/, loader: extractLESS.extract(['css-loader', 'less-loader']) },
]
},
plugins: [
extractLESS,
new webpack.optimize.UglifyJsPlugin({ minimize: true, compressor: { warnings: false } })
]
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>

View File

@ -1,3 +1,7 @@
// 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.Threading;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -12,6 +16,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// server-side prerendering APIs. This is an alternative to prerendering via
/// the asp-prerender-module tag helper.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class DefaultSpaPrerenderer : ISpaPrerenderer
{
private readonly string _applicationBasePath;

View File

@ -1,4 +1,8 @@
using System.Threading.Tasks;
// 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.Threading.Tasks;
namespace Microsoft.AspNetCore.SpaServices.Prerendering
{
@ -7,6 +11,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// JavaScript-based Single Page Applications. This is an alternative
/// to using the 'asp-prerender-module' tag helper.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public interface ISpaPrerenderer
{
/// <summary>

View File

@ -1,3 +1,6 @@
// 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;
namespace Microsoft.AspNetCore.SpaServices.Prerendering
@ -5,6 +8,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// <summary>
/// Describes how to find the JavaScript code that performs prerendering.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class JavaScriptModuleExport
{
/// <summary>
@ -27,4 +31,4 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// </summary>
public string ExportName { get; set; }
}
}
}

View File

@ -1,3 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
@ -14,6 +17,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// A tag helper for prerendering JavaScript applications on the server.
/// </summary>
[HtmlTargetElement(Attributes = PrerenderModuleAttributeName)]
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class PrerenderTagHelper : TagHelper
{
private const string PrerenderModuleAttributeName = "asp-prerender-module";

View File

@ -1,3 +1,6 @@
// 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.Threading;
using System.Threading.Tasks;
@ -10,12 +13,14 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// <summary>
/// Performs server-side prerendering by invoking code in Node.js.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class Prerenderer
{
private static readonly object CreateNodeScriptLock = new object();
private static StringAsTempFile NodeScript;
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal static Task<RenderToStringResult> RenderToString(
string applicationBasePath,
INodeServices nodeServices,
@ -63,6 +68,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// <param name="timeoutMilliseconds">The maximum duration to wait for prerendering to complete.</param>
/// <param name="requestPathBase">The PathBase for the currently-executing HTTP request.</param>
/// <returns></returns>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static Task<RenderToStringResult> RenderToString(
string applicationBasePath,
INodeServices nodeServices,
@ -88,7 +94,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
private static string GetNodeScriptFilename(CancellationToken applicationStoppingToken)
{
lock(CreateNodeScriptLock)
lock (CreateNodeScriptLock)
{
if (NodeScript == null)
{
@ -100,4 +106,4 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
return NodeScript.FileName;
}
}
}
}

View File

@ -1,10 +1,15 @@
using Microsoft.AspNetCore.SpaServices.Prerendering;
// 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.SpaServices.Prerendering;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Extension methods for setting up prerendering features in an <see cref="IServiceCollection" />.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class PrerenderingServiceCollectionExtensions
{
/// <summary>
@ -12,6 +17,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// of <see cref="ISpaPrerenderer"/>.
/// </summary>
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void AddSpaPrerenderer(this IServiceCollection serviceCollection)
{
serviceCollection.AddHttpContextAccessor();

View File

@ -1,3 +1,7 @@
// 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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text;
@ -7,6 +11,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
/// <summary>
/// Describes the prerendering result returned by JavaScript code.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class RenderToStringResult
{
/// <summary>
@ -57,4 +62,4 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
return stringBuilder.ToString();
}
}
}
}

View File

@ -1,9 +1,13 @@
// 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.Http;
using Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.SpaServices
{
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class SpaRouteConstraint : IRouteConstraint
{
private readonly string _clientRouteTokenName;
@ -34,4 +38,4 @@ namespace Microsoft.AspNetCore.SpaServices
return uri.IndexOf('.', lastSegmentStartPos + 1) >= 0;
}
}
}
}

View File

@ -1,3 +1,6 @@
// 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.Routing;
@ -10,6 +13,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// Extension methods useful for configuring routing in a single-page application (SPA).
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class SpaRouteExtensions
{
private const string ClientRouteTokenName = "clientRoute";
@ -91,4 +95,4 @@ namespace Microsoft.AspNetCore.Builder
private static IDictionary<string, object> ObjectToDictionary(object value)
=> value as IDictionary<string, object> ?? new RouteValueDictionary(value);
}
}
}

View File

@ -1,9 +1,11 @@
// 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.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.SpaServices.Webpack
@ -14,6 +16,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
/// This is useful for Webpack middleware, because it lets you fall back on prebuilt files on disk for
/// chunks not exposed by the current Webpack config (e.g., DLL/vendor chunks).
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class ConditionalProxyMiddleware
{
private const int DefaultHttpBufferSize = 4096;
@ -89,7 +92,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
}
// We can handle this
context.Response.StatusCode = (int) responseMessage.StatusCode;
context.Response.StatusCode = (int)responseMessage.StatusCode;
foreach (var header in responseMessage.Headers)
{
context.Response.Headers[header.Key] = header.Value.ToArray();
@ -120,4 +123,4 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
}
}
}
}
}

View File

@ -1,7 +1,11 @@
// 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;
namespace Microsoft.AspNetCore.SpaServices.Webpack
{
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
internal class ConditionalProxyMiddlewareOptions
{
public ConditionalProxyMiddlewareOptions(string scheme, string host, string port, TimeSpan requestTimeout)
@ -17,4 +21,4 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
public string Port { get; }
public TimeSpan RequestTimeout { get; }
}
}
}

View File

@ -1,3 +1,6 @@
// 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.IO;
using System.Threading;
@ -11,6 +14,7 @@ namespace Microsoft.AspNetCore.Builder
/// <summary>
/// Extension methods that can be used to enable Webpack dev middleware support.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static class WebpackDevMiddleware
{
private const string DefaultConfigFile = "webpack.config.js";
@ -36,6 +40,7 @@ namespace Microsoft.AspNetCore.Builder
/// </summary>
/// <param name="appBuilder">The <see cref="IApplicationBuilder"/>.</param>
/// <param name="options">Options for configuring the Webpack compiler instance.</param>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public static void UseWebpackDevMiddleware(
this IApplicationBuilder appBuilder,
WebpackDevMiddlewareOptions options = null)
@ -145,4 +150,4 @@ namespace Microsoft.AspNetCore.Builder
}
}
#pragma warning restore CS0649
}
}

View File

@ -1,3 +1,7 @@
// 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;
namespace Microsoft.AspNetCore.SpaServices.Webpack
@ -5,6 +9,7 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
/// <summary>
/// Options for configuring a Webpack dev middleware compiler.
/// </summary>
[Obsolete("Use Microsoft.AspNetCore.SpaServices.Extensions")]
public class WebpackDevMiddlewareOptions
{
/// <summary>
@ -30,10 +35,10 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
/// </summary>
public bool ReactHotModuleReplacement { get; set; }
/// <summary>
/// <summary>
/// Specifies additional options to be passed to the Webpack Hot Middleware client, if used.
/// </summary>
public IDictionary<string, string> HotModuleReplacementClientOptions { get; set; }
/// </summary>
public IDictionary<string, string> HotModuleReplacementClientOptions { get; set; }
/// <summary>
/// Specifies the Webpack configuration file to be used. If not set, defaults to 'webpack.config.js'.
@ -58,4 +63,4 @@ namespace Microsoft.AspNetCore.SpaServices.Webpack
/// </summary>
public object EnvParam { get; set; }
}
}
}