Adds bindings for Apache Cordova

This commit is contained in:
sgrebnov
2014-03-29 18:24:39 +04:00
committed by Vladimir Kotikov
parent 4891ed9bd1
commit 0ec5f624f1
21 changed files with 2517 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ List of Definitions
* [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik))
* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon))
* [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem))
* [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/))
* [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat))
* [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli))
* [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts)

229
cordova/cordova-tests.ts Normal file
View File

@@ -0,0 +1,229 @@
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
/// <reference path="cordova.d.ts"/>
// Apache Cordova core
//----------------------------------------------------------------------
console.log('cordova.version: ' + cordova.version + ', cordova.platformId: ' + cordova.platformId);
cordova.exec(null, null, "NativeClassName", "MethodName");
cordova.define('mymodule', (require, exports, module) => { });
var myModule = cordova.require('mymodule');
var argsCheck: ArgsCheck = <ArgsCheck>cordova.require('cordova/argcheck');
argsCheck.checkArgs('ssA', 'cordova.exec', [() => { }, () => { }, 'window', 'openDatabase']);
// Battery status plugin
//----------------------------------------------------------------------
window.addEventListener('batterystatus',
(ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
window.addEventListener('batterycritical',
()=> { alert('Battery is critical low!'); });
// Camera plugin
//----------------------------------------------------------------------
navigator.camera.getPicture(
(data: string) => { alert('Got photo!'); },
(message: string)=> { alert('Failed!: ' + message); },
{
allowEdit: true,
cameraDirection: Camera.Direction.BACK,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
quality: 80
});
// Contacts plugin
//----------------------------------------------------------------------
var contact: Contact = navigator.contacts.create({
nickname: 'John Smith',
displayName: 'John Smith',
phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }]
});
navigator.contacts.find(["phoneNumbers"],
(contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); },
(error: ContactError) => { alert('Error: ' + error.message); },
{
filter: "+1",
multiple: true
}
);
// Device API
//----------------------------------------------------------------------
console.log(JSON.stringify(device));
// DeviceMotion plugin
//----------------------------------------------------------------------
navigator.accelerometer.getCurrentAcceleration(
(acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); });
var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration(
(acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); },
() => { alert('Error!'); },
{ frequency: 10 });
navigator.accelerometer.clearWatch(acchandle);
// DeviceOrientation plugin
//----------------------------------------------------------------------
navigator.compass.getCurrentHeading(
(heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError)=> { alert('Error! ' + error.code); },
{ frequency: 10 });
var accelhandle = navigator.compass.watchHeading(
(heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); },
(error: CompassError) => { alert('Error! ' + error.code); },
{ frequency: 10 });
navigator.compass.clearWatch(accelhandle);
// Dialogs plugin
//----------------------------------------------------------------------
navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok');
navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); });
// FileSystem plugin
//----------------------------------------------------------------------
function fsaccessor(fs: FileSystem) {
console.log('FS root is: ' + fs.root.name);
var fsreader: DirectoryReader = fs.root.createReader();
fsreader.readEntries(
(entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); },
(err: Error)=> { alert('Error: ' + err.message); });
}
window.requestFileSystem(
window.TEMPORARY,
1024 * 1024 * 5,
fsaccessor,
(err: Error) => { alert('Error: ' + err.message); });
// FileTransfer plugin
//----------------------------------------------------------------------
var file = new FileTransfer();
file.download('http://some.server.com/download.php',
'cdvfile://localhost/persistent/path/to/downloads/',
(file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); },
(err: FileTransferError)=> { alert('Error ' + err.code); },
{ headers: null },
true);
// InAppBrowser plugin
//----------------------------------------------------------------------
// signature of window.open() added by InAppBrowser plugin
// is similar to native window.open signature, so the compiler can's
// select proper overload, but we cast result to InAppBrowser manually.
var iab = <InAppBrowser>window.open('google.com', '_self');
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
iab.show();
// Globalization plugin
//----------------------------------------------------------------------
navigator.globalization.dateToString(new Date(),
(date) => { console.log(JSON.stringify(date)); },
(error) => { alert(error.message); },
{ formatLength: "short", selector: "date" });
navigator.globalization.getDateNames(
(names) => {
names.value.forEach((name) => { console.log(name); });
},
(error) => { alert(error.message); },
{ item: "months", type: "wide" });
// Media and Media Capture
//----------------------------------------------------------------------
var media = new Media('',
() => { console.log('Media opened'); },
(err: MediaError) => { alert('Error: ' + err.code); });
media.play();
media.setVolume(10);
console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes));
navigator.device.capture.captureAudio(
(captures: MediaFile[])=> { console.log(captures.length + ' captured'); },
(err: CaptureError)=> { alert('Error ' + err.message); },
{
limit: 3,
duration: 10
});
// Push Notifications
//----------------------------------------------------------------------
var pushNotification = window.plugins.pushNotification;
pushNotification.register(
(regId: string) => { console.log('Successfully registered'); },
(err: any) => { alert('Error!'); },
{
channelName: "your_channel_name",
ecb: "onNotification"
});
function onNotification(e: any) {
navigator.notification.alert(e.text2, () => { }, e.text1);
}
window.plugins.pushNotification.unregister(() => { }, () => { });
// Network Plugin
//----------------------------------------------------------------------
console.log('Connection type is: ' + navigator.connectionSpeed);
var connType = navigator.connection.type;
if (connType == Connection.WIFI) {
console.log('Congratulations, you\'re with fast Internet!');
}
document.addEventListener('offline', () => { alert('You\'re offline!'); });
// SplashScreen plugin
//----------------------------------------------------------------------
navigator.splashscreen.show();
navigator.splashscreen.hide();
// WebSQL plugin
//----------------------------------------------------------------------
var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5);
db.transaction(
(tx: SqlTransaction) => {
tx.executeSql('CREATE TABLE Sample IF NOT EXIST...');
tx.executeSql('INSERT INTO Sample VALUES...');
},
(err: SqlError) => {
if (err.code = SqlError.SYNTAX_ERR) {
alert('Error ' + err.message);
}
},
() => { console.log('Transaction completed successfully'); }
);
// Vibration plugin
//----------------------------------------------------------------------
navigator.notification.vibrate(100);

60
cordova/cordova.d.ts vendored Normal file
View File

@@ -0,0 +1,60 @@
// Type definitions for Apache Cordova.
// Project: http://cordova.apache.org
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
/// <reference path="plugins/BatteryStatus.d.ts"/>
/// <reference path="plugins/Camera.d.ts"/>
/// <reference path="plugins/Contacts.d.ts"/>
/// <reference path="plugins/Device.d.ts"/>
/// <reference path="plugins/DeviceMotion.d.ts"/>
/// <reference path="plugins/DeviceOrientation.d.ts"/>
/// <reference path="plugins/Dialogs.d.ts"/>
/// <reference path="plugins/FileSystem.d.ts"/>
/// <reference path="plugins/FileTransfer.d.ts"/>
/// <reference path="plugins/Globalization.d.ts"/>
/// <reference path="plugins/InAppBrowser.d.ts"/>
/// <reference path="plugins/Media.d.ts"/>
/// <reference path="plugins/MediaCapture.d.ts"/>
/// <reference path="plugins/NetworkInformation.d.ts"/>
/// <reference path="plugins/Push.d.ts"/>
/// <reference path="plugins/Splashscreen.d.ts"/>
/// <reference path="plugins/Vibration.d.ts"/>
/// <reference path="plugins/WebSQL.d.ts"/>
interface Cordova {
/** Invokes native functionality by specifying corresponding service name, action and optional parameters.
* @param success A success callback function.
* @param fail An error callback function.
* @param service The service name to call on the native side (corresponds to a native class).
* @param action The action name to call on the native side (generally corresponds to the native class method).
* @param args An array of arguments to pass into the native environment.
*/
exec(success: () => any, fail: () => any, service: string, action: string, args?: string[]): void;
/** Gets the operating system name. */
platformId: string;
/** Gets Cordova framework version */
version: string;
/** Defines custom logic as a Cordova module. Other modules can later access it using module name provided. */
define(moduleName: string, factory: (require: any, exports: any, module: any) => any): void;
/** Access a Cordova module by name. */
require(moduleName: string): any;
}
// cordova/argscheck module
interface ArgsCheck {
checkArgs(argsSpec: string, functionName: string, args: any[], callee?: any): void;
getValue(value?: any, defaultValue?: any): any;
enableChecks: boolean;
}
// cordova/urlutil module
interface UrlUtil {
makeAbsolute(url: string): string
}
/** Apache Cordova instance */
declare var cordova: Cordova;

125
cordova/plugins/BatteryStatus.d.ts vendored Normal file
View File

