Updated some APIs with @param defintions. Added .impl suffix to the ImageSource module.

This commit is contained in:
atanasovg
2014-05-21 15:15:48 +03:00
parent 9dd3ba70c5
commit a6edd119d0
12 changed files with 112 additions and 70 deletions

View File

@ -130,7 +130,7 @@
</TypeScriptCompile> </TypeScriptCompile>
<TypeScriptCompile Include="image-source\image-source.d.ts" /> <TypeScriptCompile Include="image-source\image-source.d.ts" />
<TypeScriptCompile Include="image-source\image-source-native.d.ts" /> <TypeScriptCompile Include="image-source\image-source-native.d.ts" />
<TypeScriptCompile Include="image-source\image-source.ts"> <TypeScriptCompile Include="image-source\image-source.impl.ts">
<DependentUpon>image-source.d.ts</DependentUpon> <DependentUpon>image-source.d.ts</DependentUpon>
</TypeScriptCompile> </TypeScriptCompile>
<TypeScriptCompile Include="image-source\index.ts" /> <TypeScriptCompile Include="image-source\index.ts" />

View File

@ -12,7 +12,7 @@
// ## Loading and saving images // ## Loading and saving images
// </snippet> // </snippet>
import imageSource = require("image-source/image-source"); import imageSource = require("image-source");
import fs = require("file-system"); import fs = require("file-system");
import app = require("application"); import app = require("application");
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");

View File

