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.
This commit is contained in:
PanayotCankov
2014-05-21 12:23:19 +03:00
parent f3446e4099
commit 9dd3ba70c5
30 changed files with 470 additions and 467 deletions

View File

@ -9,7 +9,7 @@
*/ */
import Application = require("application/application"); import Application = require("application");
import timer = require("timer/timer"); import timer = require("timer/timer");
var runTest = function (test, testName) { var runTest = function (test, testName) {

View File

@ -4,7 +4,7 @@
// It is the main BCL module and is required for other BCL modules to work properly. // 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. // The default bootstrap.js implementation for each platform loads and initializes this module.
// ``` JavaScript // ``` JavaScript
import app = require("application/application"); import app = require("application");
// ``` // ```
// The pre-required `app` module is used throughout the following code snippets. // The pre-required `app` module is used throughout the following code snippets.
// </snippet> // </snippet>

View File

@ -1,4 +1,4 @@
import app = require("application/application"); import app = require("application");
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
import commonTests = require("Tests/application-tests-common"); import commonTests = require("Tests/application-tests-common");

View File

@ -4,7 +4,7 @@
// Using the file system requires the FileSystem module. // Using the file system requires the FileSystem module.
// TODO: var fs = require("file-system"); => this will break the intellisense of the tests // TODO: var fs = require("file-system"); => this will break the intellisense of the tests
// ``` JavaScript // ``` 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. // The pre-required `fs` module is used throughout the following code snippets.
// </snippet> // </snippet>

View File

@ -1,5 +1,5 @@
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
import http = require("http/http"); import http = require("http");
require("globals"); require("globals");
// <snippet name="http"> // <snippet name="http">

View File

@ -13,8 +13,8 @@
// </snippet> // </snippet>
import imageSource = require("image-source/image-source"); import imageSource = require("image-source/image-source");
import fs = require("file-system/file-system"); import fs = require("file-system");
import app = require("application/application"); import app = require("application");
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
export var testFromResource = function () { export var testFromResource = function () {

View File

@ -1,130 +1,134 @@
/** 
* The main entry point event. This method is expected to return an instance of the root UI for the application. declare module "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;
/** /**
* 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. * This method will be called when there is low memory on the target device.
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
*/ */
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; function init(nativeApp: any);
/**
* 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);

View File

@ -2,7 +2,7 @@
/* /*
Current launch sequence for iOS looks like: Current launch sequence for iOS looks like:
var app = require("application/application"); var app = require("application");
app.tk.ui.Application.current.onLaunch = function() { app.tk.ui.Application.current.onLaunch = function() {
log("tk.ui.Application.current.onLaunch"); log("tk.ui.Application.current.onLaunch");

View File

@ -1,2 +1,2 @@
declare var module, require; declare var module, require;
module.exports = require("application/application"); module.exports = require("application");

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
var REQUEST_IMAGE_CAPTURE: number = 1; var REQUEST_IMAGE_CAPTURE: number = 1;
var REQUEST_SELECT_PICTURE: number = 2; var REQUEST_SELECT_PICTURE: number = 2;

69
camera/camera.d.ts vendored
View File

@ -1,36 +1,39 @@
 
import promises = require("promises/promises"); declare module "camera" {
import imageSource = require("image-source/image-source");
export declare enum CameraPosition { import promises = require("promises/promises");
FRONT = 0, import imageSource = require("image-source/image-source");
BACK = 1,
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<imageSource.ImageSource>;
} }
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<imageSource.ImageSource>;

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
import textModule = require("text/text"); import textModule = require("text/text");
export class FileSystemAccess { export class FileSystemAccess {

View File

@ -1,4 +1,4 @@
import app_module = require("application/application"); import app_module = require("application");
import utilsModule = require("utils/utils_ios"); import utilsModule = require("utils/utils_ios");
import textModule = require("text/text"); import textModule = require("text/text");

View File

@ -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<any>;
/**
* Renames the current entity using the specified name.
*/
public rename(newName: string): promises.Promise<any>;
}
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<string>;
/**
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
*/
public writeText(content: string, encoding?: string): promises.Promise<any>;
}
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<any>;
/**
* 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<Array<FileSystemEntity>>;
/**
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. * Enables path-specific operations like join, extension, etc.
*/
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; 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. * Joins all the provided string components, forming a valid and normalized path.
*/ */
public remove(): promises.Promise<any>; export function join(...paths: string[]): string;
/** /**
* Renames the current entity using the specified name. * Gets the string used to separate file paths.
*/ */
public rename(newName: string): promises.Promise<any>; export var separator: string;
} }
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<string>;
/**
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
*/
public writeText(content: string, encoding?: string): promises.Promise<any>;
}
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<any>;
/**
* 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<Array<FileSystemEntity>>;
/**
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;
} }

View File

@ -1,2 +1,2 @@
declare var module, require; declare var module, require;
module.exports = require("file-system/file-system"); module.exports = require("file-system");

View File

@ -8,3 +8,4 @@ setInterval = timer.setInterval;
clearInterval = timer.clearInterval; clearInterval = timer.clearInterval;
console = new consoleModule.Console(); console = new consoleModule.Console();

View File

@ -1,6 +1,6 @@
import image = require("image-source/image-source"); import image = require("image-source/image-source");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
/** /**
* Gets string from url. * Gets string from url.

View File

@ -2,7 +2,7 @@
* Android specific http request implementation. * Android specific http request implementation.
*/ */
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
declare var exports; declare var exports;
require("utils/module-merge").merge(require("http/http-common"), exports); require("utils/module-merge").merge(require("http/http-common"), exports);