@@ -0,0 +1,125 @@
// Type definitions for Apache Cordova BatteryStatus plugin.
// Project: https://github.com/apache/cordova-plugin-battery-status
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
onbatterystatus: (type: BatteryStatusEvent) => void;
onbatterycritical: (type: BatteryStatusEvent) => void;
onbatterylow: (type: BatteryStatusEvent) => void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
}
/** Object, that passed into battery event listener */
interface BatteryStatusEvent extends Event {
/* The percentage of battery charge (0-100). */
level: number;
/* A boolean that indicates whether the device is plugged in. */
isPlugged: boolean;
}

167
cordova/plugins/Camera.d.ts vendored Normal file
View File

@@ -0,0 +1,167 @@
// Type definitions for Apache Cordova Camera plugin.
// Project: https://github.com/apache/cordova-plugin-camera
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/**
* This plugin provides an API for taking pictures and for choosing images from the system's image library.
*/
camera: Camera;
}
/**
* This plugin provides an API for taking pictures and for choosing images from the system's image library.
*/
interface Camera {
/**
* Removes intermediate photos taken by the camera from temporary storage.
* @param onSuccess Success callback, that called when cleanup succeeds.
* @param onError Error callback, that get an error message.
*/
cleanup(
onSuccess: () => void,
onError: (message: string) => void): void;
/**
* Takes a photo using the camera, or retrieves a photo from the device's image gallery.
* @param cameraSuccess Success callback, that get the image
* as a base64-encoded String, or as the URI for the image file.
* @param cameraError Error callback, that get an error message.
* @param cameraOptions Optional parameters to customize the camera settings.
*/
getPicture(
cameraSuccess: (data: string) => void,
cameraError: (message: string) => void,
cameraOptions?: CameraOptions): void;
// Next will work only on iOS
//getPicture(
// cameraSuccess: (data: string) => void,
// cameraError: (message: string) => void,
// cameraOptions?: CameraOptions): CameraPopoverHandle;
}
interface CameraOptions {
/** Picture quality in range o-100 */
quality?: number;
/**
* Choose the format of the return value.
* Defined in navigator.camera.DestinationType
* DATA_URL : 0, Return image as base64-encoded string
* FILE_URI : 1, Return image file URI
* NATIVE_URI : 2 Return image native URI
* (e.g., assets-library:// on iOS or content:// on Android)
*/
destinationType?: number;
/**
* Set the source of the picture. Defined in navigator.camera.PictureSourceType
* PHOTOLIBRARY : 0,
* CAMERA : 1,
* SAVEDPHOTOALBUM : 2
*/
sourceType?: number;
/** Allow simple editing of image before selection. */
allowEdit?: boolean;
/**
* Choose the returned image file's encoding. Defined in navigator.camera.EncodingType
* JPEG : 0 Return JPEG encoded image
* PNG : 1 Return PNG encoded image
*/
encodingType?: number;
/**
* Width in pixels to scale image. Must be used with targetHeight.
* Aspect ratio remains constant.
*/
targetWidth?: number;
/**
* Height in pixels to scale image. Must be used with targetWidth.
* Aspect ratio remains constant.
*/
targetHeight?: number;
/**
* Set the type of media to select from. Only works when PictureSourceType
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
* Will return format specified via DestinationType
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
* ALLMEDIA : 2 allow selection from all media types
*/
mediaType?: number;
/** Rotate the image to correct for the orientation of the device during capture. */
correctOrientation?: boolean;
/** Save the image to the photo album on the device after capture. */
saveToPhotoAlbum?: boolean;
/** Choose the camera to use (front- or back-facing). Defined in navigator.camera.Direction */
cameraDirection?: number;
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
popoverOptions?: CameraPopoverOptions;
}
/**
* A handle to the popover dialog created by navigator.camera.getPicture. Used on iOS only.
*/
interface CameraPopoverHandle {
/**
* Set the position of the popover.
* @param popoverOptions the CameraPopoverOptions that specify the new position.
*/
setPosition(popoverOptions: CameraPopoverOptions): void;
}
/**
* iOS-only parameters that specify the anchor element location and arrow direction
* of the popover when selecting images from an iPad's library or album.
*/
interface CameraPopoverOptions {
x: number;
y: number;
width: number;
height: number;
/**
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
* Matches iOS UIPopoverArrowDirection constants.
* ARROW_UP : 1,
* ARROW_DOWN : 2,
* ARROW_LEFT : 4,
* ARROW_RIGHT : 8,
* ARROW_ANY : 15
*/
arrowDir : number;
}
declare var Camera: {
// Camera constants, defined in Camera plugin
DestinationType: {
DATA_URL: number;
FILE_URI: number;
NATIVE_URI: number
}
Direction: {
BACK: number;
FRONT: number;
}
EncodingType: {
JPEG: number;
PNG: number;
}
MediaType: {
PICTURE: number;
VIDEO: number;
ALLMEDIA: number;
}
PictureSourceType: {
PHOTOLIBRARY: number;
CAMERA: number;
SAVEDPHOTOALBUM: number;
}
// Used only on iOS
PopoverArrowDirection: {
ARROW_UP: number;
ARROW_DOWN: number;
ARROW_LEFT: number;
ARROW_RIGHT: number;
ARROW_ANY: number;
}
};

262
cordova/plugins/Contacts.d.ts vendored Normal file
View File

