diff --git a/Tests/TKUnit.ts b/Tests/TKUnit.ts index 95363418a..18e4faa3a 100644 --- a/Tests/TKUnit.ts +++ b/Tests/TKUnit.ts @@ -9,7 +9,7 @@ */ -import Application = require("application/application"); +import Application = require("application"); import timer = require("timer/timer"); var runTest = function (test, testName) { diff --git a/Tests/application-tests-common.ts b/Tests/application-tests-common.ts index cc7cef874..1220938ee 100644 --- a/Tests/application-tests-common.ts +++ b/Tests/application-tests-common.ts @@ -4,7 +4,7 @@ // It is the main BCL module and is required for other BCL modules to work properly. // The default bootstrap.js implementation for each platform loads and initializes this module. // ``` JavaScript -import app = require("application/application"); +import app = require("application"); // ``` // The pre-required `app` module is used throughout the following code snippets. // diff --git a/Tests/application-tests.android.ts b/Tests/application-tests.android.ts index 49cc29a3d..b5c1f1e35 100644 --- a/Tests/application-tests.android.ts +++ b/Tests/application-tests.android.ts @@ -1,4 +1,4 @@ -import app = require("application/application"); +import app = require("application"); import TKUnit = require("Tests/TKUnit"); import commonTests = require("Tests/application-tests-common"); diff --git a/Tests/file-system-tests.ts b/Tests/file-system-tests.ts index 972e67f27..e5ba9920a 100644 --- a/Tests/file-system-tests.ts +++ b/Tests/file-system-tests.ts @@ -4,7 +4,7 @@ // Using the file system requires the FileSystem module. // TODO: var fs = require("file-system"); => this will break the intellisense of the tests // ``` JavaScript -import fs = require("file-system/file-system"); +import fs = require("file-system"); // ``` // The pre-required `fs` module is used throughout the following code snippets. // diff --git a/Tests/http-tests.ts b/Tests/http-tests.ts index 258b253e8..f2a882f3c 100644 --- a/Tests/http-tests.ts +++ b/Tests/http-tests.ts @@ -1,5 +1,5 @@ import TKUnit = require("Tests/TKUnit"); -import http = require("http/http"); +import http = require("http"); require("globals"); // diff --git a/Tests/image-source-tests.ts b/Tests/image-source-tests.ts index c5932f7ec..2acb5494d 100644 --- a/Tests/image-source-tests.ts +++ b/Tests/image-source-tests.ts @@ -13,8 +13,8 @@ // import imageSource = require("image-source/image-source"); -import fs = require("file-system/file-system"); -import app = require("application/application"); +import fs = require("file-system"); +import app = require("application"); import TKUnit = require("Tests/TKUnit"); export var testFromResource = function () { diff --git a/application/application.d.ts b/application/application.d.ts index 0d374598c..84b1fb96a 100644 --- a/application/application.d.ts +++ b/application/application.d.ts @@ -1,130 +1,134 @@ -/** -* The main entry point event. This method is expected to return an instance of the root UI for the application. -* This will be an Activity extends for Android and a RootViewController for iOS. -*/ -export declare function onLaunch(): any; - -/** -* This method will be called when the Application is suspended. -*/ -export declare function onSuspend(); - -/** -* This method will be called when the Application is resumed after it has been suspended. -*/ -export declare function onResume(); - -/** -* This method will be called when the Application is about to exit. -*/ -export declare function onExit(); - -/** -* This method will be called when there is low memory on the target device. -*/ -export declare function onLowMemory(); - -/** -* This is the Android-specific application object instance. -* Encapsulates methods and properties specific to the Android platform. -* Will be undefined when TargetOS is iOS. -*/ -export declare var android: AndroidApplication; - -/** -* This is the iOS-specific application object instance. -* Encapsulates methods and properties specific to the iOS platform. -* Will be undefined when TargetOS is Android. -*/ -export declare var ios: iOSApplication; - -/** -* The abstraction of an Android-specific application object. -*/ -export declare class AndroidApplication { - /** - * The android.app.Application object instance provided to the init of the module. - */ - public nativeApp: android.app.Application; + +declare module "application" { /** - * The application android.content.Context object instance. + * The main entry point event. This method is expected to return an instance of the root UI for the application. + * This will be an Activity extends for Android and a RootViewController for iOS. */ - public context: android.content.Context; + function onLaunch(): any; /** - * The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events. + * This method will be called when the Application is suspended. */ - public currentActivity: android.app.Activity; + function onSuspend(); /** - * The main (start) Activity for the application. + * This method will be called when the Application is resumed after it has been suspended. */ - public startActivity: android.app.Activity; + function onResume(); /** - * The name of the application package. + * This method will be called when the Application is about to exit. */ - public packageName: string; + function onExit(); /** - * This method is called by the JavaScript Bridge when navigation to a new activity is triggered. - * The return value of this method should be com.tns.NativeScriptActivity.extends implementation. + * This method will be called when there is low memory on the target device. */ - public getActivity: (intent: android.content.Intent) => any; + function onLowMemory(); /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method. + * This is the Android-specific application object instance. + * Encapsulates methods and properties specific to the Android platform. + * Will be undefined when TargetOS is iOS. */ - public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void; + var android: AndroidApplication; /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method. + * This is the iOS-specific application object instance. + * Encapsulates methods and properties specific to the iOS platform. + * Will be undefined when TargetOS is Android. */ - public onActivityDestroyed: (activity: android.app.Activity) => void; + var ios: iOSApplication; /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method. + * The abstraction of an Android-specific application object. */ - public onActivityStarted: (activity: android.app.Activity) => void; + class AndroidApplication { + /** + * The android.app.Application object instance provided to the init of the module. + */ + public nativeApp: android.app.Application; + + /** + * The application android.content.Context object instance. + */ + public context: android.content.Context; + + /** + * The currently active (loaded) android.app.Activity. This property is automatically updated upon Activity events. + */ + public currentActivity: android.app.Activity; + + /** + * The main (start) Activity for the application. + */ + public startActivity: android.app.Activity; + + /** + * The name of the application package. + */ + public packageName: string; + + /** + * This method is called by the JavaScript Bridge when navigation to a new activity is triggered. + * The return value of this method should be com.tns.NativeScriptActivity.extends implementation. + */ + public getActivity: (intent: android.content.Intent) => any; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityCreated method. + */ + public onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method. + */ + public onActivityDestroyed: (activity: android.app.Activity) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityDestroyed method. + */ + public onActivityStarted: (activity: android.app.Activity) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method. + */ + public onActivityPaused: (activity: android.app.Activity) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method. + */ + public onActivityResumed: (activity: android.app.Activity) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method. + */ + public onActivityStopped: (activity: android.app.Activity) => void; + + /** + * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method. + */ + public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void; + } /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityPaused method. + * The abstraction of an iOS-specific application object. */ - public onActivityPaused: (activity: android.app.Activity) => void; + class iOSApplication { + /** + * The root view controller for the application. + */ + public rootController: UIKit.UIViewController; + + /** + * The android.app.Application object instance provided to the init of the module. + */ + public nativeApp: UIKit.UIApplication; + } /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityResumed method. + * Entry point for the module. Initializes the Application singleton and hooks application lifecycle events. */ - public onActivityResumed: (activity: android.app.Activity) => void; - - /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onActivityStopped method. - */ - public onActivityStopped: (activity: android.app.Activity) => void; - - /** - * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method. - */ - public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void; -} - -/** -* The abstraction of an iOS-specific application object. -*/ -export declare class iOSApplication { - /** - * The root view controller for the application. - */ - public rootController: UIKit.UIViewController; - - /** - * The android.app.Application object instance provided to the init of the module. - */ - public nativeApp: UIKit.UIApplication; -} - -/** -* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events. -*/ -export declare function init(nativeApp: any); \ No newline at end of file + function init(nativeApp: any); +} \ No newline at end of file diff --git a/application/application.ios.ts b/application/application.ios.ts index 9003f2afa..daf35df29 100644 --- a/application/application.ios.ts +++ b/application/application.ios.ts @@ -2,7 +2,7 @@ /* Current launch sequence for iOS looks like: -var app = require("application/application"); +var app = require("application"); app.tk.ui.Application.current.onLaunch = function() { log("tk.ui.Application.current.onLaunch"); diff --git a/application/index.ts b/application/index.ts index b47c3fb54..5e860ae40 100644 --- a/application/index.ts +++ b/application/index.ts @@ -1,2 +1,2 @@ declare var module, require; -module.exports = require("application/application"); \ No newline at end of file +module.exports = require("application"); diff --git a/camera/camera.android.ts b/camera/camera.android.ts index 06a08cd46..e78eacc27 100644 --- a/camera/camera.android.ts +++ b/camera/camera.android.ts @@ -1,4 +1,4 @@ -import appModule = require("application/application"); +import appModule = require("application"); var REQUEST_IMAGE_CAPTURE: number = 1; var REQUEST_SELECT_PICTURE: number = 2; diff --git a/camera/camera.d.ts b/camera/camera.d.ts index e26c7c9ca..6912356eb 100644 --- a/camera/camera.d.ts +++ b/camera/camera.d.ts @@ -1,36 +1,39 @@  -import promises = require("promises/promises"); -import imageSource = require("image-source/image-source"); +declare module "camera" { -export declare enum CameraPosition { - FRONT = 0, - BACK = 1, + import promises = require("promises/promises"); + import imageSource = require("image-source/image-source"); + + enum CameraPosition { + FRONT = 0, + BACK = 1, + } + + enum FlashMode { + AUTO = 0, // default + ON = 1, + OFF = 2 + } + + interface Options { + /** + * Specifies which Camera to use. + */ + cameraPosition?: CameraPosition; + + /** + * Specifies flash mode. + */ + flashMode?: FlashMode; + } + + // TODO most of hardware related parts need to handle onPause and onResume of the calling activities + class CameraManager { + takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); + + // options { useSavedPhotos: true } + pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); + } + + var takePicture: (options?: Options) => promises.Promise; } - -export declare enum FlashMode { - AUTO = 0, // default - ON = 1, - OFF = 2 -} - -export interface Options { - /** - * Specifies which Camera to use - */ - cameraPosition?: CameraPosition; - - /** - * Specifies flash mode - */ - flashMode?: FlashMode; -} - -// TODO most of hardware related parts need to handle onPause and onResume of the calling activities -export declare class CameraManager { - takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); - - // options { useSavedPhotos: true } - pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); -} - -export declare var takePicture: (options?: Options) => promises.Promise; diff --git a/file-system/file-system-access.android.ts b/file-system/file-system-access.android.ts index 07ed83b3b..da9eae24f 100644 --- a/file-system/file-system-access.android.ts +++ b/file-system/file-system-access.android.ts @@ -1,4 +1,4 @@ -import appModule = require("application/application"); +import appModule = require("application"); import textModule = require("text/text"); export class FileSystemAccess { diff --git a/file-system/file-system-access.ios.ts b/file-system/file-system-access.ios.ts index 1d715f331..3dfd4721b 100644 --- a/file-system/file-system-access.ios.ts +++ b/file-system/file-system-access.ios.ts @@ -1,4 +1,4 @@ -import app_module = require("application/application"); +import app_module = require("application"); import utilsModule = require("utils/utils_ios"); import textModule = require("text/text"); diff --git a/file-system/file-system.d.ts b/file-system/file-system.d.ts index 0f81365f3..8f554773a 100644 --- a/file-system/file-system.d.ts +++ b/file-system/file-system.d.ts @@ -1,152 +1,156 @@ -import promises = require("promises/promises"); + +declare module "file-system" { + + import promises = require("promises/promises"); + + class FileSystemEntity { + /** + * Gets the Date object specifying the last time this entity was modified. + */ + public lastModified: Date; + + /** + * Gets the name of the entity. + */ + public name: string; + + /** + * Gets the fully-qualified path (including the extension for a File) of the entity. + */ + public path: string; + + /** + * Gets the Folder object representing the parent of this entity. + * Will be null for a root folder like Documents or Temporary. + * This property is readonly. + */ + public parent: Folder; + + /** + * Removes (deletes) the current Entity from the file system. + */ + public remove(): promises.Promise; + + /** + * Renames the current entity using the specified name. + */ + public rename(newName: string): promises.Promise; + } + + class File extends FileSystemEntity { + /** + * Checks whether a File with the specified path already exists. + */ + public static exists(path: string): boolean; + + /** + * Gets the extension of the file. + */ + public extension: string; + + /** + * Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running. + */ + public isLocked: boolean; + + /** + * Gets or creates a File entity at the specified path. + */ + public static fromPath(path: string): File; + + /** + * Reads the content of the file as a string using the specified encoding (defaults to UTF-8). + */ + public readText(encoding?: string): promises.Promise; + + /** + * Writes the provided string to the file, using the specified encoding (defaults to UTF-8). + */ + public writeText(content: string, encoding?: string): promises.Promise; + } + + class Folder extends FileSystemEntity { + /** + * Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). + */ + public isKnown: boolean; + + /** + * Gets or creates a Folder entity at the specified path. + */ + public static fromPath(path: string): Folder; + + /** + * Checks whether a Folder with the specified path already exists. + */ + public static exists(path: string): boolean; + + /** + Checks whether this Folder contains an Entity with the specified name. + The path of the folder is added to the name to resolve the complete path to check for. + */ + public contains(name: string): boolean; + + /** + * Deletes all the files and folders (recursively), contained within this Folder. + */ + public clear(): promises.Promise; + + /** + * Gets or creates a File entity with the specified name within this Folder. + */ + public getFile(name: string): File; + + /** + * Gets or creates a Folder entity with the specified name within this Folder. + */ + public getFolder(name: string): Folder; + + /** + * Gets all the top-level entities residing within this folder. + */ + public getEntities(): promises.Promise>; + + /** + Enumerates all the top-level FileSystem entities residing within this folder. + The first parameter is a callback that receives the current entity. + If the callback returns false this will mean for the iteration to stop. + */ + public eachEntity(onEntity: (entity: FileSystemEntity) => boolean); + } -export declare class FileSystemEntity { /** - * Gets the Date object specifying the last time this entity was modified. + * Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem. */ - public lastModified: Date; + module knownFolders { + /** + * Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. + */ + export function documents(): Folder; + + /** + * Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. + */ + export function temp(): Folder; + } /** - * Gets the name of the entity. - */ - public name: string; - - /** - * Gets the fully-qualified path (including the extension for a File) of the entity. - */ - public path: string; - - /** - * Gets the Folder object representing the parent of this entity. - * Will be null for a root folder like Documents or Temporary. - * This property is readonly. + * Enables path-specific operations like join, extension, etc. */ - public parent: Folder; + module path { + /** + * Normalizes a path, taking care of occurrances like ".." and "//" + */ + export function normalize(path: string): string; - /** - * Removes (deletes) the current Entity from the file system. - */ - public remove(): promises.Promise; + /** + * Joins all the provided string components, forming a valid and normalized path. + */ + export function join(...paths: string[]): string; - /** - * Renames the current entity using the specified name. - */ - public rename(newName: string): promises.Promise; -} - -export declare class File extends FileSystemEntity { - /** - * Checks whether a File with the specified path already exists. - */ - public static exists(path: string): boolean; - - /** - * Gets the extension of the file. - */ - public extension: string; - - /** - * Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running. - */ - public isLocked: boolean; - - /** - * Gets or creates a File entity at the specified path. - */ - public static fromPath(path: string): File; - - /** - * Reads the content of the file as a string using the specified encoding (defaults to UTF-8). - */ - public readText(encoding?: string): promises.Promise; - - /** - * Writes the provided string to the file, using the specified encoding (defaults to UTF-8). - */ - public writeText(content: string, encoding?: string): promises.Promise; -} - -export declare class Folder extends FileSystemEntity { - /** - * Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). - */ - public isKnown: boolean; - - /** - * Gets or creates a Folder entity at the specified path. - */ - public static fromPath(path: string): Folder; - - /** - * Checks whether a Folder with the specified path already exists. - */ - public static exists(path: string): boolean; - - /** - Checks whether this Folder contains an Entity with the specified name. - The path of the folder is added to the name to resolve the complete path to check for. - */ - public contains(name: string): boolean; - - /** - * Deletes all the files and folders (recursively), contained within this Folder. - */ - public clear(): promises.Promise; - - /** - * Gets or creates a File entity with the specified name within this Folder. - */ - public getFile(name: string): File; - - /** - * Gets or creates a Folder entity with the specified name within this Folder. - */ - public getFolder(name: string): Folder; - - /** - * Gets all the top-level entities residing within this folder. - */ - public getEntities(): promises.Promise>; - - /** - Enumerates all the top-level FileSystem entities residing within this folder. - The first parameter is a callback that receives the current entity. - If the callback returns false this will mean for the iteration to stop. - */ - public eachEntity(onEntity: (entity: FileSystemEntity) => boolean); -} - -/** - * Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem. - */ -export declare module knownFolders { - /** - * Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. - */ - export function documents(): Folder; - - /** - * Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. - */ - export function temp(): Folder; -} - -/** -* Enables path-specific operations like join, extension, etc. -*/ -export declare module path { - /** - * Normalizes a path, taking care of occurrances like ".." and "//" - */ - export function normalize(path: string): string; - - /** - * Joins all the provided string components, forming a valid and normalized path. - */ - export function join(...paths: string[]): string; - - /** - * Gets the string used to separate file paths. - */ - export var separator: string; + /** + * Gets the string used to separate file paths. + */ + export var separator: string; + } } \ No newline at end of file diff --git a/file-system/index.ts b/file-system/index.ts index af5098c9b..a89436af8 100644 --- a/file-system/index.ts +++ b/file-system/index.ts @@ -1,2 +1,2 @@ declare var module, require; -module.exports = require("file-system/file-system"); \ No newline at end of file +module.exports = require("file-system"); diff --git a/globals/index.ts b/globals/index.ts index eb104f54f..c0016a09d 100644 --- a/globals/index.ts +++ b/globals/index.ts @@ -7,4 +7,5 @@ clearTimeout = timer.clearTimeout; setInterval = timer.setInterval; clearInterval = timer.clearInterval; -console = new consoleModule.Console(); \ No newline at end of file +console = new consoleModule.Console(); + diff --git a/http/http-common.ts b/http/http-common.ts index 555dd4375..09142a7cf 100644 --- a/http/http-common.ts +++ b/http/http-common.ts @@ -1,6 +1,6 @@ import image = require("image-source/image-source"); import promises = require("promises/promises"); -import http = require("http/http"); +import http = require("http"); /** * Gets string from url. diff --git a/http/http.android.ts b/http/http.android.ts index 48d178d03..9b40c5e24 100644 --- a/http/http.android.ts +++ b/http/http.android.ts @@ -2,7 +2,7 @@ * Android specific http request implementation. */ import promises = require("promises/promises"); -import http = require("http/http"); +import http = require("http"); declare var exports; require("utils/module-merge").merge(require("http/http-common"), exports); diff --git a/http/http.d.ts b/http/http.d.ts index d9fc397e3..cb89b7c09 100644 --- a/http/http.d.ts +++ b/http/http.d.ts @@ -1,34 +1,37 @@ -import image = require("image-source/image-source"); -import promises = require("promises/promises"); + +declare module "http" { + import image = require("image-source/image-source"); + import promises = require("promises/promises"); -export declare function getString(url: string): promises.Promise -export declare function getString(options: HttpRequestOptions): promises.Promise + function getString(url: string): promises.Promise + function getString(options: HttpRequestOptions): promises.Promise -export declare function getJSON(url: string): promises.Promise -export declare function getJSON(options: HttpRequestOptions): promises.Promise + function getJSON(url: string): promises.Promise + function getJSON(options: HttpRequestOptions): promises.Promise -export declare function getImage(url: string): promises.Promise -export declare function getImage(options: HttpRequestOptions): promises.Promise + function getImage(url: string): promises.Promise + function getImage(options: HttpRequestOptions): promises.Promise -export declare function request(options: HttpRequestOptions): promises.Promise; + function request(options: HttpRequestOptions): promises.Promise; -export interface HttpRequestOptions { - url: string; - method: string; - headers?: any; - content?: any; - timeout?: number; -} + interface HttpRequestOptions { + url: string; + method: string; + headers?: any; + content?: any; + timeout?: number; + } -export interface HttpResponse { - statusCode: number; - headers: any; - content?: HttpContent; -} + interface HttpResponse { + statusCode: number; + headers: any; + content?: HttpContent; + } -export interface HttpContent { - raw: any; - toString: () => string; - toJSON: () => any; - toImage: () => image.ImageSource; + interface HttpContent { + raw: any; + toString: () => string; + toJSON: () => any; + toImage: () => image.ImageSource; + } } \ No newline at end of file diff --git a/http/http.ios.ts b/http/http.ios.ts index 3f5def2dc..396653a46 100644 --- a/http/http.ios.ts +++ b/http/http.ios.ts @@ -2,7 +2,7 @@ * iOS specific http request implementation. */ import promises = require("promises/promises"); -import http = require("http/http"); +import http = require("http"); declare var exports; require("utils/module-merge").merge(require("http/http-common"), exports); diff --git a/image-source/image-source-native.android.ts b/image-source/image-source-native.android.ts index 7b9c969f2..b0a45327e 100644 --- a/image-source/image-source-native.android.ts +++ b/image-source/image-source-native.android.ts @@ -1,4 +1,4 @@ -import appModule = require("application/application"); +import appModule = require("application"); export var fromResource = function (name: string) { var androidApp = appModule.android; diff --git a/image-source/image-source.d.ts b/image-source/image-source.d.ts index 04d6d3095..19501c4e6 100644 --- a/image-source/image-source.d.ts +++ b/image-source/image-source.d.ts @@ -1,86 +1,89 @@ -import promises = require("promises/promises"); - -/** -* Defines the recognized image formats. -*/ -export declare enum ImageFormat { - PNG, - JPEG, -} - -/** -* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. -*/ -export declare class ImageSource { - /** - * Gets the height of this instance. This is a read-only property. - */ - height: number; + +declare module "image-source" { + import promises = require("promises/promises"); /** - * Gets the width of this instance. This is a read-only property. + * Defines the recognized image formats. */ - width: number; + enum ImageFormat { + PNG, + JPEG, + } /** - * The iOS-specific image instance. Will be undefined when running on Android. + * Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. */ - ios: UIKit.UIImage; + class ImageSource { + /** + * Gets the height of this instance. This is a read-only property. + */ + height: number; + + /** + * Gets the width of this instance. This is a read-only property. + */ + width: number; + + /** + * The iOS-specific image instance. Will be undefined when running on Android. + */ + ios: UIKit.UIImage; + + /** + * The Android-specific image instance. Will be undefined when running on iOS. + */ + android: android.graphics.Bitmap; + + /** + * Loads this instance from the specified resource name. + */ + loadFromResource(name: string): boolean; + + /** + * Loads this instance from the specified file. + */ + loadFromFile(path: string): boolean; + + /** + * Loads this instance from the specified native image data. + */ + loadFromData(data: any): boolean; + + /** + * Sets the provided native source object (typically a Bitmap). + * This will update either the android or ios properties, depending on the target os. + */ + setNativeSource(source: any): boolean; + + /** + * Saves this instance to the specified file, using the provided image format and quality. + */ + saveToFile(path: string, format: ImageFormat, quality?: number): boolean; + } /** - * The Android-specific image instance. Will be undefined when running on iOS. + * Creates a new Image instance and loads it from the specified resource name. */ - android: android.graphics.Bitmap; + function fromResource(name: string): ImageSource; /** - * Loads this instance from the specified resource name. + * Creates a new Image instance and loads it from the specified file. */ - loadFromResource(name: string): boolean; + function fromFile(path: string): ImageSource; /** - * Loads this instance from the specified file. + * Creates a new Image instance and loads it from the specified resource name. */ - loadFromFile(path: string): boolean; + function fromData(data: any): ImageSource; /** - * Loads this instance from the specified native image data. + * Creates a new Image instance and sets the provided native source object (typically a Bitmap). + * The native source object will update either the android or ios properties, depending on the target os. */ - loadFromData(data: any): boolean; + function fromNativeSource(source: any): ImageSource; /** - * Sets the provided native source object (typically a Bitmap). - * This will update either the android or ios properties, depending on the target os. + * Downloads the image from the provided Url and creates a new Image instance from it. */ - setNativeSource(source: any): boolean; - - /** - * Saves this instance to the specified file, using the provided image format and quality. - */ - saveToFile(path: string, format: ImageFormat, quality?: number): boolean; -} - -/** -* Creates a new Image instance and loads it from the specified resource name. -*/ -export declare function fromResource(name: string): ImageSource; - -/** -* Creates a new Image instance and loads it from the specified file. -*/ -export declare function fromFile(path: string): ImageSource; - -/** -* Creates a new Image instance and loads it from the specified resource name. -*/ -export declare function fromData(data: any): ImageSource; - -/** -* Creates a new Image instance and sets the provided native source object (typically a Bitmap). -* The native source object will update either the android or ios properties, depending on the target os. -*/ -export declare function fromNativeSource(source: any): ImageSource; - -/** -* Downloads the image from the provided Url and creates a new Image instance from it. -*/ -export declare function fromUrl(url: string): promises.Promise; \ No newline at end of file + function fromUrl(url: string): promises.Promise; +} \ No newline at end of file diff --git a/image-source/image-source.ts b/image-source/image-source.ts index 4340c7438..5643ef620 100644 --- a/image-source/image-source.ts +++ b/image-source/image-source.ts @@ -1,7 +1,7 @@ -import app = require("application/application"); +import app = require("application"); import native = require("image-source/image-source-native"); import promises = require("promises/promises"); -import http = require("http/http"); +import http = require("http"); export enum ImageFormat { PNG, diff --git a/local-settings/local-settings.android.ts b/local-settings/local-settings.android.ts index 5513c053b..ca59c7086 100644 --- a/local-settings/local-settings.android.ts +++ b/local-settings/local-settings.android.ts @@ -1,4 +1,4 @@ -import appModule = require("application/application"); +import appModule = require("application"); import Common = require("local-settings/local-settings-common"); var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0); diff --git a/local-settings/local-settings.d.ts b/local-settings/local-settings.d.ts index 154e04ae9..92568d0e4 100644 --- a/local-settings/local-settings.d.ts +++ b/local-settings/local-settings.d.ts @@ -1,73 +1,72 @@ -/** -* report does such key exist -*/ -export declare var hasKey: (key: string) => boolean; + +declare module "local-settings" { + /** + * report does such key exist + */ + var hasKey: (key: string) => boolean; -// getters + /** + * gets value of the key as boolean, user can provide default value in case there is no value for the key + */ + var getBoolean: (key: string, defaultValue?: boolean) => boolean; -/** -* gets value of the key as boolean, user can provide default value in case there is no value for the key -*/ -export declare var getBoolean: (key: string, defaultValue?: boolean) => boolean; + /** + * gets value of the key as string, user can provide default value in case there is no value for the key + */ + var getString: (key: string, defaultValue?: string) => string; -/** -* gets value of the key as string, user can provide default value in case there is no value for the key -*/ -export declare var getString: (key: string, defaultValue?: string) => string; + /** + * gets value of the key as string array, user can provide default value in case there is no value for the key + */ + var getStringArray: (key: string, defaultValue?: string[]) => string[]; -/** -* gets value of the key as string array, user can provide default value in case there is no value for the key -*/ -export declare var getStringArray: (key: string, defaultValue?: string[]) => string[]; + /** + * gets value of the key as number (double), user can provide default value in case there is no value for the key + */ + var getNumber: (key: string, defaultValue?: number) => number; -/** -* gets value of the key as number (double), user can provide default value in case there is no value for the key -*/ -export declare var getNumber: (key: string, defaultValue?: number) => number; + /** + * gets value of the key as integer, user can provide default value in case there is no value for the key + */ + var getInt: (key: string, defaultValue?: number) => number; -/** -* gets value of the key as integer, user can provide default value in case there is no value for the key -*/ -export declare var getInt: (key: string, defaultValue?: number) => number; + /** + * gets value of the key as long integer (not fully supported by JS), user can provide default value in case there is no value for the key + */ + var getLong: (key: string, defaultValue?: number) => number; -/** -* gets value of the key as long integer (not fully supported by JS), user can provide default value in case there is no value for the key -*/ -export declare var getLong: (key: string, defaultValue?: number) => number; + /** + * sets value for a key as boolean + */ + var setBoolean: (key: string, value: boolean) => void; -// setters + /** + * sets value for a key as string + */ + var setString: (key: string, value: string) => void; -/** -* sets value for a key as boolean -*/ -export declare var setBoolean: (key: string, value: boolean) => void; + /** + * sets value for a key as string array + */ + var setStringArray: (key: string, value: string[]) => void; -/** -* sets value for a key as string -*/ -export declare var setString: (key: string, value: string) => void; + /** + * sets value for a key as JS number (double) + */ + var setNumber: (key: string, value: number) => void; -/** -* sets value for a key as string array -*/ -export declare var setStringArray: (key: string, value: string[]) => void; + /** + * sets value for a key as integer + */ + var setInt: (key: string, value: number) => void; -/** -* sets value for a key as JS number (double) -*/ -export declare var setNumber: (key: string, value: number) => void; + /** + * sets value for a key as long integer + */ + var setLong: (key: string, value: number) => void; -/** -* sets value for a key as integer -*/ -export declare var setInt: (key: string, value: number) => void; - -/** -* sets value for a key as long integer -*/ -export declare var setLong: (key: string, value: number) => void; - -/** -* removes a value for key -*/ -export declare var remove: (key: string) => void; + /** + * removes a value for key + */ + var remove: (key: string) => void; +} \ No newline at end of file diff --git a/location/location-manager.android.ts b/location/location-manager.android.ts index fb1e142b4..77db9324d 100644 --- a/location/location-manager.android.ts +++ b/location/location-manager.android.ts @@ -1,5 +1,5 @@ import types = require("location/location-types"); -import appModule = require("application/application"); +import appModule = require("application"); export class LocationManager { // in meters diff --git a/location/location.impl.ts b/location/location.impl.ts index 8b8c5d5ef..efd864a24 100644 --- a/location/location.impl.ts +++ b/location/location.impl.ts @@ -2,7 +2,7 @@ import promises = require("promises/promises"); import timer = require("timer/timer"); import types = require("location/location-types"); -import locationManagerModule = require("location/location-manager"); +import locationManagerModule = require("location"); // merge the exports of the types module with the exports of this file declare var exports; diff --git a/promises/promises.ts b/promises/promises.ts index c906f57f1..6425d6c31 100644 --- a/promises/promises.ts +++ b/promises/promises.ts @@ -9,7 +9,6 @@ /** Returns a new "Deferred" value that may be resolved or rejected. */ - export function defer(): Deferred { return new DeferredI(); } @@ -17,7 +16,6 @@ export function defer(): Deferred { /** Converts a value to a resolved promise. */ - export function resolve(v: Value): Promise { return defer().resolve(v).promise(); } @@ -25,7 +23,6 @@ export function resolve(v: Value): Promise { /** Returns a rejected promise. */ - export function reject(err: Rejection): Promise { return defer().reject(err).promise(); } @@ -39,7 +36,6 @@ export function reject(err: Rejection): Promise { All the values of all promise results are collected into the resulting promise which is resolved as soon the last generated element value is resolved. */ - export function unfold( unspool: (current: Seed) => { promise: Promise; next?: Seed }, seed: Seed) @@ -94,7 +90,6 @@ function unfoldCore( Once a promise is either Rejected or Resolved, it can not change its status anymore. */ - export enum Status { Unfulfilled, Rejected, @@ -105,7 +100,6 @@ export enum Status { If a promise gets rejected, at least a message that indicates the error or reason for the rejection must be provided. */ - export interface Rejection { message: string; } @@ -113,7 +107,6 @@ export interface Rejection { /** Both Promise and Deferred share these properties. */ - export interface PromiseState { /// The current status of the promise. status: Status; @@ -132,7 +125,6 @@ export interface PromiseState { When multiple handlers are registered with done(), fail(), or always(), they are called in the same order. */ - export interface Promise extends PromiseState { /** Returns a promise that represents a promise chain that consists of this @@ -161,7 +153,6 @@ export interface Promise extends PromiseState { an asynchronous process. Callers of that function should only see the Promise that is returned by promise(). */ - export interface Deferred extends PromiseState { /// Returns the encapsulated promise of this deferred instance. /// The returned promise supports composition but removes the ability to resolve or reject @@ -183,7 +174,6 @@ export interface Deferred extends PromiseState { As soon one of the arguments gets rejected, the resulting promise gets rejected. If no promises were provided, the resulting promise is immediately resolved. */ - export function when(...promises: Promise[]): Promise { var allDone = defer(); if (!promises.length) { @@ -216,7 +206,6 @@ export function when(...promises: Promise[]): Promise { The Promise instance is a proxy to the Deferred instance. */ - class PromiseI implements Promise { constructor(public deferred: DeferredI) @@ -249,7 +238,6 @@ class PromiseI implements Promise /** Implementation of a deferred. */ - class DeferredI implements Deferred{ private _resolved: (v: Value) => void = _ => { }; @@ -379,7 +367,6 @@ class DeferredI implements Deferred{ /** Promise Generators and Iterators. */ - export interface Generator { (): Iterator; } @@ -419,7 +406,6 @@ class IteratorI implements Iterator /** Iterator functions. */ - export function each(gen: Generator, f: (e: E) => void): Promise<{}> { var d = defer(); eachCore(d, gen(), f); @@ -443,7 +429,6 @@ function eachCore(fin: Deferred<{}>, it: Iterator, f: (e: E) => void): voi /** std */ - export function isUndefined(v) { return typeof v === 'undefined'; } diff --git a/text/text.d.ts b/text/text.d.ts index 35c5e2c0c..657f2cdce 100644 --- a/text/text.d.ts +++ b/text/text.d.ts @@ -8,4 +8,5 @@ export declare module encoding { export var UTF_16BE: any; export var UTF_16LE: any; export var UTF_8: any; -} \ No newline at end of file +} + diff --git a/timer/timer.d.ts b/timer/timer.d.ts index 89391242a..a731cecd6 100644 --- a/timer/timer.d.ts +++ b/timer/timer.d.ts @@ -4,4 +4,4 @@ export declare function setTimeout(callback: Function, milliseconds?: number): number; export declare function clearTimeout(id: number): void; export declare function setInterval(callback: Function, milliseconds?: number): number; -export declare function clearInterval(id: number): void; \ No newline at end of file +export declare function clearInterval(id: number): void;