opfs-worker 0.3.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/raw.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"raw.js","sources":["../src/worker.ts"],"sourcesContent":["import { expose } from 'comlink';\n\nimport { decodeBuffer } from './utils/encoder';\nimport {\n FileNotFoundError,\n OPFSError,\n OPFSNotMountedError,\n PathError\n} from './utils/errors';\n\nimport { \n calculateFileHash, \n checkOPFSSupport, \n joinPath, \n readFileData, \n splitPath, \n writeFileData,\n basename,\n dirname,\n normalizePath,\n resolvePath,\n convertBlobToUint8Array\n} from './utils/helpers';\n\nimport type { DirentData, FileStat, WatchEvent, OPFSOptions } from './types';\nimport type { BufferEncoding } from 'typescript';\n\n/**\n * OPFS (Origin Private File System) File System implementation\n * \n * This class provides a high-level interface for working with the browser's\n * Origin Private File System API, offering file and directory operations\n * similar to Node.js fs module.\n * \n * @example\n * ```typescript\n * const fs = new OPFSFileSystem();\n * await fs.init('/my-app');\n * await fs.writeFile('/data/config.json', JSON.stringify({ theme: 'dark' }));\n * const config = await fs.readFile('/data/config.json');\n * ```\n */\nexport class OPFSWorker {\n /** Root directory handle for the file system */\n private root: FileSystemDirectoryHandle | null = null;\n \n /** Map of watched paths to their last known state */\n private watchers = new Map<string, Map<string, FileStat>>();\n\n /** Interval handle for polling watched paths */\n private watchTimer: ReturnType<typeof setInterval> | null = null;\n\n /** Flag to avoid concurrent scans */\n private scanning = false;\n\n /** Promise to prevent concurrent mount operations */\n private mountingPromise: Promise<boolean> | null = null;\n\n /** BroadcastChannel instance for sending events */\n private broadcastChannel: BroadcastChannel | null = null;\n\n /** Configuration options */\n private options: Required<OPFSOptions> = {\n watchInterval: 1000,\n maxFileSize: 50 * 1024 * 1024,\n hashAlgorithm: null,\n broadcastChannel: 'opfs-worker',\n };\n \n\n /**\n * Notify about internal changes to the file system\n * \n * This method is called by internal operations to notify clients about\n * changes, even when no specific paths are being watched.\n * \n * @param path - The path that was changed\n * @param type - The type of change (create, change, delete)\n */\n private async notifyChange(event: Omit<WatchEvent, 'timestamp' | 'hash' | 'root'>): Promise<void> {\n if (!this.options.broadcastChannel) {\n return;\n }\n\n // Calculate hash if hashing is enabled and this is a file operation\n let hash: string | undefined;\n \n if (this.options.hashAlgorithm && !event.isDirectory && event.type !== 'removed') {\n try {\n const stats = await this.stat(event.path);\n\n if (stats.isFile && stats.hash) {\n hash = stats.hash;\n }\n } \n catch (error) {\n console.warn(`Failed to calculate hash for ${event.path}:`, error);\n }\n }\n\n // Send event via BroadcastChannel\n try {\n if (!this.broadcastChannel) {\n this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel);\n }\n \n const watchEvent: WatchEvent = {\n root: this.root!.name,\n timestamp: new Date().toISOString(),\n ...event,\n ...(hash && { hash })\n };\n \n this.broadcastChannel.postMessage(watchEvent);\n } \n catch (error) {\n console.warn(`Failed to send event via BroadcastChannel:`, error);\n }\n }\n\n /**\n * Creates a new OPFSFileSystem instance\n * \n * @param options - Optional configuration options\n * @param options.watchInterval - Polling interval in milliseconds for file watching\n * @param options.hashAlgorithm - Hash algorithm for file hashing\n * @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)\n * @throws {OPFSError} If OPFS is not supported in the current browser\n */\n constructor(options?: OPFSOptions) {\n checkOPFSSupport();\n \n if (options) {\n this.setOptions(options);\n }\n \n void this.mount('/');\n }\n\n /**\n * Initialize the file system within a given directory\n * \n * This method sets up the root directory for all subsequent operations.\n * If no root is specified, it will use the OPFS root directory.\n * \n * @param root - The root path for the file system (default: '/')\n * @returns Promise that resolves to true if initialization was successful\n * @throws {OPFSError} If initialization fails\n * \n * @example\n * ```typescript\n * const fs = new OPFSFileSystem();\n * \n * // Use OPFS root (default)\n * await fs.mount();\n * \n * // Use custom directory\n * await fs.mount('/my-app');\n * ```\n */\n async mount(root: string = '/'): Promise<boolean> {\n // If already mounting, wait for previous operation to complete first\n if (this.mountingPromise) {\n await this.mountingPromise;\n }\n\n this.mountingPromise = new Promise<boolean>(async(resolve, reject) => {\n this.root = null;\n \n try {\n const rootDir = await navigator.storage.getDirectory();\n \n if (root === '/') {\n this.root = rootDir;\n } \n else {\n this.root = await this.getDirectoryHandle(root, true, rootDir);\n }\n \n resolve(true);\n }\n catch (error) {\n console.error(error);\n reject(new OPFSError('Failed to initialize OPFS', 'INIT_FAILED'));\n }\n finally {\n this.mountingPromise = null;\n }\n });\n\n return this.mountingPromise;\n }\n\n\n /**\n * Update configuration options\n * \n * @param options - Configuration options to update\n * @param options.watchInterval - Polling interval in milliseconds for file watching\n * @param options.hashAlgorithm - Hash algorithm for file hashing\n * @param options.maxFileSize - Maximum file size for hashing in bytes\n * @param options.broadcastChannel - Custom name for the broadcast channel\n */\n setOptions(options: OPFSOptions): void {\n if (options.watchInterval !== undefined) {\n this.options.watchInterval = options.watchInterval;\n }\n\n if (options.hashAlgorithm !== undefined) {\n this.options.hashAlgorithm = options.hashAlgorithm;\n }\n\n if (options.maxFileSize !== undefined) {\n this.options.maxFileSize = options.maxFileSize;\n }\n\n if (options.broadcastChannel !== undefined) {\n // Close existing channel if name changed\n if (this.broadcastChannel && this.options.broadcastChannel !== options.broadcastChannel) {\n this.broadcastChannel.close();\n this.broadcastChannel = null;\n }\n \n this.options.broadcastChannel = options.broadcastChannel;\n }\n }\n\n /**\n * Automatically mount the OPFS root if not already mounted\n * \n * This method is called internally when file operations are performed\n * without explicitly mounting first.\n * \n * @returns Promise that resolves when auto-mount is complete\n * @throws {OPFSError} If auto-mount fails\n */\n private async ensureMounted(): Promise<void> {\n // If already mounted, return immediately\n if (this.root) {\n return;\n }\n\n // If already mounting, wait for that operation to complete\n if (this.mountingPromise) {\n await this.mountingPromise;\n return;\n }\n\n throw new OPFSError('OPFS not mounted', 'NOT_MOUNTED');\n }\n\n /**\n * Get a directory handle from a path\n * \n * Navigates through the directory structure to find or create a directory\n * at the specified path.\n * \n * @param path - The path to the directory (string or array of segments)\n * @param create - Whether to create the directory if it doesn't exist (default: false)\n * @param from - The directory to start from (default: root directory)\n * @returns Promise that resolves to the directory handle\n * @throws {OPFSError} If the directory cannot be accessed or created\n * \n * @example\n * ```typescript\n * const docsDir = await fs.getDirectoryHandle('/users/john/documents', true);\n * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);\n * ```\n */\n private async getDirectoryHandle(path: string | string[], create: boolean = false, from: FileSystemDirectoryHandle | null = this.root): Promise<FileSystemDirectoryHandle> {\n if (!from) {\n throw new OPFSNotMountedError();\n }\n\n const segments = Array.isArray(path) ? path : splitPath(path);\n let current = from;\n\n for (const segment of segments) {\n current = await current.getDirectoryHandle(segment, { create });\n }\n\n return current;\n }\n\n /**\n * Get a file handle from a path\n * \n * Navigates to the parent directory and retrieves or creates a file handle\n * for the specified file path.\n * \n * @param path - The path to the file (string or array of segments)\n * @param create - Whether to create the file if it doesn't exist (default: false)\n * @param from - The directory to start from (default: root directory)\n * @returns Promise that resolves to the file handle\n * @throws {PathError} If the path is empty\n * @throws {OPFSError} If the file cannot be accessed or created\n * \n * @example\n * ```typescript\n * const fileHandle = await fs.getFileHandle('/config/settings.json', true);\n * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);\n * ```\n */\n private async getFileHandle(path: string | string[], create = false, from: FileSystemDirectoryHandle | null = this.root): Promise<FileSystemFileHandle> {\n if (!from) {\n throw new OPFSNotMountedError();\n }\n\n const segments = splitPath(path);\n\n if (segments.length === 0) {\n throw new PathError('Path must not be empty', Array.isArray(path) ? path.join('/') : path);\n }\n\n const fileName = segments.pop()!;\n const dir = await this.getDirectoryHandle(segments, create, from);\n\n return dir.getFileHandle(fileName, { create });\n }\n\n\n /**\n * Get a complete index of all files and directories in the file system\n * \n * This method recursively traverses the entire file system and returns\n * a Map containing FileStat objects for every file and directory.\n * \n * @returns Promise that resolves to a Map of paths to FileStat objects\n * @throws {OPFSError} If the file system is not mounted\n * \n * @example\n * ```typescript\n * const index = await fs.index();\n * const fileStats = index.get('/data/config.json');\n * if (fileStats) {\n * console.log(`File size: ${fileStats.size} bytes`);\n * if (fileStats.hash) console.log(`Hash: ${fileStats.hash}`);\n * }\n * ```\n */\n async index(): Promise<Map<string, FileStat>> {\n const result = new Map<string, FileStat>();\n\n const walk = async(dirPath: string) => {\n const items = await this.readDir(dirPath);\n\n for (const item of items) {\n const fullPath = `${ dirPath === '/' ? '' : dirPath }/${ item.name }`;\n\n try {\n const stat = await this.stat(fullPath);\n\n result.set(fullPath, stat);\n\n if (stat.isDirectory) {\n await walk(fullPath);\n }\n }\n catch (err) {\n console.warn(`Skipping broken entry: ${ fullPath }`, err);\n }\n }\n };\n\n result.set('/', {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n });\n\n await walk('/');\n\n return result;\n }\n\n /**\n * Read a file from the file system\n * \n * Reads the contents of a file and returns it as a string or binary data\n * depending on the specified encoding.\n * \n * @param path - The path to the file to read\n * @param encoding - The encoding to use for reading the file\n * @returns Promise that resolves to the file contents\n * @throws {FileNotFoundError} If the file does not exist\n * @throws {OPFSError} If reading the file fails\n * \n * @example\n * ```typescript\n * // Read as text\n * const content = await fs.readFile('/config/settings.json');\n * \n * // Read as binary\n * const binaryData = await fs.readFile('/images/logo.png', 'binary');\n * \n * // Read with specific encoding\n * const utf8Content = await fs.readFile('/data/utf8.txt', 'utf-8');\n * ```\n */\n async readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: string, encoding?: BufferEncoding): Promise<string>;\n async readFile(\n path: string,\n encoding: BufferEncoding | 'binary' = 'utf-8'\n ): Promise<string | Uint8Array> {\n await this.ensureMounted();\n \n try {\n const fileHandle = await this.getFileHandle(path, false);\n const buffer = await readFileData(fileHandle);\n\n if (encoding === 'binary') {\n return buffer;\n }\n\n return decodeBuffer(buffer, encoding);\n }\n catch (err) {\n console.error(err);\n\n throw new FileNotFoundError(path);\n }\n }\n\n /**\n * Write data to a file\n * \n * Creates or overwrites a file with the specified data. If the file already\n * exists, it will be truncated before writing.\n * \n * @param path - The path to the file to write\n * @param data - The data to write to the file (string, Uint8Array, or ArrayBuffer)\n * @param encoding - The encoding to use when writing string data (default: 'utf-8')\n * @returns Promise that resolves when the write operation is complete\n * @throws {OPFSError} If writing the file fails\n * \n * @example\n * ```typescript\n * // Write text data\n * await fs.writeFile('/config/settings.json', JSON.stringify({ theme: 'dark' }));\n * \n * // Write binary data\n * const binaryData = new Uint8Array([1, 2, 3, 4, 5]);\n * await fs.writeFile('/data/binary.dat', binaryData);\n * \n * // Write with specific encoding\n * await fs.writeFile('/data/utf16.txt', 'Hello World', 'utf-16le');\n * ```\n */\n async writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: BufferEncoding\n ): Promise<void> {\n await this.ensureMounted();\n \n const fileHandle = await this.getFileHandle(path, true);\n\n await writeFileData(fileHandle, data, encoding, { truncate: true });\n await this.notifyChange({ path, type: 'changed', isDirectory: false });\n }\n\n /**\n * Append data to a file\n * \n * Adds data to the end of an existing file. If the file doesn't exist,\n * it will be created.\n * \n * @param path - The path to the file to append to\n * @param data - The data to append to the file (string, Uint8Array, or ArrayBuffer)\n * @param encoding - The encoding to use when appending string data (default: 'utf-8')\n * @returns Promise that resolves when the append operation is complete\n * @throws {OPFSError} If appending to the file fails\n * \n * @example\n * ```typescript\n * // Append text to a log file\n * await fs.appendFile('/logs/app.log', `[${new Date().toISOString()}] User logged in\\n`);\n * \n * // Append binary data\n * const additionalData = new Uint8Array([6, 7, 8]);\n * await fs.appendFile('/data/binary.dat', additionalData);\n * ```\n */\n async appendFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: BufferEncoding\n ): Promise<void> {\n await this.ensureMounted();\n \n const fileHandle = await this.getFileHandle(path, true);\n\n await writeFileData(fileHandle, data, encoding, { append: true });\n await this.notifyChange({ path, type: 'changed', isDirectory: false });\n }\n\n /**\n * Create a directory\n * \n * Creates a new directory at the specified path. If the recursive option\n * is enabled, parent directories will be created as needed.\n * \n * @param path - The path where the directory should be created\n * @param options - Options for directory creation\n * @param options.recursive - Whether to create parent directories if they don't exist (default: false)\n * @returns Promise that resolves when the directory is created\n * @throws {OPFSError} If the directory cannot be created\n * \n * @example\n * ```typescript\n * // Create a single directory\n * await fs.mkdir('/users/john');\n * \n * // Create nested directories\n * await fs.mkdir('/users/john/documents/projects', { recursive: true });\n * ```\n */\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n await this.ensureMounted();\n\n if (!this.root) {\n throw new OPFSNotMountedError();\n }\n\n const recursive = options?.recursive ?? false;\n const segments = splitPath(path);\n\n let current = this.root;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n\n try {\n current = await current.getDirectoryHandle(segment!, { create: recursive || i === segments.length - 1 });\n }\n catch (e: any) {\n if (e.name === 'NotFoundError') {\n throw new OPFSError(\n `Parent directory does not exist: ${ joinPath(segments.slice(0, i + 1)) }`,\n 'ENOENT'\n );\n }\n\n if (e.name === 'TypeMismatchError') {\n throw new OPFSError(`Path segment is not a directory: ${ segment }`, 'ENOTDIR');\n }\n\n throw new OPFSError('Failed to create directory', 'MKDIR_FAILED');\n }\n }\n await this.notifyChange({ path, type: 'added', isDirectory: true });\n }\n\n /**\n * Get file or directory statistics\n * \n * Returns detailed information about a file or directory, including\n * size, modification time, and optionally a hash of the file content.\n * \n * @param path - The path to the file or directory\n * @returns Promise that resolves to FileStat object\n * @throws {OPFSError} If the path does not exist or cannot be accessed\n * \n * @example\n * ```typescript\n * const stats = await fs.stat('/data/config.json');\n * console.log(`File size: ${stats.size} bytes`);\n * console.log(`Last modified: ${stats.mtime}`);\n * \n * // If hashing is enabled, hash will be included\n * if (stats.hash) {\n * console.log(`Hash: ${stats.hash}`);\n * }\n * ```\n */\n async stat(path: string): Promise<FileStat> {\n await this.ensureMounted();\n \n // Special handling for root directory\n if (path === '/') {\n return {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n };\n }\n \n const name = basename(path);\n const parentDir = await this.getDirectoryHandle(dirname(path), false);\n const includeHash = this.options.hashAlgorithm !== null;\n\n try {\n const fileHandle = await parentDir.getFileHandle(name!, { create: false });\n const file = await fileHandle.getFile();\n\n const baseStat: FileStat = {\n kind: 'file',\n size: file.size,\n mtime: new Date(file.lastModified).toISOString(),\n ctime: new Date(file.lastModified).toISOString(),\n isFile: true,\n isDirectory: false,\n };\n\n if (includeHash && this.options.hashAlgorithm) {\n try {\n const hash = await calculateFileHash(file, this.options.hashAlgorithm, this.options.maxFileSize);\n\n baseStat.hash = hash;\n }\n catch (error) {\n console.warn(`Failed to calculate hash for ${ path }:`, error);\n }\n }\n\n return baseStat;\n }\n catch (e: any) {\n if (e.name !== 'TypeMismatchError' && e.name !== 'NotFoundError') {\n throw new OPFSError('Failed to stat (file)', 'STAT_FAILED');\n }\n }\n\n try {\n await parentDir.getDirectoryHandle(name!, { create: false });\n\n return {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n };\n }\n catch (e: any) {\n if (e.name === 'NotFoundError') {\n throw new OPFSError(`No such file or directory: ${ path }`, 'ENOENT');\n }\n\n throw new OPFSError('Failed to stat (directory)', 'STAT_FAILED');\n }\n }\n\n /**\n * Read a directory's contents\n * \n * Lists all files and subdirectories within the specified directory.\n * \n * @param path - The path to the directory to read\n * @returns Promise that resolves to an array of detailed file/directory information\n * @throws {OPFSError} If the directory does not exist or cannot be accessed\n * \n * @example\n * ```typescript\n * // Get detailed information about files and directories\n * const detailed = await fs.readDir('/users/john/documents');\n * detailed.forEach(item => {\n * console.log(`${item.name} - ${item.isFile ? 'file' : 'directory'}`);\n * });\n * ```\n */\n async readDir(path: string): Promise<DirentData[]> {\n await this.ensureMounted();\n \n const dir = await this.getDirectoryHandle(path, false);\n\n const results: DirentData[] = [];\n\n for await (const [name, handle] of (dir as any).entries()) {\n const isFile = handle.kind === 'file';\n\n results.push({\n name,\n kind: handle.kind,\n isFile,\n isDirectory: !isFile,\n });\n }\n\n return results;\n }\n\n /**\n * Check if a file or directory exists\n * \n * Verifies if a file or directory exists at the specified path.\n * \n * @param path - The path to check\n * @returns Promise that resolves to true if the file or directory exists, false otherwise \n * \n * @example\n * ```typescript\n * const exists = await fs.exists('/config/settings.json');\n * console.log(`File exists: ${exists}`);\n * ```\n */\n async exists(path: string): Promise<boolean> {\n await this.ensureMounted();\n \n if (path === '/') {\n return true;\n }\n \n const name = basename(path);\n let dir: FileSystemDirectoryHandle | null = null;\n\n try {\n dir = await this.getDirectoryHandle(dirname(path), false);\n }\n catch (e: any) {\n if (e.name === 'NotFoundError' || e.name === 'TypeMismatchError') {\n dir = null;\n }\n\n throw e;\n }\n\n if (!dir || !name) {\n return false;\n }\n\n try {\n await dir.getFileHandle(name, { create: false });\n\n return true;\n }\n catch (e: any) {\n if (e.name !== 'NotFoundError' && e.name !== 'TypeMismatchError') {\n throw e;\n }\n }\n\n try {\n await dir.getDirectoryHandle(name, { create: false });\n\n return true;\n }\n catch (e: any) {\n if (e.name !== 'NotFoundError' && e.name !== 'TypeMismatchError') {\n throw e;\n }\n }\n\n return false;\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n * \n * Removes all files and subdirectories within the specified directory,\n * but keeps the directory itself.\n * \n * @param path - The path to the directory to clear (default: '/')\n * @returns Promise that resolves when all contents are removed\n * @throws {OPFSError} If the operation fails\n * \n * @example\n * ```typescript\n * // Clear root directory contents\n * await fs.clear('/');\n * \n * // Clear specific directory contents\n * await fs.clear('/data');\n * ```\n */\n async clear(path: string = '/'): Promise<void> {\n await this.ensureMounted();\n \n try {\n const items = await this.readDir(path);\n\n for (const item of items) {\n const itemPath = `${ path === '/' ? '' : path }/${ item.name }`;\n\n await this.remove(itemPath, { recursive: true });\n }\n \n // Notify about the clear operation\n await this.notifyChange({ path, type: 'changed', isDirectory: true });\n }\n catch (error: any) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to clear directory: ${ path }`, 'CLEAR_FAILED');\n }\n }\n\n /**\n * Remove files and directories\n * \n * Removes files and directories. Similar to Node.js fs.rm().\n * \n * @param path - The path to remove\n * @param options - Options for removal\n * @param options.recursive - Whether to remove directories and their contents recursively (default: false)\n * @param options.force - Whether to ignore errors if the path doesn't exist (default: false)\n * @returns Promise that resolves when the removal is complete\n * @throws {OPFSError} If the removal fails\n * \n * @example\n * ```typescript\n * // Remove a file\n * await fs.rm('/path/to/file.txt');\n * \n * // Remove a directory and all its contents\n * await fs.rm('/path/to/directory', { recursive: true });\n * \n * // Remove with force (ignore if doesn't exist)\n * await fs.rm('/maybe/exists', { force: true });\n * ```\n */\n async remove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n await this.ensureMounted();\n \n const recursive = options?.recursive ?? false;\n const force = options?.force ?? false;\n\n // Special handling for root directory\n if (path === '/') {\n throw new OPFSError('Cannot remove root directory', 'EROOT');\n }\n\n const name = basename(path);\n\n if (!name) {\n throw new PathError('Invalid path', path);\n }\n\n const parent = await this.getDirectoryHandle(dirname(path), false);\n\n try {\n await parent.removeEntry(name, { recursive });\n }\n catch (e: any) {\n if (e.name === 'NotFoundError') {\n if (!force) {\n throw new OPFSError(`No such file or directory: ${ path }`, 'ENOENT');\n }\n }\n else if (e.name === 'InvalidModificationError') {\n throw new OPFSError(`Directory not empty: ${ path }. Use recursive option to force removal.`, 'ENOTEMPTY');\n }\n else if (e.name === 'TypeMismatchError' && !recursive) {\n throw new OPFSError(`Cannot remove directory without recursive option: ${ path }`, 'EISDIR');\n }\n else {\n throw new OPFSError(`Failed to remove path: ${ path }`, 'RM_FAILED');\n }\n }\n \n await this.notifyChange({ path, type: 'removed', isDirectory: false });\n }\n\n /**\n * Resolve a path to an absolute path\n * \n * Resolves relative paths and normalizes path segments (like '..' and '.').\n * Similar to Node.js fs.realpath() but without symlink resolution since OPFS doesn't support symlinks.\n * \n * @param path - The path to resolve\n * @returns Promise that resolves to the absolute normalized path\n * @throws {FileNotFoundError} If the path does not exist\n * @throws {OPFSError} If path resolution fails\n * \n * @example\n * ```typescript\n * // Resolve relative path\n * const absolute = await fs.realpath('./config/../data/file.txt');\n * console.log(absolute); // '/data/file.txt'\n * ```\n */\n async realpath(path: string): Promise<string> {\n await this.ensureMounted();\n \n try {\n const normalizedPath = resolvePath(path);\n const exists = await this.exists(normalizedPath);\n\n if (!exists) {\n throw new FileNotFoundError(normalizedPath);\n }\n\n return normalizedPath;\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to resolve path: ${ path }`, 'REALPATH_FAILED');\n }\n }\n\n /**\n * Rename a file or directory\n * \n * Changes the name of a file or directory. If the target path already exists,\n * it will be replaced.\n * \n * @param oldPath - The current path of the file or directory\n * @param newPath - The new path for the file or directory\n * @returns Promise that resolves when the rename operation is complete\n * @throws {OPFSError} If the rename operation fails\n * \n * @example\n * ```typescript\n * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt');\n * ```\n */\n async rename(oldPath: string, newPath: string): Promise<void> {\n await this.ensureMounted();\n \n try {\n const sourceExists = await this.exists(oldPath);\n\n if (!sourceExists) {\n throw new FileNotFoundError(oldPath);\n }\n\n await this.copy(oldPath, newPath, { recursive: true });\n await this.remove(oldPath, { recursive: true });\n \n // Notify about the rename operation\n await this.notifyChange({ path: oldPath, type: 'removed', isDirectory: false });\n await this.notifyChange({ path: newPath, type: 'added', isDirectory: false });\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to rename from ${ oldPath } to ${ newPath }`, 'RENAME_FAILED');\n }\n }\n\n /**\n * Copy files and directories\n * \n * Copies files and directories. Similar to Node.js fs.cp().\n * \n * @param source - The source path to copy from\n * @param destination - The destination path to copy to\n * @param options - Options for copying\n * @param options.recursive - Whether to copy directories recursively (default: false)\n * @param options.force - Whether to overwrite existing files (default: true)\n * @returns Promise that resolves when the copy operation is complete\n * @throws {OPFSError} If the copy operation fails\n * \n * @example\n * ```typescript\n * // Copy a file\n * await fs.copy('/source/file.txt', '/dest/file.txt');\n * \n * // Copy a directory and all its contents\n * await fs.copy('/source/dir', '/dest/dir', { recursive: true });\n * \n * // Copy without overwriting existing files\n * await fs.copy('/source', '/dest', { recursive: true, force: false });\n * ```\n */\n async copy(source: string, destination: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n await this.ensureMounted();\n \n try {\n const recursive = options?.recursive ?? false;\n const force = options?.force ?? true;\n\n const sourceExists = await this.exists(source);\n\n if (!sourceExists) {\n throw new OPFSError(`Source does not exist: ${ source }`, 'ENOENT');\n }\n\n const destExists = await this.exists(destination);\n\n if (destExists && !force) {\n throw new OPFSError(`Destination already exists: ${ destination }`, 'EEXIST');\n }\n\n const sourceStats = await this.stat(source);\n\n if (sourceStats.isFile) {\n const content = await this.readFile(source, 'binary');\n \n await this.writeFile(destination, content);\n }\n else {\n if (!recursive) {\n throw new OPFSError(`Cannot copy directory without recursive option: ${ source }`, 'EISDIR');\n }\n\n await this.mkdir(destination, { recursive: true });\n\n const items = await this.readDir(source);\n\n for (const item of items) {\n const sourceItemPath = `${ source }/${ item.name }`;\n const destItemPath = `${ destination }/${ item.name }`;\n\n await this.copy(sourceItemPath, destItemPath, { recursive: true, force });\n }\n }\n \n // Notify about the copy operation\n await this.notifyChange({ path: destination, type: 'added', isDirectory: false });\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to copy from ${ source } to ${ destination }`, 'CP_FAILED');\n }\n }\n\n /**\n * Start watching a file or directory for changes\n */\n async watch(path: string): Promise<void> {\n await this.ensureMounted();\n \n const normalizedPath = normalizePath(path);\n const snapshot = await this.buildSnapshot(normalizedPath);\n\n this.watchers.set(normalizedPath, snapshot);\n\n if (!this.watchTimer) {\n this.watchTimer = setInterval(() => {\n void this.scanWatches();\n }, this.options.watchInterval);\n }\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: string): void {\n const normalizedPath = normalizePath(path);\n this.watchers.delete(normalizedPath);\n\n if (this.watchers.size === 0 && this.watchTimer) {\n clearInterval(this.watchTimer);\n this.watchTimer = null;\n }\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n * \n * This method should be called when the file system instance is no longer needed\n * to properly clean up resources like the broadcast channel and watch timers.\n */\n dispose(): void {\n if (this.broadcastChannel) {\n this.broadcastChannel.close();\n this.broadcastChannel = null;\n }\n \n if (this.watchTimer) {\n clearInterval(this.watchTimer);\n this.watchTimer = null;\n }\n \n this.watchers.clear();\n }\n\n private async buildSnapshot(rootPath: string): Promise<Map<string, FileStat>> {\n const result = new Map<string, FileStat>();\n\n const walk = async (current: string) => {\n const stat = await this.stat(current);\n result.set(current, stat);\n\n if (stat.isDirectory) {\n const entries = await this.readDir(current);\n for (const entry of entries) {\n const child = `${ current === '/' ? '' : current }/${ entry.name }`;\n await walk(child);\n }\n }\n };\n\n await walk(rootPath);\n return result;\n }\n\n private async scanWatches(): Promise<void> {\n if (this.scanning) {\n return;\n }\n\n this.scanning = true;\n\n try {\n await Promise.all(\n [...this.watchers.entries()].map(async([rootPath, prev]) => {\n let next: Map<string, FileStat>;\n\n try {\n next = await this.buildSnapshot(rootPath);\n }\n catch (error) {\n next = new Map();\n }\n\n for (const [p, stat] of next) {\n const old = prev.get(p);\n \n if (!old) {\n await this.notifyChange({ path: p, type: 'added', isDirectory: stat.isDirectory });\n }\n else if (old.mtime !== stat.mtime || old.size !== stat.size) {\n await this.notifyChange({ path: p, type: 'changed', isDirectory: stat.isDirectory });\n }\n }\n\n for (const p of prev.keys()) {\n if (!next.has(p)) {\n const oldStat = prev.get(p);\n await this.notifyChange({ path: p, type: 'removed', isDirectory: oldStat?.isDirectory ?? false });\n }\n }\n\n this.watchers.set(rootPath, next);\n })\n );\n }\n finally {\n this.scanning = false;\n }\n }\n\n /**\n * Synchronize the file system with external data\n * \n * Syncs the file system with an array of entries containing paths and data.\n * This is useful for importing data from external sources or syncing with remote data.\n * \n * @param entries - Array of [path, data] tuples to sync\n * @param options - Options for synchronization\n * @param options.cleanBefore - Whether to clear the file system before syncing (default: false)\n * @returns Promise that resolves when synchronization is complete\n * @throws {OPFSError} If the synchronization fails\n * \n * @example\n * ```typescript\n * // Sync with external data\n * const entries: [string, string | Uint8Array | Blob][] = [\n * ['/config.json', JSON.stringify({ theme: 'dark' })],\n * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],\n * ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })]\n * ];\n * \n * // Sync without clearing existing files\n * await fs.sync(entries);\n * \n * // Clean file system and then sync\n * await fs.sync(entries, { cleanBefore: true });\n * ```\n */\n async sync(entries: [string, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n await this.ensureMounted();\n \n try {\n const cleanBefore = options?.cleanBefore ?? false;\n\n if (cleanBefore) {\n await this.clear('/');\n }\n\n for (const [path, data] of entries) {\n const normalizedPath = normalizePath(path);\n\n let fileData: string | Uint8Array;\n\n if (data instanceof Blob) {\n fileData = await convertBlobToUint8Array(data);\n }\n else {\n fileData = data;\n }\n\n await this.writeFile(normalizedPath, fileData);\n }\n \n // Notify about the sync operation\n await this.notifyChange({ path: '/', type: 'changed', isDirectory: true });\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError('Failed to sync file system', 'SYNC_FAILED');\n }\n }\n}\n\n// Only expose the worker when running in a Web Worker environment\nif (typeof self !== 'undefined' && self.constructor.name === 'DedicatedWorkerGlobalScope') {\n expose(new OPFSWorker());\n}"],"names":["OPFSWorker","event","hash","stats","error","watchEvent","options","checkOPFSSupport","root","resolve","reject","rootDir","OPFSError","path","create","from","OPFSNotMountedError","segments","splitPath","current","segment","PathError","fileName","result","walk","dirPath","items","item","fullPath","stat","err","encoding","fileHandle","buffer","readFileData","decodeBuffer","FileNotFoundError","data","writeFileData","recursive","i","e","joinPath","name","basename","parentDir","dirname","includeHash","file","baseStat","calculateFileHash","dir","results","handle","isFile","itemPath","force","parent","normalizedPath","resolvePath","oldPath","newPath","source","destination","content","sourceItemPath","destItemPath","normalizePath","snapshot","rootPath","entries","entry","child","prev","next","p","old","oldStat","fileData","convertBlobToUint8Array","expose"],"mappings":";;AA0CO,MAAMA,EAAW;AAAA;AAAA,EAEZ,OAAyC;AAAA;AAAA,EAGzC,+BAAe,IAAA;AAAA;AAAA,EAGf,aAAoD;AAAA;AAAA,EAGpD,WAAW;AAAA;AAAA,EAGX,kBAA2C;AAAA;AAAA,EAG3C,mBAA4C;AAAA;AAAA,EAG5C,UAAiC;AAAA,IACrC,eAAe;AAAA,IACf,aAAa,KAAK,OAAO;AAAA,IACzB,eAAe;AAAA,IACf,kBAAkB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAatB,MAAc,aAAaC,GAAuE;AAC9F,QAAI,CAAC,KAAK,QAAQ;AACd;AAIJ,QAAIC;AAEJ,QAAI,KAAK,QAAQ,iBAAiB,CAACD,EAAM,eAAeA,EAAM,SAAS;AACnE,UAAI;AACA,cAAME,IAAQ,MAAM,KAAK,KAAKF,EAAM,IAAI;AAExC,QAAIE,EAAM,UAAUA,EAAM,SACtBD,IAAOC,EAAM;AAAA,MAErB,SACGC,GAAO;AACN,gBAAQ,KAAK,gCAAgCH,EAAM,IAAI,KAAKG,CAAK;AAAA,MACrE;AAIJ,QAAI;AACA,MAAK,KAAK,qBACN,KAAK,mBAAmB,IAAI,iBAAiB,KAAK,QAAQ,gBAAgB;AAG9E,YAAMC,IAAyB;AAAA,QAC3B,MAAM,KAAK,KAAM;AAAA,QACjB,YAAW,oBAAI,KAAA,GAAO,YAAA;AAAA,QACtB,GAAGJ;AAAA,QACH,GAAIC,KAAQ,EAAE,MAAAA,EAAA;AAAA,MAAK;AAGvB,WAAK,iBAAiB,YAAYG,CA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MAAM,KAAK,MAAM,GAAG;AAGxB,iBAAW,CAACO,GAAMwB,CAAI,KAAKiC,GAAS;AAChC,cAAMZ,IAAiBS,EAActD,CAAI;AAEzC,YAAIiE;AAEJ,QAAIzC,aAAgB,OAChByC,IAAW,MAAMC,EAAwB1C,CAAI,IAG7CyC,IAAWzC,GAGf,MAAM,KAAK,UAAUqB,GAAgBoB,CAAQ;AAAA,MACjD;AAGA,YAAM,KAAK,aAAa,EAAE,MAAM,KAAK,MAAM,WAAW,aAAa,IAAM;AAAA,IAC7E,SACO1E,GAAO;AACV,YAAIA,aAAiBQ,IACXR,IAGJ,IAAIQ,EAAU,8BAA8B,aAAa;AAAA,IACnE;AAAA,EACJ;AACJ;AAGI,OAAO,OAAS,OAAe,KAAK,YAAY,SAAS,gCAC3DoE,EAAO,IAAIhF,GAAY;"}
1
+ {"version":3,"file":"raw.js","sources":["../src/worker.ts"],"sourcesContent":["import { expose } from 'comlink';\n\n\nimport { decodeBuffer } from './utils/encoder';\nimport {\n FileNotFoundError,\n OPFSError,\n PathError\n} from './utils/errors';\n\nimport {\n basename,\n calculateFileHash,\n checkOPFSSupport,\n convertBlobToUint8Array,\n dirname,\n joinPath,\n matchMinimatch,\n normalizeMinimatch,\n normalizePath,\n readFileData,\n removeEntry,\n resolvePath,\n splitPath,\n writeFileData\n} from './utils/helpers';\n\nimport type { DirentData, FileStat, OPFSOptions, WatchEvent, WatchOptions, WatchSnapshot } from './types';\nimport type { BufferEncoding } from 'typescript';\n\n/**\n * OPFS (Origin Private File System) File System implementation\n * \n * This class provides a high-level interface for working with the browser's\n * Origin Private File System API, offering file and directory operations\n * similar to Node.js fs module.\n * \n * @example\n * ```typescript\n * const fs = new OPFSFileSystem();\n * await fs.init('/my-app');\n * await fs.writeFile('/data/config.json', JSON.stringify({ theme: 'dark' }));\n * const config = await fs.readFile('/data/config.json');\n * ```\n */\nexport class OPFSWorker {\n /** Root directory handle for the file system */\n private root: FileSystemDirectoryHandle | null = null;\n\n /** Map of watched paths and options */\n private watchers = new Map<string, WatchSnapshot>();\n\n /** Promise to prevent concurrent mount operations */\n private mountingPromise: Promise<boolean> | null = null;\n\n /** BroadcastChannel instance for sending events */\n private broadcastChannel: BroadcastChannel | null = null;\n\n /** Configuration options */\n private options: Required<OPFSOptions> = {\n root: '/',\n namespace: '',\n maxFileSize: 50 * 1024 * 1024,\n hashAlgorithm: null,\n broadcastChannel: 'opfs-worker',\n };\n\n\n /**\n * Notify about internal changes to the file system\n * \n * This method is called by internal operations to notify clients about\n * changes, even when no specific paths are being watched.\n * \n * @param path - The path that was changed\n * @param type - The type of change (create, change, delete)\n */\n private async notifyChange(event: Omit<WatchEvent, 'timestamp' | 'hash' | 'namespace'>): Promise<void> {\n // This instance not configured to send events\n if (!this.options.broadcastChannel) {\n return;\n }\n\n const path = event.path;\n\n const match = [...this.watchers.values()].some((snapshot) => {\n return (\n matchMinimatch(path, snapshot.pattern)\n && snapshot.include.some(include => include && matchMinimatch(path, include))\n && !snapshot.exclude.some(exclude => exclude && matchMinimatch(path, exclude))\n );\n });\n\n if (!match) {\n return;\n }\n\n let hash: string | undefined;\n\n if (this.options.hashAlgorithm) {\n try {\n const stat = await this.stat(path);\n\n hash = stat.hash;\n }\n catch {}\n }\n\n // Send event via BroadcastChannel\n try {\n if (!this.broadcastChannel) {\n this.broadcastChannel = new BroadcastChannel(this.options.broadcastChannel as string);\n }\n\n const watchEvent: WatchEvent = {\n namespace: this.options.namespace,\n timestamp: new Date().toISOString(),\n ...event,\n ...(hash && { hash }),\n };\n\n this.broadcastChannel.postMessage(watchEvent);\n }\n catch (error) {\n console.warn('Failed to send event via BroadcastChannel:', error);\n }\n }\n\n /**\n * Creates a new OPFSFileSystem instance\n * \n * @param options - Optional configuration options\n * @param options.root - Root path for the file system (default: '/')\n * @param options.watchInterval - Polling interval in milliseconds for file watching\n * @param options.hashAlgorithm - Hash algorithm for file hashing\n * @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)\n * @throws {OPFSError} If OPFS is not supported in the current browser\n */\n constructor(options?: OPFSOptions) {\n checkOPFSSupport();\n\n if (options) {\n void this.setOptions(options);\n }\n }\n\n /**\n * Initialize the file system within a given directory\n * \n * This method sets up the root directory for all subsequent operations.\n * If no root is specified, it will use the OPFS root directory.\n * \n * @param root - The root path for the file system (default: '/')\n * @returns Promise that resolves to true if initialization was successful\n * @throws {OPFSError} If initialization fails\n * \n * @example\n * ```typescript\n * const fs = new OPFSFileSystem();\n * \n * // Use OPFS root (default)\n * await fs.mount();\n * \n * // Use custom directory\n * await fs.mount('/my-app');\n * ```\n */\n private async mount(root: string = this.options.root): Promise<boolean> {\n // If already mounting, wait for previous operation to complete first\n if (this.mountingPromise) {\n await this.mountingPromise;\n }\n\n root = normalizePath(root);\n\n // eslint-disable-next-line no-async-promise-executor\n this.mountingPromise = new Promise<boolean>(async(resolve, reject) => {\n try {\n const rootDir = await navigator.storage.getDirectory();\n\n if (root === '/') {\n this.root = rootDir;\n }\n else {\n this.root = await this.getDirectoryHandle(root, true, rootDir);\n }\n\n resolve(true);\n }\n catch (error) {\n reject(new OPFSError('Failed to initialize OPFS', 'INIT_FAILED'));\n }\n finally {\n this.mountingPromise = null;\n }\n });\n\n return this.mountingPromise;\n }\n\n\n /**\n * Update configuration options\n * \n * @param options - Configuration options to update\n * @param options.root - Root path for the file system\n * @param options.watchInterval - Polling interval in milliseconds for file watching\n * @param options.hashAlgorithm - Hash algorithm for file hashing\n * @param options.maxFileSize - Maximum file size for hashing in bytes\n * @param options.broadcastChannel - Custom name for the broadcast channel\n */\n async setOptions(options: OPFSOptions): Promise<void> {\n if (options.hashAlgorithm !== undefined) {\n this.options.hashAlgorithm = options.hashAlgorithm;\n }\n\n if (options.maxFileSize !== undefined) {\n this.options.maxFileSize = options.maxFileSize;\n }\n\n if (options.broadcastChannel !== undefined) {\n // Close existing channel if name changed\n if (this.broadcastChannel && this.options.broadcastChannel !== options.broadcastChannel) {\n this.broadcastChannel.close();\n this.broadcastChannel = null;\n }\n\n this.options.broadcastChannel = options.broadcastChannel;\n }\n\n if (options.namespace) {\n this.options.namespace = options.namespace;\n }\n\n if (options.root !== undefined) {\n this.options.root = options.root;\n\n if (!this.options.namespace) {\n this.options.namespace = `opfs-worker:${ this.options.root }`;\n }\n\n await this.mount(this.options.root);\n }\n }\n\n /**\n * Get a directory handle from a path\n * \n * Navigates through the directory structure to find or create a directory\n * at the specified path.\n * \n * @param path - The path to the directory (string or array of segments)\n * @param create - Whether to create the directory if it doesn't exist (default: false)\n * @param from - The directory to start from (default: root directory)\n * @returns Promise that resolves to the directory handle\n * @throws {OPFSError} If the directory cannot be accessed or created\n * \n * @example\n * ```typescript\n * const docsDir = await fs.getDirectoryHandle('/users/john/documents', true);\n * const docsDir2 = await fs.getDirectoryHandle(['users', 'john', 'documents'], true);\n * ```\n */\n private async getDirectoryHandle(path: string | string[], create: boolean = false, from: FileSystemDirectoryHandle | null = this.root): Promise<FileSystemDirectoryHandle> {\n const segments = Array.isArray(path) ? path : splitPath(path);\n let current = from;\n\n for (const segment of segments) {\n current = await current!.getDirectoryHandle(segment, { create });\n }\n\n return current!;\n }\n\n /**\n * Get a file handle from a path\n * \n * Navigates to the parent directory and retrieves or creates a file handle\n * for the specified file path.\n * \n * @param path - The path to the file (string or array of segments)\n * @param create - Whether to create the file if it doesn't exist (default: false)\n * @param from - The directory to start from (default: root directory)\n * @returns Promise that resolves to the file handle\n * @throws {PathError} If the path is empty\n * @throws {OPFSError} If the file cannot be accessed or created\n * \n * @example\n * ```typescript\n * const fileHandle = await fs.getFileHandle('/config/settings.json', true);\n * const fileHandle2 = await fs.getFileHandle(['config', 'settings.json'], true);\n * ```\n */\n private async getFileHandle(path: string | string[], create = false, from: FileSystemDirectoryHandle | null = this.root): Promise<FileSystemFileHandle> {\n const segments = splitPath(path);\n\n if (segments.length === 0) {\n throw new PathError('Path must not be empty', Array.isArray(path) ? path.join('/') : path);\n }\n\n const fileName = segments.pop()!;\n const dir = await this.getDirectoryHandle(segments, create, from);\n\n return dir.getFileHandle(fileName, { create });\n }\n\n /**\n * Get a complete index of all files and directories in the file system\n * \n * This method recursively traverses the entire file system and returns\n * a Map containing FileStat objects for every file and directory.\n * \n * @returns Promise that resolves to a Map of paths to FileStat objects\n * @throws {OPFSError} If the file system is not mounted\n * \n * @example\n * ```typescript\n * const index = await fs.index();\n * const fileStats = index.get('/data/config.json');\n * if (fileStats) {\n * console.log(`File size: ${fileStats.size} bytes`);\n * if (fileStats.hash) console.log(`Hash: ${fileStats.hash}`);\n * }\n * ```\n */\n async index(): Promise<Map<string, FileStat>> {\n const result = new Map<string, FileStat>();\n\n const walk = async(dirPath: string) => {\n const items = await this.readDir(dirPath);\n\n for (const item of items) {\n const fullPath = `${ dirPath === '/' ? '' : dirPath }/${ item.name }`;\n\n try {\n const stat = await this.stat(fullPath);\n\n result.set(fullPath, stat);\n\n if (stat.isDirectory) {\n await walk(fullPath);\n }\n }\n catch (err) {\n console.warn(`Skipping broken entry: ${ fullPath }`, err);\n }\n }\n };\n\n result.set('/', {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n });\n\n await walk('/');\n\n return result;\n }\n\n /**\n * Read a file from the file system\n * \n * Reads the contents of a file and returns it as a string or binary data\n * depending on the specified encoding.\n * \n * @param path - The path to the file to read\n * @param encoding - The encoding to use for reading the file\n * @returns Promise that resolves to the file contents\n * @throws {FileNotFoundError} If the file does not exist\n * @throws {OPFSError} If reading the file fails\n * \n * @example\n * ```typescript\n * // Read as text\n * const content = await fs.readFile('/config/settings.json');\n * \n * // Read as binary\n * const binaryData = await fs.readFile('/images/logo.png', 'binary');\n * \n * // Read with specific encoding\n * const utf8Content = await fs.readFile('/data/utf8.txt', 'utf-8');\n * ```\n */\n async readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;\n async readFile(path: string, encoding?: BufferEncoding): Promise<string>;\n async readFile(\n path: string,\n encoding: BufferEncoding | 'binary' = 'utf-8'\n ): Promise<string | Uint8Array> {\n await this.mount();\n\n try {\n const fileHandle = await this.getFileHandle(path, false);\n const buffer = await readFileData(fileHandle, path);\n\n return (encoding === 'binary') ? buffer : decodeBuffer(buffer, encoding);\n }\n catch (err) {\n throw new FileNotFoundError(path, err);\n }\n }\n\n /**\n * Write data to a file\n * \n * Creates or overwrites a file with the specified data. If the file already\n * exists, it will be truncated before writing.\n * \n * @param path - The path to the file to write\n * @param data - The data to write to the file (string, Uint8Array, or ArrayBuffer)\n * @param encoding - The encoding to use when writing string data (default: 'utf-8')\n * @returns Promise that resolves when the write operation is complete\n * @throws {OPFSError} If writing the file fails\n * \n * @example\n * ```typescript\n * // Write text data\n * await fs.writeFile('/config/settings.json', JSON.stringify({ theme: 'dark' }));\n * \n * // Write binary data\n * const binaryData = new Uint8Array([1, 2, 3, 4, 5]);\n * await fs.writeFile('/data/binary.dat', binaryData);\n * \n * // Write with specific encoding\n * await fs.writeFile('/data/utf16.txt', 'Hello World', 'utf-16le');\n * ```\n */\n async writeFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: BufferEncoding\n ): Promise<void> {\n await this.mount();\n\n const fileExists = await this.exists(path);\n const fileHandle = await this.getFileHandle(path, true);\n\n await writeFileData(fileHandle, data, encoding, {}, path);\n\n // Only notify changes if the file didn't exist before or if content actually changed\n if (!fileExists) {\n await this.notifyChange({ path, type: 'added', isDirectory: false });\n }\n else {\n await this.notifyChange({ path, type: 'changed', isDirectory: false });\n }\n }\n\n /**\n * Append data to a file\n * \n * Adds data to the end of an existing file. If the file doesn't exist,\n * it will be created.\n * \n * @param path - The path to the file to append to\n * @param data - The data to append to the file (string, Uint8Array, or ArrayBuffer)\n * @param encoding - The encoding to use when appending string data (default: 'utf-8')\n * @returns Promise that resolves when the append operation is complete\n * @throws {OPFSError} If appending to the file fails\n * \n * @example\n * ```typescript\n * // Append text to a log file\n * await fs.appendFile('/logs/app.log', `[${new Date().toISOString()}] User logged in\\n`);\n * \n * // Append binary data\n * const additionalData = new Uint8Array([6, 7, 8]);\n * await fs.appendFile('/data/binary.dat', additionalData);\n * ```\n */\n async appendFile(\n path: string,\n data: string | Uint8Array | ArrayBuffer,\n encoding?: BufferEncoding\n ): Promise<void> {\n await this.mount();\n\n const fileHandle = await this.getFileHandle(path, true);\n\n await writeFileData(fileHandle, data, encoding, { append: true }, path);\n await this.notifyChange({ path, type: 'changed', isDirectory: false });\n }\n\n /**\n * Create a directory\n * \n * Creates a new directory at the specified path. If the recursive option\n * is enabled, parent directories will be created as needed.\n * \n * @param path - The path where the directory should be created\n * @param options - Options for directory creation\n * @param options.recursive - Whether to create parent directories if they don't exist (default: false)\n * @returns Promise that resolves when the directory is created\n * @throws {OPFSError} If the directory cannot be created\n * \n * @example\n * ```typescript\n * // Create a single directory\n * await fs.mkdir('/users/john');\n * \n * // Create nested directories\n * await fs.mkdir('/users/john/documents/projects', { recursive: true });\n * ```\n */\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n await this.mount();\n\n const recursive = options?.recursive ?? false;\n const segments = splitPath(path);\n\n let current: FileSystemDirectoryHandle | null = this.root;\n\n for (let i = 0; i < segments.length; i++) {\n const segment = segments[i];\n\n try {\n current = await current!.getDirectoryHandle(segment!, { create: recursive || i === segments.length - 1 });\n }\n catch (err: any) {\n if (err.name === 'NotFoundError') {\n throw new OPFSError(\n `Parent directory does not exist: ${ joinPath(segments.slice(0, i + 1)) }`,\n 'ENOENT',\n undefined,\n err\n );\n }\n\n if (err.name === 'TypeMismatchError') {\n throw new OPFSError(`Path segment is not a directory: ${ segment }`, 'ENOTDIR', undefined, err);\n }\n\n throw new OPFSError('Failed to create directory', 'MKDIR_FAILED', undefined, err);\n }\n }\n\n await this.notifyChange({ path, type: 'added', isDirectory: true });\n }\n\n /**\n * Get file or directory statistics\n * \n * Returns detailed information about a file or directory, including\n * size, modification time, and optionally a hash of the file content.\n * \n * @param path - The path to the file or directory\n * @returns Promise that resolves to FileStat object\n * @throws {OPFSError} If the path does not exist or cannot be accessed\n * \n * @example\n * ```typescript\n * const stats = await fs.stat('/data/config.json');\n * console.log(`File size: ${stats.size} bytes`);\n * console.log(`Last modified: ${stats.mtime}`);\n * \n * // If hashing is enabled, hash will be included\n * if (stats.hash) {\n * console.log(`Hash: ${stats.hash}`);\n * }\n * ```\n */\n async stat(path: string): Promise<FileStat> {\n await this.mount();\n\n // Special handling for root directory\n if (path === '/') {\n return {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n };\n }\n\n const name = basename(path);\n const parentDir = await this.getDirectoryHandle(dirname(path), false);\n const includeHash = this.options.hashAlgorithm !== null;\n\n try {\n const fileHandle = await parentDir.getFileHandle(name, { create: false });\n const file = await fileHandle.getFile();\n\n const baseStat: FileStat = {\n kind: 'file',\n size: file.size,\n mtime: new Date(file.lastModified).toISOString(),\n ctime: new Date(file.lastModified).toISOString(),\n isFile: true,\n isDirectory: false,\n };\n\n if (includeHash && this.options.hashAlgorithm) {\n try {\n const hash = await calculateFileHash(file, this.options.hashAlgorithm, this.options.maxFileSize);\n\n baseStat.hash = hash;\n }\n catch (error) {\n console.warn(`Failed to calculate hash for ${ path }:`, error);\n }\n }\n\n return baseStat;\n }\n catch (e: any) {\n if (e.name !== 'TypeMismatchError' && e.name !== 'NotFoundError') {\n throw new OPFSError('Failed to stat (file)', 'STAT_FAILED', undefined, e);\n }\n }\n\n try {\n await parentDir.getDirectoryHandle(name, { create: false });\n\n return {\n kind: 'directory',\n size: 0,\n mtime: new Date(0).toISOString(),\n ctime: new Date(0).toISOString(),\n isFile: false,\n isDirectory: true,\n };\n }\n catch (e: any) {\n if (e.name === 'NotFoundError') {\n throw new OPFSError(`No such file or directory: ${ path }`, 'ENOENT', undefined, e);\n }\n\n throw new OPFSError('Failed to stat (directory)', 'STAT_FAILED', undefined, e);\n }\n }\n\n /**\n * Read a directory's contents\n * \n * Lists all files and subdirectories within the specified directory.\n * \n * @param path - The path to the directory to read\n * @returns Promise that resolves to an array of detailed file/directory information\n * @throws {OPFSError} If the directory does not exist or cannot be accessed\n * \n * @example\n * ```typescript\n * // Get detailed information about files and directories\n * const detailed = await fs.readDir('/users/john/documents');\n * detailed.forEach(item => {\n * console.log(`${item.name} - ${item.isFile ? 'file' : 'directory'}`);\n * });\n * ```\n */\n async readDir(path: string): Promise<DirentData[]> {\n await this.mount();\n\n const dir = await this.getDirectoryHandle(path, false);\n\n const results: DirentData[] = [];\n\n for await (const [name, handle] of (dir as any).entries()) {\n const isFile = handle.kind === 'file';\n\n results.push({\n name,\n kind: handle.kind,\n isFile,\n isDirectory: !isFile,\n });\n }\n\n return results;\n }\n\n /**\n * Check if a file or directory exists\n * \n * Verifies if a file or directory exists at the specified path.\n * \n * @param path - The path to check\n * @returns Promise that resolves to true if the file or directory exists, false otherwise \n * \n * @example\n * ```typescript\n * const exists = await fs.exists('/config/settings.json');\n * console.log(`File exists: ${exists}`);\n * ```\n */\n async exists(path: string): Promise<boolean> {\n await this.mount();\n\n if (path === '/') {\n return true;\n }\n\n const name = basename(path);\n let dir: FileSystemDirectoryHandle | null = null;\n\n try {\n dir = await this.getDirectoryHandle(dirname(path), false);\n }\n catch (e: any) {\n if (e.name === 'NotFoundError' || e.name === 'TypeMismatchError') {\n dir = null;\n }\n\n throw e;\n }\n\n if (!dir || !name) {\n return false;\n }\n\n try {\n await dir.getFileHandle(name, { create: false });\n\n return true;\n }\n catch (err: any) {\n if (err.name !== 'NotFoundError' && err.name !== 'TypeMismatchError') {\n throw err;\n }\n\n try {\n await dir.getDirectoryHandle(name, { create: false });\n\n return true;\n }\n catch (err: any) {\n if (err.name !== 'NotFoundError' && err.name !== 'TypeMismatchError') {\n throw err;\n }\n\n return false;\n }\n }\n }\n\n /**\n * Clear all contents of a directory without removing the directory itself\n * \n * Removes all files and subdirectories within the specified directory,\n * but keeps the directory itself.\n * \n * @param path - The path to the directory to clear (default: '/')\n * @returns Promise that resolves when all contents are removed\n * @throws {OPFSError} If the operation fails\n * \n * @example\n * ```typescript\n * // Clear root directory contents\n * await fs.clear('/');\n * \n * // Clear specific directory contents\n * await fs.clear('/data');\n * ```\n */\n async clear(path: string = '/'): Promise<void> {\n await this.mount();\n\n try {\n const items = await this.readDir(path);\n\n for (const item of items) {\n const itemPath = `${ path === '/' ? '' : path }/${ item.name }`;\n\n await this.remove(itemPath, { recursive: true });\n }\n\n // Notify about the clear operation\n await this.notifyChange({ path, type: 'changed', isDirectory: true });\n }\n catch (error: any) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to clear directory: ${ path }`, 'CLEAR_FAILED', undefined, error);\n }\n }\n\n /**\n * Remove files and directories\n * \n * Removes files and directories. Similar to Node.js fs.rm().\n * \n * @param path - The path to remove\n * @param options - Options for removal\n * @param options.recursive - Whether to remove directories and their contents recursively (default: false)\n * @param options.force - Whether to ignore errors if the path doesn't exist (default: false)\n * @returns Promise that resolves when the removal is complete\n * @throws {OPFSError} If the removal fails\n * \n * @example\n * ```typescript\n * // Remove a file\n * await fs.rm('/path/to/file.txt');\n * \n * // Remove a directory and all its contents\n * await fs.rm('/path/to/directory', { recursive: true });\n * \n * // Remove with force (ignore if doesn't exist)\n * await fs.rm('/maybe/exists', { force: true });\n * ```\n */\n async remove(path: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n await this.mount();\n\n // Special handling for root directory\n if (path === '/') {\n throw new OPFSError('Cannot remove root directory', 'EROOT');\n }\n\n const parent = await this.getDirectoryHandle(dirname(path), false);\n\n await removeEntry(parent, path, options);\n\n await this.notifyChange({ path, type: 'removed', isDirectory: false });\n }\n\n /**\n * Resolve a path to an absolute path\n * \n * Resolves relative paths and normalizes path segments (like '..' and '.').\n * Similar to Node.js fs.realpath() but without symlink resolution since OPFS doesn't support symlinks.\n * \n * @param path - The path to resolve\n * @returns Promise that resolves to the absolute normalized path\n * @throws {FileNotFoundError} If the path does not exist\n * @throws {OPFSError} If path resolution fails\n * \n * @example\n * ```typescript\n * // Resolve relative path\n * const absolute = await fs.realpath('./config/../data/file.txt');\n * console.log(absolute); // '/data/file.txt'\n * ```\n */\n async realpath(path: string): Promise<string> {\n await this.mount();\n\n try {\n const normalizedPath = resolvePath(path);\n const exists = await this.exists(normalizedPath);\n\n if (!exists) {\n throw new FileNotFoundError(normalizedPath);\n }\n\n return normalizedPath;\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to resolve path: ${ path }`, 'REALPATH_FAILED', undefined, error);\n }\n }\n\n /**\n * Rename a file or directory\n * \n * Changes the name of a file or directory. If the target path already exists,\n * it will be replaced.\n * \n * @param oldPath - The current path of the file or directory\n * @param newPath - The new path for the file or directory\n * @returns Promise that resolves when the rename operation is complete\n * @throws {OPFSError} If the rename operation fails\n * \n * @example\n * ```typescript\n * await fs.rename('/old/path/file.txt', '/new/path/renamed.txt');\n * ```\n */\n async rename(oldPath: string, newPath: string): Promise<void> {\n await this.mount();\n\n try {\n const sourceExists = await this.exists(oldPath);\n\n if (!sourceExists) {\n throw new FileNotFoundError(oldPath);\n }\n\n await this.copy(oldPath, newPath, { recursive: true });\n await this.remove(oldPath, { recursive: true });\n\n // Notify about the rename operation\n await this.notifyChange({ path: oldPath, type: 'removed', isDirectory: false });\n await this.notifyChange({ path: newPath, type: 'added', isDirectory: false });\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to rename from ${ oldPath } to ${ newPath }`, 'RENAME_FAILED', undefined, error);\n }\n }\n\n /**\n * Copy files and directories\n * \n * Copies files and directories. Similar to Node.js fs.cp().\n * \n * @param source - The source path to copy from\n * @param destination - The destination path to copy to\n * @param options - Options for copying\n * @param options.recursive - Whether to copy directories recursively (default: false)\n * @param options.force - Whether to overwrite existing files (default: true)\n * @returns Promise that resolves when the copy operation is complete\n * @throws {OPFSError} If the copy operation fails\n * \n * @example\n * ```typescript\n * // Copy a file\n * await fs.copy('/source/file.txt', '/dest/file.txt');\n * \n * // Copy a directory and all its contents\n * await fs.copy('/source/dir', '/dest/dir', { recursive: true });\n * \n * // Copy without overwriting existing files\n * await fs.copy('/source', '/dest', { recursive: true, force: false });\n * ```\n */\n async copy(source: string, destination: string, options?: { recursive?: boolean; force?: boolean }): Promise<void> {\n await this.mount();\n\n try {\n const recursive = options?.recursive ?? false;\n const force = options?.force ?? true;\n\n const sourceExists = await this.exists(source);\n\n if (!sourceExists) {\n throw new OPFSError(`Source does not exist: ${ source }`, 'ENOENT', undefined);\n }\n\n const destExists = await this.exists(destination);\n\n if (destExists && !force) {\n throw new OPFSError(`Destination already exists: ${ destination }`, 'EEXIST', undefined);\n }\n\n const sourceStats = await this.stat(source);\n\n if (sourceStats.isFile) {\n const content = await this.readFile(source, 'binary');\n\n await this.writeFile(destination, content);\n }\n else {\n if (!recursive) {\n throw new OPFSError(`Cannot copy directory without recursive option: ${ source }`, 'EISDIR', undefined);\n }\n\n await this.mkdir(destination, { recursive: true });\n\n const items = await this.readDir(source);\n\n for (const item of items) {\n const sourceItemPath = `${ source }/${ item.name }`;\n const destItemPath = `${ destination }/${ item.name }`;\n\n await this.copy(sourceItemPath, destItemPath, { recursive: true, force });\n }\n }\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError(`Failed to copy from ${ source } to ${ destination }`, 'CP_FAILED', undefined, error);\n }\n }\n\n /**\n * Start watching a file or directory for changes\n * \n * @param path - The path to watch (minimatch syntax allowed)\n * @param options - Watch options\n * @param options.recursive - Whether to watch recursively (default: true)\n * @param options.exclude - Glob pattern(s) to exclude (minimatch).\n * @returns Promise that resolves when watching starts\n * \n * @example\n * ```typescript\n * // Watch entire directory tree recursively (default)\n * await fs.watch('/data');\n * \n * // Watch only immediate children (shallow)\n * await fs.watch('/data', { recursive: false });\n * \n * // Watch a single file\n * await fs.watch('/config.json', { recursive: false });\n * \n * // Watch all json files but not in dist directory\n * await fs.watch('/**\\/*.json', { recursive: false, exclude: ['dist/**'] });\n *\n * ```\n */\n async watch(path: string, options?: WatchOptions): Promise<void> {\n if (!this.options.broadcastChannel) {\n throw new OPFSError('This instance is not configured to send events. Please specify options.broadcastChannel to enable watching.', 'ENOENT');\n }\n\n const snapshot: WatchSnapshot = {\n pattern: normalizeMinimatch(path, options?.recursive ?? true),\n include: Array.isArray(options?.include) ? options.include : [options?.include ?? '**'],\n exclude: Array.isArray(options?.exclude) ? options.exclude : [options?.exclude ?? ''],\n };\n\n this.watchers.set(path, snapshot);\n }\n\n /**\n * Stop watching a previously watched path\n */\n unwatch(path: string): void {\n this.watchers.delete(path);\n }\n\n /**\n * Dispose of resources and clean up the file system instance\n * \n * This method should be called when the file system instance is no longer needed\n * to properly clean up resources like the broadcast channel and watch timers.\n */\n dispose(): void {\n if (this.broadcastChannel) {\n this.broadcastChannel.close();\n this.broadcastChannel = null;\n }\n\n this.watchers.clear();\n }\n\n /**\n * Synchronize the file system with external data\n * \n * Syncs the file system with an array of entries containing paths and data.\n * This is useful for importing data from external sources or syncing with remote data.\n * \n * @param entries - Array of [path, data] tuples to sync\n * @param options - Options for synchronization\n * @param options.cleanBefore - Whether to clear the file system before syncing (default: false)\n * @returns Promise that resolves when synchronization is complete\n * @throws {OPFSError} If the synchronization fails\n * \n * @example\n * ```typescript\n * // Sync with external data\n * const entries: [string, string | Uint8Array | Blob][] = [\n * ['/config.json', JSON.stringify({ theme: 'dark' })],\n * ['/data/binary.dat', new Uint8Array([1, 2, 3, 4])],\n * ['/upload.txt', new Blob(['file content'], { type: 'text/plain' })]\n * ];\n * \n * // Sync without clearing existing files\n * await fs.sync(entries);\n * \n * // Clean file system and then sync\n * await fs.sync(entries, { cleanBefore: true });\n * ```\n */\n async sync(entries: [string, string | Uint8Array | Blob][], options?: { cleanBefore?: boolean }): Promise<void> {\n await this.mount();\n\n try {\n const cleanBefore = options?.cleanBefore ?? false;\n\n if (cleanBefore) {\n await this.clear('/');\n }\n\n for (const [path, data] of entries) {\n const normalizedPath = normalizePath(path);\n\n let fileData: string | Uint8Array;\n\n if (data instanceof Blob) {\n fileData = await convertBlobToUint8Array(data);\n }\n else {\n fileData = data;\n }\n\n await this.writeFile(normalizedPath, fileData);\n }\n }\n catch (error) {\n if (error instanceof OPFSError) {\n throw error;\n }\n\n throw new OPFSError('Failed to sync file system', 'SYNC_FAILED', undefined, error);\n }\n }\n}\n\n// Only expose the worker when running in a Web Worker environment\nif (typeof globalThis !== 'undefined' && globalThis.constructor.name === 'DedicatedWorkerGlobalScope') {\n expose(new OPFSWorker());\n}\n"],"names":["OPFSWorker","event","path","snapshot","matchMinimatch","include","exclude","hash","watchEvent","error","options","checkOPFSSupport","root","normalizePath","resolve","reject","rootDir","OPFSError","create","from","segments","splitPath","current","segment","PathError","fileName","result","walk","dirPath","items","item","fullPath","stat","err","encoding","fileHandle","buffer","readFileData","decodeBuffer","FileNotFoundError","data","fileExists","writeFileData","recursive","i","joinPath","name","basename","parentDir","dirname","includeHash","file","baseStat","calculateFileHash","e","dir","results","handle","isFile","itemPath","parent","removeEntry","normalizedPath","resolvePath","oldPath","newPath","source","destination","force","content","sourceItemPath","destItemPath","normalizeMinimatch","entries","fileData","convertBlobToUint8Array","expose"],"mappings":";;AA6CO,MAAMA,EAAW;AAAA;AAAA,EAEZ,OAAyC;AAAA;AAAA,EAGzC,+BAAe,IAAA;AAAA;AAAA,EAGf,kBAA2C;AAAA;AAAA,EAG3C,mBAA4C;AAAA;AAAA,EAG5C,UAAiC;AAAA,IACrC,MAAM;AAAA,IACN,WAAW;AAAA,IACX,aAAa,KAAK,OAAO;AAAA,IACzB,eAAe;AAAA,IACf,kBAAkB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAatB,MAAc,aAAaC,GAA4E;AAEnG,QAAI,CAAC,KAAK,QAAQ;AACd;AAGJ,UAAMC,IAAOD,EAAM;AAUnB,QAAI,CARU,CAAC,GAAG,KAAK,SAAS,QAAQ,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AAEX,QAAI;AAGA,OAFoBA,GAAS,eAAe,OAGxC,MAAM,KAAK,MAAM,GAAG;AAGxB,iBAAW,CAACR,GAAMsC,CAAI,KAAKiC,GAAS;AAChC,cAAMX,IAAiBjD,EAAcX,CAAI;AAEzC,YAAIwE;AAEJ,QAAIlC,aAAgB,OAChBkC,IAAW,MAAMC,EAAwBnC,CAAI,IAG7CkC,IAAWlC,GAGf,MAAM,KAAK,UAAUsB,GAAgBY,CAAQ;AAAA,MACjD;AAAA,IACJ,SACOjE,GAAO;AACV,YAAIA,aAAiBQ,IACXR,IAGJ,IAAIQ,EAAU,8BAA8B,eAAe,QAAWR,CAAK;AAAA,IACrF;AAAA,EACJ;AACJ;AAGI,OAAO,aAAe,OAAe,WAAW,YAAY,SAAS,gCACrEmE,EAAO,IAAI5E,GAAY;"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Remote } from 'comlink';
2
1
  import type { OPFSWorker } from './worker';