@@ -0,0 +1,262 @@
// Type definitions for Apache Cordova Contacts plugin.
// Project: https://github.com/apache/cordova-plugin-contacts
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** Provides access to the device contacts database. */
contacts: Contacts;
}
interface Contacts {
/**
* The navigator.contacts.create method is synchronous, and returns a new Contact object.
* This method does not retain the Contact object in the device contacts database,
* for which you need to invoke the Contact.save method.
* @param properties Object with contact fields
*/
create(properties?: ContactProperties): Contact;
/**
* The navigator.contacts.find method executes asynchronously, querying the device contacts database
* and returning an array of Contact objects. The resulting objects are passed to the onSuccess
* callback function specified by the onSuccess parameter.
* @param fields The fields parameter specifies the fields to be used as a search qualifier,
* and only those results are passed to the onSuccess callback function. A zero-length fields parameter
* is invalid and results in ContactError.INVALID_ARGUMENT_ERROR. A contactFields value of "*" returns all contact fields.
* @param onSuccess Success callback function invoked with the array of Contact objects returned from the database
* @param onError Error callback function, invoked when an error occurs.
* @param options Search options to filter navigator.contacts.
*/
find(fields: string[],
onSuccess: (contacts: Contact[]) => void,
onError: (error: ContactError) => void,
options?: ContactFindOptions): void;
}
interface ContactProperties {
/** A globally unique identifier. */
id?: string;
/** The name of this Contact, suitable for display to end users. */
displayName?: string;
/** An object containing all components of a persons name. */
name?: ContactName;
/** A casual name by which to address the contact. */
nickname?: string;
/** An array of all the contact's phone numbers. */
phoneNumbers?: ContactField[];
/** An array of all the contact's email addresses. */
emails?: ContactField[];
/** An array of all the contact's addresses. */
addresses?: ContactAddress[];
/** An array of all the contact's IM addresses. */
ims?: ContactField[];
/** An array of all the contact's organizations. */
organizations?: ContactOrganization[];
/** The birthday of the contact. */
birthday?: Date;
/** A note about the contact. */
note?: string;
/** An array of the contact's photos. */
photos?: ContactField[];
/** An array of all the user-defined categories associated with the contact. */
categories?: ContactField[];
/** An array of web pages associated with the contact. */
urls?: ContactField[];
}
/**
* The Contact object represents a user's contact. Contacts can be created, stored, or removed
* from the device contacts database. Contacts can also be retrieved (individually or in bulk)
* from the database by invoking the navigator.contacts.find method.
*/
interface Contact extends ContactProperties {
/**
* Returns a new Contact object that is a deep copy of the calling object, with the id property set to null
*/
clone(): Contact;
/**
* Removes the contact from the device contacts database, otherwise executes an error callback with a ContactError object.
* @param onSuccess Success callback function invoked on success operation.
* @param onError Error callback function, invoked when an error occurs.
*/
remove(
onSuccess: () => void,
onError: (error: Error) => void): void;
/**
* Saves a new contact to the device contacts database, or updates an existing contact if a contact with the same id already exists.
* @param onSuccess Success callback function invoked on success operation with che Contact object.
* @param onError Error callback function, invoked when an error occurs.
*/
save(
onSuccess: (contact: Contact) => void,
onError: (error: Error) => void): void;
}
declare var Contact: {
/** Constructor of Contact object */
new(id?: string,
displayName?: string,
name?: ContactName,
nickname?: string,
phoneNumbers?: ContactField[],
emails?: ContactField[],
addresses?: ContactAddress[],
ims?: ContactField[],
organizations?: ContactOrganization[],
birthday?: Date,
note?: string,
photos?: ContactField[],
categories?: ContactField,
urls?: ContactField[]): Contact
};
/** The ContactError object is returned to the user through the contactError callback function when an error occurs. */
interface ContactError {
/** Error code */
code: number;
/** Error message */
message: string;
}
declare var ContactError: {
new(code: number): ContactError;
UNKNOWN_ERROR: number;
INVALID_ARGUMENT_ERROR: number;
TIMEOUT_ERROR: number;
PENDING_OPERATION_ERROR: number;
IO_ERROR: number;
NOT_SUPPORTED_ERROR: number;
PERMISSION_DENIED_ERROR: number
};
/** Contains different kinds of information about a Contact object's name. */
interface ContactName {
/** The complete name of the contact. */
formatted?: string;
/** The contact's family name. */
familyName?: string;
/** The contact's given name. */
givenName?: string;
/** The contact's middle name. */
middleName?: string;
/** The contact's prefix (example Mr. or Dr.) */
honorifixPrefix?: string;
/** The contact's suffix (example Esq.). */
honorifixSuffix?: string;
}
declare var ContactName: {
/** Constructor for ContactName object */
new(formatted?: string,
familyName?: string,
givenName?: string,
middleName?: string,
honorifixPrefix?: string,
honorifixSuffix?: string): ContactName
};
/**
* The ContactField object is a reusable component that represents contact fields generically.
* Each ContactField object contains a value, type, and pref property. A Contact object stores
* several properties in ContactField[] arrays, such as phone numbers and email addresses.
*
* In most instances, there are no pre-determined values for a ContactField object's type attribute.
* For example, a phone number can specify type values of home, work, mobile, iPhone,
* or any other value that is supported by a particular device platform's contact database.
* However, for the Contact photos field, the type field indicates the format of the returned image:
* url when the value attribute contains a URL to the photo image, or base64 when the value
* contains a base64-encoded image string.
*/
interface ContactField {
/** Set to true if this ContactField contains the user's preferred value. */
pref: boolean;
/** A string that indicates what type of field this is, home for example. */
type: string;
/** The value of the field, such as a phone number or email address. */
value: string;
}
declare var ContactField: {
/** Constructor for ContactField object */
new(type?: string,
pref?: boolean,
value?: string): ContactField
};
/**
* The ContactAddress object stores the properties of a single address of a contact.
* A Contact object may include more than one address in a ContactAddress[] array.
*/
interface ContactAddress {
/** Set to true if this ContactAddress contains the user's preferred value. */
pref?: boolean;
/** A string indicating what type of field this is, home for example. */
type?: string;
/** The full address formatted for display. */
formatted?: string;
/** The full street address. */
streetAddress?: string;
/** The city or locality. */
locality?: string;
/** The state or region. */
region?: string;
/** The zip code or postal code. */
postalCode?: string;
/** The country name. */
country?: string;
}
declare var ContactAddress: {
/** Constructor of ContactAddress object */
new(pref?: boolean,
type?: string,
formatted?: string,
streetAddress?: string,
locality?: string,
region?: string,
postalCode?: string,
country?: string): ContactAddress
};
/**
* The ContactOrganization object stores a contact's organization properties. A Contact object stores
* one or more ContactOrganization objects in an array.
*/
interface ContactOrganization {
/** Set to true if this ContactOrganization contains the user's preferred value. */
pref?: boolean;
/** A string that indicates what type of field this is, home for example. */
type?: string;
/** The name of the organization. */
name?: string;
/** The department the contract works for. */
department?: string;
/** The contact's title at the organization. */
title?: string;
}
declare var ContactOrganization: {
/** Constructor for ContactOrganization object */
new(pref?: boolean,
type?: string,
name?: string,
department?: string,
title?: string): ContactOrganization
};
/** Search options to filter navigator.contacts. */
interface ContactFindOptions {
/** The search string used to find navigator.contacts. */
filter?: string;
/** Determines if the find operation returns multiple navigator.contacts. */
multiple?: boolean;
}
declare var ContactFindOptions: {
/** Constructor for ContactFindOptions object */
new(filter?: string,
multiple?: boolean): ContactFindOptions
};

31
cordova/plugins/Device.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
// Type definitions for Apache Cordova Device plugin.
// Project: https://github.com/apache/cordova-plugin-device
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
/**
* This plugin defines a global device object, which describes the device's hardware and software.
* Although the object is in the global scope, it is not available until after the deviceready event.
*/
interface Device {
/** Get the version of Cordova running on the device. */
cordova: string;
/**
* The device.model returns the name of the device's model or product. The value is set
* by the device manufacturer and may be different across versions of the same product.
*/
model: string;
/** device.name is deprecated as of version 2.3.0. Use device.model instead. */
name: string;
/** Get the device's operating system name. */
platform: string;
/** Get the device's Universally Unique Identifier (UUID). */
uuid: string;
/** Get the operating system version. */
version: string;
}
declare var device: Device;

77
cordova/plugins/DeviceMotion.d.ts vendored Normal file
View File

@@ -0,0 +1,77 @@
// Type definitions for Apache Cordova Device Motion plugin.
// Project: https://github.com/apache/cordova-plugin-device-motion
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/**
* This plugin provides access to the device's accelerometer. The accelerometer is a motion sensor
* that detects the change (delta) in movement relative to the current device orientation,
* in three dimensions along the x, y, and z axis.
*/
accelerometer: Accelerometer;
}
/**
* This plugin provides access to the device's accelerometer. The accelerometer is a motion sensor
* that detects the change (delta) in movement relative to the current device orientation,
* in three dimensions along the x, y, and z axis.
*/
interface Accelerometer {
/**
* Stop watching the Acceleration referenced by the watchID parameter.
* @param watchID The ID returned by navigator.accelerometer.watchAcceleration.
*/
clearWatch(watchID: WatchHandle): void;
/**
* Get the current acceleration along the x, y, and z axes.
* These acceleration values are returned to the accelerometerSuccess callback function.
* @param accelerometerSuccess Success callback that gets the Acceleration object.
* @param accelerometerError Success callback
*/
getCurrentAcceleration(
accelerometerSuccess: (acceleration: Acceleration) => void,
accelerometerError: () => void): void;
/**
* Retrieves the device's current Acceleration at a regular interval, executing the
* accelerometerSuccess callback function each time. Specify the interval in milliseconds
* via the acceleratorOptions object's frequency parameter.
* The returned watch ID references the accelerometer's watch interval, and can be used
* with navigator.accelerometer.clearWatch to stop watching the accelerometer.
* @param accelerometerSuccess Callback, that called at every time interval and passes an Acceleration object.
* @param accelerometerError Error callback.
* @param accelerometerOptions Object with options for watchAcceleration
*/
watchAcceleration(
accelerometerSuccess: (acceleration: Acceleration) => void,
accelerometerError: () => void,
accelerometerOptions?: AccelerometerOptions): WatchHandle;
}
/**
* Contains Accelerometer data captured at a specific point in time. Acceleration values include
* the effect of gravity (9.81 m/s^2), so that when a device lies flat and facing up, x, y, and z
* values returned should be 0, 0, and 9.81.
*/
interface Acceleration {
/** Amount of acceleration on the x-axis. (in m/s^2) */
x: number;
/** Amount of acceleration on the y-axis. (in m/s^2) */
y: number;
/** Amount of acceleration on the z-axis. (in m/s^2) */
z: number;
/** Creation timestamp in milliseconds. */
timestamp: number;
}
/** Object with options for watchAcceleration */
interface AccelerometerOptions {
/** How often to retrieve the Acceleration in milliseconds. (Default: 10000) */
frequency?: number;
}
/** Abstract type for watch IDs used by Accelerometer. Values of these type are actually `number` at runtime.*/
interface WatchHandle { }

86
cordova/plugins/DeviceOrientation.d.ts vendored Normal file
View File

