mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 02:57:31 +00:00
Implement and document asp-prerender-data
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aspnet-prerendering",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Helpers for server-side rendering of JavaScript applications in ASP.NET Core projects. Works in conjunction with the Microsoft.AspNetCore.SpaServices NuGet package.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface BootFuncParams {
|
||||
url: string; // e.g., '/some/path'
|
||||
absoluteUrl: string; // e.g., 'https://example.com:1234/some/path'
|
||||
domainTasks: Promise<any>;
|
||||
data: any; // any custom object passed through from .NET
|
||||
}
|
||||
|
||||
export interface BootModuleInfo {
|
||||
@@ -32,7 +33,7 @@ export interface BootModuleInfo {
|
||||
webpackConfig?: string;
|
||||
}
|
||||
|
||||
export function renderToString(callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string) {
|
||||
export function renderToString(callback: RenderToStringCallback, applicationBasePath: string, bootModule: BootModuleInfo, absoluteRequestUrl: string, requestPathAndQuery: string, customDataParameter: any) {
|
||||
findBootFunc(applicationBasePath, bootModule, (findBootFuncError, bootFunc) => {
|
||||
if (findBootFuncError) {
|
||||
callback(findBootFuncError, null);
|
||||
@@ -51,7 +52,8 @@ export function renderToString(callback: RenderToStringCallback, applicationBase
|
||||
origin: parsedAbsoluteRequestUrl.protocol + '//' + parsedAbsoluteRequestUrl.host,
|
||||
url: requestPathAndQuery,
|
||||
absoluteUrl: absoluteRequestUrl,
|
||||
domainTasks: domainTaskCompletionPromise
|
||||
domainTasks: domainTaskCompletionPromise,
|
||||
data: customDataParameter
|
||||
};
|
||||
|
||||
// Open a new domain that can track all the async tasks involved in the app's execution
|
||||
@@ -86,7 +88,7 @@ function findBootModule<T>(applicationBasePath: string, bootModule: BootModuleIn
|
||||
const bootModuleNameFullPath = path.resolve(applicationBasePath, bootModule.moduleName);
|
||||
if (bootModule.webpackConfig) {
|
||||
const webpackConfigFullPath = path.resolve(applicationBasePath, bootModule.webpackConfig);
|
||||
|
||||
|
||||
let aspNetWebpackModule: any;
|
||||
try {
|
||||
aspNetWebpackModule = require('aspnet-webpack');
|
||||
|
||||
Reference in New Issue
Block a user