1- import appModule = require( "./application-common" ) ;
1+ import common = require( "./application-common" ) ;
22import frame = require( "ui/frame" ) ;
3- import types = require( "utils/types" ) ;
4- import view = require( "ui/core/view" ) ;
53import definition = require( "application" ) ;
6- import enums = require( "ui/enums" ) ;
7- import uiUtils = require( "ui/utils" ) ;
8- import fileResolverModule = require( "file-system/file-name-resolver" ) ;
4+ import * as uiUtilsModule from "ui/utils" ;
5+ import * as typesModule from "utils/types" ;
6+ import * as fileResolverModule from "file-system/file-name-resolver" ;
7+ import * as enumsModule from "ui/enums" ;
98
10- global . moduleMerge ( appModule , exports ) ;
9+ global . moduleMerge ( common , exports ) ;
1110
1211class Responder extends UIResponder {
1312 //
1413}
1514
1615class Window extends UIWindow {
1716
18- private _content : view . View ;
17+ private _content ;
1918
2019 initWithFrame ( frame : CGRect ) : UIWindow {
2120 var window = super . initWithFrame ( frame ) ;
@@ -25,14 +24,16 @@ class Window extends UIWindow {
2524 return window ;
2625 }
2726
28- public get content ( ) : view . View {
27+ public get content ( ) {
2928 return this . _content ;
3029 }
31- public set content ( value : view . View ) {
30+ public set content ( value ) {
3231 this . _content = value ;
3332 }
3433
3534 public layoutSubviews ( ) : void {
35+ var uiUtils : typeof uiUtilsModule = require ( "ui/utils" ) ;
36+
3637 uiUtils . ios . _layoutRootView ( this . _content , UIScreen . mainScreen ( ) . bounds ) ;
3738 }
3839}
@@ -113,17 +114,17 @@ class IOSApplication implements definition.iOSApplication {
113114 }
114115
115116 exports . notify ( {
116- eventName : definition . launchEvent ,
117+ eventName : exports . launchEvent ,
117118 object : this ,
118119 ios : notification . userInfo && notification . userInfo . objectForKey ( "UIApplicationLaunchOptionsLocalNotificationKey" ) || null
119120 } ) ;
120121
121122 var topFrame = frame . topmost ( ) ;
122123 if ( ! topFrame ) {
123124 // try to navigate to the mainEntry/Module (if specified)
124- var navParam = definition . mainEntry ;
125+ var navParam = exports . mainEntry ;
125126 if ( ! navParam ) {
126- navParam = definition . mainModule ;
127+ navParam = exports . mainModule ;
127128 }
128129
129130 if ( navParam ) {
@@ -147,31 +148,31 @@ class IOSApplication implements definition.iOSApplication {
147148 exports . onResume ( ) ;
148149 }
149150
150- exports . notify ( { eventName : definition . resumeEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
151+ exports . notify ( { eventName : exports . resumeEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
151152 }
152153
153154 private didEnterBackground ( notification : NSNotification ) {
154155 if ( exports . onSuspend ) {
155156 exports . onSuspend ( ) ;
156157 }
157158
158- exports . notify ( { eventName : definition . suspendEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
159+ exports . notify ( { eventName : exports . suspendEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
159160 }
160161
161162 private willTerminate ( notification : NSNotification ) {
162163 if ( exports . onExit ) {
163164 exports . onExit ( ) ;
164165 }
165166
166- exports . notify ( { eventName : definition . exitEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
167+ exports . notify ( { eventName : exports . exitEvent , object : this , ios : UIApplication . sharedApplication ( ) } ) ;
167168 }
168169
169170 private didReceiveMemoryWarning ( notification : NSNotification ) {
170171 if ( exports . onLowMemory ) {
171172 exports . onLowMemory ( ) ;
172173 }
173174
174- exports . notify ( { eventName : definition . lowMemoryEvent , object : this , android : undefined , ios : UIApplication . sharedApplication ( ) } ) ;
175+ exports . notify ( { eventName : exports . lowMemoryEvent , object : this , android : undefined , ios : UIApplication . sharedApplication ( ) } ) ;
175176 }
176177
177178 private orientationDidChange ( notification : NSNotification ) {
@@ -180,6 +181,8 @@ class IOSApplication implements definition.iOSApplication {
180181 if ( this . _currentOrientation !== orientation ) {
181182 this . _currentOrientation = orientation ;
182183
184+ var enums : typeof enumsModule = require ( "ui/enums" ) ;
185+
183186 var newValue ;
184187 switch ( orientation ) {
185188 case UIDeviceOrientation . UIDeviceOrientationLandscapeRight :
@@ -196,7 +199,7 @@ class IOSApplication implements definition.iOSApplication {
196199 }
197200
198201 exports . notify ( < definition . OrientationChangedEventData > {
199- eventName : definition . orientationChangedEvent ,
202+ eventName : exports . orientationChangedEvent ,
200203 ios : this ,
201204 newValue : newValue ,
202205 object : this
@@ -210,19 +213,21 @@ var iosApp = new IOSApplication();
210213exports . ios = iosApp ;
211214
212215global . __onUncaughtError = function ( error : Error ) {
216+ var types : typeof typesModule = require ( "utils/types" ) ;
217+
213218 // TODO: This should be obsoleted
214219 if ( types . isFunction ( exports . onUncaughtError ) ) {
215220 exports . onUncaughtError ( error ) ;
216221 }
217222
218- definition . notify ( { eventName : definition . uncaughtErrorEvent , object : < any > definition . ios , ios : error } ) ;
223+ exports . notify ( { eventName : exports . uncaughtErrorEvent , object : < any > exports . ios , ios : error } ) ;
219224}
220225
221226var started : boolean = false ;
222227exports . start = function ( ) {
223228 if ( ! started ) {
224229 started = true ;
225- appModule . loadCss ( ) ;
230+ exports . loadCss ( ) ;
226231 UIApplicationMain ( 0 , null , null , exports . ios && exports . ios . delegate ? NSStringFromClass ( exports . ios . delegate ) : NSStringFromClass ( Responder ) ) ;
227232 } else {
228233 throw new Error ( "iOS Application already started!" ) ;
@@ -234,11 +239,13 @@ global.__onLiveSync = function () {
234239 return ;
235240 }
236241
242+ var fileResolver : typeof fileResolverModule = require ( "file-system/file-name-resolver" ) ;
243+
237244 // Clear file resolver cache to respect newly added files.
238- fileResolverModule . clearCache ( ) ;
245+ fileResolver . clearCache ( ) ;
239246
240247 // Reload app.css in case it was changed.
241- appModule . loadCss ( ) ;
248+ exports . loadCss ( ) ;
242249
243250 // Reload current page.
244251 frame . reloadPage ( ) ;
0 commit comments