@@ -0,0 +1,86 @@
// Type definitions for Apache Cordova Device Orientation plugin.
// Project: https://github.com/apache/cordova-plugin-device-orientation
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/**
* This plugin provides access to the device's compass. The compass is a sensor that detects
* the direction or heading that the device is pointed, typically from the top of the device.
* It measures the heading in degrees from 0 to 359.99, where 0 is north.
*/
compass: Compass;
}
/**
* This plugin provides access to the device's compass. The compass is a sensor that detects
* the direction or heading that the device is pointed, typically from the top of the device.
* It measures the heading in degrees from 0 to 359.99, where 0 is north.
*/
interface Compass {
/**
* Get the current compass heading. The compass heading is returned via a CompassHeading
* object using the onSuccess callback function.
* @param onSuccess Success callback that passes CompassHeading object.
* @param onError Error callback that passes CompassError object.
*/
getCurrentHeading(
onSuccess: (heading: CompassHeading) => void,
onError: (error: CompassError) => void,
options?: CompassOptions): void;
/**
* Gets the device's current heading at a regular interval. Each time the heading is retrieved,
* the headingSuccess callback function is executed. The returned watch ID references the compass
* watch interval. The watch ID can be used with navigator.compass.clearWatch to stop watching
* the navigator.compass.
* @param onSuccess Success callback that passes CompassHeading object.
* @param onError Error callback that passes CompassError object.
* @param options CompassOptions object
*/
watchHeading(
onSuccess: (heading: CompassHeading) => void,
onError: (error: CompassError) => void,
options?: CompassOptions): number;
/**
* Stop watching the compass referenced by the watch ID parameter.
* @param id The ID returned by navigator.compass.watchHeading.
*/
clearWatch(id: number): void;
}
/** A CompassHeading object is returned to the compassSuccess callback function. */
interface CompassHeading {
/** The heading in degrees from 0-359.99 at a single moment in time. */
magneticHeading: number;
/** The heading relative to the geographic North Pole in degrees 0-359.99 at a single moment in time. A negative value indicates that the true heading can't be determined. */
trueHeading: number;
/** The deviation in degrees between the reported heading and the true heading. */
headingAccuracy: number;
/** The time at which this heading was determined. */
timestamp: number;
}
interface CompassOptions {
filter?: number;
frequency?: number;
}
/** A CompassError object is returned to the onError callback function when an error occurs. */
interface CompassError {
/**
* One of the predefined error codes
* CompassError.COMPASS_INTERNAL_ERR
* CompassError.COMPASS_NOT_SUPPORTED
*/
code: number;
}
declare var CompassError: {
/** Constructor for CompassError object */
new(code: number): CompassError;
COMPASS_INTERNAL_ERR: number;
COMPASS_NOT_SUPPORTED: number
}

66
cordova/plugins/Dialogs.d.ts vendored Normal file
View File

@@ -0,0 +1,66 @@
// Type definitions for Apache Cordova Dialogs plugin.
// Project: https://github.com/apache/cordova-plugin-dialogs
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** This plugin provides access to some native dialog UI elements. */
notification: Notification
}
/** This plugin provides access to some native dialog UI elements. */
interface Notification {
/**
* Shows a custom alert or dialog box. Most Cordova implementations use a native dialog box for this feature,
* but some platforms use the browser's alert function, which is typically less customizable.
* @param message Dialog message.
* @param alertCallback Callback to invoke when alert dialog is dismissed.
* @param title Dialog title, defaults to 'Alert'.
* @param buttonName Button name, defaults to OK.
*/
alert(message: string,
alertCallback: () => void,
title?: string,
buttonName?: string): void;
/**
* The device plays a beep sound.
* @param times The number of times to repeat the beep.
*/
beep(times: number): void;
/**
* Displays a customizable confirmation dialog box.
* @param message Dialog message.
* @param confirmCallback Callback to invoke with index of button pressed (1, 2, or 3)
* or when the dialog is dismissed without a button press (0).
* @param title Dialog title, defaults to Confirm.
* @param buttonLabels Array of strings specifying button labels, defaults to [OK,Cancel].
*/
confirm(message: string,
confirmCallback: (choice: number) => void,
title?: string,
buttonLabels?: string[]): void;
/**
* Displays a native dialog box that is more customizable than the browser's prompt function.
* @param message Dialog message.
* @param promptCallback Callback to invoke when a button is pressed.
* @param title Dialog title, defaults to "Prompt".
* @param buttonLabels Array of strings specifying button labels, defaults to ["OK","Cancel"].
* @param defaultText Default textbox input value, default: "".
*/
prompt(message: string,
promptCallback: (result: NotificationPromptResult) => void,
title?: string,
buttonLabels?: string[],
defaultText?: string): void;
}
/** Object, passed to promptCallback */
interface NotificationPromptResult {
/** The index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc. */
buttonIndex: number;
/** The text entered in the prompt dialog box. */
input1: string;
}

294
cordova/plugins/FileSystem.d.ts vendored Normal file
View File

@@ -0,0 +1,294 @@
// Type definitions for Apache Cordova File System plugin.
// Project: https://github.com/apache/cordova-plugin-file
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
/**
* Requests a filesystem in which to store application data.
* @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT.
* @param size This is an indicator of how much storage space, in bytes, the application expects to need.
* @param successCallback The callback that is called when the user agent provides a filesystem.
* @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied.
*/
requestFileSystem(
type: number,
size: number,
successCallback: (fileSystem: FileSystem) => void,
errorCallback?: (fileError: Error) => void): void;
TEMPORARY: number;
PERSISTENT: number;
}
/** This interface represents a file system. */
interface FileSystem {
/**
* Constructor for FileSystem object
* @param name This is the name of the file system. The specifics of naming filesystems
* is unspecified, but a name must be unique across the list of exposed file systems.
* @param root The root directory of the file system.
*/
new (name: string, root: DirectoryEntry)
/**
* This is the name of the file system. The specifics of naming filesystems
* is unspecified, but a name must be unique across the list of exposed file systems.
*/
name: string;
/** The root directory of the file system. */
root: DirectoryEntry;
}
/**
* An abstract interface representing entries in a file system,
* each of which may be a File or DirectoryEntry.
*/
interface Entry {
/** Constructor for Entry object */
new ( isFile: boolean, isDirectory: boolean, name: string, fullPath: string, fileSystem: FileSystem, nativeURL: string) ;
/** Entry is a file. */
isFile: boolean;
/** Entry is a directory. */
isDirectory: boolean;
/** The name of the entry, excluding the path leading to it. */
name: string;
/** The full absolute path from the root to the entry. */
fullPath: string;
/** The file system on which the entry resides. */
fileSystem: FileSystem;
nativeURL: string;
/**
* Look up metadata about this entry.
* @param successCallback A callback that is called with the time of the last modification.
* @param errorCallback A callback that is called when errors happen.
*/
getMetadata(
successCallback: (metadata: Metadata) => void,
errorCallback?: (error: Error) => void): void;
/**
* Move an entry to a different location on the file system. It is an error to try to:
* move a directory inside itself or to any child at any depth;move an entry into its parent if a name different from its current one isn't provided;
* move a file to a path occupied by a directory;
* move a directory to a path occupied by a file;
* move any element to a path occupied by a directory which is not empty.
* A move of a file on top of an existing file must attempt to delete and replace that file.
* A move of a directory on top of an existing empty directory must attempt to delete and replace that directory.
* @param parent The directory to which to move the entry.
* @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
* @param successCallback A callback that is called with the Entry for the new location.
* @param errorCallback A callback that is called when errors happen.
*/
moveTo(parent: DirectoryEntry,
newName?: string,
successCallback?: (entry: Entry) => void ,
errorCallback?: (error: Error) => void ): void;
/**
* Copy an entry to a different location on the file system. It is an error to try to:
* copy a directory inside itself or to any child at any depth;
* copy an entry into its parent if a name different from its current one isn't provided;
* copy a file to a path occupied by a directory;
* copy a directory to a path occupied by a file;
* copy any element to a path occupied by a directory which is not empty.
* A copy of a file on top of an existing file must attempt to delete and replace that file.
* A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory.
* Directory copies are always recursive--that is, they copy all contents of the directory.
* @param parent The directory to which to move the entry.
* @param newName The new name of the entry. Defaults to the Entry's current name if unspecified.
* @param successCallback A callback that is called with the Entry for the new object.
* @param errorCallback A callback that is called when errors happen.
*/
copyTo(parent: DirectoryEntry,
newName?: string,
successCallback?: (entry: Entry) => void ,
errorCallback?: (error: Error) => void ): void;
toURL(): string;
/**
* Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem.
* @param successCallback A callback that is called on success.
* @param errorCallback A callback that is called when errors happen.
*/
remove(successCallback: () => void ,
errorCallback?: (error: Error) => void ): void;
/**
* Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself.
* @param successCallback A callback that is called with the time of the last modification.
* @param errorCallback A callback that is called when errors happen.
*/
getParent(successCallback: (entry: Entry) => void ,
errorCallback?: (error: Error) => void ): void;
}
/** This interface supplies information about the state of a file or directory. */
interface Metadata {
/** This is the time at which the file or directory was last modified. */
modificationTime: Date;
/** The size of the file, in bytes. This must return 0 for directories. */
size: number;
}
/** This interface represents a directory on a file system. */
interface DirectoryEntry extends Entry {
/**
* Creates a new DirectoryReader to read Entries from this Directory.
*/
createReader(): DirectoryReader;
/**
* Creates or looks up a file.
* @param path Either an absolute path or a relative path from this DirectoryEntry
* to the file to be looked up or created.
* It is an error to attempt to create a file whose immediate parent does not yet exist.
* @param options If create and exclusive are both true, and the path already exists, getFile must fail.
* If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry.
* If create is not true and the path doesn't exist, getFile must fail.
* If create is not true and the path exists, but is a directory, getFile must fail.
* Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path.
* @param successCallback A callback that is called to return the File selected or created.
* @param errorCallback A callback that is called when errors happen.
*/
getFile(path: string, options?: Flags,
successCallback?: (entry: FileEntry) => void,
errorCallback?: (error: Error) => void): void;
/**
* Creates or looks up a directory.
* @param path Either an absolute path or a relative path from this DirectoryEntry
* to the directory to be looked up or created.
* It is an error to attempt to create a directory whose immediate parent does not yet exist.
* @param options If create and exclusive are both true and the path already exists, getDirectory must fail.
* If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
* If create is not true and the path doesn't exist, getDirectory must fail.
* If create is not true and the path exists, but is a file, getDirectory must fail.
* Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
* @param successCallback A callback that is called to return the Directory selected or created.
* @param errorCallback A callback that is called when errors happen.
*/
getDirectory(path: string, options?: Flags,
successCallback?: (entry: DirectoryEntry) => void,
errorCallback?: (error: Error) => void): void;
/**
* Deletes a directory and all of its contents, if any. In the event of an error (e.g. trying
* to delete a directory that contains a file that cannot be removed), some of the contents
* of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
* @param successCallback A callback that is called on success.
* @param errorCallback A callback that is called when errors happen.
*/
removeRecursively(successCallback: () => void,
errorCallback?: (error: Error) => void): void;
}
/**
* This dictionary is used to supply arguments to methods
* that look up or create files or directories.
*/
interface Flags {
/** Used to indicate that the user wants to create a file or directory if it was not previously there. */
create?: boolean;
/** By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. */
exclusive?: boolean;
}
/**
* This interface lets a user list files and directories in a directory. If there are
* no additions to or deletions from a directory between the first and last call to
* readEntries, and no errors occur, then:
* A series of calls to readEntries must return each entry in the directory exactly once.
* Once all entries have been returned, the next call to readEntries must produce an empty array.
* If not all entries have been returned, the array produced by readEntries must not be empty.
* The entries produced by readEntries must not include the directory itself ["."] or its parent [".."].
*/
interface DirectoryReader {
/**
* Read the next block of entries from this directory.
* @param successCallback Called once per successful call to readEntries to deliver the next
* previously-unreported set of Entries in the associated Directory.
* If all Entries have already been returned from previous invocations
* of readEntries, successCallback must be called with a zero-length array as an argument.
* @param errorCallback A callback indicating that there was an error reading from the Directory.
*/
readEntries(successCallback: (entries: Entry[]) => void, errorCallback?: (error: Error) => void): void;
}
/** This interface represents a file on a file system. */
interface FileEntry extends Entry {
/**
* Creates a new FileWriter associated with the file that this FileEntry represents.
* @param successCallback A callback that is called with the new FileWriter.
* @param errorCallback A callback that is called when errors happen.
*/
createWriter(successCallback: (
writer: FileWriter) => void,
errorCallback?: (error: Error) => void): void;
/**
* Returns a File that represents the current state of the file that this FileEntry represents.
* @param successCallback A callback that is called with the File.
* @param errorCallback A callback that is called when errors happen.
*/
file(successCallback: (file: File) => void,
errorCallback?: (error: Error) => void): void;
}
/**
* This interface provides methods to monitor the asynchronous writing of blobs
* to disk using progress events and event handler attributes.
*/
interface FileSaver extends EventTarget {
/** Terminate file operation */
abort(): void;
/**
* The FileSaver object can be in one of 3 states. The readyState attribute, on getting,
* must return the current state, which must be one of the following values:
* INIT
* WRITING
* DONE
*/
readyState: number;
/** Handler for writestart events. */
onwritestart: (event: ProgressEvent) => void;
/** Handler for progress events. */
onprogress: (event: ProgressEvent) => void;
/** Handler for write events. */
onwrite: (event: ProgressEvent) => void;
/** Handler for abort events. */
onabort: (event: ProgressEvent) => void;
/** Handler for error events. */
onerror: (event: ProgressEvent) => void;
/** Handler for writeend events. */
onwriteend: (event: ProgressEvent) => void;
/** The last error that occurred on the FileSaver. */
error: Error;
}
/**
* This interface expands on the FileSaver interface to allow for multiple write
* actions, rather than just saving a single Blob.
*/
interface FileWriter extends FileSaver {
/**
* The byte offset at which the next write to the file will occur. This must be no greater than length.
* A newly-created FileWriter must have position set to 0.
*/
position: number;
/**
* The length of the file. If the user does not have read access to the file,
* this must be the highest byte offset at which the user has written.
*/
length: number;
/**
* Write the supplied data to the file at position.
* @param {Blob} data The blob to write.
*/
write(data: Blob): void;
/**
* The file position at which the next write will occur.
* @param offset If nonnegative, an absolute byte offset into the file.
* If negative, an offset back from the end of the file.
*/
seek(offset: number): void;
/**
* Changes the length of the file to that specified. If shortening the file, data beyond the new length
* must be discarded. If extending the file, the existing data must be zero-padded up to the new length.
* @param size The size to which the length of the file is to be adjusted, measured in bytes.
*/
truncate(size: number): void;
}

129
cordova/plugins/FileTransfer.d.ts vendored Normal file
View File

@@ -0,0 +1,129 @@
// Type definitions for Apache Cordova FileTransfer plugin.
// Project: https://github.com/apache/cordova-plugin-file-transfer
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
/// <reference path="FileSystem.d.ts"/>
/**
* The FileTransfer object provides a way to upload files using an HTTP multi-part POST request,
* and to download files as well.
*/
interface FileTransfer {
/** Called with a ProgressEvent whenever a new chunk of data is transferred. */
onprogress: Function;
/**
* Sends a file to a server.
* @param fileURL Filesystem URL representing the file on the device. For backwards compatibility,
* this can also be the full path of the file on the device.
* @param server URL of the server to receive the file, as encoded by encodeURI().
* @param successCallback A callback that is passed a FileUploadResult object.
* @param errorCallback A callback that executes if an error occurs retrieving the FileUploadResult.
* Invoked with a FileTransferError object.
* @param options Optional parameters.
* @param trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates.
* This is useful since Android rejects self-signed security certificates.
* Not recommended for production use. Supported on Android and iOS.
*/
upload(
fileURL: string,
server: string,
successCallback: (result: FileUploadResult) => void,
errorCallback: (error: FileTransferError) => void,
options?: FileUploadOptions,
trustAllHosts?: boolean): void;
/**
* downloads a file from server.
* @param source URL of the server to download the file, as encoded by encodeURI().
* @param target Filesystem url representing the file on the device. For backwards compatibility,
* this can also be the full path of the file on the device.
* @param successCallback A callback that is passed a FileEntry object. (Function)
* @param errorCallback A callback that executes if an error occurs when retrieving the fileEntry.
* Invoked with a FileTransferError object.
* @param options Optional parameters.
* @param trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates.
* This is useful since Android rejects self-signed security certificates.
* Not recommended for production use. Supported on Android and iOS.
*/
download(
source: string,
target: string,
successCallback: (fileEntry: FileEntry) => void,
errorCallback: (error: FileTransferError) => void,
options?: FileDownloadOptions,
trustAllHosts?: boolean): void;
/**
* Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object
* which has an error code of FileTransferError.ABORT_ERR.
*/
abort(): void;
}
declare var FileTransfer: {
new (): FileTransfer;
};
/** A FileUploadResult object is passed to the success callback of the FileTransfer object's upload() method. */
interface FileUploadResult {
/** The number of bytes sent to the server as part of the upload. */
bytesSent: number;
/** The HTTP response code returned by the server. */
responseCode: number;
/** The HTTP response returned by the server. */
response: string;
/** The HTTP response headers by the server. Currently supported on iOS only.*/
headers: any;
}
/** Optional parameters for upload method. */
interface FileUploadOptions {
/** The name of the form element. Defaults to file. */
fileKey?: string;
/** The file name to use when saving the file on the server. Defaults to image.jpg. */
fileName?: string;
/** The mime type of the data to upload. Defaults to image/jpeg. */
mimeType?: string;
/** A set of optional key/value pairs to pass in the HTTP request. */
params?: Object;
/** Whether to upload the data in chunked streaming mode. Defaults to true. */
chunkedMode?: boolean;
/** A map of header name/header values. Use an array to specify more than one value. */
headers?: Object[];
}
/** Optional parameters for download method. */
interface FileDownloadOptions {
/** A map of header name/header values. Use an array to specify more than one value. */
headers?: Object[];
}
/** A FileTransferError object is passed to an error callback when an error occurs. */
interface FileTransferError {
/**
* One of the predefined error codes listed below.
* FileTransferError.FILE_NOT_FOUND_ERR
* FileTransferError.INVALID_URL_ERR
* FileTransferError.CONNECTION_ERR
* FileTransferError.ABORT_ERR
*/
code: number;
/** URL to the source. */
source: string;
/** URL to the target. */
target: string;
/** HTTP status code. This attribute is only available when a response code is received from the HTTP connection. */
http_status: number;
body: any;
}
declare var FileTransferError: {
/** Constructor for FileTransferError object */
new (code?: number, source?: string, target?: string, status?: number, body?: any): FileTransferError;
FILE_NOT_FOUND_ERR: number;
INVALID_URL_ERR: number;
CONNECTION_ERR: number;
ABORT_ERR: number;
}

