import { File } from '@ionic-native/file/ngx'; import { HttpClient } from '@angular/common/http'; import { Platform } from '@ionic/angular'; import { ImageLoaderConfig } from './image-loader-config'; import { WebView } from '@ionic-native/ionic-webview/ngx'; export declare class ImageLoader { private config; private file; private http; private platform; private webview; /** * Indicates if the cache service is ready. * When the cache service isn't ready, images are loaded via browser instead. */ private isCacheReady; /** * Indicates if this service is initialized. * This service is initialized once all the setup is done. */ private isInit; /** * Number of concurrent requests allowed */ private concurrency; /** * Queue items */ private queue; private processing; /** * Fast accessable Object for currently processing items */ private currentlyProcessing; private cacheIndex; private currentCacheSize; private indexed; constructor(config: ImageLoaderConfig, file: File, http: HttpClient, platform: Platform, webview: WebView); readonly nativeAvailable: boolean; private readonly isCacheSpaceExceeded; private readonly isIonicWebview; private readonly isDevServer; /** * Check if we can process more items in the queue */ private readonly canProcess; /** * Preload an image * @param imageUrl {string} Image URL */ preload(imageUrl: string): Promise; /** * Clears the cache */ clearCache(): void; /** * Gets the filesystem path of an image. * This will return the remote path if anything goes wrong or if the cache service isn't ready yet. * @param imageUrl {string} The remote URL of the image */ getImagePath(imageUrl: string): Promise; /** * Returns if an imageUrl is an relative path * @param imageUrl */ private isImageUrlRelative; /** * Add an item to the queue * @param imageUrl * @param resolve * @param reject */ private addItemToQueue; getFileCacheDirectory(): string; /** * Processes one item from the queue */ private processQueue; /** * Search if the url is currently in the queue * @param imageUrl {string} Image url to search */ private currentlyInQueue; /** * Initialize the cache service * @param replace {boolean} Whether to replace the cache directory if it already exists */ private initCache; /** * Adds a file to index. * Also deletes any files if they are older than the set maximum cache age. * @param file {FileEntry} File to index */ private addFileToIndex; /** * Indexes the cache if necessary */ private indexCache; /** * This method runs every time a new file is added. * It checks the cache size and ensures that it doesn't exceed the maximum cache size set in the config. * If the limit is reached, it will delete old images to create free space. */ private maintainCacheSize; /** * Remove a file * @param file {string} The name of the file to remove */ private removeFile; /** * Get the local path of a previously cached image if exists * @param url {string} The remote URL of the image */ private getCachedImagePath; /** * Throws a console error if debug mode is enabled * @param args {any[]} Error message */ private throwError; /** * Throws a console warning if debug mode is enabled * @param args {any[]} Error message */ private throwWarning; /** * Check if the cache directory exists * @param directory {string} The directory to check. Either this.file.tempDirectory or this.file.cacheDirectory */ private cacheDirectoryExists; /** * Create the cache directories * @param replace {boolean} override directory if exists */ private createCacheDirectory; /** * Creates a unique file name out of the URL * @param url {string} URL of the file */ private createFileName; /** * Converts a string to a unique 32-bit int * @param string {string} string to hash */ private hashString; /** * extract extension from filename or url * * @param filename */ private getExtensionFromFileName; }