зеркало из https://github.com/microsoft/TACO.git
Initial project structure
This commit is contained in:
Родитель
3aa0158400
Коммит
ce7f2591bf
|
@ -0,0 +1,3 @@
|
|||
# NodejsConsoleApp1
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/// <reference path="./src/util/typings/node.d.ts" />
|
||||
/// <reference path="./src/compile/gulpfile.ts" />
|
||||
|
||||
var gulp = require('gulp');
|
||||
require('./src/compile/gulpfile');
|
||||
|
||||
import styleCopUtil = require('./src/util/styleCopUtil');
|
||||
|
||||
/* Project wide tasks. */
|
||||
gulp.task('default', ['compilerDefault', 'styleCop']);
|
||||
|
||||
/* Runs style cop on the utilities. */
|
||||
gulp.task('styleCop', ['compilerStyleCop'], function (cb) {
|
||||
|
||||
var styleCop = new styleCopUtil.CordovaTools.StyleCopUtil();
|
||||
var excludedFiles = ["node.d.ts",
|
||||
"typescript.d.ts",
|
||||
"gulp.d.ts"
|
||||
];
|
||||
|
||||
styleCop.runCop('src/util', "tools/TSStyleCop/TSStyleCop.js", excludedFiles, cb);
|
||||
});
|
||||
|
||||
module.exports = gulp;
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "taco-compile",
|
||||
"version": "0.0.1",
|
||||
"description": "taco-compile",
|
||||
"author": "Microsoft Corp.",
|
||||
"main": "./bin/compile/src/hookInstaller.js",
|
||||
"bin": {
|
||||
"taco-compile": "./bin/compile/src/taco-compile"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"dependencies" : {
|
||||
"typescript": ">=1.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"del": "^1.0.0",
|
||||
"event-stream": "^3.1.7",
|
||||
"gulp": "^3.8.10",
|
||||
"gulp-concat": "^2.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
"taco",
|
||||
"compile",
|
||||
"typescript"
|
||||
],
|
||||
"license": "ISC"
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"EnsuringCorrectInstallation": "------ Ensuring correct global installation of package from source package directory: {0}",
|
||||
"InvalidInstallSourceDirectory": "------ Invalid installation source directory. No package.json found.",
|
||||
"NameOfPackage": "------ Name from source package.json: {0}",
|
||||
"VersionOfPackage": "------ Version from source package.json: {0}",
|
||||
"InstalledVersion": "------ Current globally installed version: {0}",
|
||||
"InstalledVersionDifferent": "------ Current globally installed version different from package version. Will install from source package.",
|
||||
"NotYetInstalled": "------ Package not currently installed globally.",
|
||||
"InstalledVersionSame": "------ Package already installed globally at correct version.",
|
||||
"InstallingGlobally": "------ Installing globally from source package. This could take a few minutes...",
|
||||
"NpmInstallError": "------ npm install error: {0}",
|
||||
"NpmInstallFailed": "------ npm install failed. Exit code: {0}",
|
||||
"NpmInstallCompleted": "------ npm install of {0} from {1} completed.",
|
||||
|
||||
"ConfigXmlInvalidNameElement": "Validation failed for config.xml. Invalid name element: '{0}'.",
|
||||
|
||||
"UnsupportedPlatform": "------ Unsupported platform type {0}.",
|
||||
"UnsupportedBuildCommand": "------ Unsupported build command {0}. Currently, build or prepare are supported.",
|
||||
|
||||
"CopyingIconsAndSplashscreens": "------ Copying Icons and Splashscreens for {0}",
|
||||
"CreatingApp": "------ Creating app at {0}",
|
||||
"AppDirAlreadyExists": "------ App dir {0} already exists",
|
||||
"CopyingAppFilesToWww": "------ Copying app files to www",
|
||||
"DoneCopyingAppFilesToWww": "------ Done copying app files to www",
|
||||
"CopyingResFiles": "------ Copying res files",
|
||||
"DoneCopyingResFiles": "------ Done copying res files",
|
||||
"NoResFilesToCopy": "------ Source directory {0} does not exist, no res files to copy",
|
||||
"PreparingRippleForiOS": "------ Preparing Ripple for iOS on a Windows device. Using Android for platform directory since iOS cannot be built on Windows.",
|
||||
"AddingPlatform": "------ Adding platform: {0}",
|
||||
"PlatformAlreadyExists": "------ Platform {0} already exists",
|
||||
"UpdatingPlugins": "------ Updating plugins",
|
||||
"DependentPluginNotRemoved": "------ Plugin was not removed because other plugin(s) depend on it: {0}",
|
||||
"PluginAlreadyRemoved": "------ Plugin was already removed",
|
||||
"UnexpectedPluginRemovalError": "ERROR: Please rebuild the solution. An unexpected plugin removal error occured: {0}",
|
||||
"CurrentInstalledPlugins": "------ Currently installed plugins: {0}",
|
||||
"CurrentDependentPlugins": "------ Currently installed dependent plugins: {0}",
|
||||
"CurrentConfiguredPlugins": "------ Currently configured plugins: {0}",
|
||||
"RemovingPlugin": "------ Removing plugin: {0}",
|
||||
"AddingPlugin": "------ Adding plugin: {0}",
|
||||
"CopyingPlatformMergeFiles": "------ Copying platform merge files from {0} to {1}",
|
||||
"DoneCopyingPlatformMergeFiles": "------ Done copying platform merge files to {0}",
|
||||
"CopyingNativeFiles": "------ Copying native files from {0} to {1}",
|
||||
"DoneCopyingNativeFiles": "------ Done copying native files to {0}",
|
||||
"BuildingPlatform": "------ Building platform: {0}",
|
||||
"BuildConfigurationOptions": "------ Build configuration options: {0}",
|
||||
"RemoteBuildServerNotConfigured": "A remote iOS build agent has not been configured. Configure one in Tools > Options > Tools for Apache Cordova > Remote Agent Configuration. For details and alternatives see http://go.microsoft.com/fwlink/?LinkID=511904",
|
||||
"PreparingPlatform": "------ Preparing platform: {0}",
|
||||
"CopyingBackToProject": "------ Copying back to project: {0}",
|
||||
"CopyingPkgInfoTextFile": "------ Copying generated _pkginfo.txt file",
|
||||
"WritingFromTo": "------ Writing {0} to {1}",
|
||||
"DoneCopyingCompiledFiles": "------ Done copying compiled files: {0}",
|
||||
"CheckingFor": "------ Checking for: {0}",
|
||||
"RenamingFromTo": "------ Renaming {0} to {1}",
|
||||
"CopyingAppxFiles": "------ Copying appx packages to output location",
|
||||
"NoAppxPackageOutputPath": "------ No packageOutputPath is specified for the project. Nothing to copy.",
|
||||
"CopyingAppxFilesFromTo": "------ Copying appx packages from {0} to {1}",
|
||||
"DoneCopyingAppxFiles": "------ Done copying appx packages to output location",
|
||||
"UpdatingAppxManifest": "------ Updating package.appxmanifest with platform specific values.",
|
||||
"FailedToAddWindowsBOM": "------ Failed to add BOM: {0}",
|
||||
"UninstallingProjectPlugin": "------ Uninstalling project directory plugin: {0}",
|
||||
"AddingProjectPlugin": "------ Adding project directory plugin: {0}",
|
||||
"CreatingDirectory": "------ Creating directory: {0}",
|
||||
"NoSourceDirectoryForCopy": "------ Source directory did not exist for copy: {0}",
|
||||
"SourceAssetDoesNotExist": "------ Source asset does not exist: {0}",
|
||||
"RemovingTargetAsset": "------ Removing mapped target asset: {0}",
|
||||
"CopiedFromTo": "------ Copied {0} to {1}",
|
||||
"CopyFailedFileNotFound": "------ Failed to copy - file not found: {0}",
|
||||
"ErrorCopyingFromTo": "------ Error copying {0} to {1}: {2}",
|
||||
"MaxPathErrorCopyingFromTo": "------ Unable to copy file {0} to {1} The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters",
|
||||
|
||||
"InvalidRemoteBuildUrl": "The remote build server Url {0} is invalid. It should specify http or https.",
|
||||
"RemoteBuildClientCertMissing": "The remote build client certificate is missing. To build your project, you must generate and configure a security PIN. See http://go.microsoft.com/fwlink/?LinkID=511904.",
|
||||
"IncrementalBuild": "------ Incremental Build: {0}",
|
||||
"SubmittingRemoteBuild": "------ Submitting new build request to: {0}",
|
||||
"ErrorUploadingRemoteBuild": "An error occurred uploading to the build server {0}: {1}",
|
||||
"InvalidRemoteBuildClientCert": "The remote build server denied the build request, because the client certificate is invalid or has expired. To build your project, you must generate and configure a security PIN. See http://go.microsoft.com/fwlink/?LinkID=511904",
|
||||
"NewRemoteBuildInfo": "------ New Build information: {0}",
|
||||
"CheckingRemoteBuildStatus": "------ {0} Checking on build status from {1} [Attempt {2}]",
|
||||
"RemoteBuildLogFollows": "------ Remote build log follows",
|
||||
"RemoteBuildError": "Remote build error from the build server {0}: {1}",
|
||||
"RemoteBuildSslConnectionReset": "Secure connection to {0} could not be established. Verify that the build server is running in secure mode.",
|
||||
"RemoteBuildNonSslConnectionReset": "Non-secure connection to {0} could not be established. Verify that the build server is not running in secure mode.",
|
||||
"RemoteBuildHostNotFound": "Host unreachable for build server {0}.",
|
||||
"RemoteBuildNoConnection": "Remote build server {0} connection failed. Verify that the server is running.",
|
||||
"InvalidRemoteBuild": "Invalid remote build: {0}",
|
||||
"DownloadingRemoteBuild": "------ Downloading completed build files from {0} to {1}",
|
||||
"DownloadedRemoteBuild": "------ Done downloading the build outputs to {0}",
|
||||
"ErrorDownloadingRemoteBuild": "Error from downloading build outputs to {0}: {1}",
|
||||
"ExtractingRemoteBuild": "------ Extracting the build outputs to {0}",
|
||||
"DoneExtractingRemoteBuild": "------ Done extracting the build outputs to {0}",
|
||||
"FailedToDeleteRemoteZip": "------ Failed to delete downloaded zip file {0}. This did not prevent a successful build.",
|
||||
"RequestingRemoteiOSEmulate": "Requesting emulate on iOS Simulator for buildNumber {0} on server {1}...",
|
||||
"RequestingRemoteiOSDeploy": "Requesting deploy on remote iOS device for buildNumber {0} on server {1}...",
|
||||
"RequestingRemoteiOSLaunch": "Requesting launch on remote iOS device for buildNumber {0} on server {1}...",
|
||||
"RequestingRemoteiOSDebug": "Requesting debug on remote iOS device for buildNumber {0} on server {1}...",
|
||||
"FailedRemoteiOSEmulate": "Failed to launch iOS remote for build {0} to {1} for deploy target {2}:\n{3}",
|
||||
"FailedRemoteiOSDeploy": "Failed to deploy iOS remote for build {0} to {1} :\n{2}",
|
||||
"FailedRemoteiOSLaunch": "Failed to launch iOS remote for build {0} to {1} :\n{2}",
|
||||
"FailedRemoteiOSDebug": "Failed to Debug iOS remote for build {0} to {1} :\n{2}",
|
||||
|
||||
"BuildError": "A build error occurred: {0}",
|
||||
|
||||
"PerformanceSummary": "------ vs-mda Performance Summary"
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/********************************************************
|
||||
* *
|
||||
* Copyright (C) Microsoft. All rights reserved. *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
// Note: cordova.d.ts defines typings for cordova as a cordova app would see it.
|
||||
// This file defines typings as the npm cordova module is used
|
||||
|
||||
declare module "cordova" {
|
||||
import Q = require('q');
|
||||
import http = require('http');
|
||||
|
||||
module Cordova {
|
||||
export interface ICordovaRaw {
|
||||
prepare(options?: any): Q.Promise<any>;
|
||||
build(options?: any): Q.Promise<any>;
|
||||
help: any;
|
||||
config: any;
|
||||
create(dir: string, id?: string, name?: string, cfg?: any): Q.Promise<any>;
|
||||
emulate(options?: any): Q.Promise<any>;
|
||||
plugin(command: any, targets?: any, opts?: any): Q.Promise<any>;
|
||||
plugins(command: any, targets?: any, opts?: any): Q.Promise<any>;
|
||||
serve(port: number): Q.Promise<http.Server>;
|
||||
platform(command: any, targets?: any, opts?: any): Q.Promise<any>;
|
||||
platforms(command: any, targets?: any, opts?: any): Q.Promise<any>;
|
||||
compile(options: any): Q.Promise<any>;
|
||||
run(options?: any): Q.Promise<any>;
|
||||
info(): Q.Promise<any[]>;
|
||||
save(target: any, opts?: any): Q.Promise<any>;
|
||||
restore(target: any, args: any): Q.Promise<any>;
|
||||
}
|
||||
|
||||
export function on(event: string, ...args: any[]) : void;
|
||||
export function off(event: string, ...args: any[]) : void;
|
||||
export function emit(event: string, ...args: any[]) : void;
|
||||
export function trigger(event: string, ...args: any[]) : void;
|
||||
export var raw: ICordovaRaw;
|
||||
}
|
||||
|
||||
export = Cordova
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
// 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;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
addEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
addEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
|
||||
removeEventListener(type: "deviceready", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "pause", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "resume", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "backbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "menubutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "searchbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "startcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "endcallbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "volumedownbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: "volumeupbutton", listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
|
||||
addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
// 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;
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
// 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 0-100. Default is 50 */
|
||||
quality?: number;
|
||||
/**
|
||||
* Choose the format of the return value.
|
||||
* Defined in navigator.camera.DestinationType. Default is FILE_URI.
|
||||
* 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. Default is CAMERA.
|
||||
* 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. Default is JPEG
|
||||
* 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. Default is BACK.
|
||||
* FRONT: 0
|
||||
* BACK: 1
|
||||
*/
|
||||
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;
|
||||
}
|
||||
};
|
|
@ -0,0 +1,273 @@
|
|||
// 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;
|
||||
/**
|
||||
* The navigator.contacts.pickContact method launches the Contact Picker to select a single contact.
|
||||
* The resulting object is passed to the contactSuccess callback function specified by the contactSuccess parameter.
|
||||
* @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.
|
||||
*/
|
||||
pickContact(onSuccess: (contact: Contact) => void,
|
||||
onError: (error: ContactError) => void): 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.) */
|
||||
honorificPrefix?: string;
|
||||
/** The contact's suffix (example Esq.). */
|
||||
honorificSuffix?: string;
|
||||
}
|
||||
|
||||
declare var ContactName: {
|
||||
/** Constructor for ContactName object */
|
||||
new(formatted?: string,
|
||||
familyName?: string,
|
||||
givenName?: string,
|
||||
middleName?: string,
|
||||
honorificPrefix?: string,
|
||||
honorificSuffix?: 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 {
|
||||
/** 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;
|
||||
/** Set to true if this ContactField contains the user's preferred value. */
|
||||
pref: boolean;
|
||||
}
|
||||
|
||||
declare var ContactField: {
|
||||
/** Constructor for ContactField object */
|
||||
new(type?: string,
|
||||
value?: string,
|
||||
pref?: boolean): 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;
|
||||
/* Contact fields to be returned back. If specified, the resulting Contact object only features values for these fields. */
|
||||
desiredFields?: string[];
|
||||
}
|
||||
|
||||
declare var ContactFindOptions: {
|
||||
/** Constructor for ContactFindOptions object */
|
||||
new(filter?: string,
|
||||
multiple?: boolean,
|
||||
desiredFields?: string[]): ContactFindOptions
|
||||
};
|
|
@ -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;
|
|
@ -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 { }
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
// 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.
|
||||
* 0 is the result when the dialog is dismissed without a button press.
|
||||
*/
|
||||
buttonIndex: number;
|
||||
/** The text entered in the prompt dialog box. */
|
||||
input1: string;
|
||||
}
|
|
@ -0,0 +1,364 @@
|
|||
// 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: FileError) => void): void;
|
||||
/**
|
||||
* Look up file system Entry referred to by local URI.
|
||||
* @param string uri URI referring to a local file or directory
|
||||
* @param successCallback invoked with Entry object corresponding to URI
|
||||
* @param errorCallback invoked if error occurs retrieving file system entry
|
||||
*/
|
||||
resolveLocalFileSystemURI(uri: string,
|
||||
successCallback: (entry: Entry) => void,
|
||||
errorCallback?: (error: FileError) => void): void;
|
||||
TEMPORARY: number;
|
||||
PERSISTENT: number;
|
||||
}
|
||||
|
||||
/** This interface represents a file system. */
|
||||
interface FileSystem {
|
||||
/* The name of the file system, 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 {
|
||||
/** 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: FileError) => 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: FileError) => 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: FileError) => void): void;
|
||||
/**
|
||||
* Returns a URL that can be used as the src attribute of a <video> or <audio> tag.
|
||||
* If that is not possible, construct a cdvfile:// URL.
|
||||
* @return string URL
|
||||
*/
|
||||
toURL(): string;
|
||||
/**
|
||||
* Return a URL that can be passed across the bridge to identify this entry.
|
||||
* @return string URL that can be passed across the bridge to identify this entry
|
||||
*/
|
||||
toInternalURL(): 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: FileError) => 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: FileError) => 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: FileError) => 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: FileError) => 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: FileError) => 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: FileError) => 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: FileError) => 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: FileError) => 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 always less or equal than length.
|
||||
* A newly-created FileWriter will have position set to 0.
|
||||
*/
|
||||
position: number;
|
||||
/**
|
||||
* The length of the file. If the user does not have read access to the file,
|
||||
* this will 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
|
||||
* will be discarded. If extending the file, the existing data will 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;
|
||||
}
|
||||
|
||||
/* FileWriter states */
|
||||
declare var FileWriter: {
|
||||
INIT: number;
|
||||
WRITING: number;
|
||||
DONE: number
|
||||
};
|
||||
|
||||
interface FileError {
|
||||
/** Error code */
|
||||
code: number;
|
||||
}
|
||||
|
||||
declare var FileError: {
|
||||
new (code: number): FileError;
|
||||
NOT_FOUND_ERR: number;
|
||||
SECURITY_ERR: number;
|
||||
ABORT_ERR: number;
|
||||
NOT_READABLE_ERR: number;
|
||||
ENCODING_ERR: number;
|
||||
NO_MODIFICATION_ALLOWED_ERR: number;
|
||||
INVALID_STATE_ERR: number;
|
||||
SYNTAX_ERR: number;
|
||||
INVALID_MODIFICATION_ERR: number;
|
||||
QUOTA_EXCEEDED_ERR: number;
|
||||
TYPE_MISMATCH_ERR: number;
|
||||
PATH_EXISTS_ERR: number;
|
||||
};
|
||||
|
||||
/*
|
||||
* Constants defined in fileSystemPaths
|
||||
*/
|
||||
interface Cordova {
|
||||
file: {
|
||||
/* Read-only directory where the application is installed. */
|
||||
applicationDirectory: string;
|
||||
/* Root of app's private writable storage */
|
||||
applicationStorageDirectory: string;
|
||||
/* Where to put app-specific data files. */
|
||||
dataDirectory: string;
|
||||
/* Cached files that should survive app restarts. Apps should not rely on the OS to delete files in here. */
|
||||
cacheDirectory: string;
|
||||
/* Android: the application space on external storage. */
|
||||
externalApplicationStorageDirectory: string;
|
||||
/* Android: Where to put app-specific data files on external storage. */
|
||||
externalDataDirectory: string;
|
||||
/* Android: the application cache on external storage. */
|
||||
externalCacheDirectory: string;
|
||||
/* Android: the external storage (SD card) root. */
|
||||
externalRootDirectory: string;
|
||||
/* iOS: Temp directory that the OS can clear at will. */
|
||||
tempDirectory: string;
|
||||
/* iOS: Holds app-specific files that should be synced (e.g. to iCloud). */
|
||||
syncedDataDirectory: string;
|
||||
/* iOS: Files private to the app, but that are meaningful to other applciations (e.g. Office files) */
|
||||
documentsDirectory: string;
|
||||
/* BlackBerry10: Files globally available to all apps */
|
||||
sharedDirectory: string
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
// 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: (event: ProgressEvent) => void;
|
||||
/**
|
||||
* 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;
|
||||
/* Request body */
|
||||
body: any;
|
||||
/* Exception that is thrown by native code */
|
||||
exception: any;
|
||||
}
|
||||
|
||||
declare var FileTransferError: {
|
||||
/** Constructor for FileTransferError object */
|
||||
new (code?: number, source?: string, target?: string, status?: number, body?: any, exception?: any): FileTransferError;
|
||||
FILE_NOT_FOUND_ERR: number;
|
||||
INVALID_URL_ERR: number;
|
||||
CONNECTION_ERR: number;
|
||||
ABORT_ERR: number;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
// 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 {
|
||||
/**
|
||||
* 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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
// 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: Plugins
|
||||
}
|
||||
|
||||
interface 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
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
// 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
|
||||
/**
|
||||
* Vibrates the device with a given pattern.
|
||||
* @param number[] pattern Pattern with which to vibrate the device.
|
||||
* The first value - number of milliseconds to wait before turning the vibrator on.
|
||||
* The next value - the number of milliseconds for which to keep the vibrator on before turning it off.
|
||||
* @param number repeat Optional index into the pattern array at which to start repeating (will repeat until canceled),
|
||||
* or -1 for no repetition (default).
|
||||
*/
|
||||
vibrateWithPattern(pattern: number[], repeat: number): void;
|
||||
/**
|
||||
* Immediately cancels any currently running vibration.
|
||||
*/
|
||||
cancelVibration(): void;
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
// Type definitions for Apache Cordova WebSQL plugin.
|
||||
// Project: https://github.com/MSOpenTech/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;
|
||||
};
|
|
@ -0,0 +1,288 @@
|
|||
// Type definitions for Gulp v3.8.x
|
||||
// Project: http://gulpjs.com
|
||||
// Definitions by: Drew Noakes <https://drewnoakes.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="node.d.ts" />
|
||||
|
||||
declare module gulp {
|
||||
|
||||
/**
|
||||
* Options to pass to node-glob through glob-stream.
|
||||
* Specifies two options in addition to those used by node-glob:
|
||||
* https://github.com/isaacs/node-glob#options
|
||||
*/
|
||||
interface ISrcOptions {
|
||||
/**
|
||||
* Setting this to <code>false</code> will return <code>file.contents</code> as <code>null</code>
|
||||
* and not read the file at all.
|
||||
* Default: <code>true</code>.
|
||||
*/
|
||||
read?: boolean;
|
||||
|
||||
/**
|
||||
* Setting this to false will return <code>file.contents</code> as a stream and not buffer files.
|
||||
* This is useful when working with large files.
|
||||
* Note: Plugins might not implement support for streams.
|
||||
* Default: <code>true</code>.
|
||||
*/
|
||||
buffer?: boolean;
|
||||
|
||||
/**
|
||||
* The current working directory in which to search.
|
||||
* Defaults to process.cwd().
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* The place where patterns starting with / will be mounted onto.
|
||||
* Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.)
|
||||
*/
|
||||
root?: string;
|
||||
|
||||
/**
|
||||
* Include .dot files in normal matches and globstar matches.
|
||||
* Note that an explicit dot in a portion of the pattern will always match dot files.
|
||||
*/
|
||||
dot?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid
|
||||
* filesystem path is returned. Set this flag to disable that behavior.
|
||||
*/
|
||||
nomount?: boolean;
|
||||
|
||||
/**
|
||||
* Add a / character to directory matches. Note that this requires additional stat calls.
|
||||
*/
|
||||
mark?: boolean;
|
||||
|
||||
/**
|
||||
* Don't sort the results.
|
||||
*/
|
||||
nosort?: boolean;
|
||||
|
||||
/**
|
||||
* Set to true to stat all results. This reduces performance somewhat, and is completely unnecessary, unless
|
||||
* readdir is presumed to be an untrustworthy indicator of file existence. It will cause ELOOP to be triggered one
|
||||
* level sooner in the case of cyclical symbolic links.
|
||||
*/
|
||||
stat?: boolean;
|
||||
|
||||
/**
|
||||
* When an unusual error is encountered when attempting to read a directory, a warning will be printed to stderr.
|
||||
* Set the silent option to true to suppress these warnings.
|
||||
*/
|
||||
silent?: boolean;
|
||||
|
||||
/**
|
||||
* When an unusual error is encountered when attempting to read a directory, the process will just continue on in
|
||||
* search of other matches. Set the strict option to raise an error in these cases.
|
||||
*/
|
||||
strict?: boolean;
|
||||
|
||||
/**
|
||||
* See cache property above. Pass in a previously generated cache object to save some fs calls.
|
||||
*/
|
||||
cache?: boolean;
|
||||
|
||||
/**
|
||||
* A cache of results of filesystem information, to prevent unnecessary stat calls.
|
||||
* While it should not normally be necessary to set this, you may pass the statCache from one glob() call to the
|
||||
* options object of another, if you know that the filesystem will not change between calls.
|
||||
*/
|
||||
statCache?: boolean;
|
||||
|
||||
/**
|
||||
* Perform a synchronous glob search.
|
||||
*/
|
||||
sync?: boolean;
|
||||
|
||||
/**
|
||||
* In some cases, brace-expanded patterns can result in the same file showing up multiple times in the result set.
|
||||
* By default, this implementation prevents duplicates in the result set. Set this flag to disable that behavior.
|
||||
*/
|
||||
nounique?: boolean;
|
||||
|
||||
/**
|
||||
* Set to never return an empty set, instead returning a set containing the pattern itself.
|
||||
* This is the default in glob(3).
|
||||
*/
|
||||
nonull?: boolean;
|
||||
|
||||
/**
|
||||
* Perform a case-insensitive match. Note that case-insensitive filesystems will sometimes result in glob returning
|
||||
* results that are case-insensitively matched anyway, since readdir and stat will not raise an error.
|
||||
*/
|
||||
nocase?: boolean;
|
||||
|
||||
/**
|
||||
* Set to enable debug logging in minimatch and glob.
|
||||
*/
|
||||
debug?: boolean;
|
||||
|
||||
/**
|
||||
* Set to enable debug logging in glob, but not minimatch.
|
||||
*/
|
||||
globDebug?: boolean;
|
||||
}
|
||||
|
||||
interface IDestOptions {
|
||||
/**
|
||||
* The output folder. Only has an effect if provided output folder is relative.
|
||||
* Default: process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Octal permission string specifying mode for any folders that need to be created for output folder.
|
||||
* Default: 0777.
|
||||
*/
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options that are passed to <code>gaze</code>.
|
||||
* https://github.com/shama/gaze
|
||||
*/
|
||||
interface IWatchOptions {
|
||||
/** Interval to pass to fs.watchFile. */
|
||||
interval?: number;
|
||||
/** Delay for events called in succession for the same file/event. */
|
||||
debounceDelay?: number;
|
||||
/** Force the watch mode. Either 'auto' (default), 'watch' (force native events), or 'poll' (force stat polling). */
|
||||
mode?: string;
|
||||
/** The current working directory to base file patterns from. Default is process.cwd().. */
|
||||
cwd?: string;
|
||||
}
|
||||
|
||||
interface IWatchEvent {
|
||||
/** The type of change that occurred, either added, changed or deleted. */
|
||||
type: string;
|
||||
/** The path to the file that triggered the event. */
|
||||
path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to be called on each watched file change.
|
||||
*/
|
||||
interface IWatchCallback {
|
||||
(event:IWatchEvent): void;
|
||||
}
|
||||
|
||||
interface ITaskCallback {
|
||||
/**
|
||||
* Defines a task.
|
||||
* Tasks may be made asynchronous if they are passing a callback or return a promise or a stream.
|
||||
* @param cb callback used to signal asynchronous completion. Caller includes <code>err</code> in case of error.
|
||||
*/
|
||||
(cb?:(err?:any)=>void): any;
|
||||
}
|
||||
|
||||
interface EventEmitter {
|
||||
any: any;
|
||||
}
|
||||
|
||||
interface Gulp {
|
||||
/**
|
||||
* Define a task.
|
||||
*
|
||||
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
|
||||
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
|
||||
*/
|
||||
task(name:string, fn:ITaskCallback): any;
|
||||
|
||||
/**
|
||||
* Define a task.
|
||||
*
|
||||
* @param name the name of the task. Tasks that you want to run from the command line should not have spaces in them.
|
||||
* @param dep an array of tasks to be executed and completed before your task will run.
|
||||
* @param fn the function that performs the task's operations. Generally this takes the form of gulp.src().pipe(someplugin()).
|
||||
*/
|
||||
task(name:string, dep:string[], fn?:ITaskCallback): any;
|
||||
|
||||
|
||||
/**
|
||||
* Takes a glob and represents a file structure. Can be piped to plugins.
|
||||
* @param glob a glob string, using node-glob syntax
|
||||
* @param opt an optional option object
|
||||
*/
|
||||
src(glob:string, opt?:ISrcOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* Takes a glob and represents a file structure. Can be piped to plugins.
|
||||
* @param glob an array of glob strings, using node-glob syntax
|
||||
* @param opt an optional option object
|
||||
*/
|
||||
src(glob:string[], opt?:ISrcOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
|
||||
/**
|
||||
* Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
|
||||
* Folders that don't exist will be created.
|
||||
*
|
||||
* @param outFolder the path (output folder) to write files to.
|
||||
* @param opt
|
||||
*/
|
||||
dest(outFolder:string, opt?:IDestOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
/**
|
||||
* Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
|
||||
* Folders that don't exist will be created.
|
||||
*
|
||||
* @param outFolder a function that converts a vinyl File instance into an output path
|
||||
* @param opt
|
||||
*/
|
||||
dest(outFolder:(file:string)=>string, opt?:IDestOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param tasks names of task(s) to run when a file changes, added with gulp.task()
|
||||
*/
|
||||
watch(glob:string, tasks:string[]): EventEmitter;
|
||||
watch(glob:string[], tasks:string[]): EventEmitter;
|
||||
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param opt options, that are passed to the gaze library.
|
||||
* @param tasks names of task(s) to run when a file changes, added with gulp.task()
|
||||
*/
|
||||
watch(glob:string, opt:IWatchOptions, tasks:string[]): EventEmitter;
|
||||
watch(glob:string[], opt:IWatchOptions, tasks:string[]): EventEmitter;
|
||||
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param fn a callback or array of callbacks to be called on each change.
|
||||
*/
|
||||
watch(glob:string, fn:IWatchCallback): EventEmitter;
|
||||
watch(glob:string[], fn:IWatchCallback): EventEmitter;
|
||||
watch(glob:string, fn:IWatchCallback[]): EventEmitter;
|
||||
watch(glob:string[], fn:IWatchCallback[]): EventEmitter;
|
||||
|
||||
/**
|
||||
* Watch files and do something when a file changes. This always returns an EventEmitter that emits change events.
|
||||
*
|
||||
* @param glob a single glob or array of globs that indicate which files to watch for changes.
|
||||
* @param opt options, that are passed to the gaze library.
|
||||
* @param fn a callback or array of callbacks to be called on each change.
|
||||
*/
|
||||
watch(glob:string, opt:IWatchOptions, fn:IWatchCallback): EventEmitter;
|
||||
watch(glob:string, opt:IWatchOptions, fn:IWatchCallback[]): EventEmitter;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "gulp" {
|
||||
var _tmp:gulp.Gulp;
|
||||
export = _tmp;
|
||||
}
|
||||
|
||||
interface IGulpPlugin {
|
||||
(...args: any[]): NodeJS.ReadWriteStream;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// Type definitions for nconf
|
||||
// Project: https://github.com/flatiron/nconf
|
||||
// Definitions by: Jeff Goddard <https://github.com/jedigo>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/nconf.d.ts
|
||||
|
||||
declare module "nconf" {
|
||||
export var version: number;
|
||||
export var stores: any;
|
||||
export var sources: any[];
|
||||
|
||||
export function clear(key: string, callback?: ICallbackFunction): any;
|
||||
export function get (key: string, callback?: ICallbackFunction): any;
|
||||
export function merge(key: string, value: any, callback?: ICallbackFunction): any;
|
||||
export function set (key: string, value: any, callback?: ICallbackFunction): any;
|
||||
export function reset(callback?: ICallbackFunction): any;
|
||||
|
||||
export function load(callback?: ICallbackFunction): any;
|
||||
export function mergeSources(data: any): void;
|
||||
export function loadSources(): any;
|
||||
export function save(value: any, callback?: ICallbackFunction): any;
|
||||
|
||||
export function add(name: string, options?: IOptions): Provider;
|
||||
export function argv(options?: IOptions): Provider;
|
||||
export function env(options?: IOptions): Provider;
|
||||
export function file(name: string, options?: IFileOptions): Provider;
|
||||
export function file(options: IFileOptions): Provider;
|
||||
export function use(name: string, options?: IOptions): Provider;
|
||||
export function defaults(options?: IOptions): Provider;
|
||||
export function init(options?: IOptions): void;
|
||||
export function overrides(options?: IOptions): Provider;
|
||||
export function remove(name: string): void;
|
||||
export function create(name: string, options: IOptions): IStore;
|
||||
|
||||
export function key(...values: any[]): string;
|
||||
export function path(key: any): any[];
|
||||
export function loadFiles(files: any, callback?: ICallbackFunction): void;
|
||||
export function loadFilesSync(files: any, callback?: ICallbackFunction): void;
|
||||
|
||||
export enum formats {
|
||||
json,
|
||||
ini
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export interface IFileOptions extends IOptions {
|
||||
file?: string;
|
||||
dir?: string;
|
||||
search?: boolean;
|
||||
json_spacing?: number;
|
||||
}
|
||||
|
||||
export interface ICallbackFunction {
|
||||
(err: Error): void;
|
||||
}
|
||||
|
||||
export class Provider {
|
||||
constructor(options: IOptions);
|
||||
|
||||
stores: any;
|
||||
sources: any[];
|
||||
|
||||
clear(key: string, callback?: ICallbackFunction): any;
|
||||
get (key: string, callback?: ICallbackFunction): any;
|
||||
merge(key: string, value: any, callback?: ICallbackFunction): any;
|
||||
set (key: string, value: any, callback?: ICallbackFunction): any;
|
||||
reset(callback?: ICallbackFunction): any;
|
||||
|
||||
load(callback?: ICallbackFunction): any;
|
||||
mergeSources(data: any): void;
|
||||
loadSources(): any;
|
||||
save(value: any, callback?: ICallbackFunction): any;
|
||||
|
||||
add(name: string, options?: IOptions): Provider;
|
||||
argv(options?: IOptions): Provider;
|
||||
env(options?: IOptions): Provider;
|
||||
file(name: string, options?: IFileOptions): Provider;
|
||||
file(options: IFileOptions): Provider;
|
||||
use(name: string, options?: IOptions): Provider;
|
||||
|
||||
defaults(options?: IOptions): Provider;
|
||||
init(options?: IOptions): void;
|
||||
overrides(options?: IOptions): Provider;
|
||||
remove(name: string): void;
|
||||
create(name: string, options: IOptions): IStore;
|
||||
}
|
||||
|
||||
export interface IStore {
|
||||
type: string;
|
||||
get (key: string): any;
|
||||
set (key: string, value: any): boolean;
|
||||
clear(key: string): boolean;
|
||||
merge(key: string, value: any): boolean;
|
||||
reset(callback?: ICallbackFunction): boolean;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
/// <reference path="node.d.ts" />
|
||||
|
||||
import assert = require("assert");
|
||||
import fs = require("fs");
|
||||
import events = require("events");
|
||||
import zlib = require("zlib");
|
||||
import url = require('url');
|
||||
import util = require("util");
|
||||
import crypto = require("crypto");
|
||||
import http = require("http");
|
||||
import net = require("net");
|
||||
import dgram = require("dgram");
|
||||
|
||||
assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
|
||||
|
||||
assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
|
||||
|
||||
assert.equal(3, "3", "uses == comparator");
|
||||
|
||||
assert.notStrictEqual(2, "2", "uses === comparator");
|
||||
|
||||
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
|
||||
|
||||
assert.doesNotThrow(() => {
|
||||
if (false) { throw "a hammer at your face"; }
|
||||
}, undefined, "What the...*crunch*");
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// File system tests : http://nodejs.org/api/fs.html
|
||||
////////////////////////////////////////////////////
|
||||
fs.writeFile("thebible.txt",
|
||||
"Do unto others as you would have them do unto you.",
|
||||
assert.ifError);
|
||||
|
||||
fs.writeFile("Harry Potter",
|
||||
"\"You be wizzing, Harry,\" jived Dumbledore.",
|
||||
{
|
||||
encoding: "ascii"
|
||||
},
|
||||
assert.ifError);
|
||||
|
||||
var content: string,
|
||||
buffer: Buffer;
|
||||
|
||||
content = fs.readFileSync('testfile', 'utf8');
|
||||
content = fs.readFileSync('testfile', {encoding : 'utf8'});
|
||||
buffer = fs.readFileSync('testfile');
|
||||
buffer = fs.readFileSync('testfile', {flag : 'r'});
|
||||
fs.readFile('testfile', 'utf8', (err, data) => content = data);
|
||||
fs.readFile('testfile', {encoding : 'utf8'}, (err, data) => content = data);
|
||||
fs.readFile('testfile', (err, data) => buffer = data);
|
||||
fs.readFile('testfile', {flag : 'r'}, (err, data) => buffer = data);
|
||||
|
||||
class Networker extends events.EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.emit("mingling");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Url tests : http://nodejs.org/api/url.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
url.format(url.parse('http://www.example.com/xyz'));
|
||||
|
||||
// https://google.com/search?q=you're%20a%20lizard%2C%20gary
|
||||
url.format({
|
||||
protocol: 'https',
|
||||
host: "google.com",
|
||||
pathname: 'search',
|
||||
query: { q: "you're a lizard, gary" }
|
||||
});
|
||||
|
||||
var helloUrl = url.parse('http://example.com/?hello=world', true)
|
||||
assert.equal(helloUrl.query.hello, 'world');
|
||||
|
||||
|
||||
// Old and new util.inspect APIs
|
||||
util.inspect(["This is nice"], false, 5);
|
||||
util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false });
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Stream tests : http://nodejs.org/api/stream.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
// http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options
|
||||
function stream_readable_pipe_test() {
|
||||
var r = fs.createReadStream('file.txt');
|
||||
var z = zlib.createGzip();
|
||||
var w = fs.createWriteStream('file.txt.gz');
|
||||
r.pipe(z).pipe(w);
|
||||
r.close();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Crypto tests : http://nodejs.org/api/crypto.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
|
||||
|
||||
function crypto_cipher_decipher_string_test() {
|
||||
var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
|
||||
var clearText:string = "This is the clear text.";
|
||||
var cipher:crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
|
||||
var cipherText:string = cipher.update(clearText, "utf8", "hex");
|
||||
cipherText += cipher.final("hex");
|
||||
|
||||
var decipher:crypto.Decipher = crypto.createDecipher("aes-128-ecb", key);
|
||||
var clearText2:string = decipher.update(cipherText, "hex", "utf8");
|
||||
clearText2 += decipher.final("utf8");
|
||||
|
||||
assert.equal(clearText2, clearText);
|
||||
}
|
||||
|
||||
function crypto_cipher_decipher_buffer_test() {
|
||||
var key:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]);
|
||||
var clearText:Buffer = new Buffer([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4]);
|
||||
var cipher:crypto.Cipher = crypto.createCipher("aes-128-ecb", key);
|
||||
var cipherBuffers:Buffer[] = [];
|
||||
cipherBuffers.push(cipher.update(clearText));
|
||||
cipherBuffers.push(cipher.final());
|
||||
|
||||
var cipherText:Buffer = Buffer.concat(cipherBuffers);
|
||||
|
||||
var decipher:crypto.Decipher = crypto.createDecipher("aes-128-ecb", key);
|
||||
var decipherBuffers:Buffer[] = [];
|
||||
decipherBuffers.push(decipher.update(cipherText));
|
||||
decipherBuffers.push(decipher.final());
|
||||
|
||||
var clearText2:Buffer = Buffer.concat(decipherBuffers);
|
||||
|
||||
assert.deepEqual(clearText2, clearText);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
// Make sure .listen() and .close() retuern a Server instance
|
||||
http.createServer().listen(0).close().address();
|
||||
net.createServer().listen(0).close().address();
|
||||
|
||||
var request = http.request('http://0.0.0.0');
|
||||
request.once('error', function () {});
|
||||
request.setNoDelay(true);
|
||||
request.abort();
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Http tests : http://nodejs.org/api/http.html
|
||||
////////////////////////////////////////////////////
|
||||
module http_tests {
|
||||
// Status codes
|
||||
var code = 100;
|
||||
var codeMessage = http.STATUS_CODES['400'];
|
||||
var codeMessage = http.STATUS_CODES[400];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Dgram tests : http://nodejs.org/api/dgram.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
var ds: dgram.Socket = dgram.createSocket("udp4", (msg: Buffer, rinfo: dgram.RemoteInfo): void => {
|
||||
});
|
||||
var ai: dgram.AddressInfo = ds.address();
|
||||
ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error, bytes: number): void => {
|
||||
});
|
||||
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,7 @@
|
|||
// Type definitions for nopt
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
declare module 'nopt' {
|
||||
export function nopt(types: any, shorthands: any, args: any, slice?: any): any;
|
||||
export function clean(data: any, types: any, typeDefs: any[]): any;
|
||||
}
|
|
@ -0,0 +1,386 @@
|
|||
// Type definitions for Q
|
||||
// Project: https://github.com/kriskowal/q
|
||||
// Definitions by: Barrie Nemetchek <https://github.com/bnemetchek>, Andrew Gaspar <https://github.com/AndrewGaspar/>, John Reilly <https://github.com/johnnyreilly>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* If value is a Q promise, returns the promise.
|
||||
* If value is a promise from another library it is coerced into a Q promise (where possible).
|
||||
*/
|
||||
declare function Q<T>(promise: Q.IPromise<T>): Q.Promise<T>;
|
||||
/**
|
||||
* If value is not a promise, returns a promise that is fulfilled with value.
|
||||
*/
|
||||
declare function Q<T>(value: T): Q.Promise<T>;
|
||||
|
||||
declare module Q {
|
||||
interface IPromise<T> {
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason: any) => U): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise<U>): IPromise<U>;
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => U): IPromise<U>;
|
||||
}
|
||||
|
||||
interface Deferred<T> {
|
||||
promise: Promise<T>;
|
||||
resolve(value: T): void;
|
||||
reject(reason: any): void;
|
||||
notify(value: any): void;
|
||||
makeNodeResolver(): (reason: any, value: T) => void;
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
|
||||
|
||||
* finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
|
||||
*/
|
||||
fin(finallyCallback: () => any): Promise<T>;
|
||||
/**
|
||||
* Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object.
|
||||
|
||||
* finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished.
|
||||
*/
|
||||
finally(finallyCallback: () => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason: any) => IPromise<U>, onProgress?: Function): Promise<U>;
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => IPromise<U>, onReject?: (reason: any) => U, onProgress?: Function): Promise<U>;
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise<U>, onProgress?: Function): Promise<U>;
|
||||
/**
|
||||
* The then method from the Promises/A+ specification, with an additional progress handler.
|
||||
*/
|
||||
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => U, onProgress?: Function): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
*
|
||||
* This is especially useful in conjunction with all
|
||||
*/
|
||||
spread<U>(onFulfilled: Function, onRejected?: Function): Promise<U>;
|
||||
|
||||
fail<U>(onRejected: (reason: any) => IPromise<U>): Promise<U>;
|
||||
fail<U>(onRejected: (reason: any) => U): Promise<U>;
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, onRejected).
|
||||
*/
|
||||
catch<U>(onRejected: (reason: any) => U): Promise<U>;
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, onRejected).
|
||||
*/
|
||||
catch<U>(onRejected: (reason: any) => IPromise<U>): Promise<U>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(undefined, undefined, onProgress).
|
||||
*/
|
||||
progress(onProgress: (progress: any) => any): Promise<T>;
|
||||
|
||||
/**
|
||||
* Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop.
|
||||
*
|
||||
* This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object.
|
||||
*
|
||||
* Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn.
|
||||
*
|
||||
* The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it.
|
||||
*/
|
||||
done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void;
|
||||
|
||||
/**
|
||||
* If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise.
|
||||
*/
|
||||
nodeify(callback: (reason: any, value: any) => void): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise to get the named property of an object. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return o[propertyName];
|
||||
* });
|
||||
*/
|
||||
get<U>(propertyName: String): Promise<U>;
|
||||
set<U>(propertyName: String, value: any): Promise<U>;
|
||||
delete<U>(propertyName: String): Promise<U>;
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return o[methodName].apply(o, args);
|
||||
* });
|
||||
*/
|
||||
post<U>(methodName: String, args: any[]): Promise<U>;
|
||||
/**
|
||||
* Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call.
|
||||
*/
|
||||
invoke<U>(methodName: String, ...args: any[]): Promise<U>;
|
||||
fapply<U>(args: any[]): Promise<U>;
|
||||
fcall<U>(...args: any[]): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise for an array of the property names of an object. Essentially equivalent to
|
||||
*
|
||||
* promise.then(function (o) {
|
||||
* return Object.keys(o);
|
||||
* });
|
||||
*/
|
||||
keys(): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(function () { return value; }).
|
||||
*/
|
||||
thenResolve<U>(value: U): Promise<U>;
|
||||
/**
|
||||
* A sugar method, equivalent to promise.then(function () { throw reason; }).
|
||||
*/
|
||||
thenReject(reason: any): Promise<T>;
|
||||
timeout(ms: number, message?: string): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
delay(ms: number): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
valueOf(): any;
|
||||
|
||||
/**
|
||||
* Returns a "state snapshot" object, which will be in one of three forms:
|
||||
*
|
||||
* - { state: "pending" }
|
||||
* - { state: "fulfilled", value: <fulfllment value> }
|
||||
* - { state: "rejected", reason: <rejection reason> }
|
||||
*/
|
||||
inspect(): PromiseState<T>;
|
||||
}
|
||||
|
||||
interface PromiseState<T> {
|
||||
/**
|
||||
* "fulfilled", "rejected", "pending"
|
||||
*/
|
||||
state: string;
|
||||
value?: T;
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
// If no value provided, returned promise will be of void type
|
||||
export function when(): Promise<void>;
|
||||
|
||||
// if no fulfill, reject, or progress provided, returned promise will be of same type
|
||||
export function when<T>(value: IPromise<T>): Promise<T>;
|
||||
export function when<T>(value: T): Promise<T>;
|
||||
|
||||
// If a non-promise value is provided, it will not reject or progress
|
||||
export function when<T, U>(value: T, onFulfilled: (val: T) => IPromise<U>): Promise<U>;
|
||||
export function when<T, U>(value: T, onFulfilled: (val: T) => U): Promise<U>;
|
||||
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason: any) => IPromise<U>, onProgress?: (progress: any) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => IPromise<U>, onRejected?: (reason: any) => U, onProgress?: (progress: any) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason: any) => IPromise<U>, onProgress?: (progress: any) => any): Promise<U>;
|
||||
export function when<T, U>(value: IPromise<T>, onFulfilled: (val: T) => U, onRejected?: (reason: any) => U, onProgress?: (progress: any) => any): Promise<U>;
|
||||
|
||||
//export function try(method: Function, ...args: any[]): Promise<any>; // <- This is broken currently - not sure how to fix.
|
||||
|
||||
export function fbind<T>(method: (...args: any[]) => IPromise<T>, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function fbind<T>(method: (...args: any[]) => T, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
|
||||
export function fcall<T>(method: (...args: any[]) => T, ...args: any[]): Promise<T>;
|
||||
|
||||
export function send<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function invoke<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function mcall<T>(obj: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
export function denodeify<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nbind<T>(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfbind<T>(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise<T>;
|
||||
export function nfcall<T>(nodeFunction: Function, ...args: any[]): Promise<T>;
|
||||
export function nfapply<T>(nodeFunction: Function, args: any[]): Promise<T>;
|
||||
|
||||
export function ninvoke<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function npost<T>(nodeModule: any, functionName: string, args: any[]): Promise<T>;
|
||||
export function nsend<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
export function nmcall<T>(nodeModule: any, functionName: string, ...args: any[]): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<T>(promises: IPromise<T>[]): Promise<T[]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected.
|
||||
*/
|
||||
export function all<T>(promises: any[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
||||
*/
|
||||
export function allSettled<T>(promises: IPromise<T>[]): Promise<PromiseState<T>[]>;
|
||||
/**
|
||||
* Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected.
|
||||
*/
|
||||
export function allSettled<T>(promises: any[]): Promise<PromiseState<T>[]>;
|
||||
|
||||
export function allResolved<T>(promises: IPromise<T>[]): Promise<Promise<T>[]>;
|
||||
export function allResolved<T>(promises: any[]): Promise<Promise<T>[]>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<U>(promises: any[], onFulfilled: (...args: any[]) => IPromise<U>, onRejected?: (reason: any) => IPromise<U>): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<U>(promises: any[], onFulfilled: (...args: any[]) => IPromise<U>, onRejected?: (reason: any) => U): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<U>(promises: any[], onFulfilled: (...args: any[]) => U, onRejected?: (reason: any) => IPromise<U>): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<U>(promises: any[], onFulfilled: (...args: any[]) => U, onRejected?: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: IPromise<T>[], onFulfilled: (...args: T[]) => IPromise<U>, onRejected?: (reason: any) => IPromise<U>): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: IPromise<T>[], onFulfilled: (...args: T[]) => IPromise<U>, onRejected?: (reason: any) => U): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: IPromise<T>[], onFulfilled: (...args: T[]) => U, onRejected?: (reason: any) => IPromise<U>): Promise<U>;
|
||||
/**
|
||||
* Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason.
|
||||
* This is especially useful in conjunction with all.
|
||||
*/
|
||||
export function spread<T, U>(promises: IPromise<T>[], onFulfilled: (...args: T[]) => U, onRejected?: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms".
|
||||
*/
|
||||
export function timeout<T>(promise: Promise<T>, ms: number, message?: string): Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay<T>(promise: Promise<T>, ms: number): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay<T>(value: T, ms: number): Promise<T>;
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed.
|
||||
*/
|
||||
export function delay(ms: number): Promise <void>;
|
||||
/**
|
||||
* Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true.
|
||||
*/
|
||||
export function isFulfilled(promise: Promise<any>): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isRejected(promise: Promise<any>): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isPending(promise: Promise<any>): boolean;
|
||||
|
||||
/**
|
||||
* Returns a "deferred" object with a:
|
||||
* promise property
|
||||
* resolve(value) method
|
||||
* reject(reason) method
|
||||
* notify(value) method
|
||||
* makeNodeResolver() method
|
||||
*/
|
||||
export function defer<T>(): Deferred<T>;
|
||||
|
||||
/**
|
||||
* Returns a promise that is rejected with reason.
|
||||
*/
|
||||
export function reject<T>(reason?: any): Promise<T>;
|
||||
|
||||
export function Promise<T>(resolver: (resolve: (val: IPromise<T>) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise<T>;
|
||||
export function Promise<T>(resolver: (resolve: (val: T) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise<T>;
|
||||
|
||||
/**
|
||||
* Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively.
|
||||
*
|
||||
* This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions.
|
||||
*/
|
||||
export function promised<T>(callback: (...args: any[]) => T): (...args: any[]) => Promise<T>;
|
||||
|
||||
/**
|
||||
* Returns whether the given value is a Q promise.
|
||||
*/
|
||||
export function isPromise(object: any): boolean;
|
||||
/**
|
||||
* Returns whether the given value is a promise (i.e. it's an object with a then function).
|
||||
*/
|
||||
export function isPromiseAlike(object: any): boolean;
|
||||
/**
|
||||
* Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false.
|
||||
*/
|
||||
export function isPending(object: any): boolean;
|
||||
|
||||
/**
|
||||
* This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield.
|
||||
*/
|
||||
export function async<T>(generatorFunction: any): (...args: any[]) => Promise<T>;
|
||||
export function nextTick(callback: Function): void;
|
||||
|
||||
/**
|
||||
* A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror.
|
||||
*/
|
||||
export var onerror: (reason: any) => void;
|
||||
/**
|
||||
* A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced.
|
||||
*/
|
||||
export var longStackSupport: boolean;
|
||||
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
|
||||
* Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
|
||||
* Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
|
||||
* Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
export function resolve<T>(object: IPromise<T>): Promise<T>;
|
||||
/**
|
||||
* Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does).
|
||||
* Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason.
|
||||
* Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value.
|
||||
* Calling resolve with a non-promise value causes promise to be fulfilled with that value.
|
||||
*/
|
||||
export function resolve<T>(object: T): Promise<T>;
|
||||
}
|
||||
|
||||
declare module "q" {
|
||||
export = Q;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/********************************************************
|
||||
* *
|
||||
* Copyright (C) Microsoft. All rights reserved. *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
// Note: cordova.d.ts defines typings for cordova as a cordova app would see it.
|
||||
// This file defines typings as the npm cordova module is used
|
||||
|
||||
declare module "taco-lib" {
|
||||
|
||||
import Q = require('q');
|
||||
|
||||
export function create(dir: string, id: string, name: string, cfg: string): Q.Promise<any>;
|
||||
export function build(options?: any): Q.Promise<any>;
|
||||
export function compile(options?: any): Q.Promise<any>;
|
||||
export function prepare(options?: any): Q.Promise<any>;
|
||||
export function platform(command: string, targets?: string, options?: any): Q.IPromise<any>;
|
||||
export function run(options?: any): Q.Promise<any>;
|
||||
export function emulate(options?: any): Q.Promise<any>;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче