native-update
Version:
Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.
76 lines (75 loc) • 2.06 kB
TypeScript
import type { DownloadProgressEvent } from '../definitions';
/**
* Manages file downloads with progress tracking and resume capability
*/
export declare class DownloadManager {
private activeDownloads;
private readonly logger;
private readonly configManager;
private filesystem;
constructor();
/**
* Initialize the download manager
*/
initialize(): Promise<void>;
/**
* Validate URL against allowed hosts
*/
private validateUrl;
/**
* Download a file with progress tracking
*/
download(url: string, bundleId: string, onProgress?: (event: DownloadProgressEvent) => void): Promise<Blob>;
/**
* Resume a previously interrupted download
*/
resumeDownload(url: string, bundleId: string, partialData: Blob, onProgress?: (event: DownloadProgressEvent) => void): Promise<Blob>;
/**
* Check if a download can be resumed
*/
canResume(url: string): Promise<boolean>;
/**
* Validate content type
*/
private isValidContentType;
/**
* Validate blob size
*/
private validateBlobSize;
/**
* Cancel a download
*/
cancelDownload(bundleId: string): void;
/**
* Cancel all active downloads
*/
cancelAllDownloads(): void;
/**
* Check if a download is active
*/
isDownloading(bundleId: string): boolean;
/**
* Get active download count
*/
getActiveDownloadCount(): number;
/**
* Download with retry logic
*/
downloadWithRetry(url: string, bundleId: string, onProgress?: (event: DownloadProgressEvent) => void): Promise<Blob>;
/**
* Convert blob to ArrayBuffer
*/
blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer>;
/**
* Save blob to filesystem
*/
saveBlob(bundleId: string, blob: Blob): Promise<string>;
/**
* Load blob from filesystem
*/
loadBlob(bundleId: string): Promise<Blob | null>;
/**
* Delete blob from filesystem
*/
deleteBlob(bundleId: string): Promise<void>;
}