mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-14 02:14:52 +08:00
typings inside test, devdependencies
This commit is contained in:
@@ -111,7 +111,7 @@ gulp.task("compile-test", function () {
|
||||
var ts = require("gulp-typescript");
|
||||
var insert = require("gulp-insert");
|
||||
|
||||
return gulp.src([testPath + tsFiles])
|
||||
return gulp.src([testPath + "/test.ts"])
|
||||
.pipe(ts(tsCompileOptions))
|
||||
.pipe(insert.prepend(compiledSourceWarningMessage))
|
||||
.pipe(gulp.dest(path.join(binPath, testPath)));
|
||||
@@ -158,7 +158,7 @@ gulp.task("tslint", function () {
|
||||
}
|
||||
}
|
||||
|
||||
return gulp.src([testPath + tsFiles])
|
||||
return gulp.src([testPath + tsFiles, "!" + testPath + "/typings/*"])
|
||||
.pipe(tslint({ configuration: config }))
|
||||
.pipe(tslint.report("verbose"));
|
||||
});
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
"url": "https://github.com/Microsoft/react-native-code-push"
|
||||
},
|
||||
"dependencies": {
|
||||
"code-push": "1.8.0-beta"
|
||||
},
|
||||
"devDependencies": {
|
||||
"archiver": "latest",
|
||||
"body-parser": "latest",
|
||||
"code-push": "1.8.0-beta",
|
||||
"del": "latest",
|
||||
"express": "latest",
|
||||
"gulp-typescript": "2.12.2",
|
||||
|
||||
13
test/test.ts
13
test/test.ts
@@ -1,10 +1,9 @@
|
||||
/// <reference path="../typings/assert.d.ts" />
|
||||
/// <reference path="../typings/codePush.d.ts" />
|
||||
/// <reference path="./typings/assert.d.ts" />
|
||||
/// <reference path="../node_modules/code-push-plugin-testing-framework/typings/code-push-plugin-testing-framework.d.ts" />
|
||||
/// <reference path="../typings/mocha.d.ts" />
|
||||
/// <reference path="../typings/mkdirp.d.ts" />
|
||||
/// <reference path="../typings/node.d.ts" />
|
||||
/// <reference path="../typings/q.d.ts" />
|
||||
/// <reference path="./typings/mocha.d.ts" />
|
||||
/// <reference path="./typings/mkdirp.d.ts" />
|
||||
/// <reference path="./typings/node.d.ts" />
|
||||
/// <reference path="./typings/q.d.ts" />
|
||||
|
||||
"use strict";
|
||||
|
||||
@@ -571,7 +570,7 @@ PluginTestingFramework.initializeTests(new RNProjectManager(), supportedTargetPl
|
||||
try {
|
||||
assert.equal(requestBody.message, ServerUtil.TestMessage.CHECK_UPDATE_AVAILABLE);
|
||||
assert.notEqual(requestBody.args[0], null);
|
||||
var remotePackage: IRemotePackage = requestBody.args[0];
|
||||
var remotePackage: any = requestBody.args[0];
|
||||
assert.equal(remotePackage.downloadUrl, updateResponse.downloadURL);
|
||||
assert.equal(remotePackage.isMandatory, updateResponse.isMandatory);
|
||||
assert.equal(remotePackage.label, updateResponse.label);
|
||||
|
||||
0
typings/q.d.ts → test/typings/q.d.ts
vendored
0
typings/q.d.ts → test/typings/q.d.ts
vendored
400
typings/codePush.d.ts
vendored
400
typings/codePush.d.ts
vendored
@@ -1,400 +0,0 @@
|
||||
// Type definitions for Apache Cordova CodePush plugin.
|
||||
// Project: https://github.com/Microsoft/cordova-plugin-code-push
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
declare module Http {
|
||||
export const enum Verb {
|
||||
GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
|
||||
}
|
||||
|
||||
export interface Response {
|
||||
statusCode: number;
|
||||
body?: string;
|
||||
}
|
||||
|
||||
export interface Requester {
|
||||
request(verb: Verb, url: string, callback: Callback<Response>): void;
|
||||
request(verb: Verb, url: string, requestBody: string, callback: Callback<Response>): void;
|
||||
}
|
||||
}
|
||||
|
||||
interface Window {
|
||||
codePush: CodePushCordovaPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a package. All fields are non-nullable, except when retrieving the currently running package on the first run of the app,
|
||||
* in which case only the appVersion is compulsory.
|
||||
*
|
||||
* !! THIS TYPE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
interface IPackage {
|
||||
deploymentKey: string;
|
||||
description: string;
|
||||
label: string;
|
||||
appVersion: string;
|
||||
isMandatory: boolean;
|
||||
packageHash: string;
|
||||
packageSize: number;
|
||||
failedInstall: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a remote package, which represents an update package available for download.
|
||||
*/
|
||||
interface IRemotePackage extends IPackage {
|
||||
/**
|
||||
* The URL at which the package is available for download.
|
||||
*/
|
||||
downloadUrl: string;
|
||||
|
||||
/**
|
||||
* Downloads the package update from the CodePush service.
|
||||
*
|
||||
* @param downloadSuccess Called with one parameter, the downloaded package information, once the download completed successfully.
|
||||
* @param downloadError Optional callback invoked in case of an error.
|
||||
* @param downloadProgress Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
||||
*/
|
||||
download(downloadSuccess: SuccessCallback<ILocalPackage>, downloadError?: ErrorCallback, downloadProgress?: SuccessCallback<DownloadProgress>): void;
|
||||
|
||||
/**
|
||||
* Aborts the current download session, previously started with download().
|
||||
*
|
||||
* @param abortSuccess Optional callback invoked if the abort operation succeeded.
|
||||
* @param abortError Optional callback invoked in case of an error.
|
||||
*/
|
||||
abortDownload(abortSuccess?: SuccessCallback<void>, abortError?: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a local package.
|
||||
*
|
||||
* !! THIS TYPE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
interface ILocalPackage extends IPackage {
|
||||
/**
|
||||
* The local storage path where this package is located.
|
||||
*/
|
||||
localPath: string;
|
||||
|
||||
/**
|
||||
* Indicates if the current application run is the first one after the package was applied.
|
||||
*/
|
||||
isFirstRun: boolean;
|
||||
|
||||
/**
|
||||
* Applies this package to the application. The application will be reloaded with this package and on every application launch this package will be loaded.
|
||||
* On the first run after the update, the application will wait for a codePush.notifyApplicationReady() call. Once this call is made, the install operation is considered a success.
|
||||
* Otherwise, the install operation will be marked as failed, and the application is reverted to its previous version on the next run.
|
||||
*
|
||||
* @param installSuccess Callback invoked if the install operation succeeded.
|
||||
* @param installError Optional callback inovoked in case of an error.
|
||||
* @param installOptions Optional parameter used for customizing the installation behavior.
|
||||
*/
|
||||
install(installSuccess: SuccessCallback<void>, errorCallback?: ErrorCallback, installOptions?: InstallOptions): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decomposed static side of RemotePackage.
|
||||
* For Class Decomposition guidelines see http://www.typescriptlang.org/Handbook#writing-dts-files-guidelines-and-specifics
|
||||
*/
|
||||
interface RemotePackage_Static {
|
||||
new (): IRemotePackage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decomposed static side of LocalPackage.
|
||||
* For Class Decomposition guidelines see http://www.typescriptlang.org/Handbook#writing-dts-files-guidelines-and-specifics
|
||||
*/
|
||||
interface LocalPackage_Static {
|
||||
new (): ILocalPackage;
|
||||
}
|
||||
|
||||
declare var RemotePackage: RemotePackage_Static;
|
||||
declare var LocalPackage: LocalPackage_Static;
|
||||
|
||||
/**
|
||||
* Defines the JSON format of the current package information file.
|
||||
* This file is stored in the local storage of the device and persists between store updates and code-push updates.
|
||||
*
|
||||
* !! THIS FILE IS READ FROM NATIVE CODE AS WELL. ANY CHANGES TO THIS INTERFACE NEEDS TO BE UPDATED IN NATIVE CODE !!
|
||||
*/
|
||||
interface IPackageInfoMetadata extends ILocalPackage {
|
||||
nativeBuildTime: string;
|
||||
}
|
||||
|
||||
interface NativeUpdateNotification {
|
||||
updateAppVersion: boolean; // Always true
|
||||
appVersion: string;
|
||||
}
|
||||
|
||||
interface Callback<T> { (error: Error, parameter: T): void; }
|
||||
interface SuccessCallback<T> { (result?: T): void; }
|
||||
interface ErrorCallback { (error?: Error): void; }
|
||||
|
||||
interface Configuration {
|
||||
appVersion: string;
|
||||
clientUniqueId: string;
|
||||
deploymentKey: string;
|
||||
serverUrl: string;
|
||||
ignoreAppVersion?: boolean
|
||||
}
|
||||
|
||||
declare class AcquisitionStatus {
|
||||
static DeploymentSucceeded: string;
|
||||
static DeploymentFailed: string;
|
||||
}
|
||||
|
||||
declare class AcquisitionManager {
|
||||
constructor(httpRequester: Http.Requester, configuration: Configuration);
|
||||
public queryUpdateWithCurrentPackage(currentPackage: IPackage, callback?: Callback<IRemotePackage | NativeUpdateNotification>): void;
|
||||
public reportStatusDeploy(pkg?: IPackage, status?: string, previousLabelOrAppVersion?: string, previousDeploymentKey?: string, callback?: Callback<void>): void;
|
||||
public reportStatusDownload(pkg: IPackage, callback?: Callback<void>): void;
|
||||
}
|
||||
|
||||
interface CodePushCordovaPlugin {
|
||||
|
||||
/**
|
||||
* Get the current package information.
|
||||
*
|
||||
* @param packageSuccess Callback invoked with the currently deployed package information.
|
||||
* @param packageError Optional callback invoked in case of an error.
|
||||
*/
|
||||
getCurrentPackage(packageSuccess: SuccessCallback<ILocalPackage>, packageError?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Gets the pending package information, if any. A pending package is one that has been installed but the application still runs the old code.
|
||||
* This happends only after a package has been installed using ON_NEXT_RESTART or ON_NEXT_RESUME mode, but the application was not restarted/resumed yet.
|
||||
*/
|
||||
getPendingPackage(packageSuccess: SuccessCallback<ILocalPackage>, packageError?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Checks with the CodePush server if an update package is available for download.
|
||||
*
|
||||
* @param querySuccess Callback invoked in case of a successful response from the server.
|
||||
* The callback takes one RemotePackage parameter. A non-null package is a valid update.
|
||||
* A null package means the application is up to date for the current native application version.
|
||||
* @param queryError Optional callback invoked in case of an error.
|
||||
* @param deploymentKey Optional deployment key that overrides the config.xml setting.
|
||||
*/
|
||||
checkForUpdate(querySuccess: SuccessCallback<IRemotePackage>, queryError?: ErrorCallback, deploymentKey?: string): void;
|
||||
|
||||
/**
|
||||
* Notifies the plugin that the update operation succeeded and that the application is ready.
|
||||
* Calling this function is required on the first run after an update. On every subsequent application run, calling this function is a noop.
|
||||
* If using sync API, calling this function is not required since sync calls it internally.
|
||||
*
|
||||
* @param notifySucceeded Optional callback invoked if the plugin was successfully notified.
|
||||
* @param notifyFailed Optional callback invoked in case of an error during notifying the plugin.
|
||||
*/
|
||||
notifyApplicationReady(notifySucceeded?: SuccessCallback<void>, notifyFailed?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Reloads the application. If there is a pending update package installed using ON_NEXT_RESTART or ON_NEXT_RESUME modes, the update
|
||||
* will be immediately visible to the user. Otherwise, calling this function will simply reload the current version of the application.
|
||||
*/
|
||||
restartApplication(installSuccess: SuccessCallback<void>, errorCallback?: ErrorCallback): void;
|
||||
|
||||
/**
|
||||
* Convenience method for installing updates in one method call.
|
||||
* This method is provided for simplicity, and its behavior can be replicated by using window.codePush.checkForUpdate(), RemotePackage's download() and LocalPackage's install() methods.
|
||||
*
|
||||
* The algorithm of this method is the following:
|
||||
* - Checks for an update on the CodePush server.
|
||||
* - If an update is available
|
||||
* - If the update is mandatory and the alertMessage is set in options, the user will be informed that the application will be updated to the latest version.
|
||||
* The update package will then be downloaded and applied.
|
||||
* - If the update is not mandatory and the confirmMessage is set in options, the user will be asked if they want to update to the latest version.
|
||||
* If they decline, the syncCallback will be invoked with SyncStatus.UPDATE_IGNORED.
|
||||
* - Otherwise, the update package will be downloaded and applied with no user interaction.
|
||||
* - If no update is available on the server, or if a previously rolled back update is available and the ignoreFailedUpdates is set to true, the syncCallback will be invoked with the SyncStatus.UP_TO_DATE.
|
||||
* - If an error occurs during checking for update, downloading or installing it, the syncCallback will be invoked with the SyncStatus.ERROR.
|
||||
*
|
||||
* @param syncCallback Optional callback to be called with the status of the sync operation.
|
||||
* The callback will be called only once, and the possible statuses are defined by the SyncStatus enum.
|
||||
* @param syncOptions Optional SyncOptions parameter configuring the behavior of the sync operation.
|
||||
* @param downloadProgress Optional callback invoked during the download process. It is called several times with one DownloadProgress parameter.
|
||||
*
|
||||
*/
|
||||
sync(syncCallback?: SuccessCallback<SyncStatus>, syncOptions?: SyncOptions, downloadProgress?: SuccessCallback<DownloadProgress>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the possible result statuses of the window.codePush.sync operation.
|
||||
*/
|
||||
declare enum SyncStatus {
|
||||
/**
|
||||
* The application is up to date.
|
||||
*/
|
||||
UP_TO_DATE,
|
||||
|
||||
/**
|
||||
* An update is available, it has been downloaded, unzipped and copied to the deployment folder.
|
||||
* After the completion of the callback invoked with SyncStatus.UPDATE_INSTALLED, the application will be reloaded with the updated code and resources.
|
||||
*/
|
||||
UPDATE_INSTALLED,
|
||||
|
||||
/**
|
||||
* An optional update is available, but the user declined to install it. The update was not downloaded.
|
||||
*/
|
||||
UPDATE_IGNORED,
|
||||
|
||||
/**
|
||||
* An error happened during the sync operation. This might be an error while communicating with the server, downloading or unziping the update.
|
||||
* The console logs should contain more information about what happened. No update has been applied in this case.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* There is an ongoing sync in progress, so this attempt to sync has been aborted.
|
||||
*/
|
||||
IN_PROGRESS,
|
||||
|
||||
/**
|
||||
* Intermediate status - the plugin is about to check for updates.
|
||||
*/
|
||||
CHECKING_FOR_UPDATE,
|
||||
|
||||
/**
|
||||
* Intermediate status - a user dialog is about to be displayed. This status will be reported only if user interaction is enabled.
|
||||
*/
|
||||
AWAITING_USER_ACTION,
|
||||
|
||||
/**
|
||||
* Intermediate status - the update package is about to be downloaded.
|
||||
*/
|
||||
DOWNLOADING_PACKAGE,
|
||||
|
||||
/**
|
||||
* Intermediate status - the update package is about to be installed.
|
||||
*/
|
||||
INSTALLING_UPDATE
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the available install modes for updates.
|
||||
*/
|
||||
declare enum InstallMode {
|
||||
/**
|
||||
* The update will be applied to the running application immediately. The application will be reloaded with the new content immediately.
|
||||
*/
|
||||
IMMEDIATE,
|
||||
|
||||
/**
|
||||
* The update is downloaded but not installed immediately. The new content will be available the next time the application is started.
|
||||
*/
|
||||
ON_NEXT_RESTART,
|
||||
|
||||
/**
|
||||
* The udpate is downloaded but not installed immediately. The new content will be available the next time the application is resumed or restarted, whichever event happends first.
|
||||
*/
|
||||
ON_NEXT_RESUME
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the install operation options.
|
||||
*/
|
||||
interface InstallOptions {
|
||||
/**
|
||||
* Used to specify the InstallMode used for the install operation. This is optional and defaults to InstallMode.ON_NEXT_RESTART.
|
||||
*/
|
||||
installMode?: InstallMode;
|
||||
|
||||
/**
|
||||
* If installMode === ON_NEXT_RESUME, the minimum amount of time (in seconds) which needs to pass with the app in the background before an update install occurs when the app is resumed.
|
||||
*/
|
||||
minimumBackgroundDuration?: number;
|
||||
|
||||
/**
|
||||
* Used to specify the InstallMode used for the install operation if the update is mandatory. This is optional and defaults to InstallMode.IMMEDIATE.
|
||||
*/
|
||||
mandatoryInstallMode?: InstallMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the sync operation options.
|
||||
*/
|
||||
interface SyncOptions extends InstallOptions {
|
||||
/**
|
||||
* Optional boolean flag. If set, previous updates which were rolled back will be ignored. Defaults to true.
|
||||
*/
|
||||
ignoreFailedUpdates?: boolean;
|
||||
|
||||
/**
|
||||
* Used to enable, disable or customize the user interaction during sync.
|
||||
* If set to false, user interaction will be disabled. If set to true, the user will be alerted or asked to confirm new updates, based on whether the update is mandatory.
|
||||
* To customize the user dialog, this option can be set to a custom UpdateDialogOptions instance.
|
||||
*/
|
||||
updateDialog?: boolean | UpdateDialogOptions;
|
||||
|
||||
/**
|
||||
* Overrides the config.xml deployment key when checking for updates.
|
||||
*/
|
||||
deploymentKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the configuration options for the alert or confirmation dialog
|
||||
*/
|
||||
interface UpdateDialogOptions {
|
||||
/**
|
||||
* If a mandatory update is available and this option is set, the message will be displayed to the user in an alert dialog before downloading and installing the update.
|
||||
* The user will not be able to cancel the operation, since the update is mandatory.
|
||||
*/
|
||||
mandatoryUpdateMessage?: string;
|
||||
|
||||
/**
|
||||
* If an optional update is available and this option is set, the message will be displayed to the user in a confirmation dialog.
|
||||
* If the user confirms the update, it will be downloaded and installed. Otherwise, the update update is not downloaded.
|
||||
*/
|
||||
optionalUpdateMessage?: string;
|
||||
|
||||
/**
|
||||
* The title of the dialog box used for interacting with the user in case of a mandatory or optional update.
|
||||
* This title will only be used if at least one of mandatoryUpdateMessage or optionalUpdateMessage options are set.
|
||||
*/
|
||||
updateTitle?: string;
|
||||
|
||||
/**
|
||||
* The label of the confirmation button in case of an optional update.
|
||||
*/
|
||||
optionalInstallButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* The label of the cancel button in case of an optional update.
|
||||
*/
|
||||
optionalIgnoreButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* The label of the continue button in case of a mandatory update.
|
||||
*/
|
||||
mandatoryContinueButtonLabel?: string;
|
||||
|
||||
/**
|
||||
* Flag indicating if the update description provided by the CodePush server should be displayed in the dialog box appended to the update message.
|
||||
*/
|
||||
appendReleaseDescription?: boolean;
|
||||
|
||||
/**
|
||||
* Optional prefix to add to the release description.
|
||||
*/
|
||||
descriptionPrefix?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the JSON format of the package diff manifest file.
|
||||
*/
|
||||
interface IDiffManifest {
|
||||
deletedFiles: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the format of the DownloadProgress object, used to send periodical update notifications on the progress of the update download.
|
||||
*/
|
||||
interface DownloadProgress {
|
||||
totalBytes: number;
|
||||
receivedBytes: number;
|
||||
}
|
||||
77
typings/cordova.d.ts
vendored
77
typings/cordova.d.ts
vendored
@@ -1,77 +0,0 @@
|
||||
// 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.
|
||||
|
||||
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;
|
||||
/** Namespace for Cordova plugin functionality */
|
||||
plugins: CordovaPlugins;
|
||||
}
|
||||
|
||||
interface CordovaPlugins { }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
interface Window {
|
||||
cordova: Cordova;
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
34
typings/device.d.ts
vendored
34
typings/device.d.ts
vendored
@@ -1,34 +0,0 @@
|
||||
// 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;
|
||||
/** 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;
|
||||
/** Get the device's manufacturer. */
|
||||
manufacturer: string;
|
||||
/** Whether the device is running on a simulator. */
|
||||
isVirtual: boolean;
|
||||
/** Get the device hardware serial number. */
|
||||
serial: string;}
|
||||
|
||||
declare var device: Device;
|
||||
69
typings/dialogs.d.ts
vendored
69
typings/dialogs.d.ts
vendored
@@ -1,69 +0,0 @@
|
||||
// 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;
|
||||
}
|
||||
363
typings/fileSystem.d.ts
vendored
363
typings/fileSystem.d.ts
vendored
@@ -1,363 +0,0 @@
|
||||
// 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
|
||||
*/
|
||||
resolveLocalFileSystemURL(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
|
||||
};
|
||||
}
|
||||
136
typings/fileTransfer.d.ts
vendored
136
typings/fileTransfer.d.ts
vendored
@@ -1,136 +0,0 @@
|
||||
// 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 HTTP method to use - either `PUT` or `POST`. Defaults to `POST`. */
|
||||
httpMethod?: 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
|
||||
* FileTransferError.NOT_MODIFIED_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;
|
||||
/* Response body. This attribute is only available when a response is received from the HTTP connection. */
|
||||
body: string;
|
||||
/* 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;
|
||||
NOT_MODIFIED_ERR: number;
|
||||
};
|
||||
Reference in New Issue
Block a user