Merge pull request #32881 from DefinitelyTyped/revert-cordova-plugin-background-download

Revert "Merge pull request #32709 from MrBullfinsh/cordova-plugin-bac…
This commit is contained in:
Nathan Shively-Sanders
2019-02-07 16:21:39 -08:00
committed by GitHub
4 changed files with 0 additions and 137 deletions
@@ -1,24 +0,0 @@
let fileName = "PointerEventsCordovaPlugin.wmv";
let uriString = "http://media.ch9.ms/ch9/8c03/f4fe2512-59e5-4a07-bded-124b06ac8c03/PointerEventsCordovaPlugin.wmv";
// open target file for download
(window as any).requestFileSystem(1, 0, (fileSystem: any) => {
fileSystem.root.getFile(fileName, { create: true }, (targetFile: File) => {
// plugin callbacks to track operation execution status and progress
const onSuccess = () => {
console.log('Done');
};
const onError = (err: any) => {
console.log(err);
};
const onProgress = (progress: BackgroundTransfer.Progress) => {
console.log((100 * progress.bytesReceived / progress.totalBytesToReceive) + '%');
};
const downloader = new BackgroundTransfer.BackgroundDownloader();
// Create a new download operation.
const download = downloader.createDownload(uriString, targetFile);
// Start the download and persist the promise to be able to cancel the download.
const downloadPromise = download.startAsync().then(onSuccess, onError, onProgress);
});
});
-86
View File
@@ -1,86 +0,0 @@
// Type definitions for cordova-plugin-background-download 0.5
// Project: https://github.com/sgrebnov/cordova-plugin-background-download
// Definitions by: Tobias Gimpel <https://github.com/mrbullfinsh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
/**
* Provides an advanced file transfer functionality that persists beyond app termination and
* runs in the background. Background transfer doesn't support concurrent downloads of the same uri.
*/
declare namespace BackgroundTransfer {
class BackgroundDownloader {
/**
* Initializes a new instance of BackgroundDownloader object.
* Used to configure downloads prior to the actual creation of the download operation using CreateDownload.
*
* @param uriMatcher The regexp to compare location of the resources with already downloading ones.
*/
constructor(uriMatcher?: RegExp);
/**
* Initializes a DownloadOperation object that contains the specified Uri and the file that the response is written to.
*
* @param uri The location of the resource.
* @param resultFile The file that the response will be written to.
* @param notificationTitle The title for downloading in notification.
*/
createDownload(uri: string, resultFile: File, notificationTitle?: string): DownloadOperation;
}
interface Progress {
bytesReceived: number;
totalBytesToReceive: number;
}
/**
* Provides a mechanism for managing interactions with asynchronous APIs based on Promises.
* See 'Asynchronous programming in JavaScript' for more details
* http://msdn.microsoft.com/en-us/library/windows/apps/hh700330.aspx
* http://msdn.microsoft.com/en-us/library/windows/apps/br211867.aspx
* Note. Functionality is limited, support of .then and .cancel methods only, other methods are in progress.
*/
interface Promise {
_completeCallbacks: Array<() => void>;
_errorCallbacks: Array<(error: any) => void>;
_progressCallbacks: Array<(progress: Progress) => void>;
_chainedDefer: Deferral;
_state: 'pending' | 'resolved' | 'rejected' | 'cancelled';
result: any;
then(onComplete?: () => void, onError?: (error: any) => void, onProgress?: (progress: Progress) => void): Promise;
/**
* Attempts to cancel the fulfillment of a promised value. If the promise hasn't already been fulfilled and
* cancellation is supported, the promise enters the error state with a value of Error("Canceled").
* http://msdn.microsoft.com/en-us/library/windows/apps/br211667.aspx
* @param flag
*/
cancel(flag?: boolean): void;
executeCallback(callback: (() => void) | ((error: any) => void) | ((progress: Progress) => void), args: any): void;
}
interface Deferral {
resolve(data: any): void;
reject(error: any): void;
notify(value: any): void;
bind(promise: Promise): void;
}
}
declare class DownloadOperation {
/**
* Performs an asynchronous download operation in the background.
*
* @param uri The location of the resource.
* @param resultFile The file that the response will be written to.
* @param uriMatcher The regexp to compare location of the resources with already downloading ones.
* @param notificationTitle The title for downloading in notification.
*/
constructor(uri: string, resultFile: File, uriMatcher?: RegExp, notificationTitle?: string);
/**
* Starts an asynchronous download operation.
*/
startAsync(): BackgroundTransfer.Promise;
/**
* Stops a download operation.
*/
stop(): void;
}
@@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cordova-plugin-background-download-tests.ts"
]
}
@@ -1,3 +0,0 @@
{
"extends": "dtslint/dt.json"
}