2
+ import type { Remote } from 'comlink';
3
3
  export type Kind = 'file' | 'directory';
4
4
  export interface FileStat {
5
5
  kind: Kind;
@@ -18,7 +18,7 @@ export interface DirentData {
18
18
  isDirectory: boolean;
19
19
  }
20
20
  export interface WatchEvent {
21
- root: string;
21
+ namespace: string;
22
22
  path: string;
23
23
  type: 'added' | 'changed' | 'removed';
24
24
  isDirectory: boolean;
@@ -28,13 +28,28 @@ export interface WatchEvent {
28
28
  export type { OPFSWorker };
29
29
  export type RemoteOPFSWorker = Remote<OPFSWorker>;
30
30
  export interface OPFSOptions {
31
- /** Polling interval in milliseconds for file watching (default: 1000) */
32
- watchInterval?: number;
31
+ /** Root path for the file system (default: '/') */
32
+ root?: string;
33
+ /** Namespace for the events (default: 'opfs-worker:${root}') */
34
+ namespace?: string;
33
35
  /** Hash algorithm for file hashing, or null to disable (default: null) */
34
36
  hashAlgorithm?: null | 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
35
37
  /** Maximum file size in bytes for hashing (default: 50MB) */
36
38
  maxFileSize?: number;
37
39
  /** Custom name for the broadcast channel (default: 'opfs-worker') */
38
- broadcastChannel?: string | null;
40
+ broadcastChannel?: string | BroadcastChannel | null;
41
+ }
42
+ export interface WatchOptions {
43
+ /** Whether to watch recursively (default: true) */
44
+ recursive?: boolean;
45
+ /** Glob patterns to include in watching (minimatch syntax, default: ['**']) */
46
+ include?: string | string[];
47
+ /** Glob patterns to exclude from watching (minimatch syntax, default: []) */
48
+ exclude?: string | string[];
49
+ }
50
+ export interface WatchSnapshot {
51
+ pattern: string;
52
+ include: string[];
53
+ exclude: string[];
39
54
  }
40
55
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,WAAW,CAAC;AAExC,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IAC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S,GAAG,SAAS,CAAC;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAElD,MAAM,WAAW,WAAW;IACxB,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACnE,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,YAAY;IACzB,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB"}
@@ -4,54 +4,54 @@
4
4
  export declare class OPFSError extends Error {
5
5
  readonly code: string;
6
6
  readonly path?: string | undefined;
7
- constructor(message: string, code: string, path?: string | undefined);
7
+ constructor(message: string, code: string, path?: string | undefined, cause?: any);
8
8
  }
9
9
  /**
10
10
  * Error thrown when OPFS is not supported in the current browser
11
11
  */
12
12
  export declare class OPFSNotSupportedError extends OPFSError {
13
- constructor();
13
+ constructor(cause?: unknown);
14
14
  }
15
15
  /**
16
16
  * Error thrown when OPFS is not mounted
17
17
  */
18
18
  export declare class OPFSNotMountedError extends OPFSError {
19
- constructor();
19
+ constructor(cause?: unknown);
20
20
  }
21
21
  /**
22
22
  * Error thrown for invalid paths or path traversal attempts
23
23
  */
24
24
  export declare class PathError extends OPFSError {
25
- constructor(message: string, path: string);
25
+ constructor(message: string, path: string, cause?: unknown);
26
26
  }
27
27
  /**
28
28
  * Error thrown when a requested file doesn't exist
29
29
  */
30
30
  export declare class FileNotFoundError extends OPFSError {
31
- constructor(path: string);
31
+ constructor(path: string, cause?: unknown);
32
32
  }
33
33
  /**
34
34
  * Error thrown when a requested directory doesn't exist
35
35
  */
36
36
  export declare class DirectoryNotFoundError extends OPFSError {
37
- constructor(path: string);
37
+ constructor(path: string, cause?: unknown);
38
38
  }
39
39
  /**
40
40
  * Error thrown when permission is denied for an operation
41
41
  */
42
42
  export declare class PermissionError extends OPFSError {
43
- constructor(path: string, operation: string);
43
+ constructor(path: string, operation: string, cause?: unknown);
44
44
  }
45
45
  /**
46
46
  * Error thrown when an operation fails due to insufficient storage
47
47
  */
48
48
  export declare class StorageError extends OPFSError {
49
- constructor(message: string, path?: string);
49
+ constructor(message: string, path?: string, cause?: unknown);
50
50
  }
51
51
  /**
52
52
  * Error thrown when an operation times out
53
53
  */
54
54
  export declare class TimeoutError extends OPFSError {
55
- constructor(operation: string, path?: string);
55
+ constructor(operation: string, path?: string, cause?: unknown);
56
56
  }
57
57
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;aACa,IAAI,EAAE,MAAM;aAAkB,IAAI,CAAC,EAAE,MAAM;gBAA5E,OAAO,EAAE,MAAM,EAAkB,IAAI,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAI3F;AAED;;GAEG;AACH,qBAAa,qBAAs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AE,OAAO;CAG7D;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;gBAChC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG5C;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,SAAS;gBACrC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG5C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAC9B,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG/D;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,SAAS;gBAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG9D;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,SAAS;gBAC3B,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAGhE"}
@@ -5,6 +5,7 @@ import type { BufferEncoding } from 'typescript';
5
5
  * @throws {OPFSNotSupportedError} If the browser does not support the OPFS API
6
6
  */
7
7
  export declare function checkOPFSSupport(): void;
8
+ export declare function withLock<T>(path: string, mode: 'shared' | 'exclusive', fn: () => Promise<T>): Promise<T>;
8
9
  /**
9
10
  * Split a path into an array of segments
10
11
  *
@@ -69,6 +70,16 @@ export declare function dirname(path: string): string;
69
70
  * ```
70
71
  */
71
72
  export declare function normalizePath(path: string): string;
73
+ export declare function normalizeMinimatch(path: string, recursive?: boolean): string;
74
+ export declare function matchMinimatch(path: string, pattern: string): boolean;
75
+ /**
76
+ * Check if a path matches any of the provided exclude patterns (minimatch syntax)
77
+ *
78
+ * @param path - Absolute or relative path
79
+ * @param patterns - Glob pattern(s) to match against
80
+ * @returns true if excluded, false otherwise
81
+ */
82
+ export declare function isPathExcluded(path: string, patterns?: string | string[]): boolean;
72
83
  /**
73
84
  * Resolve a path to an absolute path, handling relative segments
74
85
  *
@@ -106,7 +117,7 @@ export declare function createBuffer(data: string | Uint8Array | ArrayBuffer, en
106
117
  * @param fileHandle - The file handle to read from
107
118
  * @returns The raw binary data as Uint8Array
108
119
  */
109
- export declare function readFileData(fileHandle: FileSystemFileHandle): Promise<Uint8Array>;
120
+ export declare function readFileData(fileHandle: FileSystemFileHandle, path: string): Promise<Uint8Array>;
110
121
  /**
111
122
  * Write data to a file using a file handle
112
123
  *
@@ -114,11 +125,12 @@ export declare function readFileData(fileHandle: FileSystemFileHandle): Promise<
114
125
  * @param data - The data to write to the file
115
126
  * @param encoding - The encoding to use
116
127
  * @param options - Write options (truncate or append)
128
+ * @param path - Optional path for locking (if not provided, no locking is used)
117
129
  */
118
130
  export declare function writeFileData(fileHandle: FileSystemFileHandle, data: string | Uint8Array | ArrayBuffer, encoding?: BufferEncoding, options?: {
119
131
  truncate?: boolean;
120
132
  append?: boolean;
121
- }): Promise<void>;
133
+ }, path?: string): Promise<void>;
122
134
  /**
123
135
  * Calculate file hash using Web Crypto API
124
136
  *
@@ -129,6 +141,14 @@ export declare function writeFileData(fileHandle: FileSystemFileHandle, data: st
129
141
  * @throws Error if file size exceeds maxSize
130
142
  */
131
143
  export declare function calculateFileHash(buffer: File | ArrayBuffer | Uint8Array, algorithm?: string, maxSize?: number): Promise<string>;
144
+ /**
145
+ * Compare two Uint8Array buffers for equality
146
+ *
147
+ * @param a - First buffer
148
+ * @param b - Second buffer
149
+ * @returns true if buffers are equal, false otherwise
150
+ */
151
+ export declare function buffersEqual(a: Uint8Array, b: Uint8Array): boolean;
132
152
  /**
133
153
  * Convert a Blob to Uint8Array
134
154
  *
@@ -146,7 +166,19 @@ export declare function calculateFileHash(buffer: File | ArrayBuffer | Uint8Arra
146
166
  * const data = await convertBlobToUint8Array(file);
147
167
  * await fs.writeFile('/uploaded-file', data);
148
168
  * }
169
+ * }
149
170
  * ```
150
171
  */
151
172
  export declare function convertBlobToUint8Array(blob: Blob): Promise<Uint8Array>;
173
+ /**
174
+ * Remove a file or directory entry using a directory handle
175
+ *
176
+ * @param parentHandle - The parent directory handle
177
+ * @param path - The full path of the entry to remove
178
+ * @param options - Remove options (recursive, force)
179
+ */
180
+ export declare function removeEntry(parentHandle: FileSystemDirectoryHandle, path: string, options?: {
181
+ recursive?: boolean;
182
+ force?: boolean;
183
+ }): Promise<void>;
152
184
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAQ3D;AAGD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAI5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyBhD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,EAAE,QAAQ,GAAE,cAAwB,GAAG,UAAU,CAMpH;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,CAAA;CAAO,EACtD,IAAI,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACnC,MAAM,EAAE,IAAI,GAAG,WAAW,GAAG,UAAU,EACvC,SAAS,GAAE,MAAgB,EAC3B,OAAO,GAAE,MAAyB,GACnC,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAYlE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAI7E;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC7B,YAAY,EAAE,yBAAyB,EACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACvD,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
package/dist/worker.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DirentData, FileStat, OPFSOptions } from './types';
1
+ import type { DirentData, FileStat, OPFSOptions, WatchOptions } from './types';
2
2
  import type { BufferEncoding } from 'typescript';