59
http/http.d.ts vendored
View File

@ -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<string> function getString(url: string): promises.Promise<string>
export declare function getString(options: HttpRequestOptions): promises.Promise<string> function getString(options: HttpRequestOptions): promises.Promise<string>
export declare function getJSON<T>(url: string): promises.Promise<T> function getJSON<T>(url: string): promises.Promise<T>
export declare function getJSON<T>(options: HttpRequestOptions): promises.Promise<T> function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
export declare function getImage(url: string): promises.Promise<image.ImageSource> function getImage(url: string): promises.Promise<image.ImageSource>
export declare function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource> function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
export declare function request(options: HttpRequestOptions): promises.Promise<HttpResponse>; function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
export interface HttpRequestOptions { interface HttpRequestOptions {
url: string; url: string;
method: string; method: string;
headers?: any; headers?: any;
content?: any; content?: any;
timeout?: number; timeout?: number;
} }
export interface HttpResponse { interface HttpResponse {
statusCode: number; statusCode: number;
headers: any; headers: any;
content?: HttpContent; content?: HttpContent;
} }
export interface HttpContent { interface HttpContent {
raw: any; raw: any;
toString: () => string; toString: () => string;
toJSON: () => any; toJSON: () => any;
toImage: () => image.ImageSource; toImage: () => image.ImageSource;
}
} }

View File

