@@ -60,6 +60,7 @@ export interface AppRunOptions<T, K> {
6060 appModuleBootstrap : ( reason : NgModuleReason ) => Promise < NgModuleRef < T > > ;
6161 loadingModule ?: ( reason : NgModuleReason ) => Promise < NgModuleRef < K > > ;
6262 launchView ?: ( reason : NgModuleReason ) => AppLaunchView ;
63+ embedded ?: boolean ;
6364}
6465
6566if ( import . meta[ 'webpackHot' ] ) {
@@ -213,10 +214,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
213214 if ( NativeScriptDebug . isLogEnabled ( ) ) {
214215 NativeScriptDebug . bootstrapLog ( `Setting RootView to ${ ref } ` ) ;
215216 }
216- if ( launchEventDone ) {
217- Application . resetRootView ( {
218- create : ( ) => ref ,
219- } ) ;
217+ if ( options . embedded ) {
218+ Application . run ( { create : ( ) => ref } ) ;
219+ } else if ( launchEventDone ) {
220+ Application . resetRootView ( { create : ( ) => ref } ) ;
220221 } else {
221222 targetRootView = ref ;
222223 }
@@ -227,10 +228,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
227228 if ( NativeScriptDebug . isLogEnabled ( ) ) {
228229 NativeScriptDebug . bootstrapLog ( `Setting RootView to ${ newRoot } ` ) ;
229230 }
230- if ( launchEventDone ) {
231- Application . resetRootView ( {
232- create : ( ) => newRoot ,
233- } ) ;
231+ if ( options . embedded ) {
232+ Application . run ( { create : ( ) => newRoot } ) ;
233+ } else if ( launchEventDone ) {
234+ Application . resetRootView ( { create : ( ) => newRoot } ) ;
234235 } else {
235236 targetRootView = newRoot ;
236237 }
@@ -393,7 +394,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
393394 oldAddEventListener = global . NativeScriptGlobals . events . addEventListener ;
394395 global . NativeScriptGlobals . events . addEventListener = global . NativeScriptGlobals . events [ Zone . __symbol__ ( 'addEventListener' ) ] ;
395396 }
396- Application . on ( Application . launchEvent , launchCallback ) ;
397+ if ( ! options . embedded ) {
398+ Application . on ( Application . launchEvent , launchCallback ) ;
399+ }
397400 Application . on ( Application . exitEvent , exitCallback ) ;
398401 if ( oldAddEventListener ) {
399402 global . NativeScriptGlobals . events . addEventListener = oldAddEventListener ;
@@ -431,5 +434,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
431434 return ;
432435 }
433436
434- Application . run ( ) ;
437+ if ( options . embedded ) {
438+ bootstrapRoot ( 'applaunch' ) ;
439+ } else {
440+ Application . run ( ) ;
441+ }
435442}
0 commit comments