diff --git a/src/lib/bindings/cache.ts b/src/lib/bindings/cache.ts new file mode 100644 index 0000000..4ede901 --- /dev/null +++ b/src/lib/bindings/cache.ts @@ -0,0 +1,60 @@ +import { invoke } from '@tauri-apps/api/core'; +import type { WaveformTiers, ThumbnailSpritesheet } from '$lib/bindings/mediaAnalysis'; + +export interface CachedAnalysis { + waveformTiers: WaveformTiers | null; + keyframePositions: number[]; + thumbnailSpritesheets: ThumbnailSpritesheet[]; + captionFilePath: string | null; +} + +export interface CacheStats { + entryCount: number; + totalBytes: number; +} + +export async function loadCachedAnalysis(url: string): Promise { + return invoke('load_cached_analysis', { url }); +} + +export async function saveAnalysisToCache( + url: string, + title: string, + duration: number, + fps: number, + waveformTiers: WaveformTiers | null, + keyframePositions: number[], + thumbnailSpritesheets: ThumbnailSpritesheet[], + captionFilePath: string | null +): Promise { + return invoke('save_analysis_to_cache', { + url, + title, + duration, + fps, + waveformTiers, + keyframePositions, + thumbnailSpritesheets, + captionFilePath, + }); +} + +export async function clearVideoCache(url: string): Promise { + return invoke('clear_video_cache', { url }); +} + +export async function clearAllCache(): Promise { + return invoke('clear_all_cache'); +} + +export async function getCacheStats(): Promise { + return invoke('get_cache_stats'); +} + +export async function getThumbnailCacheDir(url: string): Promise { + return invoke('get_thumbnail_cache_dir', { url }); +} + +export async function getCaptionCacheDir(url: string): Promise { + return invoke('get_caption_cache_dir', { url }); +}