@ -2,7 +2,7 @@
* iOS specific http request implementation. * iOS specific http request implementation.
*/ */
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
declare var exports; declare var exports;
require("utils/module-merge").merge(require("http/http-common"), exports); require("utils/module-merge").merge(require("http/http-common"), exports);

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
export var fromResource = function (name: string) { export var fromResource = function (name: string) {
var androidApp = appModule.android; var androidApp = appModule.android;

View File

@ -1,86 +1,89 @@
import promises = require("promises/promises"); 
declare module "image-source" {
import promises = require("promises/promises");
/** /**
* Defines the recognized image formats. * Defines the recognized image formats.
*/ */
export declare enum ImageFormat { enum ImageFormat {
PNG, PNG,
JPEG, JPEG,
}
/**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/
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;
}
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
function fromResource(name: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified file.
*/
function fromFile(path: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
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.
*/
function fromNativeSource(source: any): ImageSource;
/**
* Downloads the image from the provided Url and creates a new Image instance from it.
*/
function fromUrl(url: string): promises.Promise<ImageSource>;
} }
/**
* 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;
/**
* 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;
}
/**
* 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<ImageSource>;

View File

@ -1,7 +1,7 @@
import app = require("application/application"); import app = require("application");
import native = require("image-source/image-source-native"); import native = require("image-source/image-source-native");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
export enum ImageFormat { export enum ImageFormat {
PNG, PNG,

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
import Common = require("local-settings/local-settings-common"); import Common = require("local-settings/local-settings-common");
var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0); var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0);

View File

@ -1,73 +1,72 @@
/** 
* report does such key exist declare module "local-settings" {
*/ /**
export declare var hasKey: (key: string) => boolean; * 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 * gets value of the key as string, user can provide default value in case there is no value for the key
*/ */
export declare var getBoolean: (key: string, defaultValue?: boolean) => boolean; 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 * 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 getString: (key: string, defaultValue?: string) => string; 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 * 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 getStringArray: (key: string, defaultValue?: string[]) => string[]; 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 * gets value of the key as integer, user can provide default value in case there is no value for the key
*/ */
export declare var getNumber: (key: string, defaultValue?: number) => number; 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 * 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 getInt: (key: string, defaultValue?: number) => number; 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 * sets value for a key as boolean
*/ */
export declare var getLong: (key: string, defaultValue?: number) => number; 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 * sets value for a key as string array
*/ */
export declare var setBoolean: (key: string, value: boolean) => void; var setStringArray: (key: string, value: string[]) => void;
/** /**
* sets value for a key as string * sets value for a key as JS number (double)
*/ */
export declare var setString: (key: string, value: string) => void; var setNumber: (key: string, value: number) => void;
/** /**
* sets value for a key as string array * sets value for a key as integer
*/ */
export declare var setStringArray: (key: string, value: string[]) => void; var setInt: (key: string, value: number) => void;
/** /**
* sets value for a key as JS number (double) * sets value for a key as long integer
*/ */
export declare var setNumber: (key: string, value: number) => void; var setLong: (key: string, value: number) => void;
/** /**
* sets value for a key as integer * removes a value for key
*/ */
export declare var setInt: (key: string, value: number) => void; var remove: (key: string) => 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;

View File

@ -1,5 +1,5 @@
import types = require("location/location-types"); import types = require("location/location-types");
import appModule = require("application/application"); import appModule = require("application");
export class LocationManager { export class LocationManager {
// in meters // in meters

View File

@ -2,7 +2,7 @@
import promises = require("promises/promises"); import promises = require("promises/promises");
import timer = require("timer/timer"); import timer = require("timer/timer");
import types = require("location/location-types"); 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 // merge the exports of the types module with the exports of this file
declare var exports; declare var exports;

View File

@ -9,7 +9,6 @@
/** /**
Returns a new "Deferred" value that may be resolved or rejected. Returns a new "Deferred" value that may be resolved or rejected.
*/ */
export function defer<Value>(): Deferred<Value> { export function defer<Value>(): Deferred<Value> {
return new DeferredI<Value>(); return new DeferredI<Value>();
} }
@ -17,7 +16,6 @@ export function defer<Value>(): Deferred<Value> {
/** /**
Converts a value to a resolved promise. Converts a value to a resolved promise.
*/ */
export function resolve<Value>(v: Value): Promise<Value> { export function resolve<Value>(v: Value): Promise<Value> {
return defer<Value>().resolve(v).promise(); return defer<Value>().resolve(v).promise();
} }
@ -25,7 +23,6 @@ export function resolve<Value>(v: Value): Promise<Value> {
/** /**
Returns a rejected promise. Returns a rejected promise.
*/ */
export function reject<Value>(err: Rejection): Promise<Value> { export function reject<Value>(err: Rejection): Promise<Value> {
return defer<Value>().reject(err).promise(); return defer<Value>().reject(err).promise();
} }
@ -39,7 +36,6 @@ export function reject<Value>(err: Rejection): Promise<Value> {
All the values of all promise results are collected into the resulting promise which is resolved as soon 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. the last generated element value is resolved.
*/ */
export function unfold<Seed, Element>( export function unfold<Seed, Element>(
unspool: (current: Seed) => { promise: Promise<Element>; next?: Seed }, unspool: (current: Seed) => { promise: Promise<Element>; next?: Seed },
seed: Seed) seed: Seed)
@ -94,7 +90,6 @@ function unfoldCore<Seed, Element>(
Once a promise is either Rejected or Resolved, it can not change its Once a promise is either Rejected or Resolved, it can not change its
status anymore. status anymore.
*/ */
export enum Status { export enum Status {
Unfulfilled, Unfulfilled,
Rejected, Rejected,
@ -105,7 +100,6 @@ export enum Status {
If a promise gets rejected, at least a message that indicates the error or If a promise gets rejected, at least a message that indicates the error or
reason for the rejection must be provided. reason for the rejection must be provided.
*/ */
export interface Rejection { export interface Rejection {
message: string; message: string;
} }
@ -113,7 +107,6 @@ export interface Rejection {
/** /**
Both Promise<T> and Deferred<T> share these properties. Both Promise<T> and Deferred<T> share these properties.
*/ */
export interface PromiseState<Value> { export interface PromiseState<Value> {
/// The current status of the promise. /// The current status of the promise.
status: Status; status: Status;
@ -132,7 +125,6 @@ export interface PromiseState<Value> {
When multiple handlers are registered with done(), fail(), or always(), they are called in the When multiple handlers are registered with done(), fail(), or always(), they are called in the
same order. same order.
*/ */
export interface Promise<Value> extends PromiseState<Value> { export interface Promise<Value> extends PromiseState<Value> {
/** /**
Returns a promise that represents a promise chain that consists of this Returns a promise that represents a promise chain that consists of this
@ -161,7 +153,6 @@ export interface Promise<Value> extends PromiseState<Value> {
an asynchronous process. Callers of that function should only see the Promise<Value> that an asynchronous process. Callers of that function should only see the Promise<Value> that
is returned by promise(). is returned by promise().
*/ */
export interface Deferred<Value> extends PromiseState<Value> { export interface Deferred<Value> extends PromiseState<Value> {
/// Returns the encapsulated promise of this deferred instance. /// Returns the encapsulated promise of this deferred instance.
/// The returned promise supports composition but removes the ability to resolve or reject /// The returned promise supports composition but removes the ability to resolve or reject
@ -183,7 +174,6 @@ export interface Deferred<Value> extends PromiseState<Value> {
As soon one of the arguments gets rejected, the resulting promise gets rejected. As soon one of the arguments gets rejected, the resulting promise gets rejected.
If no promises were provided, the resulting promise is immediately resolved. If no promises were provided, the resulting promise is immediately resolved.
*/ */
export function when(...promises: Promise<any>[]): Promise<any[]> { export function when(...promises: Promise<any>[]): Promise<any[]> {
var allDone = defer<any[]>(); var allDone = defer<any[]>();
if (!promises.length) { if (!promises.length) {
@ -216,7 +206,6 @@ export function when(...promises: Promise<any>[]): Promise<any[]> {
The Promise<Value> instance is a proxy to the Deferred<Value> instance. The Promise<Value> instance is a proxy to the Deferred<Value> instance.
*/ */
class PromiseI<Value> implements Promise<Value> class PromiseI<Value> implements Promise<Value>
{ {
constructor(public deferred: DeferredI<Value>) constructor(public deferred: DeferredI<Value>)
@ -249,7 +238,6 @@ class PromiseI<Value> implements Promise<Value>
/** /**
Implementation of a deferred. Implementation of a deferred.
*/ */
class DeferredI<Value> implements Deferred<Value>{ class DeferredI<Value> implements Deferred<Value>{
private _resolved: (v: Value) => void = _ => { }; private _resolved: (v: Value) => void = _ => { };
@ -379,7 +367,6 @@ class DeferredI<Value> implements Deferred<Value>{
/** /**
Promise Generators and Iterators. Promise Generators and Iterators.
*/ */
export interface Generator<E> { export interface Generator<E> {
(): Iterator<E>; (): Iterator<E>;
} }
@ -419,7 +406,6 @@ class IteratorI<E> implements Iterator<E>
/** /**
Iterator functions. Iterator functions.
*/ */
export function each<E>(gen: Generator<E>, f: (e: E) => void): Promise<{}> { export function each<E>(gen: Generator<E>, f: (e: E) => void): Promise<{}> {
var d = defer(); var d = defer();
eachCore(d, gen(), f); eachCore(d, gen(), f);
@ -443,7 +429,6 @@ function eachCore<E>(fin: Deferred<{}>, it: Iterator<E>, f: (e: E) => void): voi
/** /**
std std
*/ */
export function isUndefined(v) { export function isUndefined(v) {
return typeof v === 'undefined'; return typeof v === 'undefined';
} }

1
text/text.d.ts vendored
View File

@ -9,3 +9,4 @@ export declare module encoding {
export var UTF_16LE: any; export var UTF_16LE: any;
export var UTF_8: any; export var UTF_8: any;
} }