1- import { ApplicationRef , EnvironmentProviders , NgModuleRef , NgZone , PlatformRef , Provider , Type , ɵinternalCreateApplication as internalCreateApplication } from '@angular/core' ;
1+ import { ApplicationRef , EnvironmentProviders , NgModuleRef , NgZone , PlatformRef , Provider } from '@angular/core' ;
2+ import {
3+ Application ,
4+ ApplicationEventData ,
5+ Color ,
6+ LaunchEventData ,
7+ LayoutBase ,
8+ profile ,
9+ removeTaggedAdditionalCSS ,
10+ TextView ,
11+ Utils ,
12+ View ,
13+ } from '@nativescript/core' ;
14+ import { Observable , Subject } from 'rxjs' ;
215import { filter , map , take } from 'rxjs/operators' ;
3- import { Application , ApplicationEventData , Color , LaunchEventData , LayoutBase , profile , removeTaggedAdditionalCSS , StackLayout , TextView , View , Utils , Trace } from '@nativescript/core' ;
416import { AppHostView } from './app-host-view' ;
517import { NativeScriptLoadingService } from './loading.service' ;
618import { APP_ROOT_VIEW , DISABLE_ROOT_VIEW_HANDLING , NATIVESCRIPT_ROOT_MODULE_ID } from './tokens' ;
7- import { Observable , Subject } from 'rxjs' ;
819import { NativeScriptDebug } from './trace' ;
9- import { NATIVESCRIPT_MODULE_PROVIDERS , NATIVESCRIPT_MODULE_STATIC_PROVIDERS } from './nativescript' ;
1020
1121export interface AppLaunchView extends LayoutBase {
1222 // called when the animation is to begin
@@ -45,7 +55,7 @@ export const postAngularBootstrap$ = new Subject<NgModuleEvent>();
4555 */
4656export const onBeforeLivesync : Observable < NgModuleRef < any > > = preAngularDisposal$ . pipe (
4757 filter ( ( v ) => v . moduleType === 'main' && v . reason === 'hotreload' ) ,
48- map ( ( v ) => v . reference as NgModuleRef < any > )
58+ map ( ( v ) => v . reference as NgModuleRef < any > ) ,
4959) ;
5060/**
5161 * @deprecated
@@ -55,7 +65,7 @@ export const onAfterLivesync: Observable<{
5565 error ?: Error ;
5666} > = postAngularBootstrap$ . pipe (
5767 filter ( ( v ) => v . moduleType === 'main' ) ,
58- map ( ( v ) => ( { moduleRef : v . reference as NgModuleRef < any > } ) )
68+ map ( ( v ) => ( { moduleRef : v . reference as NgModuleRef < any > } ) ) ,
5969) ;
6070export interface AppRunOptions < T , K > {
6171 /**
@@ -92,7 +102,11 @@ if (import.meta['webpackHot']) {
92102 } ;
93103}
94104
95- function emitModuleBootstrapEvent < T > ( ref : NgModuleRef < T > | ApplicationRef , name : 'main' | 'loading' , reason : NgModuleReason ) {
105+ function emitModuleBootstrapEvent < T > (
106+ ref : NgModuleRef < T > | ApplicationRef ,
107+ name : 'main' | 'loading' ,
108+ reason : NgModuleReason ,
109+ ) {
96110 postAngularBootstrap$ . next ( {
97111 moduleType : name ,
98112 reference : ref ,
@@ -136,7 +150,7 @@ function runZoneSyncTask(fn: () => void) {
136150 } ,
137151 ( ) => {
138152 //
139- }
153+ } ,
140154 ) ;
141155 try {
142156 // console.log(task.state);
@@ -198,22 +212,12 @@ function runSynchronously(fn: () => void, done?: () => void): void {
198212 }
199213}
200214
201- function createProvidersConfig ( options ?: ApplicationConfig ) {
202- return {
203- appProviders : [ ...NATIVESCRIPT_MODULE_PROVIDERS , ...NATIVESCRIPT_MODULE_STATIC_PROVIDERS , ...( options ?. providers ?? [ ] ) ] ,
204- // platformProviders: INTERNAL_BROWSER_PLATFORM_PROVIDERS
205- } ;
206- }
207-
208215export interface ApplicationConfig {
209216 /**
210217 * List of providers that should be available to the root component and all its children.
211218 */
212219 providers : Array < Provider | EnvironmentProviders > ;
213220}
214- export function bootstrapApplication ( rootComponent : Type < unknown > , options ?: ApplicationConfig ) : Promise < ApplicationRef > {
215- return internalCreateApplication ( { rootComponent, ...createProvidersConfig ( options ) } ) ;
216- }
217221
218222export function runNativeScriptAngularApp < T , K > ( options : AppRunOptions < T , K > ) {
219223 let mainModuleRef : NgModuleRef < T > | ApplicationRef = null ;
@@ -301,7 +305,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
301305 }
302306 mainModuleRef = ref ;
303307
304- ( ref instanceof ApplicationRef ? ref . components [ 0 ] : ref ) . onDestroy ( ( ) => ( mainModuleRef = mainModuleRef === ref ? null : mainModuleRef ) ) ;
308+ ( ref instanceof ApplicationRef ? ref . components [ 0 ] : ref ) . onDestroy (
309+ ( ) => ( mainModuleRef = mainModuleRef === ref ? null : mainModuleRef ) ,
310+ ) ;
305311 updatePlatformRef ( ref , reason ) ;
306312 const styleTag = ref . injector . get ( NATIVESCRIPT_ROOT_MODULE_ID ) ;
307313 ( ref instanceof ApplicationRef ? ref . components [ 0 ] : ref ) . onDestroy ( ( ) => {
@@ -317,7 +323,7 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
317323 NativeScriptDebug . bootstrapLogError ( `Error bootstrapping app module:\n${ err . message } \n\n${ err . stack } ` ) ;
318324 showErrorUI ( err ) ;
319325 throw err ;
320- }
326+ } ,
321327 ) ,
322328 ( ) => {
323329 if ( currentBootstrapId !== bootstrapId ) {
@@ -335,10 +341,16 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
335341 return ;
336342 }
337343 loadingModuleRef = loadingRef ;
338- ( loadingModuleRef instanceof ApplicationRef ? loadingModuleRef . components [ 0 ] : loadingModuleRef ) . onDestroy ( ( ) => ( loadingModuleRef = loadingModuleRef === loadingRef ? null : loadingModuleRef ) ) ;
344+ ( loadingModuleRef instanceof ApplicationRef
345+ ? loadingModuleRef . components [ 0 ]
346+ : loadingModuleRef
347+ ) . onDestroy ( ( ) => ( loadingModuleRef = loadingModuleRef === loadingRef ? null : loadingModuleRef ) ) ;
339348 updatePlatformRef ( loadingRef , reason ) ;
340349 const styleTag = loadingModuleRef . injector . get ( NATIVESCRIPT_ROOT_MODULE_ID ) ;
341- ( loadingModuleRef instanceof ApplicationRef ? loadingModuleRef . components [ 0 ] : loadingModuleRef ) . onDestroy ( ( ) => {
350+ ( loadingModuleRef instanceof ApplicationRef
351+ ? loadingModuleRef . components [ 0 ]
352+ : loadingModuleRef
353+ ) . onDestroy ( ( ) => {
342354 removeTaggedAdditionalCSS ( styleTag ) ;
343355 } ) ;
344356 setRootView ( loadingRef ) ;
@@ -352,7 +364,7 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
352364 loadingService . readyToDestroy$
353365 . pipe (
354366 filter ( ( ready ) => ready ) ,
355- take ( 1 )
367+ take ( 1 ) ,
356368 )
357369 . subscribe ( ( ) => {
358370 destroyRef ( loadingModuleRef , 'loading' , reason ) ;
@@ -364,11 +376,13 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
364376 emitModuleBootstrapEvent ( loadingModuleRef , 'loading' , reason ) ;
365377 } ,
366378 ( err ) => {
367- NativeScriptDebug . bootstrapLogError ( `Error bootstrapping loading module:\n${ err . message } \n\n${ err . stack } ` ) ;
379+ NativeScriptDebug . bootstrapLogError (
380+ `Error bootstrapping loading module:\n${ err . message } \n\n${ err . stack } ` ,
381+ ) ;
368382 showErrorUI ( err ) ;
369383 throw err ;
370- }
371- )
384+ } ,
385+ ) ,
372386 ) ;
373387 } else if ( options . launchView ) {
374388 let launchView = options . launchView ( reason ) ;
@@ -397,10 +411,12 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
397411 } ) ;
398412 } ;
399413 } else {
400- console . warn ( 'App is bootstrapping asynchronously (likely APP_INITIALIZER) but did not provide a launchView or LoadingModule.' ) ;
414+ console . warn (
415+ 'App is bootstrapping asynchronously (likely APP_INITIALIZER) but did not provide a launchView or LoadingModule.' ,
416+ ) ;
401417 }
402418 }
403- }
419+ } ,
404420 ) ;
405421 } catch ( err ) {
406422 NativeScriptDebug . bootstrapLogError ( `Error in Bootstrap Function:\n${ err . message } \n\n${ err . stack } ` ) ;
@@ -431,7 +447,8 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
431447 let oldAddEventListener ;
432448 if ( typeof Zone !== 'undefined' && global . NativeScriptGlobals ?. events ?. [ Zone . __symbol__ ( 'addEventListener' ) ] ) {
433449 oldAddEventListener = global . NativeScriptGlobals . events . addEventListener ;
434- global . NativeScriptGlobals . events . addEventListener = global . NativeScriptGlobals . events [ Zone . __symbol__ ( 'addEventListener' ) ] ;
450+ global . NativeScriptGlobals . events . addEventListener =
451+ global . NativeScriptGlobals . events [ Zone . __symbol__ ( 'addEventListener' ) ] ;
435452 }
436453 if ( ! options . embedded ) {
437454 Application . on ( Application . launchEvent , launchCallback ) ;
0 commit comments