@@ -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
@@ -105,24 +103,23 @@ export function bootstrap(appComponentType: any,
105
103
NS_COMPILER_PROVIDERS ,
106
104
provide ( ElementSchemaRegistry , { useClass : NativeScriptElementSchemaRegistry } ) ,
107
105
provide ( XHR , { useClass : FileSystemXHR } )
108
- ]
106
+ ] ;
109
107
110
- var appProviders = [ defaultAppProviders ] ;
108
+ let appProviders = [ defaultAppProviders ] ;
111
109
if ( isPresent ( customProviders ) ) {
112
110
appProviders . push ( customProviders ) ;
113
111
}
114
112
115
- var platform = getPlatform ( ) ;
113
+ let platform = getPlatform ( ) ;
116
114
if ( ! isPresent ( platform ) ) {
117
115
platform = createPlatform ( ReflectiveInjector . resolveAndCreate ( platformProviders ) ) ;
118
116
}
119
117
120
- // reflector.reflectionCapabilities = new ReflectionCapabilities();
121
- var appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
118
+ let appInjector = ReflectiveInjector . resolveAndCreate ( appProviders , platform . injector ) ;
122
119
return coreLoadAndBootstrap ( appComponentType , appInjector ) ;
123
120
}
124
121
125
- function createNavigationEntry ( params : BootstrapParams , resolve : ( comp : ComponentRef < any > ) => void , reject : ( e : Error ) => void , isReboot : boolean ) {
122
+ function createNavigationEntry ( params : BootstrapParams , resolve ? : ( comp : ComponentRef < any > ) => void , reject ? : ( e : Error ) => void , isReboot : boolean = false ) {
126
123
const navEntry : NavigationEntry = {
127
124
create : ( ) : Page => {
128
125
let page = new Page ( ) ;
@@ -141,7 +138,10 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
141
138
//profiling.stop('ng-bootstrap');
142
139
rendererLog ( 'ANGULAR BOOTSTRAP DONE.' ) ;
143
140
lastBootstrappedApp = new WeakRef ( compRef ) ;
144
- resolve ( compRef ) ;
141
+
142
+ if ( resolve ) {
143
+ resolve ( compRef ) ;
144
+ }
145
145
} , ( err ) => {
146
146
rendererError ( 'ERROR BOOTSTRAPPING ANGULAR' ) ;
147
147
let errorMessage = err . message + "\n\n" + err . stack ;
@@ -150,9 +150,12 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
150
150
let view = new TextView ( ) ;
151
151
view . text = errorMessage ;
152
152
page . content = view ;
153
- reject ( err ) ;
153
+
154
+ if ( reject ) {
155
+ reject ( err ) ;
156
+ }
154
157
} ) ;
155
- }
158
+ } ;
156
159
157
160
page . on ( 'loaded' , onLoadedHandler ) ;
158
161
@@ -168,23 +171,21 @@ function createNavigationEntry(params: BootstrapParams, resolve: (comp: Componen
168
171
return navEntry ;
169
172
}
170
173
171
- export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : Promise < ComponentRef < any > > {
174
+ export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : void {
172
175
bootstrapCache = { appComponentType, customProviders, appOptions } ;
173
176
174
177
if ( appOptions && appOptions . cssFile ) {
175
178
application . cssFile = appOptions . cssFile ;
176
179
}
177
180
178
- return new Promise ( ( resolve , reject ) => {
179
- const navEntry = createNavigationEntry ( bootstrapCache , resolve , reject , false ) ;
180
- application . start ( navEntry ) ;
181
- } )
181
+ const navEntry = createNavigationEntry ( bootstrapCache ) ;
182
+ application . start ( navEntry ) ;
182
183
}
183
184
184
185
// Patch livesync
185
186
const _baseLiveSync = global . __onLiveSync ;
186
187
global . __onLiveSync = function ( ) {
187
- rendererLog ( "LiveSync Started" )
188
+ rendererLog ( "LiveSync Started" ) ;
188
189
if ( bootstrapCache ) {
189
190
onBeforeLivesync . next ( lastBootstrappedApp ? lastBootstrappedApp . get ( ) : null ) ;
190
191
@@ -205,6 +206,4 @@ global.__onLiveSync = function () {
205
206
else {
206
207
_baseLiveSync ( ) ;
207
208
}
208
- }
209
-
210
-
209
+ } ;
0 commit comments