feat(platform-server): add API to render Module and ModuleFactory to string (#14381)

- PlatformState provides an interface to serialize the current Platform State as a string or Document.

- renderModule and renderModuleFactory are convenience methods to wait for Angular Application to stabilize and then render the state to a string.

- refactor code to remove defaultDoc from DomAdapter and inject DOCUMENT where it's needed.
This commit is contained in:
vikerman
2017-02-14 16:14:40 -08:00
committed by Igor Minar
parent 2f2b65bd38
commit b4d444a0a7
39 changed files with 462 additions and 187 deletions

View File

@ -120,8 +120,8 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
get _EVENT_MANAGER_PLUGINS_15(): any[] {
if ((this.__EVENT_MANAGER_PLUGINS_15 == (null as any))) {
(this.__EVENT_MANAGER_PLUGINS_15 = [
new import20.DomEventsPlugin(), new import21.KeyEventsPlugin(),
new import10.HammerGesturesPlugin(this._HAMMER_GESTURE_CONFIG_14)
new import20.DomEventsPlugin(document), new import21.KeyEventsPlugin(document),
new import10.HammerGesturesPlugin(document, this._HAMMER_GESTURE_CONFIG_14)
]);
}
return this.__EVENT_MANAGER_PLUGINS_15;
@ -163,7 +163,7 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
}
get _DomSanitizer_21(): import14.DomSanitizerImpl {
if ((this.__DomSanitizer_21 == (null as any))) {
(this.__DomSanitizer_21 = new import14.DomSanitizerImpl());
(this.__DomSanitizer_21 = new import14.DomSanitizerImpl(document));
}
return this.__DomSanitizer_21;
}
@ -206,7 +206,7 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
}
get _Title_27(): import16.Title {
if ((this.__Title_27 == (null as any))) {
(this.__Title_27 = new import16.Title());
(this.__Title_27 = new import16.Title(document));
}
return this.__Title_27;
}

View File

@ -92,7 +92,7 @@ export class AppModule implements Injector {
constructor() {
initServicesIfNeeded();
this.sanitizer = new DomSanitizerImpl();
this.sanitizer = new DomSanitizerImpl(document);
trustedEmptyColor = this.sanitizer.bypassSecurityTrustStyle('');
trustedGreyColor = this.sanitizer.bypassSecurityTrustStyle('grey');
this.componentFactory = createComponentFactory('#root', TreeComponent, TreeComponent_Host);

View File

@ -120,8 +120,8 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
get _EVENT_MANAGER_PLUGINS_15(): any[] {
if ((this.__EVENT_MANAGER_PLUGINS_15 == (null as any))) {
(this.__EVENT_MANAGER_PLUGINS_15 = [
new import20.DomEventsPlugin(), new import21.KeyEventsPlugin(),
new import10.HammerGesturesPlugin(this._HAMMER_GESTURE_CONFIG_14)
new import20.DomEventsPlugin(document), new import21.KeyEventsPlugin(document),
new import10.HammerGesturesPlugin(document, this._HAMMER_GESTURE_CONFIG_14)
]);
}
return this.__EVENT_MANAGER_PLUGINS_15;
@ -163,7 +163,7 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
}
get _DomSanitizer_21(): import14.DomSanitizerImpl {
if ((this.__DomSanitizer_21 == (null as any))) {
(this.__DomSanitizer_21 = new import14.DomSanitizerImpl());
(this.__DomSanitizer_21 = new import14.DomSanitizerImpl(document));
}
return this.__DomSanitizer_21;
}
@ -206,7 +206,7 @@ class AppModuleInjector extends import0.NgModuleInjector<import1.AppModule> {
}
get _Title_27(): import16.Title {
if ((this.__Title_27 == (null as any))) {
(this.__Title_27 = new import16.Title());
(this.__Title_27 = new import16.Title(document));
}
return this.__Title_27;
}