255
cordova/plugins/Globalization.d.ts vendored Normal file
View File

@@ -0,0 +1,255 @@
// Type definitions for Apache Cordova Globalization plugin.
// Project: https://github.com/apache/cordova-plugin-globalization
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** This plugin obtains information and performs operations specific to the user's locale and timezone. */
globalization: Globalization
}
/** This plugin obtains information and performs operations specific to the user's locale and timezone. */
interface Globalization {
/**
* Get the string identifier for the client's current language.
* @param onSuccess Called on success getting the language with a properties object,
* that should have a value property with a String value.
* @param onError Called on error getting the language with a GlobalizationError object.
* The error's expected code is GlobalizationError.UNKNOWN_ERROR.
*/
getPreferredLanguage(
onSuccess: (language: { value: string; }) => void,
onError: (error: GlobalizationError) => void): void;
/**
* Get the string identifier for the client's current locale setting.
* @param onSuccess Called on success getting the locale identifier with a properties object,
* that should have a value property with a String value.
* @param onError Called on error getting the locale identifier with a GlobalizationError object.
* The error's expected code is GlobalizationError.UNKNOWN\_ERROR.
*/
getLocaleName(
onSuccess: (locale: { value: string; }) => void,
onError: (error: GlobalizationError) => void): void;
/**
* Returns a date formatted as a string according to the client's locale and timezone.
* @param date Date to format.
* @param onSuccess Called on success with a properties object,
* that should have a value property with a String value.
* @param onError Called on error with a GlobalizationError object.
* The error's expected code is GlobalizationError.FORMATTING_ERROR.
* @param options Optional format parameters. Default {formatLength:'short', selector:'date and time'}
*/
dateToString(
date: Date,
onSuccess: (date: { value: string; }) => void,
onError: (error: GlobalizationError) => void,
options?: { type?: string; item?: string; }): void;
/**
* Parses a date formatted as a string, according to the client's user preferences
* and calendar using the time zone of the client, and returns the corresponding date object.
* @param dateString String to parse
* @param onSuccess Called on success with GlobalizationDate object
* @param onError Called on error getting the language with a GlobalizationError object.
* The error's expected code is GlobalizationError.PARSING_ERROR.
* @param options Optional parse parameters. Default {formatLength:'short', selector:'date and time'}
*/
stringToDate(
dateString: string,
onSuccess: (date: GlobalizationDate) => void,
onError: (error: GlobalizationError) => void,
options?: { type?: string; item?: string; }): void;
/**
* Returns a pattern string to format and parse dates according to the client's user preferences.
* @param onSuccess Called on success getting pattern with a GlobalizationDatePattern object
* @param onError Called on error getting pattern with a GlobalizationError object.
* The error's expected code is GlobalizationError.PATTERN_ERROR.
* @param options Optional format parameters. Default {formatLength:'short', selector:'date and time'}
*/
getDatePattern(
onSuccess: (datePattern: GlobalizationDatePattern) => void,
onError: (error: GlobalizationError) => void,
options?: { type?: string; item?: string; }): void;
/**
* Returns an array of the names of the months or days of the week, depending on the client's user preferences and calendar.
* @param onSuccess Called on success getting names with a properties object,
* that should have a value property with a String[] value.
* @param onError Called on error getting the language with a GlobalizationError object.
* The error's expected code is GlobalizationError.UNKNOWN_ERROR.
* @param options Optional parameters. Default: {type:'wide', item:'months'}
*/
getDateNames(
onSuccess: (names: { value: string[]; }) => void,
onError: (error: GlobalizationError) => void,
options?: { type?: string; item?: string; }): void;
/**
* Indicates whether daylight savings time is in effect for a given date using the client's time zone and calendar.
* @param {Date} date Date to check
* @param onSuccess Called on success with a properties object,
* that should have a dst property with a boolean value.
* @param onError Called on error with a GlobalizationError object.
* The error's expected code is GlobalizationError.UNKNOWN_ERROR.
*/
isDaylightSavingsTime(
date: Date,
onSuccess: (result: { dst: boolean; }) => void,
onError: (error: GlobalizationError) => void): void;
/**
* Returns the first day of the week according to the client's user preferences and calendar.
* @param onSuccess Called on success with a day object,
* that should have a value property with a number value.
* @param onError Called on error with a GlobalizationError object.
* The error's expected code is GlobalizationError.UNKNOWN_ERROR.
*/
getFirstDayOfWeek(
onSuccess: (day: { value: number; }) => void,
onError: (error: GlobalizationError) => void): void;
/**
* Returns a number formatted as a string according to the client's user preferences.
* @param value Number to format
* @param onSuccess Called on success with a result object,
* that should have a value property with a String value.
* @param onError Called on error with a GlobalizationError object.
* The error's expected code is GlobalizationError.FORMATTING_ERROR.
* @param format Optional format parameters. Default: {type:'decimal'}
*/
nubmerToString(
value: number,
onSuccess: (result: { value: string; }) => void,
onError: (error: GlobalizationError) => void,
format?: { type?: string; }): void;
/**
* Parses a number formatted as a string according to the client's user preferences and returns the corresponding number.
* @param value String to parse
* @param onSuccess Called on success with a result object,
* that should have a value property with a number value.
* @param onError Called on error with a GlobalizationError object.
* The error's expected code is GlobalizationError.FORMATTING_ERROR.
* @param format Optional format parameters. Default: {type:'decimal'}
*/
stringToNumber(
value: string,
onSuccess: (result: { value: number; }) => void,
onError: (error: GlobalizationError) => void,
format?: { type?: string; }): void;
/**
* Returns a pattern string to format and parse numbers according to the client's user preferences.
* @param onSuccess Called on success getting pattern with a GlobalizationNumberPattern object
* @param onError Called on error getting the language with a GlobalizationError object.
* The error's expected code is GlobalizationError.PATTERN_ERROR.
* @param options Optional format parameters. Default {type:'decimal'}.
*/
getNumberPattern(
onSuccess: (result: GlobalizationNumberPattern) => void,
onError: (error: GlobalizationError) => void,
format?: { type?: string; }): void;
/**
* Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code.
* @param currencyCode Should be a String of one of the ISO 4217 currency codes, for example 'USD'.
* @param onSuccess Called on success getting pattern with a GlobalizatioCurrencyPattern object
* @param onError Called on error getting pattern with a GlobalizationError object.
* The error's expected code is GlobalizationError.FORMATTING_ERROR.
* @param options Optional format parameters. Default {type:'decimal'}.
*/
getCurrencyPattern(
currencyCode: string,
onSuccess: (result: GlobalizationCurrencyPattern) => void,
onError: (error: GlobalizationError) => void): void;
}
/** Date returned by stringToDate */
interface GlobalizationDate {
/* The four digit year. */
year: number;
/* The month from (0-11). */
month: number;
/* The day from (1-31). */
day: number;
/* The hour from (0-23). */
hour: number;
/* The minute from (0-59). */
minute: number;
/* The second from (0-59). */
second: number;
/* The milliseconds (from 0-999), not available on all platforms. */
millisecond: number;
}
/** Pattern to format and parse dates according to the client's user preferences.*/
interface GlobalizationDatePattern {
/* The date and time pattern to format and parse dates. The patterns follow Unicode Technical Standard #35. */
pattern: string;
/* The abbreviated name of the time zone on the client. */
timezone: string;
/* The current difference in seconds between the client's time zone and coordinated universal time. */
utc_offset: number;
/* The current daylight saving time offset in seconds between the client's non-daylight saving's time zone and the client's daylight saving's time zone. */
dst_offset: number;
}
interface GlobalizationDateNameOptions {
type?: string;
item?: string;
}
/** Pattern to format and parse numbers according to the client's user preferences. */
interface GlobalizationNumberPattern {
/* The number pattern to format and parse numbers. The patterns follow Unicode Technical Standard #35. */
pattern: string;
/* The symbol to use when formatting and parsing, such as a percent or currency symbol. */
symbol: string;
/* The number of fractional digits to use when parsing and formatting numbers. */
fraction: number;
/* The rounding increment to use when parsing and formatting. */
rounding: number;
/* The symbol to use for positive numbers when parsing and formatting. */
positive: string;
/* The symbol to use for negative numbers when parsing and formatting. */
negative: string;
/* The decimal symbol to use for parsing and formatting. */
decimal: string;
/* The grouping symbol to use for parsing and formatting. */
grouping: string;
}
/**
* Pattern to format and parse currency values according
* to the client's user preferences and ISO 4217 currency code.
*/
interface GlobalizationCurrencyPattern {
/** The currency pattern to format and parse currency values. The patterns follow Unicode Technical Standard #35. */
pattern: string;
/** The ISO 4217 currency code for the pattern. */
code: string;
/** The number of fractional digits to use when parsing and formatting currency. */
fraction: number;
/** The rounding increment to use when parsing and formatting. */
rounding: number;
/** The decimal symbol to use for parsing and formatting. */
decimal: string;
/** The grouping symbol to use for parsing and formatting. */
grouping: string;
}
/** An object representing a error from the Globalization API. */
interface GlobalizationError {
/** One of the following codes representing the error type:
* GlobalizationError.UNKNOWN_ERROR: 0
* GlobalizationError.FORMATTING_ERROR: 1
* GlobalizationError.PARSING_ERROR: 2
* GlobalizationError.PATTERN_ERROR: 3
*/
code: number;
/** A text message that includes the error's explanation and/or details */
message: string;
}
/** An object representing a error from the Globalization API. */
declare var GlobalizationError: {
UNKNOWN_ERROR: number;
FORMATTING_ERROR: number;
PARSING_ERROR: number;
PATTERN_ERROR: number;
}

