@@ -9,16 +9,14 @@ import {rendererLog, rendererError} from "./trace";
9
9
import { SanitizationService } from '@angular/core/src/security' ;
10
10
import { isPresent , Type , print } from '@angular/core/src/facade/lang' ;
11
11
import { 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' ;
14
14
15
15
import { RootRenderer , Renderer } from '@angular/core/src/render/api' ;
16
16
import { NativeScriptRootRenderer , NativeScriptRenderer } from './renderer' ;
17
17
import { NativeScriptDomAdapter , NativeScriptElementSchemaRegistry , NativeScriptSanitizationService } from './dom-adapter' ;
18
18
import { ElementSchemaRegistry , XHR , COMPILER_PROVIDERS , CompilerConfig } from '@angular/compiler' ;
19
19
import { FileSystemXHR } from './http/xhr' ;
20
- import { NSFileSystem } from './file-system/ns-file-system' ;
21
- import { Parse5DomAdapter } from '@angular/platform-server/src/parse5_adapter' ;
22
20
import { ExceptionHandler } from '@angular/core/src/facade/exception_handler' ;
23
21
import { APPLICATION_COMMON_PROVIDERS } from '@angular/core/src/application_common_providers' ;
24
22
import { PLATFORM_COMMON_PROVIDERS } from '@angular/core/src/platform_common_providers' ;
@@ -29,7 +27,6 @@ import {Page} from 'ui/page';
29
27
import { TextView } from 'ui/text-view' ;
30
28
import application = require( 'application' ) ;
31
29
import { topmost , NavigationEntry } from "ui/frame" ;
32
- import { Observable } from "rxjs" ;
33
30
34
31
export type ProviderArray = Array < Type | Provider | any [ ] > ;
35
32
@@ -55,9 +52,10 @@ interface BootstrapParams {
55
52
customProviders ?: ProviderArray ,
56
53
appOptions ?: AppOptions
57
54
}
58
- var bootstrapCache : BootstrapParams
59
55
60
- var lastBootstrappedApp : WeakRef < ComponentRef < any > > ;
56
+ let bootstrapCache : BootstrapParams ;
57
+ let lastBootstrappedApp : WeakRef < ComponentRef < any > > ;
58
+
61
59
export const onBeforeLivesync = new EventEmitter < ComponentRef < any > > ( ) ;
62
60
export const onAfterLivesync = new EventEmitter < ComponentRef < any > > ( ) ;
63
61
@@ -104,24 +102,23 @@ export function bootstrap(appComponentType: any,
104
102
NS_COMPILER_PROVIDERS ,
105
103
provide ( ElementSchemaRegistry , { useClass : NativeScriptElementSchemaRegistry } ) ,
106
104
provide ( XHR , { useClass : FileSystemXHR } )
107
- ]
105
+ ] ;
108
106
109
- var appProviders = [ defaultAppProviders ] ;
107
+ let appProviders = [ defaultAppProviders ] ;
110
108
if ( isPresent ( customProviders ) ) {
111
109
appProviders . push ( customProviders ) ;
112
110
}
113
111
114
- var platform = getPlatform ( ) ;
112
+ let platform = getPlatform ( ) ;
115
113
if ( ! isPresent ( platform ) ) {
116
114
platform = createPlatform ( ReflectiveInjector . resolveAndCreate ( platformProviders ) ) ;
117
115
}
118
116
119
- // reflector.reflectionCapabilities = new ReflectionCapabilities();
120
- var appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
117
+ let appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
121
118
return coreLoadAndBootstrap ( appComponentType , appInjector ) ;
122
119
}
123
120
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 ) {
125
122
const navEntry : NavigationEntry = {
126
123
create : ( ) : Page => {
127
124
let page = new Page ( ) ;
@@ -140,7 +137,10 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
140
137
//profiling.stop('ng-bootstrap');
141
138
rendererLog ( 'ANGULAR BOOTSTRAP DONE.' ) ;
142
139
lastBootstrappedApp = new WeakRef ( compRef ) ;
143
- resolve ( compRef ) ;
140
+
141
+ if ( resolve ) {
142
+ resolve ( compRef ) ;
143
+ }
144
144
} , ( err ) => {
145
145
rendererError ( 'ERROR BOOTSTRAPPING ANGULAR' ) ;
146
146
let errorMessage = err . message + "\n\n" + err . stack ;
@@ -149,9 +149,12 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
149
149
let view = new TextView ( ) ;
150
150
view . text = errorMessage ;
151
151
page . content = view ;
152
- reject ( err ) ;
152
+
153
+ if ( reject ) {
154
+ reject ( err ) ;
155
+ }
153
156
} ) ;
154
- }
157
+ } ;
155
158
156
159
page . on ( 'loaded' , onLoadedHandler ) ;
157
160
@@ -167,23 +170,21 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
167
170
return navEntry ;
168
171
}
169
172
170
- export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : Promise < ComponentRef < any > > {
173
+ export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : void {
171
174
bootstrapCache = { appComponentType, customProviders, appOptions } ;
172
175
173
176
if ( appOptions && appOptions . cssFile ) {
174
177
application . cssFile = appOptions . cssFile ;
175
178
}
176
179
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 ) ;
181
182
}
182
183
183
184
// Patch livesync
184
185
const _baseLiveSync = global . __onLiveSync ;
185
186
global . __onLiveSync = function ( ) {
186
- rendererLog ( "LiveSync Started" )
187
+ rendererLog ( "LiveSync Started" ) ;
187
188
if ( bootstrapCache ) {
188
189
onBeforeLivesync . next ( lastBootstrappedApp ? lastBootstrappedApp . get ( ) : null ) ;
189
190
@@ -204,6 +205,4 @@ global.__onLiveSync = function () {
204
205
else {
205
206
_baseLiveSync ( ) ;
206
207
}
207
- }
208
-
209
-
208
+ } ;
0 commit comments