feat: add TypeScript bindings for cache IPC commands
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
60
src/lib/bindings/cache.ts
Normal file
60
src/lib/bindings/cache.ts
Normal file
@@ -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<CachedAnalysis | null> {
|
||||||
|
return invoke<CachedAnalysis | null>('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<void> {
|
||||||
|
return invoke<void>('save_analysis_to_cache', {
|
||||||
|
url,
|
||||||
|
title,
|
||||||
|
duration,
|
||||||
|
fps,
|
||||||
|
waveformTiers,
|
||||||
|
keyframePositions,
|
||||||
|
thumbnailSpritesheets,
|
||||||
|
captionFilePath,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function clearVideoCache(url: string): Promise<void> {
|
||||||
|
return invoke<void>('clear_video_cache', { url });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function clearAllCache(): Promise<void> {
|
||||||
|
return invoke<void>('clear_all_cache');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCacheStats(): Promise<CacheStats> {
|
||||||
|
return invoke<CacheStats>('get_cache_stats');
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getThumbnailCacheDir(url: string): Promise<string> {
|
||||||
|
return invoke<string>('get_thumbnail_cache_dir', { url });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getCaptionCacheDir(url: string): Promise<string> {
|
||||||
|
return invoke<string>('get_caption_cache_dir', { url });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user