1- import hypernova , { load } from 'hypernova' ;
2- import { BrowserModule } from '@angular/platform-browser' ;
3-
4- import { platformBrowserDynamic } from '@angular/platform-browser-dynamic' ;
5-
6- import { NgModule } from '@angular/core' ;
7-
81import { findNode , getData } from 'nova-helpers' ;
92
103export { load } from 'hypernova' ;
114
5+ export { HypernovaModuleFactory , HYPERNOVA_DATA } from './hypernova.module.factory' ;
6+
127export const loadById = ( name , id ) => {
138 const node = findNode ( name , id ) ;
149 const data = getData ( name , id ) ;
@@ -22,52 +17,3 @@ export const loadById = (name, id) => {
2217
2318 return null ;
2419} ;
25-
26- const APP_ID = 'hypernova' ;
27-
28- export const HYPERNOVA_DATA = 'Hypernova.Data' ;
29-
30- const getBrowserAppModule = ( Component , Module , node , propsData ) => {
31- function AppModule ( ) {
32- this . ngDoBootstrap = ( app ) => {
33- app . bootstrap ( Component , node ) ;
34- } ;
35- }
36- return NgModule ( {
37- imports : [
38- Module ,
39- BrowserModule . withServerTransition ( { appId : APP_ID } ) ,
40- ] ,
41- entryComponents : [ Component ] ,
42- providers : [
43- {
44- provide : HYPERNOVA_DATA ,
45- useValue : propsData ,
46- } ,
47- ] ,
48- } ) ( AppModule ) ;
49- } ;
50-
51- export const mountComponent = ( Component , Module , node , propsData ) => {
52- const BrowserAppModule = getBrowserAppModule ( Component , Module , node , propsData ) ;
53-
54- platformBrowserDynamic ( ) . bootstrapModule ( BrowserAppModule ) ;
55- } ;
56-
57- export const renderAngular = ( name , Component , Module ) => hypernova ( {
58- server ( ) {
59- throw new Error ( 'Use hypernova-angular/server instead' ) ;
60- } ,
61-
62- client ( ) {
63- const payloads = load ( name ) ;
64- if ( payloads ) {
65- payloads . forEach ( ( payload ) => {
66- const { node, data : propsData } = payload ;
67-
68- mountComponent ( Component , Module , node , propsData ) ;
69- } ) ;
70- }
71- return Component ;
72- } ,
73- } ) ;
0 commit comments