/** * Versioned filesystem cache of a remote pose-runtime payload (legacy * stub-loader helper). * * The light SDK’s default path does **not** use this cache: TF.js loads from * CDN and the model from a URL inside the WebView each boot. This class * remains exported for advanced hosts that still want to download / verify * Strapi `/api/sdk/pose-runtime` parts. * * Guarantees when used: * - sha256 is verified BEFORE a part is committed to the cache. * - `purge()` on revocation signals. */ import type { PoseRuntimeDescriptor } from '../types/manifest'; import { type FileStore } from '../engine/EngineLoader'; /** Decoded, ready-to-inject runtime parts. */ export interface PoseRuntimeParts { version: string; /** TF.js bundle (core + converter + webgl + wasm backends). */ tfjsJs: string; /** XNNPACK wasm binaries (base64). */ tfjsWasmB64: { plain: string; simd: string; threadedSimd: string; }; /** MoveNet graph model topology (raw model.json). */ modelJson: string; /** Weight shards (base64, manifest order). */ weightsB64: string[]; /** Proprietary pose pipeline wasm (base64), null when not deployed. */ pipelineWasmB64: string | null; /** Page runtime (camera, presets, inference loop, events). */ runtimeJs: string; } export interface RuntimeCacheProgress { part: string; completedParts: number; totalParts: number; /** Bytes of the part being downloaded (from the manifest). */ partBytes: number; } export interface RuntimeCacheOptions { fileStore?: FileStore | null; /** Injectable for tests. */ fetchFn?: typeof fetch; } export declare class RuntimeCache { private readonly files; private readonly fetchFn; private memoryParts; /** True when no persistent FS module is installed (memory-only fallback). */ readonly persistent: boolean; constructor(options?: RuntimeCacheOptions); /** Version currently committed to the cache, or null when cold/empty. */ getCachedVersion(): Promise; /** * Ensure the cache holds the version described by the manifest. Downloads * only what is missing/outdated; every part is checksum-verified BEFORE * being committed. The previous version keeps serving until the new one is * fully committed (atomic flip of `current.json`, then best-effort GC). * * Returns true when the cache is warm (either already up-to-date or * successfully updated); false when it could not be warmed (offline...) — * the caller decides whether a stale/absent cache is acceptable. */ warm(descriptor: PoseRuntimeDescriptor | null, onProgress?: (progress: RuntimeCacheProgress) => void): Promise; /** Load (and decode) the committed runtime parts; null when cache is cold. */ load(): Promise; /** Wipe the whole runtime cache (revocation / recovery). */ purge(): Promise; private isKnownPart; private readCurrent; private readVerified; }