Skip to content

Commit 9dd3ba7

Browse files
committed
Added "External Ambient Module Declarations" for most modules.
Now they are required by module name e.g require("file-system") instead of by file name.
1 parent f3446e4 commit 9dd3ba7

30 files changed

+470
-467
lines changed

Tests/TKUnit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
*/
1111

12-
import Application = require("application/application");
12+
import Application = require("application");
1313
import timer = require("timer/timer");
1414

1515
var runTest = function (test, testName) {

Tests/application-tests-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// It is the main BCL module and is required for other BCL modules to work properly.
55
// The default bootstrap.js implementation for each platform loads and initializes this module.
66
// ``` JavaScript
7-
import app = require("application/application");
7+
import app = require("application");
88
// ```
99
// The pre-required `app` module is used throughout the following code snippets.
1010
// </snippet>

Tests/application-tests.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import app = require("application/application");
1+
import app = require("application");
22
import TKUnit = require("Tests/TKUnit");
33
import commonTests = require("Tests/application-tests-common");
44

Tests/file-system-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Using the file system requires the FileSystem module.
55
// TODO: var fs = require("file-system"); => this will break the intellisense of the tests
66
// ``` JavaScript
7-
import fs = require("file-system/file-system");
7+
import fs = require("file-system");
88
// ```
99
// The pre-required `fs` module is used throughout the following code snippets.
1010
// </snippet>

Tests/http-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import TKUnit = require("Tests/TKUnit");
2-
import http = require("http/http");
2+
import http = require("http");
33
require("globals");
44

55
// <snippet name="http">

Tests/image-source-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// </snippet>
1414

1515
import imageSource = require("image-source/image-source");
16-
import fs = require("file-system/file-system");
17-
import app = require("application/application");
16+
import fs = require("file-system");
17+
import app = require("application");
1818
import TKUnit = require("Tests/TKUnit");
1919

2020
export var testFromResource = function () {

application/application.d.ts

Lines changed: 104 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,134 @@
1-
/**
2-
* The main entry point event. This method is expected to return an instance of the root UI for the application.
3-
* This will be an Activity extends for Android and a RootViewController for iOS.
4-
*/
5-
export declare function onLaunch(): any;
6-
7-
/**
8-
* This method will be called when the Application is suspended.
9-
*/
10-
export declare function onSuspend();
11-
12-
/**
13-
* This method will be called when the Application is resumed after it has been suspended.
14-
*/
15-
export declare function onResume();
16-
17-
/**
18-
* This method will be called when the Application is about to exit.
19-
*/
20-
export declare function onExit();
21-
22-
/**
23-
* This method will be called when there is low memory on the target device.
24-
*/
25-
export declare function onLowMemory();
26-
27-
/**
28-
* This is the Android-specific application object instance.
29-
* Encapsulates methods and properties specific to the Android platform.
30-
* Will be undefined when TargetOS is iOS.
31-
*/
32-
export declare var android: AndroidApplication;
33-
34-
/**
35-
* This is the iOS-specific application object instance.
36-
* Encapsulates methods and properties specific to the iOS platform.
37-
* Will be undefined when TargetOS is Android.
38-
*/
39-
export declare var ios: iOSApplication;
40-
41-
/**
42-
* The abstraction of an Android-specific application object.
43-
*/
44-
export declare class AndroidApplication {
45-
/**
46-
* The android.app.Application object instance provided to the init of the module.
47-
*/
48-
public nativeApp: android.app.Application;
49-
50-
/**
51-
* The application android.content.Context object instance.
52-
*/
53-
public context: android.content.Context;
54-
55-
/**
56-
* The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events.
57-
*/
58-
public currentActivity: android.app.Activity;
1+

2+
declare module "application" {
593

604
/**
61-
* The main (start) Activity for the application.
5+
* The main entry point event. This method is expected to return an instance of the root UI for the application.
6+
* This will be an Activity extends for Android and a RootViewController for iOS.
627
*/
63-
public startActivity: android.app.Activity;
8+
function onLaunch(): any;
649

6510
/**
66-
* The name of the application package.
11+
* This method will be called when the Application is suspended.
6712
*/
68-
public packageName: string;
13+
function onSuspend();
6914

7015
/**
71-
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
72-
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
16+
* This method will be called when the Application is resumed after it has been suspended.
7317
*/
74-
public getActivity: (intent: android.content.Intent) => any;
18+
function onResume();
7519

7620
/**
77-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.
21+
* This method will be called when the Application is about to exit.
7822
*/
79-
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
23+
function onExit();
8024

8125
/**
82-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
26+
* This method will be called when there is low memory on the target device.
8327
*/
84-
public onActivityDestroyed: (activity: android.app.Activity) => void;
28+
function onLowMemory();
8529

8630
/**
87-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
31+
* This is the Android-specific application object instance.
32+
* Encapsulates methods and properties specific to the Android platform.
33+
* Will be undefined when TargetOS is iOS.
8834
*/
89-
public onActivityStarted: (activity: android.app.Activity) => void;
35+
var android: AndroidApplication;
9036

9137
/**
92-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method.
38+
* This is the iOS-specific application object instance.
39+
* Encapsulates methods and properties specific to the iOS platform.
40+
* Will be undefined when TargetOS is Android.
9341
*/
94-
public onActivityPaused: (activity: android.app.Activity) => void;
42+
var ios: iOSApplication;
9543

9644
/**
97-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method.
45+
* The abstraction of an Android-specific application object.
9846
*/
99-
public onActivityResumed: (activity: android.app.Activity) => void;
47+
class AndroidApplication {
48+
/**
49+
* The android.app.Application object instance provided to the init of the module.
50+
*/
51+
public nativeApp: android.app.Application;
52+
53+
/**
54+
* The application android.content.Context object instance.
55+
*/
56+
public context: android.content.Context;
57+
58+
/**
59+
* The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events.
60+
*/
61+
public currentActivity: android.app.Activity;
62+
63+
/**
64+
* The main (start) Activity for the application.
65+
*/
66+
public startActivity: android.app.Activity;
67+
68+
/**
69+
* The name of the application package.
70+
*/
71+
public packageName: string;
72+
73+
/**
74+
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
75+
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
76+
*/
77+
public getActivity: (intent: android.content.Intent) => any;
78+
79+
/**
80+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method.
81+
*/
82+
public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
83+
84+
/**
85+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
86+
*/
87+
public onActivityDestroyed: (activity: android.app.Activity) => void;
88+
89+
/**
90+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method.
91+
*/
92+
public onActivityStarted: (activity: android.app.Activity) => void;
93+
94+
/**
95+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method.
96+
*/
97+
public onActivityPaused: (activity: android.app.Activity) => void;
98+
99+
/**
100+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method.
101+
*/
102+
public onActivityResumed: (activity: android.app.Activity) => void;
103+
104+
/**
105+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method.
106+
*/
107+
public onActivityStopped: (activity: android.app.Activity) => void;
108+
109+
/**
110+
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
111+
*/
112+
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
113+
}
100114

101115
/**
102-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method.
116+
* The abstraction of an iOS-specific application object.
103117
*/
104-
public onActivityStopped: (activity: android.app.Activity) => void;
118+
class iOSApplication {
119+
/**
120+
* The root view controller for the application.
121+
*/
122+
public rootController: UIKit.UIViewController;
123+
124+
/**
125+
* The android.app.Application object instance provided to the init of the module.
126+
*/
127+
public nativeApp: UIKit.UIApplication;
128+
}
105129

106130
/**
107-
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
131+
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
108132
*/
109-
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
110-
}
111-
112-
/**
113-
* The abstraction of an iOS-specific application object.
114-
*/
115-
export declare class iOSApplication {
116-
/**
117-
* The root view controller for the application.
118-
*/
119-
public rootController: UIKit.UIViewController;
120-
121-
/**
122-
* The android.app.Application object instance provided to the init of the module.
123-
*/
124-
public nativeApp: UIKit.UIApplication;
125-
}
126-
127-
/**
128-
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
129-
*/
130-
export declare function init(nativeApp: any);
133+
function init(nativeApp: any);
134+
}

application/application.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
Current launch sequence for iOS looks like:
44
5-
var app = require("application/application");
5+
var app = require("application");
66
77
app.tk.ui.Application.current.onLaunch = function() {
88
log("tk.ui.Application.current.onLaunch");

application/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
declare var module, require;
2-
module.exports = require("application/application");
2+
module.exports = require("application");

camera/camera.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import appModule = require("application/application");
1+
import appModule = require("application");
22

33
var REQUEST_IMAGE_CAPTURE: number = 1;
44
var REQUEST_SELECT_PICTURE: number = 2;

0 commit comments

Comments
 (0)