@ -5,46 +5,52 @@ declare module "application" {
* The main entry point event. This method is expected to return an instance of the root UI for the application. * 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. * This will be an Activity extends for Android and a RootViewController for iOS.
*/ */
function onLaunch(): any; export function onLaunch(): any;
/** /**
* This method will be called when the Application is suspended. * This method will be called when the Application is suspended.
*/ */
function onSuspend(); export function onSuspend();
/** /**
* This method will be called when the Application is resumed after it has been suspended. * This method will be called when the Application is resumed after it has been suspended.
*/ */
function onResume(); export function onResume();
/** /**
* This method will be called when the Application is about to exit. * This method will be called when the Application is about to exit.
*/ */
function onExit(); export function onExit();
/** /**
* This method will be called when there is low memory on the target device. * This method will be called when there is low memory on the target device.
*/ */
function onLowMemory(); export function onLowMemory();
/** /**
* This is the Android-specific application object instance. * This is the Android-specific application object instance.
* Encapsulates methods and properties specific to the Android platform. * Encapsulates methods and properties specific to the Android platform.
* Will be undefined when TargetOS is iOS. * Will be undefined when TargetOS is iOS.
*/ */
var android: AndroidApplication; export var android: AndroidApplication;
/** /**
* This is the iOS-specific application object instance. * This is the iOS-specific application object instance.
* Encapsulates methods and properties specific to the iOS platform. * Encapsulates methods and properties specific to the iOS platform.
* Will be undefined when TargetOS is Android. * Will be undefined when TargetOS is Android.
*/ */
var ios: iOSApplication; export var ios: iOSApplication;
/**
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
* @param nativeApp The instance of the platform Application object - e.g. android.app.Application
*/
export function init(nativeApp: any);
/** /**
* The abstraction of an Android-specific application object. * The abstraction of an Android-specific application object.
*/ */
class AndroidApplication { export class AndroidApplication {
/** /**
* The android.app.Application object instance provided to the init of the module. * The android.app.Application object instance provided to the init of the module.
*/ */
@ -73,6 +79,7 @@ declare module "application" {
/** /**
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered. * 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. * The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
* @param intent The android.content.Intent object for which the activity is required.
*/ */
public getActivity: (intent: android.content.Intent) => any; public getActivity: (intent: android.content.Intent) => any;
@ -115,7 +122,7 @@ declare module "application" {
/** /**
* The abstraction of an iOS-specific application object. * The abstraction of an iOS-specific application object.
*/ */
class iOSApplication { export class iOSApplication {
/** /**
* The root view controller for the application. * The root view controller for the application.
*/ */
@ -126,9 +133,4 @@ declare module "application" {
*/ */
public nativeApp: UIKit.UIApplication; public nativeApp: UIKit.UIApplication;
} }
/**
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
*/
function init(nativeApp: any);
} }

2
camera/camera.d.ts vendored
View File

@ -2,7 +2,7 @@
declare module "camera" { declare module "camera" {
import promises = require("promises/promises"); import promises = require("promises/promises");
import imageSource = require("image-source/image-source"); import imageSource = require("image-source");
enum CameraPosition { enum CameraPosition {
FRONT = 0, FRONT = 0,

View File

@ -1,6 +1,5 @@
 import promises = require("promises/promises");
import promises = require("promises/promises"); import imageSource = require("image-source");
import imageSource = require("image-source/image-source");
import types = require("camera/camera-types"); import types = require("camera/camera-types");
var imagePickerController; var imagePickerController;

14
console/console.d.ts vendored
View File

@ -5,36 +5,49 @@
export declare class Console { export declare class Console {
/** /**
* Begins counting a time span for a given name (key). * Begins counting a time span for a given name (key).
* @param reportName The key for the operation.
*/ */
public time(reportName: string): void; public time(reportName: string): void;
/** /**
* Ends a previously started time span through the time method. * Ends a previously started time span through the time method.
* @param reportName The key for the operation. Must have an already started time(reportName) operation with the same key.
*/ */
public timeEnd(reportName: string): void; public timeEnd(reportName: string): void;
/** /**
* Asserts a boolean condition and prints a message in case the assert fails. * Asserts a boolean condition and prints a message in case the assert fails.
* @param test A value that should not be Falsy.
* @param message The message to be displayed in case the asserted value is Falsy.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/ */
public assert(test: boolean, message: string, ...formatParams: any[]): void; public assert(test: boolean, message: string, ...formatParams: any[]): void;
/** /**
* Reports some information. * Reports some information.
* @param message The information message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/ */
public info(message: any, ...formatParams: any[]): void; public info(message: any, ...formatParams: any[]): void;
/** /**
* Reports a warning. * Reports a warning.
* @param message The warning message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/ */
public warn(message: any, ...formatParams: any[]): void; public warn(message: any, ...formatParams: any[]): void;
/** /**
* Reports an error. * Reports an error.
* @param message The error message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/ */
public error(message: any, ...formatParams: any[]): void; public error(message: any, ...formatParams: any[]): void;
/** /**
* Verbously logs a message. * Verbously logs a message.
* @param message The message to be printed to the console.
* @param formatParams Optional formatting parameters to be applied to the printed message.
*/ */
public log(message: any, ...formatParams: any[]): void; public log(message: any, ...formatParams: any[]): void;
@ -45,6 +58,7 @@ export declare class Console {
/** /**
* Prints the state of the specified object to the console. * Prints the state of the specified object to the console.
* @param obj The object instance to be dumped.
*/ */
public dump(obj: any): void; public dump(obj: any): void;
} }

View File

@ -3,7 +3,7 @@ declare module "file-system" {
import promises = require("promises/promises"); import promises = require("promises/promises");
class FileSystemEntity { export class FileSystemEntity {
/** /**
* Gets the Date object specifying the last time this entity was modified. * Gets the Date object specifying the last time this entity was modified.
*/ */
@ -33,62 +33,71 @@ declare module "file-system" {
/** /**
* Renames the current entity using the specified name. * Renames the current entity using the specified name.
* @param newName The new name to be applied to the entity.
*/ */
public rename(newName: string): promises.Promise<any>; public rename(newName: string): promises.Promise<any>;
} }
class File extends FileSystemEntity { export class File extends FileSystemEntity {
/** /**
* Checks whether a File with the specified path already exists. * Checks whether a File with the specified path already exists.
*/ * @param path The path to check for.
*/
public static exists(path: string): boolean; public static exists(path: string): boolean;
/** /**
* Gets the extension of the file. * Gets the extension of the file.
*/ */
public extension: string; public extension: string;
/** /**
* Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running. * Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.
*/ */
public isLocked: boolean; public isLocked: boolean;
/** /**
* Gets or creates a File entity at the specified path. * Gets or creates a File entity at the specified path.
*/ * @param path The path to get/create the file at.
*/
public static fromPath(path: string): File; public static fromPath(path: string): File;
/** /**
* Reads the content of the file as a string using the specified encoding (defaults to UTF-8). * Reads the content of the file as a string using the specified encoding (defaults to UTF-8).
*/ * @param encoding An optional value specifying the preferred encoding (defaults to UTF-8).
*/
public readText(encoding?: string): promises.Promise<string>; public readText(encoding?: string): promises.Promise<string>;
/** /**
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8). * Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
*/ * @param content The content to be saved to the file.
* @param encoding An optional value specifying the preferred encoding (defaults to UTF-8).
*/
public writeText(content: string, encoding?: string): promises.Promise<any>; public writeText(content: string, encoding?: string): promises.Promise<any>;
} }
class Folder extends FileSystemEntity { export class Folder extends FileSystemEntity {
/** /**
* Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). * Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).
*/ */
public isKnown: boolean; public isKnown: boolean;
/** /**
* Gets or creates a Folder entity at the specified path. * Gets or creates a Folder entity at the specified path.
*/ * @param path The path to get/create the folder at.
*/
public static fromPath(path: string): Folder; public static fromPath(path: string): Folder;
/** /**
* Checks whether a Folder with the specified path already exists. * Checks whether a Folder with the specified path already exists.
*/ * @param path The path to check for.
*/
public static exists(path: string): boolean; public static exists(path: string): boolean;
/** /**
Checks whether this Folder contains an Entity with the specified name. * 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. * The path of the folder is added to the name to resolve the complete path to check for.
*/ * @param name The name of the entity to check for.
*/
public contains(name: string): boolean; public contains(name: string): boolean;
/** /**
@ -97,12 +106,14 @@ declare module "file-system" {
public clear(): promises.Promise<any>; public clear(): promises.Promise<any>;
/** /**
* Gets or creates a File entity with the specified name within this Folder. * Gets or creates a File entity with the specified name within this Folder.
*/ * @param name The name of the file to get/create.
*/
public getFile(name: string): File; public getFile(name: string): File;
/** /**
* Gets or creates a Folder entity with the specified name within this Folder. * Gets or creates a Folder entity with the specified name within this Folder.
* @param name The name of the folder to get/create.
*/ */
public getFolder(name: string): Folder; public getFolder(name: string): Folder;
@ -112,17 +123,16 @@ declare module "file-system" {
public getEntities(): promises.Promise<Array<FileSystemEntity>>; public getEntities(): promises.Promise<Array<FileSystemEntity>>;
/** /**
Enumerates all the top-level FileSystem entities residing within this folder. * Enumerates all the top-level FileSystem entities residing within this folder.
The first parameter is a callback that receives the current entity. * @param onEntity A callback that receives the current entity. If the callback returns false this will mean for the iteration to stop.
If the callback returns false this will mean for the iteration to stop.
*/ */
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean); 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. * Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem.
*/ */
module knownFolders { export 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. * Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
*/ */
@ -137,14 +147,16 @@ declare module "file-system" {
/** /**
* Enables path-specific operations like join, extension, etc. * Enables path-specific operations like join, extension, etc.
*/ */
module path { export module path {
/** /**
* Normalizes a path, taking care of occurrances like ".." and "//" * Normalizes a path, taking care of occurrances like ".." and "//".
* @param path The path to be normalized.
*/ */
export function normalize(path: string): string; export function normalize(path: string): string;
/** /**
* Joins all the provided string components, forming a valid and normalized path. * Joins all the provided string components, forming a valid and normalized path.
* @param paths An array of string components to be joined.
*/ */
export function join(...paths: string[]): string; export function join(...paths: string[]): string;

View File

@ -1,4 +1,4 @@
import image = require("image-source/image-source"); import image = require("image-source");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http"); import http = require("http");

2
http/http.d.ts vendored
View File

@ -1,6 +1,6 @@
 
declare module "http" { declare module "http" {
import image = require("image-source/image-source"); import image = require("image-source");
import promises = require("promises/promises"); import promises = require("promises/promises");
function getString(url: string): promises.Promise<string> function getString(url: string): promises.Promise<string>

View File

@ -5,7 +5,7 @@ declare module "image-source" {
/** /**
* Defines the recognized image formats. * Defines the recognized image formats.
*/ */
enum ImageFormat { export enum ImageFormat {
PNG, PNG,
JPEG, JPEG,
} }
@ -13,7 +13,7 @@ declare module "image-source" {
/** /**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. * Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/ */
class ImageSource { export class ImageSource {
/** /**
* Gets the height of this instance. This is a read-only property. * Gets the height of this instance. This is a read-only property.
*/ */
@ -36,54 +36,66 @@ declare module "image-source" {
/** /**
* Loads this instance from the specified resource name. * Loads this instance from the specified resource name.
* @param name The name of the resource (without its extension).
*/ */
loadFromResource(name: string): boolean; loadFromResource(name: string): boolean;
/** /**
* Loads this instance from the specified file. * Loads this instance from the specified file.
* @param path The location of the file on the file system.
*/ */
loadFromFile(path: string): boolean; loadFromFile(path: string): boolean;
/** /**
* Loads this instance from the specified native image data. * Loads this instance from the specified native image data.
* @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
*/ */
loadFromData(data: any): boolean; loadFromData(data: any): boolean;
/** /**
* Sets the provided native source object (typically a Bitmap). * Sets the provided native source object (typically a Bitmap).
* This will update either the android or ios properties, depending on the target os. * This will update either the android or ios properties, depending on the target os.
* @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
*/ */
setNativeSource(source: any): boolean; setNativeSource(source: any): boolean;
/** /**
* Saves this instance to the specified file, using the provided image format and quality. * Saves this instance to the specified file, using the provided image format and quality.
* @param path The path of the file on the file system to save to.
* @param format The format (encoding) of the image.
* @param quality Optional parameter, specifying the quality of the encoding. Defaults to the maximum available quality.
*/ */
saveToFile(path: string, format: ImageFormat, quality?: number): boolean; saveToFile(path: string, format: ImageFormat, quality?: number): boolean;
} }
/** /**
* Creates a new Image instance and loads it from the specified resource name. * Creates a new ImageSource instance and loads it from the specified resource name.
* @param name The name of the resource (without its extension).
*/ */
function fromResource(name: string): ImageSource; export function fromResource(name: string): ImageSource;
/** /**
* Creates a new Image instance and loads it from the specified file. * Creates a new ImageSource instance and loads it from the specified file.
* @param path The location of the file on the file system.
*/ */
function fromFile(path: string): ImageSource; export function fromFile(path: string): ImageSource;
/** /**
* Creates a new Image instance and loads it from the specified resource name. * Creates a new ImageSource instance and loads it from the specified resource name.
* @param data The native data (byte array) to load the image from. This will be either Stream for Android or NSData for iOS.
*/ */
function fromData(data: any): ImageSource; export function fromData(data: any): ImageSource;
/** /**
* Creates a new Image instance and sets the provided native source object (typically a Bitmap). * Creates a new ImageSource 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. * The native source object will update either the android or ios properties, depending on the target os.
* @param source The native image object. Will be either a Bitmap for Android or a UIImage for iOS.
*/ */
function fromNativeSource(source: any): ImageSource; export function fromNativeSource(source: any): ImageSource;
/** /**
* Downloads the image from the provided Url and creates a new Image instance from it. * Downloads the image from the provided Url and creates a new ImageSource instance from it.
* @param url The link to the remote image object. This operation will download and decode the image.
*/ */
function fromUrl(url: string): promises.Promise<ImageSource>; export function fromUrl(url: string): promises.Promise<ImageSource>;
} }

View File

@ -3,6 +3,9 @@ import native = require("image-source/image-source-native");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http"); import http = require("http");
// This is used for definition purposes only, it does not generate JavaScript for it.
import definition = require("image-source");
export enum ImageFormat { export enum ImageFormat {
PNG, PNG,
JPEG, JPEG,
@ -105,6 +108,6 @@ export function fromNativeSource(source: any): ImageSource {
return image.setNativeSource(source) ? image : null; return image.setNativeSource(source) ? image : null;
} }
export function fromUrl(url: string): promises.Promise<ImageSource> { export function fromUrl(url: string): promises.Promise<definition.ImageSource> {
return http.getImage(url); return http.getImage(url);
} }

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"); import locationManagerModule = require("location/location-manager");
// 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;