Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Owns the OPFS metadata file (_cache_meta.json) lifecycle: load + parse on init, debounced save on mutation, orphan cleanup when the file is corrupt, and the in-flight + pending-timer state that lets OPFSStore.dispose() flush cleanly.

    Counters (parseFailures, orphansRemoved) are surfaced through OPFSStore.getStats().

    Index
    parseFailures: number = 0
    orphansRemoved: number = 0
    timer: Timeout | null = null
    inFlight: Promise<void> | null = null
    • Read and parse _cache_meta.json. Returns null on cold start (file missing). On parse failure, returns a fresh snapshot with needsOrphanCleanup = true and increments parseFailures — caller should run cleanupOrphans to reclaim stray files.

      Parameters

      • root: FileSystemDirectoryHandle

      Returns Promise<LoadOutcome | null>

    • Schedule a debounced metadata save. Replaces any previously- scheduled save (last writer wins on the timer). When the timer fires, getSnapshot is called to produce the latest state and the file is written; failures invoke onError.

      Parameters

      • params: {
            root: FileSystemDirectoryHandle;
            getSnapshot: () => MetadataSnapshot;
            delayMs: number;
            onError: (error: unknown) => void;
        }

      Returns void

    • Reclaim OPFS files that exist on disk but have no entry in the provided expected set. Called from OPFSStore.init() after a metadata-parse failure; safe to skip otherwise (the cache rebuilds itself in seconds and orphans are bounded by quota).

      Increments orphansRemoved per file actually deleted.

      shouldStop is re-polled across the crawl's awaits; when it turns true (the owning store was disposed) the crawl halts before its next delete, so a stale expected-set can never keep reclaiming files a newer same-URL store is concurrently writing.

      Parameters

      • root: FileSystemDirectoryHandle
      • expectedFileNames: Set<string>
      • OptionalshouldStop: () => boolean

      Returns Promise<void>