3
3
  /**
4
4
  * OPFS (Origin Private File System) File System implementation
@@ -18,12 +18,8 @@ import type { BufferEncoding } from 'typescript';
18
18
  export declare class OPFSWorker {
19
19
  /** Root directory handle for the file system */
20
20
  private root;
21
- /** Map of watched paths to their last known state */
21
+ /** Map of watched paths and options */
22
22
  private watchers;
23
- /** Interval handle for polling watched paths */
24
- private watchTimer;
25
- /** Flag to avoid concurrent scans */
26
- private scanning;
27
23
  /** Promise to prevent concurrent mount operations */
28
24
  private mountingPromise;
29
25
  /** BroadcastChannel instance for sending events */
@@ -44,6 +40,7 @@ export declare class OPFSWorker {
44
40
  * Creates a new OPFSFileSystem instance
45
41
  *
46
42
  * @param options - Optional configuration options
43
+ * @param options.root - Root path for the file system (default: '/')
47
44
  * @param options.watchInterval - Polling interval in milliseconds for file watching
48
45
  * @param options.hashAlgorithm - Hash algorithm for file hashing
49
46
  * @param options.maxFileSize - Maximum file size for hashing in bytes (default: 50MB)
@@ -71,27 +68,18 @@ export declare class OPFSWorker {
71
68
  * await fs.mount('/my-app');
72
69
  * ```
73
70
  */
74
- mount(root?: string): Promise<boolean>;
71
+ private mount;
75
72
  /**
76
73
  * Update configuration options
77
74
  *
78
75
  * @param options - Configuration options to update
76
+ * @param options.root - Root path for the file system
79
77
  * @param options.watchInterval - Polling interval in milliseconds for file watching
80
78
  * @param options.hashAlgorithm - Hash algorithm for file hashing
81
79
  * @param options.maxFileSize - Maximum file size for hashing in bytes
82
80
  * @param options.broadcastChannel - Custom name for the broadcast channel
83
81
  */
84
- setOptions(options: OPFSOptions): void;
85
- /**
86
- * Automatically mount the OPFS root if not already mounted
87
- *
88
- * This method is called internally when file operations are performed
89
- * without explicitly mounting first.
90
- *
91
- * @returns Promise that resolves when auto-mount is complete
92
- * @throws {OPFSError} If auto-mount fails
93
- */
94
- private ensureMounted;
82
+ setOptions(options: OPFSOptions): Promise<void>;
95
83
  /**
96
84
  * Get a directory handle from a path
97
85
  *
@@ -422,8 +410,30 @@ export declare class OPFSWorker {
422
410
  }): Promise<void>;
423
411
  /**
424
412
  * Start watching a file or directory for changes
413
+ *
414
+ * @param path - The path to watch (minimatch syntax allowed)
415
+ * @param options - Watch options
416
+ * @param options.recursive - Whether to watch recursively (default: true)
417
+ * @param options.exclude - Glob pattern(s) to exclude (minimatch).
418
+ * @returns Promise that resolves when watching starts
419
+ *
420
+ * @example
421
+ * ```typescript
422
+ * // Watch entire directory tree recursively (default)
423
+ * await fs.watch('/data');
424
+ *
425
+ * // Watch only immediate children (shallow)
426
+ * await fs.watch('/data', { recursive: false });
427
+ *
428
+ * // Watch a single file
429
+ * await fs.watch('/config.json', { recursive: false });
430
+ *
431
+ * // Watch all json files but not in dist directory
432
+ * await fs.watch('/**\/*.json', { recursive: false, exclude: ['dist/**'] });
433
+ *
434
+ * ```
425
435
  */
426
- watch(path: string): Promise<void>;
436
+ watch(path: string, options?: WatchOptions): Promise<void>;
427
437
  /**
428
438
  * Stop watching a previously watched path
429
439
  */
@@ -435,8 +445,6 @@ export declare class OPFSWorker {
435
445
  * to properly clean up resources like the broadcast channel and watch timers.
436
446
  */
437
447
  dispose(): void;
438
- private buildSnapshot;
439
- private scanWatches;
440
448
  /**
441
449
  * Synchronize the file system with external data
442
450
  *
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAc,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAU;IACnB,gDAAgD;IAChD,OAAO,CAAC,IAAI,CAA0C;IAEtD,qDAAqD;IACrD,OAAO,CAAC,QAAQ,CAA4C;IAE5D,gDAAgD;IAChD,OAAO,CAAC,UAAU,CAA+C;IAEjE,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAS;IAEzB,qDAAqD;IACrD,OAAO,CAAC,eAAe,CAAiC;IAExD,mDAAmD;IACnD,OAAO,CAAC,gBAAgB,CAAiC;IAEzD,4BAA4B;IAC5B,OAAO,CAAC,OAAO,CAKb;IAGF;;;;;;;;OAQG;YACW,YAAY;IAyC1B;;;;;;;;OAQG;gBACS,OAAO,CAAC,EAAE,WAAW;IAUjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,KAAK,CAAC,IAAI,GAAE,MAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAkCjD;;;;;;;;OAQG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAwB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