@@ -9,16 +9,14 @@ import {rendererLog, rendererError} from "./trace";
99import { SanitizationService } from '@angular/core/src/security' ;
1010import { isPresent , Type , print } from '@angular/core/src/facade/lang' ;
1111import { ReflectiveInjector , coreLoadAndBootstrap , createPlatform , EventEmitter ,
12- getPlatform , assertPlatform , ComponentRef , PlatformRef , PLATFORM_DIRECTIVES , PLATFORM_PIPES } from '@angular/core' ;
13- import { bind , provide , Provider } from '@angular/core/src/di' ;
12+ getPlatform , ComponentRef , PLATFORM_DIRECTIVES , PLATFORM_PIPES } from '@angular/core' ;
13+ import { provide , Provider } from '@angular/core/src/di' ;
1414
1515import { RootRenderer , Renderer } from '@angular/core/src/render/api' ;
1616import { NativeScriptRootRenderer , NativeScriptRenderer } from './renderer' ;
1717import { NativeScriptDomAdapter , NativeScriptElementSchemaRegistry , NativeScriptSanitizationService } from './dom-adapter' ;
1818import { ElementSchemaRegistry , XHR , COMPILER_PROVIDERS , CompilerConfig } from '@angular/compiler' ;
1919import { FileSystemXHR } from './http/xhr' ;
20- import { NSFileSystem } from './file-system/ns-file-system' ;
21- import { Parse5DomAdapter } from '@angular/platform-server/src/parse5_adapter' ;
2220import { ExceptionHandler } from '@angular/core/src/facade/exception_handler' ;
2321import { APPLICATION_COMMON_PROVIDERS } from '@angular/core/src/application_common_providers' ;
2422import { PLATFORM_COMMON_PROVIDERS } from '@angular/core/src/platform_common_providers' ;
@@ -29,7 +27,6 @@ import {Page} from 'ui/page';
2927import { TextView } from 'ui/text-view' ;
3028import application = require( 'application' ) ;
3129import { topmost , NavigationEntry } from "ui/frame" ;
32- import { Observable } from "rxjs" ;
3330
3431export type ProviderArray = Array < Type | Provider | any [ ] > ;
3532
@@ -55,9 +52,10 @@ interface BootstrapParams {
5552 customProviders ?: ProviderArray ,
5653 appOptions ?: AppOptions
5754}
58- var bootstrapCache : BootstrapParams
5955
60- var lastBootstrappedApp : WeakRef < ComponentRef < any > > ;
56+ let bootstrapCache : BootstrapParams ;
57+ let lastBootstrappedApp : WeakRef < ComponentRef < any > > ;
58+
6159export const onBeforeLivesync = new EventEmitter < ComponentRef < any > > ( ) ;
6260export const onAfterLivesync = new EventEmitter < ComponentRef < any > > ( ) ;
6361
@@ -104,24 +102,23 @@ export function bootstrap(appComponentType: any,
104102 NS_COMPILER_PROVIDERS ,
105103 provide ( ElementSchemaRegistry , { useClass : NativeScriptElementSchemaRegistry } ) ,
106104 provide ( XHR , { useClass : FileSystemXHR } )
107- ]
105+ ] ;
108106
109- var appProviders = [ defaultAppProviders ] ;
107+ let appProviders = [ defaultAppProviders ] ;
110108 if ( isPresent ( customProviders ) ) {
111109 appProviders . push ( customProviders ) ;
112110 }
113111
114- var platform = getPlatform ( ) ;
112+ let platform = getPlatform ( ) ;
115113 if ( ! isPresent ( platform ) ) {
116114 platform = createPlatform ( ReflectiveInjector . resolveAndCreate ( platformProviders ) ) ;
117115 }
118116
119- // reflector.reflectionCapabilities = new ReflectionCapabilities();
120- var appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
117+ let appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
121118 return coreLoadAndBootstrap ( appComponentType , appInjector ) ;
122119}
123120
124- function createNavigationEntry ( params : BootstrapParams , resolve : ( comp : ComponentRef < any > ) => void , reject : ( e : Error ) => void , isReboot : boolean ) {
121+ function createNavigationEntry ( params : BootstrapParams , resolve ? : ( comp : ComponentRef < any > ) => void , reject ? : ( e : Error ) => void , isReboot : boolean = false ) {
125122 const navEntry : NavigationEntry = {
126123 create : ( ) : Page => {
127124 let page = new Page ( ) ;
@@ -140,7 +137,10 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
140137 //profiling.stop('ng-bootstrap');
141138 rendererLog ( 'ANGULAR BOOTSTRAP DONE.' ) ;
142139 lastBootstrappedApp = new WeakRef ( compRef ) ;
143- resolve ( compRef ) ;
140+
141+ if ( resolve ) {
142+ resolve ( compRef ) ;
143+ }
144144 } , ( err ) => {
145145 rendererError ( 'ERROR BOOTSTRAPPING ANGULAR' ) ;
146146 let errorMessage = err . message + "\n\n" + err . stack ;
@@ -149,9 +149,12 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
149149 let view = new TextView ( ) ;
150150 view . text = errorMessage ;
151151 page . content = view ;
152- reject ( err ) ;
152+
153+ if ( reject ) {
154+ reject ( err ) ;
155+ }
153156 } ) ;
154- }
157+ } ;
155158
156159 page . on ( 'loaded' , onLoadedHandler ) ;
157160
@@ -167,23 +170,21 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
167170 return navEntry ;
168171}
169172
170- export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : Promise < ComponentRef < any > > {
173+ export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : void {
171174 bootstrapCache = { appComponentType, customProviders, appOptions } ;
172175
173176 if ( appOptions && appOptions . cssFile ) {
174177 application . cssFile = appOptions . cssFile ;
175178 }
176179
177- return new Promise ( ( resolve , reject ) => {
178- const navEntry = createNavigationEntry ( bootstrapCache , resolve , reject , false ) ;
179- application . start ( navEntry ) ;
180- } )
180+ const navEntry = createNavigationEntry ( bootstrapCache ) ;
181+ application . start ( navEntry ) ;
181182}
182183
183184// Patch livesync
184185const _baseLiveSync = global . __onLiveSync ;
185186global . __onLiveSync = function ( ) {
186- rendererLog ( "LiveSync Started" )
187+ rendererLog ( "LiveSync Started" ) ;
187188 if ( bootstrapCache ) {
188189 onBeforeLivesync . next ( lastBootstrappedApp ? lastBootstrappedApp . get ( ) : null ) ;
189190
@@ -204,6 +205,4 @@ global.__onLiveSync = function () {
204205 else {
205206 _baseLiveSync ( ) ;
206207 }
207- }
208-
209-
208+ } ;
0 commit comments