mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Remove obsolete 1.x APIs
This commit is contained in:
@@ -41,7 +41,6 @@ namespace NodeServicesExamples
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
loggerFactory.AddConsole();
|
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
@@ -53,6 +52,11 @@ namespace NodeServicesExamples
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
|
.ConfigureLogging(factory =>
|
||||||
|
{
|
||||||
|
factory.AddConsole();
|
||||||
|
factory.AddDebug();
|
||||||
|
})
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseIISIntegration()
|
.UseIISIntegration()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
|
|
||||||
// Here, you could put any logic that synchronously or asynchronously prerenders
|
|
||||||
// your SPA components. For example, see the boot-server.ts files in the AngularSpa
|
|
||||||
// and ReactReduxSpa templates for ways to prerender Angular and React components.
|
|
||||||
//
|
|
||||||
// If you wanted, you could use a property on the 'params.data' object to specify
|
|
||||||
// which SPA component or template to render.
|
|
||||||
|
|
||||||
const html = `
|
|
||||||
<h1>Hello</h1>
|
|
||||||
It works! You passed <b>${ JSON.stringify(params.data) }</b>
|
|
||||||
and are currently requesting <b>${ params.location.path }</b>`;
|
|
||||||
resolve({ html });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.SpaServices.Prerendering;
|
|
||||||
using Webpack.ActionResults;
|
|
||||||
|
|
||||||
namespace Webpack.Controllers
|
|
||||||
{
|
|
||||||
// This sample shows how you could invoke the prerendering APIs directly from an MVC
|
|
||||||
// action result.
|
|
||||||
public class FullPagePrerenderingController : Controller
|
|
||||||
{
|
|
||||||
private static JavaScriptModuleExport BootModule = new JavaScriptModuleExport("Clientside/PrerenderingSample")
|
|
||||||
{
|
|
||||||
// Because the boot module is written in TypeScript, we need to specify a webpack
|
|
||||||
// config so it can be built. If it was written in JavaScript, this would not be needed.
|
|
||||||
WebpackConfig = "webpack.config.js"
|
|
||||||
};
|
|
||||||
|
|
||||||
public IActionResult Index()
|
|
||||||
{
|
|
||||||
var dataToSupply = new { nowTime = DateTime.Now.Ticks };
|
|
||||||
return this.Prerender(BootModule, dataToSupply);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,7 +32,6 @@ namespace Webpack
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
loggerFactory.AddConsole();
|
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
routes.MapRoute(
|
routes.MapRoute(
|
||||||
@@ -44,6 +43,11 @@ namespace Webpack
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
|
.ConfigureLogging(factory =>
|
||||||
|
{
|
||||||
|
factory.AddConsole();
|
||||||
|
factory.AddDebug();
|
||||||
|
})
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseIISIntegration()
|
.UseIISIntegration()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
|
|||||||
@@ -5,9 +5,6 @@
|
|||||||
<h1>Hello</h1>
|
<h1>Hello</h1>
|
||||||
Hi there. Enter some text: <input />
|
Hi there. Enter some text: <input />
|
||||||
|
|
||||||
<hr />
|
|
||||||
See also: <a asp-controller='FullPagePrerendering'>Full-page prerendering example</a>
|
|
||||||
|
|
||||||
@section scripts {
|
@section scripts {
|
||||||
<script src="dist/main.js"></script>
|
<script src="dist/main.js"></script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,20 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||||||
public static void AddNodeServices(this IServiceCollection serviceCollection)
|
public static void AddNodeServices(this IServiceCollection serviceCollection)
|
||||||
=> AddNodeServices(serviceCollection, _ => {});
|
=> AddNodeServices(serviceCollection, _ => {});
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
|
|
||||||
/// <param name="options">Options for configuring the <see cref="INodeServices"/> instances.</param>
|
|
||||||
[Obsolete("Use the AddNodeServices(Action<NodeServicesOptions> setupAction) overload instead.")]
|
|
||||||
public static void AddNodeServices(this IServiceCollection serviceCollection, NodeServicesOptions options)
|
|
||||||
{
|
|
||||||
serviceCollection.AddSingleton(typeof (INodeServices), _ =>
|
|
||||||
{
|
|
||||||
return NodeServicesFactory.CreateNodeServices(options);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
|
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -50,26 +50,5 @@ namespace Microsoft.AspNetCore.NodeServices
|
|||||||
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
||||||
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
/// <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);
|
Task<T> InvokeExportAsync<T>(CancellationToken cancellationToken, string moduleName, string exportedFunctionName, params object[] args);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Asynchronously invokes code in the Node.js instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
||||||
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root whose default CommonJS export is the function to be invoked.</param>
|
|
||||||
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
||||||
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
||||||
[Obsolete("Use InvokeAsync instead")]
|
|
||||||
Task<T> Invoke<T>(string moduleName, params object[] args);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Asynchronously invokes code in the Node.js instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
||||||
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked.</param>
|
|
||||||
/// <param name="exportedFunctionName">Specifies the CommonJS export to be invoked.</param>
|
|
||||||
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
||||||
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
||||||
[Obsolete("Use InvokeExportAsync instead")]
|
|
||||||
Task<T> InvokeExport<T>(string moduleName, string exportedFunctionName, params object[] args);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,17 +161,5 @@ namespace Microsoft.AspNetCore.NodeServices
|
|||||||
{
|
{
|
||||||
return _nodeInstanceFactory();
|
return _nodeInstanceFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obsolete method - will be removed soon
|
|
||||||
public Task<T> Invoke<T>(string moduleName, params object[] args)
|
|
||||||
{
|
|
||||||
return InvokeAsync<T>(moduleName, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obsolete method - will be removed soon
|
|
||||||
public Task<T> InvokeExport<T>(string moduleName, string exportedFunctionName, params object[] args)
|
|
||||||
{
|
|
||||||
return InvokeExportAsync<T>(moduleName, exportedFunctionName, args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,11 +26,5 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
/// If not set, the JavaScript module's default CommonJS export must itself be the prerendering function.
|
/// If not set, the JavaScript module's default CommonJS export must itself be the prerendering function.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ExportName { get; set; }
|
public string ExportName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Obsolete. Do not use. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Do not use. This feature will be removed. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.")]
|
|
||||||
public string WebpackConfig { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
{
|
{
|
||||||
private const string PrerenderModuleAttributeName = "asp-prerender-module";
|
private const string PrerenderModuleAttributeName = "asp-prerender-module";
|
||||||
private const string PrerenderExportAttributeName = "asp-prerender-export";
|
private const string PrerenderExportAttributeName = "asp-prerender-export";
|
||||||
private const string PrerenderWebpackConfigAttributeName = "asp-prerender-webpack-config";
|
|
||||||
private const string PrerenderDataAttributeName = "asp-prerender-data";
|
private const string PrerenderDataAttributeName = "asp-prerender-data";
|
||||||
private const string PrerenderTimeoutAttributeName = "asp-prerender-timeout";
|
private const string PrerenderTimeoutAttributeName = "asp-prerender-timeout";
|
||||||
private static INodeServices _fallbackNodeServices; // Used only if no INodeServices was registered with DI
|
private static INodeServices _fallbackNodeServices; // Used only if no INodeServices was registered with DI
|
||||||
@@ -59,13 +58,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
[HtmlAttributeName(PrerenderExportAttributeName)]
|
[HtmlAttributeName(PrerenderExportAttributeName)]
|
||||||
public string ExportName { get; set; }
|
public string ExportName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Obsolete. Do not use. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Do not use. This feature will be removed. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.")]
|
|
||||||
[HtmlAttributeName(PrerenderWebpackConfigAttributeName)]
|
|
||||||
public string WebpackConfigPath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An optional JSON-serializable parameter to be supplied to the prerendering code.
|
/// An optional JSON-serializable parameter to be supplied to the prerendering code.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -111,10 +103,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering
|
|||||||
_nodeServices,
|
_nodeServices,
|
||||||
new JavaScriptModuleExport(ModuleName)
|
new JavaScriptModuleExport(ModuleName)
|
||||||
{
|
{
|
||||||
ExportName = ExportName,
|
ExportName = ExportName
|
||||||
#pragma warning disable CS0618 // Type or member is obsolete
|
|
||||||
WebpackConfig = WebpackConfigPath
|
|
||||||
#pragma warning restore CS0618 // Type or member is obsolete
|
|
||||||
},
|
},
|
||||||
unencodedAbsoluteUrl,
|
unencodedAbsoluteUrl,
|
||||||
unencodedPathAndQuery,
|
unencodedPathAndQuery,
|
||||||
|
|||||||
Reference in New Issue
Block a user