/** * Lazy-loading filesystem from CDN with IndexedDB cache and hash invalidation. */ import type { FSManifest, FSStats, IFileSystem, ManifestEntry } from 'emception'; export type { FSManifest } from 'emception'; export type FileEntry = ManifestEntry; export declare class LazyFS implements IFileSystem { private manifest; /** * Optional injected brotli decompressor. * When set, used instead of the bundled Emscripten-compiled Brotli WASM * module (brotli_wasm.js) which is loaded from the CDN at runtime. */ static customBrotliDecompressor: ((data: Uint8Array) => Uint8Array) | null; private pendingFetches; private pendingBundles; private blobUrls; /** Track which bundles have been fully extracted to IDB. */ private loadedBundles; private idb; private dbName; /** * Pre-computed directory index: maps each directory path to the set of * immediate child names (files and subdirectories). Built once from the * manifest during construction. Enables O(1) readdir/exists lookups * without scanning all manifest keys. */ private dirIndex; private static readonly P; private static fmtSize; constructor(manifest: FSManifest, dbName?: string); /** * Build the directory index from manifest file paths. * For each file /a/b/c.txt, adds: * dirIndex['/a/b'] = { 'c.txt' } * dirIndex['/a'] = { 'b' } * dirIndex['/'] = { 'a' } */ private buildDirIndex; init(): Promise; private invalidateStaleCache; private openDatabase; readFile(path: string): Promise; /** Create a blob URL for a file (used for .wasm/.mjs/.js that need URL-based loading). */ private createBlobUrl; private fetchFile; private loadBundle; private loadBundleImpl; /** * Batch-write multiple entries to IDB in a single transaction. * Much faster than one transaction per file for large bundles. */ private idbPutBatch; private extractTar; exists(path: string): Promise; /** Synchronous existence check using manifest + dirIndex (O(1)). */ existsSync(path: string): boolean; stat(path: string): Promise; /** Synchronous stat from manifest metadata + dirIndex (O(1)). */ statSync(path: string): FSStats | null; readdir(path: string): Promise; /** Synchronous readdir from pre-computed dirIndex (O(1)). */ readdirSync(path: string): string[]; /** * Synchronous file read — always returns null. * File data is no longer cached in RAM; use the async readFile() path * (via Asyncify hooks) to load from IDB/CDN on demand. */ readFileSync(_path: string): Uint8Array | null; preload(paths: string[]): Promise; /** Preload a specific bundle by name. Downloads and extracts all files into IDB. */ preloadBundle(bundleName: string): Promise; /** Preload all bundles in parallel. */ preloadAllBundles(): Promise; /** * Preload all files under a directory path into IDB. * Uses the dirIndex for efficient path enumeration instead of * scanning all manifest keys. */ preloadDir(dirPath: string): Promise; /** * Recursively collect all file paths under a directory using the dirIndex. */ private collectFilesInDir; /** Get the bundle name a file belongs to, or undefined. */ getBundleForFile(path: string): string | undefined; /** Get all file paths belonging to a bundle. */ getBundleFilePaths(bundleName: string): string[]; /** Async version of getUrl: ensures the file's bundle is loaded first, then returns blob URL. */ getUrlAsync(path: string): Promise; writeFile(): Promise; deleteFile(): Promise; mkdir(): Promise; getUrl(path: string): string; private normalizePath; private resolveSymlink; /** Cache for manifest-unlisted files fetched individually over HTTP. */ private unlistedCache; /** * CDN prefixes where unlisted files legitimately exist (tool sources the * LazyFS HTTP fallback serves). Everything else — workspace paths the IDE * probes, /tmp, etc. — must return null without a network round-trip, * otherwise every existence probe becomes a spurious 404 fetch. */ private static readonly UNLISTED_FETCH_PREFIXES; private fetchUnlistedFile; private idbGet; private idbPut; private readTarString; private computeHash; private decompressGzip; private decompressBrotli; } //# sourceMappingURL=lazy.d.ts.map