1- import hypernova , { serialize , load } from 'hypernova' ;
2- import { first } from 'rxjs/operators' ;
1+ import hypernova , { load } from 'hypernova' ;
32import { BrowserModule } from '@angular/platform-browser' ;
4- import {
5- ServerModule ,
6- platformDynamicServer ,
7- INITIAL_CONFIG ,
8- PlatformState ,
9- } from '@angular/platform-server' ;
103
114import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' ;
125
13- import { NgModule , ApplicationRef } from '@angular/core' ;
6+ import { NgModule } from '@angular/core' ;
147
158import { findNode , getData } from 'nova-helpers' ;
169
@@ -34,22 +27,6 @@ const APP_ID = 'hypernova';
3427
3528export const HYPERNOVA_DATA = 'Hypernova.Data' ;
3629
37- const getServerAppModule = ( Component , Module ) => {
38- function AppModule ( ) {
39- this . ngDoBootstrap = ( app ) => {
40- app . bootstrap ( Component , `#${ APP_ID } ` ) ;
41- } ;
42- }
43- return NgModule ( {
44- imports : [
45- Module ,
46- BrowserModule ,
47- ServerModule ,
48- ] ,
49- entryComponents : [ Component ] ,
50- } ) ( AppModule ) ;
51- } ;
52-
5330const getBrowserAppModule = ( Component , Module , node , propsData ) => {
5431 function AppModule ( ) {
5532 this . ngDoBootstrap = ( app ) => {
@@ -71,34 +48,6 @@ const getBrowserAppModule = (Component, Module, node, propsData) => {
7148 } ) ( AppModule ) ;
7249} ;
7350
74- const renderServer = ( ServerAppModule , propsData ) => {
75- const platform = platformDynamicServer ( [
76- {
77- provide : INITIAL_CONFIG ,
78- useValue : {
79- document : `<div id="${ APP_ID } "></div>` ,
80- } ,
81- } ,
82- {
83- provide : HYPERNOVA_DATA ,
84- useValue : propsData ,
85- } ,
86- ] ) ;
87-
88- return platform . bootstrapModule ( ServerAppModule )
89- . then ( ( moduleRef ) => {
90- const applicationRef = moduleRef . injector . get ( ApplicationRef ) ;
91- return applicationRef . isStable . pipe ( first ( isStable => isStable ) )
92- . toPromise ( )
93- . then ( ( ) => {
94- const platformState = platform . injector . get ( PlatformState ) ;
95-
96- platform . destroy ( ) ;
97- return platformState . getDocument ( ) . getElementById ( APP_ID ) . serialize ( ) ;
98- } ) ;
99- } ) ;
100- } ;
101-
10251export const mountComponent = ( Component , Module , node , propsData ) => {
10352 const BrowserAppModule = getBrowserAppModule ( Component , Module , node , propsData ) ;
10453
@@ -107,13 +56,7 @@ export const mountComponent = (Component, Module, node, propsData) => {
10756
10857export const renderAngular = ( name , Component , Module ) => hypernova ( {
10958 server ( ) {
110- return async ( propsData ) => {
111- const ServerAppModule = getServerAppModule ( Component , Module ) ;
112-
113- const html = await renderServer ( ServerAppModule , propsData ) ;
114-
115- return serialize ( name , html , propsData ) ;
116- } ;
59+ throw new Error ( 'Use hypernova-angular/server instead' ) ;
11760 } ,
11861
11962 client ( ) {
0 commit comments