UNPKG

@pstdio/opfs-utils

Version:

Utilities for the browser's OPFS: ls, grep, safe file read, unified diff patching, and MIME helpers.

20 lines (19 loc) 871 B
export type DirectoryWatcherCleanup = () => void; export type ChangeType = "appeared" | "modified" | "disappeared" | "moved" | "unknown" | "errored"; export interface ChangeRecord { type: ChangeType; path: string[]; size?: number; lastModified?: number; handleKind?: FileSystemHandle["kind"]; } export interface WatchOptions { intervalMs?: number; pauseWhenHidden?: boolean; emitInitial?: boolean; recursive?: boolean; signal?: AbortSignal; ignore?: RegExp | RegExp[] | ((path: string[], handle: FileSystemHandle) => boolean); } export declare function watchOPFS(callback: (changes: ChangeRecord[]) => void, options?: WatchOptions): Promise<DirectoryWatcherCleanup>; export declare function watchDirectory(dirPath: string, callback: (changes: ChangeRecord[]) => void, options?: WatchOptions): Promise<DirectoryWatcherCleanup>;