219
cordova/plugins/InAppBrowser.d.ts vendored Normal file
View File

@@ -0,0 +1,219 @@
// Type definitions for Apache Cordova InAppBrowser plugin.
// Project: https://github.com/apache/cordova-plugin-inappbrowser
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_self", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_blank", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_system", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser;
}
/**
* The object returned from a call to window.open.
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
onloadstart: (type: InAppBrowserEvent) => void;
onloadstop: (type: InAppBrowserEvent) => void;
onloaderror: (type: InAppBrowserEvent) => void;
onexit: (type: InAppBrowserEvent) => void;
// addEventListener overloads
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: string, callback: (event: InAppBrowserEvent) => void): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: string, callback: (event: InAppBrowserEvent) => void): void;
/** Closes the InAppBrowser window. */
close(): void;
/**
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
* if the InAppBrowser was already visible.
*/
show(): void;
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { code: string }, callback: (result: any) => void): void;
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { file: string }, callback: (result: any) => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { code: string }, callback: () => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { file: string }, callback: () => void): void;
}
interface InAppBrowserEvent extends Event {
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
type: string;
/** the URL that was loaded. */
url: string;
/** the error code, only in the case of loaderror. */
code: number;
/** the error message, only in the case of loaderror. */
message: string;
}

86
cordova/plugins/Media.d.ts vendored Normal file
View File

@@ -0,0 +1,86 @@
// Type definitions for Apache Cordova Media plugin.
// Project: https://github.com/apache/cordova-plugin-media
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
declare var Media: {
new (
src: string,
mediaSuccess: () => void,
mediaError?: (error: MediaError) => any,
mediaStatus?: (status: number) => void): Media;
//Media statuses
MEDIA_NONE: number;
MEDIA_STARTING: number;
MEDIA_RUNNING: number;
MEDIA_PAUSED: number;
MEDIA_STOPPED: number
};
/**
* This plugin provides the ability to record and play back audio files on a device.
* NOTE: The current implementation does not adhere to a W3C specification for media capture,
* and is provided for convenience only. A future implementation will adhere to the latest
* W3C specification and may deprecate the current APIs.
*/
interface Media {
/**
* Constructor for Media object.
* @param src A URI containing the audio content.
* @param mediaSuccess The callback that executes after a Media object has completed
* the current play, record, or stop action.
* @param mediaError The callback that executes if an error occurs.
* @param mediaStatus The callback that executes to indicate status changes.
*/
new (
src: string,
mediaSuccess: () => void,
mediaError?: (error: MediaError) => any,
mediaStatus?: (status: number) => void): Media;
/**
* Returns the current position within an audio file. Also updates the Media object's position parameter.
* @param mediaSuccess The callback that is passed the current position in seconds.
* @param mediaError The callback to execute if an error occurs.
*/
getCurrentPosition(
mediaSuccess: (position: number) => void,
mediaError?: (error: MediaError) => void): void;
/** Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1. */
getDuration(): number;
/** Starts or resumes playing an audio file. */
play(): void;
/** Pauses playing an audio file. */
pause(): void;
/**
* Releases the underlying operating system's audio resources. This is particularly important
* for Android, since there are a finite amount of OpenCore instances for media playback.
* Applications should call the release function for any Media resource that is no longer needed.
*/
release(): void;
/**
* Sets the current position within an audio file.
* @param position Position in milliseconds.
*/
seekTo(position: number): void;
/**
* Set the volume for an audio file.
* @param volume The volume to set for playback. The value must be within the range of 0.0 to 1.0.
*/
setVolume(volume: number): void;
/** Starts recording an audio file. */
startRecord(): void;
/** Stops recording an audio file. */
stopRecord(): void;
/** Stops playing an audio file. */
stop(): void;
/**
* The position within the audio playback, in seconds.
* Not automatically updated during play; call getCurrentPosition to update.
*/
position: number;
/** The duration of the media, in seconds. */
duration: number;
}

167
cordova/plugins/MediaCapture.d.ts vendored Normal file
View File

@@ -0,0 +1,167 @@
// Type definitions for Apache Cordova MediaCapture plugin.
// Project: https://github.com/apache/cordova-plugin-media-capture
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
device: Device;
}
interface Device {
capture: Capture;
}
/** This plugin provides access to the device's audio, image, and video capture capabilities. */
interface Capture {
/**
* Start the audio recorder application and return information about captured audio clip files.
* @param onSuccess Executes when the capture operation finishes with an array
* of MediaFile objects describing each captured audio clip file.
* @param onError Executes, if the user terminates the operation before an audio clip is captured,
* with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code.
* @param options Encapsulates audio capture configuration options.
*/
captureAudio(
onSuccess: (mediaFiles: MediaFile[]) => void,
onError: (error: CaptureError) => void,
options?: AudioOptions): void ;
/**
* Start the camera application and return information about captured image files.
* @param onSuccess Executes when the capture operation finishes with an array
* of MediaFile objects describing each captured image clip file.
* @param onError Executes, if the user terminates the operation before an audio clip is captured,
* with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code.
* @param options Encapsulates audio capture configuration options.
*/
captureImage(
onSuccess: (mediaFiles: MediaFile[]) => void,
onError: (error: CaptureError) => void,
options?: ImageOptions): void ;
/**
* Start the video recorder application and return information about captured video clip files.
* @param onSuccess Executes when the capture operation finishes with an array
* of MediaFile objects describing each captured video clip file.
* @param onError Executes, if the user terminates the operation before an audio clip is captured,
* with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code.
* @param options Encapsulates audio capture configuration options.
*/
captureVideo(
onSuccess: (mediaFiles: MediaFile[]) => void,
onError: (error: CaptureError) => void,
options?: VideoOptions): void ;
/** The audio recording formats supported by the device. */
supportedAudioModes: ConfigurationData[];
/** The recording image sizes and formats supported by the device. */
supportedImageModes: ConfigurationData[];
/** The recording video resolutions and formats supported by the device. */
supportedVideoModes: ConfigurationData[];
}
/** Encapsulates properties of a media capture file. */
interface MediaFile {
/** The name of the file, without path information. */
name: string;
/** The full path of the file, including the name. */
fullPath: string;
/** The file's mime type */
type: string;
/** The date and time when the file was last modified. */
lastModifiedDate: Date;
/** The size of the file, in bytes. */
size: number;
/**
* Retrieves format information about the media capture file.
* @param successCallback Invoked with a MediaFileData object when successful.
* @param errorCallback Invoked if the attempt fails, this function.
*/
getFormatData(
successCallback: (data: MediaFileData) => void,
errorCallback?: () => void): void;
}
/** Encapsulates format information about a media file. */
interface MediaFileData {
/** The actual format of the audio and video content. */
codecs: string;
/** The average bitrate of the content. The value is zero for images. */
bitrate: number;
/** The height of the image or video in pixels. The value is zero for audio clips. */
height: number;
/** The width of the image or video in pixels. The value is zero for audio clips. */
width: number;
/** The length of the video or sound clip in seconds. The value is zero for images. */
duration: number;
}
/** Encapsulates the error code resulting from a failed media capture operation. */
interface CaptureError {
/**
* One of the pre-defined error codes listed below.
* CaptureError.CAPTURE_INTERNAL_ERR
* The camera or microphone failed to capture image or sound.
* CaptureError.CAPTURE_APPLICATION_BUSY
* The camera or audio capture application is currently serving another capture request.
* CaptureError.CAPTURE_INVALID_ARGUMENT
* Invalid use of the API (e.g., the value of limit is less than one).
* CaptureError.CAPTURE_NO_MEDIA_FILES
* The user exits the camera or audio capture application before capturing anything.
* CaptureError.CAPTURE_NOT_SUPPORTED
* The requested capture operation is not supported.
*/
code: number;
message: string;
}
declare var CaptureError: {
/** Constructor for CaptureError */
new (code: number, message: string): CaptureError;
CAPTURE_INTERNAL_ERR: number;
CAPTURE_APPLICATION_BUSY: number;
CAPTURE_INVALID_ARGUMENT: number;
CAPTURE_NO_MEDIA_FILES: number;
CAPTURE_NOT_SUPPORTED: number;
}
/** Encapsulates audio capture configuration options. */
interface AudioOptions {
/**
* The maximum number of audio clips the device's user can capture in a single
* capture operation. The value must be greater than or equal to 1.
*/
limit?: number;
/** The maximum duration of a audio clip, in seconds. */
duration?: number;
}
/** Encapsulates image capture configuration options. */
interface ImageOptions {
/**
* The maximum number of images the user can capture in a single capture operation.
* The value must be greater than or equal to 1 (defaults to 1).
*/
limit?: number;
}
/** Encapsulates video capture configuration options. */
interface VideoOptions {
/**
* The maximum number of video clips the device's user can capture in a single
* capture operation. The value must be greater than or equal to 1.
*/
limit?: number;
/** The maximum duration of a video clip, in seconds. */
duration?: number;
}
/** Encapsulates a set of media capture parameters that a device supports. */
interface ConfigurationData {
/** The ASCII-encoded lowercase string representing the media type. */
type: string;
/** The height of the image or video in pixels. The value is zero for sound clips. */
height: number;
/** The width of the image or video in pixels. The value is zero for sound clips. */
width: number;
}

