UNPKG

@dbs-portal/core-module-registry

Version:

Core module registry system for automatic module discovery and registration

101 lines 3.24 kB
/** * Browser-compatible file system utilities * * Provides file system functions that work in browser environments * while maintaining compatibility with Node.js fs/promises API. */ export interface FileSystemUtils { readFile(path: string, encoding?: string): Promise<string>; writeFile(path: string, data: string, encoding?: string): Promise<void>; access(path: string): Promise<void>; stat(path: string): Promise<FileStats>; readdir(path: string): Promise<string[]>; mkdir(path: string, options?: { recursive?: boolean; }): Promise<void>; exists(path: string): Promise<boolean>; } export interface FileStats { isFile(): boolean; isDirectory(): boolean; size: number; mtime: Date; ctime: Date; } declare class BrowserFileSystem implements FileSystemUtils { private cache; private mockFiles; /** * Read file content * In browser environment, this will work with pre-loaded or cached content */ readFile(path: string, _encoding?: string): Promise<string>; /** * Write file content * In browser environment, this stores in memory cache */ writeFile(path: string, data: string, _encoding?: string): Promise<void>; /** * Check file access */ access(path: string): Promise<void>; /** * Get file stats */ stat(path: string): Promise<FileStats>; /** * Read directory contents */ readdir(path: string): Promise<string[]>; /** * Create directory */ mkdir(path: string, _options?: { recursive?: boolean; }): Promise<void>; /** * Check if file exists */ exists(path: string): Promise<boolean>; /** * Pre-load file content (for browser usage) */ preloadFile(path: string, content: string): void; /** * Pre-load directory listing (for browser usage) */ preloadDirectory(path: string, files: string[]): void; /** * Set mock file content (for testing) */ setMockFile(path: string, content: string): void; /** * Clear all cached content */ clearCache(): void; /** * Check if path is a URL */ private isUrl; /** * Check if URL exists */ private checkUrlExists; } declare const browserFs: BrowserFileSystem; export declare const readFile: (path: string, _encoding?: string) => Promise<string>; export declare const writeFile: (path: string, data: string, _encoding?: string) => Promise<void>; export declare const access: (path: string) => Promise<void>; export declare const stat: (path: string) => Promise<FileStats>; export declare const readdir: (path: string) => Promise<string[]>; export declare const mkdir: (path: string, _options?: { recursive?: boolean; }) => Promise<void>; export declare const exists: (path: string) => Promise<boolean>; export declare const preloadFile: (path: string, content: string) => void; export declare const preloadDirectory: (path: string, files: string[]) => void; export declare const setMockFile: (path: string, content: string) => void; export declare const clearCache: () => void; export default browserFs; export { BrowserFileSystem }; //# sourceMappingURL=browser-fs.d.ts.map