@nguniversal/aspnetcore-engine
Advanced tools
Comparing version 1.0.0-beta.3 to 5.0.0-beta.1
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./src/main","export":["ngAspnetCoreEngine"]},{"from":"./src/create-transfer-script","export":["createTransferScript"]},{"from":"./src/tokens","export":["REQUEST","ORIGIN_URL"]},{"from":"./src/interfaces/engine-options","export":["IEngineOptions"]},{"from":"./src/interfaces/request-params","export":["IRequestParams"]}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./src/main","export":["ngAspnetCoreEngine"]},{"from":"./src/create-transfer-script","export":["createTransferScript"]},{"from":"./src/tokens","export":["REQUEST","ORIGIN_URL"]},{"from":"./src/interfaces/engine-options","export":["IEngineOptions"]},{"from":"./src/interfaces/request-params","export":["IRequestParams"]}]}] | ||
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./src/main","export":["ngAspnetCoreEngine"]},{"from":"./src/create-transfer-script","export":["createTransferScript"]},{"from":"./src/tokens","export":["REQUEST","ORIGIN_URL"]},{"from":"./src/interfaces/engine-options","export":["IEngineOptions"]},{"from":"./src/interfaces/request-params","export":["IRequestParams"]}]}] |
@@ -5,3 +5,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "1.0.0-beta.3", | ||
"version": "5.0.0-beta.1", | ||
"description": "ASP.NET Core Engine for running Server Angular Apps", | ||
@@ -37,16 +37,16 @@ "homepage": "https://github.com/angular/universal", | ||
"peerDependencies": { | ||
"@angular/core": "^4.0.0", | ||
"@angular/platform-server": "^4.0.0" | ||
"@angular/core": "^5.0.0-beta.7", | ||
"@angular/platform-server": "^5.0.0-beta.7" | ||
}, | ||
"devDependencies": { | ||
"@angular/common": "^4.0.0", | ||
"@angular/compiler": "^4.0.0", | ||
"@angular/core": "^4.0.0", | ||
"@angular/http": "^4.0.0", | ||
"@angular/platform-browser": "^4.0.0", | ||
"@angular/platform-server": "^4.0.0", | ||
"@angular/common": "^5.0.0-beta.7", | ||
"@angular/compiler": "^5.0.0-beta.7", | ||
"@angular/core": "^5.0.0-beta.7", | ||
"@angular/http": "^5.0.0-beta.7", | ||
"@angular/platform-browser": "^5.0.0-beta.7", | ||
"@angular/platform-server": "^5.0.0-beta.7", | ||
"rimraf": "^2.6.1", | ||
"rxjs": "^5.2.0", | ||
"typescript": "~2.3.2", | ||
"zone.js": "^0.8.4" | ||
"typescript": "2.4.2", | ||
"zone.js": "^0.8.12" | ||
}, | ||
@@ -53,0 +53,0 @@ "dependencies": { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"createTransferScript":{"__symbolic":"function","parameters":["transferData"],"value":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"binop","operator":"+","left":"<script>window['TRANSFER_CACHE'] = ","right":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"JSON"},"member":"stringify"},"arguments":[{"__symbolic":"reference","name":"transferData"}]}},"right":";</script>"}}}},{"__symbolic":"module","version":1,"metadata":{"createTransferScript":{"__symbolic":"function","parameters":["transferData"],"value":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"binop","operator":"+","left":"<script>window['TRANSFER_CACHE'] = ","right":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"JSON"},"member":"stringify"},"arguments":[{"__symbolic":"reference","name":"transferData"}]}},"right":";</script>"}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"createTransferScript":{"__symbolic":"function","parameters":["transferData"],"value":{"__symbolic":"binop","operator":"+","left":{"__symbolic":"binop","operator":"+","left":"<script>window['TRANSFER_CACHE'] = ","right":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"JSON"},"member":"stringify"},"arguments":[{"__symbolic":"reference","name":"transferData"}]}},"right":";</script>"}}}}] |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FileLoader":{"__symbolic":"class","members":{"get":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FileLoader":{"__symbolic":"class","members":{"get":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"FileLoader":{"__symbolic":"class","members":{"get":[{"__symbolic":"method"}]}}}}] |
import { IRequestParams } from "./request-params"; | ||
import { Type, NgModuleFactory, Provider } from '@angular/core'; | ||
import { Type, NgModuleFactory, StaticProvider } from '@angular/core'; | ||
export interface IEngineOptions { | ||
@@ -7,3 +7,3 @@ appSelector: string; | ||
ngModule: Type<{}> | NgModuleFactory<{}>; | ||
providers?: Provider[]; | ||
providers?: StaticProvider[]; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
; | ||
//# sourceMappingURL=engine-options.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"IEngineOptions":{"__symbolic":"interface"}}},{"__symbolic":"module","version":1,"metadata":{"IEngineOptions":{"__symbolic":"interface"}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"IEngineOptions":{"__symbolic":"interface"}}}] |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"IRequestParams":{"__symbolic":"interface"}}},{"__symbolic":"module","version":1,"metadata":{"IRequestParams":{"__symbolic":"interface"}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"IRequestParams":{"__symbolic":"interface"}}}] |
import { IEngineOptions } from './interfaces/engine-options'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/first'; | ||
export declare class UniversalData { | ||
static appNode: string; | ||
static title: string; | ||
static scripts: string; | ||
static styles: string; | ||
static meta: string; | ||
static links: string; | ||
} | ||
export declare function ngAspnetCoreEngine(options: IEngineOptions): Promise<{ | ||
@@ -5,0 +11,0 @@ html: string; |
182
src/main.js
@@ -8,5 +8,59 @@ "use strict"; | ||
var file_loader_1 = require("./file-loader"); | ||
require("rxjs/add/operator/filter"); | ||
require("rxjs/add/operator/first"); | ||
var platform_browser_1 = require("@angular/platform-browser"); | ||
/* @internal */ | ||
var UniversalData = (function () { | ||
function UniversalData() { | ||
} | ||
UniversalData.appNode = ''; | ||
UniversalData.title = ''; | ||
UniversalData.scripts = ''; | ||
UniversalData.styles = ''; | ||
UniversalData.meta = ''; | ||
UniversalData.links = ''; | ||
return UniversalData; | ||
}()); | ||
exports.UniversalData = UniversalData; | ||
/* @internal */ | ||
var appSelector = 'app-root'; // default | ||
/* @internal */ | ||
function beforeAppSerialized(doc /* TODO: type definition for Domino - DomAPI Spec (similar to "Document") */) { | ||
return function () { | ||
var STYLES = []; | ||
var SCRIPTS = []; | ||
var META = []; | ||
var LINKS = []; | ||
for (var i = 0; i < doc.head.children.length; i++) { | ||
var element = doc.head.children[i]; | ||
var tagName = element.tagName.toUpperCase(); | ||
switch (tagName) { | ||
case 'SCRIPT': | ||
SCRIPTS.push(element.outerHTML); | ||
break; | ||
case 'STYLE': | ||
STYLES.push(element.outerHTML); | ||
break; | ||
case 'LINK': | ||
LINKS.push(element.outerHTML); | ||
break; | ||
case 'META': | ||
META.push(element.outerHTML); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
UniversalData.title = doc.title; | ||
UniversalData.appNode = doc.querySelector(appSelector).outerHTML; | ||
UniversalData.scripts = SCRIPTS.join(' '); | ||
UniversalData.styles = STYLES.join(' '); | ||
UniversalData.meta = META.join(' '); | ||
UniversalData.links = LINKS.join(' '); | ||
}; | ||
} | ||
function ngAspnetCoreEngine(options) { | ||
if (!options.appSelector) { | ||
throw new Error("appSelector is required! Pass in \" appSelector: '<app-root></app-root>' \", for your root App component."); | ||
} | ||
// Grab the DOM "selector" from the passed in Template <app-root> for example = "app-root" | ||
appSelector = options.appSelector.substring(1, options.appSelector.indexOf('>')); | ||
var compilerFactory = platform_server_1.platformDynamicServer().injector.get(core_1.CompilerFactory); | ||
@@ -16,3 +70,3 @@ var compiler = compilerFactory.createCompiler([ | ||
providers: [ | ||
{ provide: compiler_1.ResourceLoader, useClass: file_loader_1.FileLoader } | ||
{ provide: compiler_1.ResourceLoader, useClass: file_loader_1.FileLoader, deps: [] } | ||
] | ||
@@ -28,97 +82,34 @@ } | ||
options.providers = options.providers || []; | ||
var extraProviders = options.providers.concat(options.providers, [ | ||
{ | ||
provide: platform_server_1.INITIAL_CONFIG, | ||
useValue: { | ||
document: options.appSelector, | ||
url: options.request.url | ||
var extraProviders_1 = (_a = options.providers).concat.apply(_a, options.providers.concat([[{ | ||
provide: tokens_1.ORIGIN_URL, | ||
useValue: options.request.origin | ||
}, { | ||
provide: tokens_1.REQUEST, | ||
useValue: options.request.data.request | ||
}, { | ||
provide: platform_server_1.BEFORE_APP_SERIALIZED, | ||
useFactory: beforeAppSerialized, multi: true, deps: [platform_browser_1.DOCUMENT] | ||
} | ||
}, | ||
{ | ||
provide: tokens_1.ORIGIN_URL, | ||
useValue: options.request.origin | ||
}, { | ||
provide: tokens_1.REQUEST, | ||
useValue: options.request.data.request | ||
} | ||
]); | ||
var platform_1 = platform_server_1.platformServer(extraProviders); | ||
]])); | ||
getFactory(moduleOrFactory, compiler) | ||
.then(function (factory) { | ||
return platform_1.bootstrapModuleFactory(factory).then(function (moduleRef) { | ||
var state = moduleRef.injector.get(platform_server_1.PlatformState); | ||
var appRef = moduleRef.injector.get(core_1.ApplicationRef); | ||
appRef.isStable | ||
.filter(function (isStable) { return isStable; }) | ||
.first() | ||
.subscribe(function () { | ||
// Fire the TransferState Cache | ||
var bootstrap = moduleRef.instance.ngOnBootstrap; | ||
bootstrap && bootstrap(); | ||
// The parse5 Document itself | ||
var AST_DOCUMENT = state.getDocument(); | ||
// Strip out the Angular application | ||
var htmlDoc = state.renderToString(); | ||
var APP_HTML = htmlDoc.substring(htmlDoc.indexOf('<body>') + 6, htmlDoc.indexOf('</body>')); | ||
// Strip out Styles / Meta-tags / Title | ||
// const STYLES = []; | ||
var META = []; | ||
var LINKS = []; | ||
var TITLE = ''; | ||
var STYLES_STRING = htmlDoc.substring(htmlDoc.indexOf('<style ng-transition'), htmlDoc.lastIndexOf('</style>') + 8); | ||
// STYLES_STRING = STYLES_STRING.replace(/\s/g, '').replace('<styleng-transition', '<style ng-transition'); | ||
var HEAD = AST_DOCUMENT.head; | ||
var count = 0; | ||
for (var i = 0; i < HEAD.children.length; i++) { | ||
var element = HEAD.children[i]; | ||
if (element.name === 'title') { | ||
TITLE = element.children[0].data; | ||
} | ||
// Broken after 4.0 (worked in rc) - needs investigation | ||
// As other things could be in <style> so we ideally want to get them this way | ||
// if (element.name === 'style') { | ||
// let styleTag = '<style '; | ||
// for (let key in element.attribs) { | ||
// if (key) { | ||
// styleTag += `${key}="${element.attribs[key]}">`; | ||
// } | ||
// } | ||
// styleTag += `${element.children[0].data}</style>`; | ||
// STYLES.push(styleTag); | ||
// } | ||
if (element.name === 'meta') { | ||
count = count + 1; | ||
var metaString = '<meta'; | ||
for (var key in element.attribs) { | ||
if (key) { | ||
metaString += " " + key + "=\"" + element.attribs[key] + "\""; | ||
} | ||
} | ||
META.push(metaString + " />\n"); | ||
} | ||
if (element.name === 'link') { | ||
var linkString = '<link'; | ||
for (var key in element.attribs) { | ||
if (key) { | ||
linkString += " " + key + "=\"" + element.attribs[key] + "\""; | ||
} | ||
} | ||
LINKS.push(linkString + " />\n"); | ||
} | ||
} | ||
// Return parsed App | ||
resolve({ | ||
html: APP_HTML, | ||
globals: { | ||
styles: STYLES_STRING, | ||
title: TITLE, | ||
meta: META.join(' '), | ||
links: LINKS.join(' ') | ||
} | ||
}); | ||
moduleRef.destroy(); | ||
}, function (err) { | ||
reject(err); | ||
}); | ||
return platform_server_1.renderModuleFactory(factory, { | ||
document: options.appSelector, | ||
url: options.request.url, | ||
extraProviders: extraProviders_1 | ||
}); | ||
}) | ||
.then(function () { | ||
resolve({ | ||
html: UniversalData.appNode, | ||
globals: { | ||
styles: UniversalData.styles, | ||
title: UniversalData.title, | ||
scripts: UniversalData.scripts, | ||
meta: UniversalData.meta, | ||
links: UniversalData.links | ||
} | ||
}); | ||
}, function (err) { | ||
reject(err); | ||
}); | ||
@@ -129,6 +120,7 @@ } | ||
} | ||
var _a; | ||
}); | ||
} | ||
exports.ngAspnetCoreEngine = ngAspnetCoreEngine; | ||
/* ********************** Private / Internal ****************** */ | ||
/* @internal */ | ||
var factoryCacheMap = new Map(); | ||
@@ -135,0 +127,0 @@ function getFactory(moduleOrFactory, compiler) { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"ngAspnetCoreEngine":{"__symbolic":"function"}}},{"__symbolic":"module","version":1,"metadata":{"ngAspnetCoreEngine":{"__symbolic":"function"}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"UniversalData":{"__symbolic":"class","statics":{"appNode":"","title":"","scripts":"","styles":"","meta":"","links":""}},"ngAspnetCoreEngine":{"__symbolic":"function"}}}] |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"REQUEST":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["REQUEST"]},"ORIGIN_URL":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["ORIGIN_URL"]}}},{"__symbolic":"module","version":1,"metadata":{"REQUEST":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["REQUEST"]},"ORIGIN_URL":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["ORIGIN_URL"]}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"REQUEST":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["REQUEST"]},"ORIGIN_URL":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["ORIGIN_URL"]}}}] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37
32713
240