60
cordova/plugins/NetworkInformation.d.ts vendored Normal file
View File

@@ -0,0 +1,60 @@
// Type definitions for Apache Cordova Network Information plugin.
// Project: https://github.com/apache/cordova-plugin-network-information
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection;
// see https://github.com/apache/cordova-plugin-network-information/blob/dev/doc/index.md#api-change
// for
network: {
/**
* This plugin provides an implementation of an old version of the Network Information API.
* It provides information about the device's cellular and wifi connection, and whether the device has an internet connection.
*/
connection: Connection
}
}
interface Document {
addEventListener(type: "online", connectionStateCallback: () => any, useCapture?: boolean): void;
addEventListener(type: "offline", connectionStateCallback: () => any, useCapture?: boolean): void;
}
/**
* The connection object, exposed via navigator.connection, provides information
* about the device's cellular and wifi connection.
*/
interface Connection {
/**
* This property offers a fast way to determine the device's network connection state, and type of connection.
* One of:
* Connection.UNKNOWN
* Connection.ETHERNET
* Connection.WIFI
* Connection.CELL_2G
* Connection.CELL_3G
* Connection.CELL_4G
* Connection.CELL
* Connection.NONE
*/
type: number
}
declare var Connection: {
UNKNOWN: number;
ETHERNET: number;
WIFI: number;
CELL_2G: number;
CELL_3G: number;
CELL_4G: number;
CELL: number;
NONE: number;
}

68
cordova/plugins/Push.d.ts vendored Normal file
View File

@@ -0,0 +1,68 @@
// Type definitions for Apache Cordova Push plugin.
// Project: https://github.com/phonegap-build/PushPlugin
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
plugins: {
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
pushNotification: PushNotification
}
}
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
interface PushNotification {
/**
* Registers as push notification receiver.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
* @param registrationOptions Options for registration process.
*/
register(
successCallback: (registrationId: string) => void,
errorCallback: (error: any) => void,
registrationOptions: RegistrationOptions): void;
/**
* Unregisters as push notification receiver.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
*/
unregister(
successCallback: (result: any) => void,
errorCallback: (error: any) => void): void;
/**
* Sets the badge count visible when the app is not running. iOS only.
* @param successCallback Called when a plugin method returns without error.
* @param errorCallback Called when the plugin returns an error.
* @param badgeCount An integer indicating what number should show up in the badge. Passing 0 will clear the badge.
*/
setApplicationIconBadgeNumber(
successCallback: (result: any) => void,
errorCallback: (error: any) => void,
badgeCount: number): void;
}
/** Options for registration process. */
interface RegistrationOptions {
/** This is the Google project ID you need to obtain by registering your application for GCM. Android only */
senderID?: string;
/** WP8 only */
channelName?: string;
/** Callback, that is fired when notification arrived */
ecb?: string;
badge?: boolean;
sound?: boolean;
alert?: boolean
}

17
cordova/plugins/Splashscreen.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for Apache Cordova Splashscreen plugin.
// Project: https://github.com/apache/cordova-plugin-splashscreen
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Navigator {
/** This plugin displays and hides a splash screen during application launch. */
splashscreen: {
/** Dismiss the splash screen. */
hide(): void;
/** Displays the splash screen. */
show(): void;
}
}

15
cordova/plugins/Vibration.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
// Type definitions for Apache Cordova Vibration plugin.
// Project: https://github.com/apache/cordova-plugin-vibration
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Notification {
/**
* Vibrates the device for the specified amount of time.
* @param time Milliseconds to vibrate the device. Ignored on iOS.
*/
vibrate(time: number): void
}

103
cordova/plugins/WebSQL.d.ts vendored Normal file
View File

@@ -0,0 +1,103 @@
// Type definitions for Apache Cordova WebSQL plugin.
// Project: https://github.com/sgrebnov/cordova-plugin-websql
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies, Inc.
// Licensed under the MIT license.
interface Window {
/**
* Creates (opens, if exist) database with supplied parameters.
* @param name Database name
* @param version Database version
* @param displayname Database display name
* @param size Size, in bytes
* @param creationCallback Callback, that executed on database creation. Accepts Database object.
*/
openDatabase(name: string,
version: string,
displayname: string,
size: number,
creationCallback?: (database: Database) => void): Database;
}
interface Database {
/**
* Starts new transaction.
* @param callback Function, that will be called when transaction starts.
* @param errorCallback Called, when Transaction fails.
* @param successCallback Called, when transaction committed.
*/
transaction(callback: (transaction: SqlTransaction) => void,
errorCallback?: (error: SqlError) => void,
successCallback?: () => void): void;
/**
* Starts new transaction.
* @param callback Function, that will be called when transaction starts.
* @param errorCallback Called, when Transaction fails.
* @param successCallback Called, when transaction committed.
*/
readTransaction(callback: (transaction: SqlTransaction) => void,
errorCallback?: (error: SqlError) => void,
successCallback?: () => void): void;
name: string;
version: string;
displayname: string;
size: number;
}
declare var Database: {
/** Constructor for Database object */
new(name: string,
version: string,
displayname: string,
size: number,
creationCallback: (database: Database)=> void): Database;
};
interface SqlTransaction {
/**
* Executes SQL statement via current transaction.
* @param sql SQL statement to execute.
* @param arguments SQL stetement arguments.
* @param successCallback Called in case of query has been successfully done.
* @param errorCallback Called, when query fails.
*/
executeSql(sql: string,
arguments?: any[],
successCallback?: (transaction: SqlTransaction, resultSet: SqlResultSet) => void,
errorCallback?: (transaction: SqlTransaction, error: SqlError) => void): void;
}
declare var SqlTransaction: {
new(): SqlTransaction;
};
interface SqlResultSet {
insertId: number;
rowsAffected: number;
rows: SqlResultSetRowList;
}
interface SqlResultSetRowList {
length: number;
item(index: number): Object;
}
interface SqlError {
code: number;
message: string;
}
declare var SqlError: {
// Error code constants from http://www.w3.org/TR/webdatabase/#sqlerror
UNKNOWN_ERR: number;
DATABASE_ERR: number;
VERSION_ERR: number;
TOO_LARGE_ERR: number;
QUOTA_ERR: number;
SYNTAX_ERR: number;
CONSTRAINT_ERR: number;
TIMEOUT_ERR: number;
};