import { WorkingState } from "../../types"; type Bytes = Uint8Array; type RawFileData = string | Bytes; export type FileSource = { kind: "blob"; blob: Blob; } | { kind: "opfs"; handle: any; } | { kind: "url"; url: string; headers?: Record; } | { kind: "stream"; openRead: () => AsyncIterable; size?: number; }; export declare enum FileNodeKind { Memory = "file", Disk = "stub", Network = "network" } export declare enum DirNodeKind { DIR = "dir" } interface BaseFileNode { kind: FileNodeKind; name: string; path?: string; size?: number; mime?: string; checksum?: string; extra?: Record; } export interface StubFileNode extends BaseFileNode { kind: FileNodeKind.Disk; source: FileSource; } export interface MemoryFileNode extends BaseFileNode { kind: FileNodeKind.Memory; data: Bytes; } export type FileNode = StubFileNode | MemoryFileNode; export interface DirNode { kind: DirNodeKind.DIR; name: string; children: Map; } export type VNode = DirNode | FileNode; export declare class MemoryFS { private root; /** * Creates directory (including parent directories) * @param path - The directory path to create */ mkdirp(path: string): void; /** * Writes file data to memory (creates parent directories if needed) * @param path - The file path * @param data - File content as string or Uint8Array * @param mime - Optional MIME type */ writeMemoryFile(path: string, data: RawFileData, mime?: string): void; /** * Registers a stub node (no bytes in RAM) that references external data sources * @param path - The stub path * @param stub - Stub configuration (omit name and kind, they're auto-set) */ writeStubFile(path: string, stub: Omit & { name?: string; }): void; /** * Reads file into memory (Uint8Array). MUST throw for stub nodes to avoid loading GB files into RAM. * @param path - The file path * @returns File data as Uint8Array * @throws Error if path is not a file or if it's a stub */ readFile(path: string): Bytes; readWorkingState(path?: string): WorkingState | undefined; /** * Checks if a path exists * @param path - The path to check * @returns True if path exists */ exists(path: string): boolean; /** * Gets node (file, dir, or stub) at path * @param path - The path to get * @returns The node or undefined if not found */ getNode(path: string): VNode | undefined; /** * Lists directory contents (non-recursive) * @param dirPath - Directory path (defaults to root) * @returns Array of directory entries */ list(dirPath?: string): { name: string; path: string; kind: "file" | "dir" | "stub"; size?: number; mime?: string; }[]; /** * Recursively walks directory tree (depth-first) * @param dirPath - Directory path (defaults to root) * @returns Array of all entries in the tree */ walk(dirPath?: string): { name: string; path: string; kind: "file" | "dir" | "stub"; size?: number; mime?: string; }[]; /** * Renders directory tree in a pretty format * @param dirPath - Directory path (defaults to root) * @returns Pretty-printed tree string */ tree(dirPath?: string): string; /** * Gets basic metadata for a path * @param path - The path to stat * @returns Basic stat information */ stat(path: string): { kind: "dir" | "file" | "stub"; size?: number; mime?: string; }; /** * Opens a unified streaming reader for file or stub (never buffers entire content) * @param path - The path to open for reading * @returns AsyncIterable that yields chunks of data */ openRead(path: string): AsyncIterable; /** * Turns stub into file node by fully loading bytes into memory * WARNING: Dangerous for large files! Only use for small files. * @param path - Path to the stub to materialize */ materialize(path: string): Promise; /** * Exports ZIP with everything in-memory; streams stubs into entries without buffering * @param jszip - JSZip constructor or instance * @returns ZIP blob */ toZipBlob(jszip: any): Promise; } export {}; /** * Basic unit tests - uncomment to run */ //# sourceMappingURL=memory-fs.d.ts.map