opfs-worker 1.1.0 → 1.2.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.
@@ -0,0 +1,141 @@
1
+ import type { DirentData, Encoding, FileOpenOptions, FileStat, OPFSOptions, RenameOptions, WatchOptions } from './types';
2
+ /**
3
+ * Facade class that provides a clean interface for communicating with the OPFS worker
4
+ * while hiding Comlink implementation details.
5
+ */
6
+ export declare class OPFSFileSystem {
7
+ #private;
8
+ constructor(options?: OPFSOptions);
9
+ /**
10
+ * Update configuration options
11
+ */
12
+ setOptions(options: OPFSOptions): Promise<void>;
13
+ /**
14
+ * Get a complete index of all files and directories in the file system
15
+ */
16
+ index(): Promise<Map<string, FileStat>>;
17
+ /**
18
+ * Read a file from the file system
19
+ */
20
+ readFile(path: string, encoding: 'binary'): Promise<Uint8Array>;
21
+ readFile(path: string, encoding: Encoding): Promise<string>;
22
+ readFile(path: string, encoding?: Encoding | 'binary'): Promise<string | Uint8Array>;
23
+ /**
24
+ * Write data to a file
25
+ */
26
+ writeFile(path: string, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
27
+ /**
28
+ * Append data to a file
29
+ */
30
+ appendFile(path: string, data: string | Uint8Array | ArrayBuffer, encoding?: Encoding): Promise<void>;
31
+ /**
32
+ * Create a directory
33
+ */
34
+ mkdir(path: string, options?: {
35
+ recursive?: boolean;
36
+ }): Promise<void>;
37
+ /**
38
+ * Get file or directory statistics
39
+ */
40
+ stat(path: string): Promise<FileStat>;
41
+ /**
42
+ * Read a directory's contents
43
+ */
44
+ readDir(path: string): Promise<DirentData[]>;
45
+ /**
46
+ * Check if a file or directory exists
47
+ */
48
+ exists(path: string): Promise<boolean>;
49
+ /**
50
+ * Clear all contents of a directory without removing the directory itself
51
+ */
52
+ clear(path?: string): Promise<void>;
53
+ /**
54
+ * Remove files and directories
55
+ */
56
+ remove(path: string, options?: {
57
+ recursive?: boolean;
58
+ force?: boolean;
59
+ }): Promise<void>;
60
+ /**
61
+ * Resolve a path to an absolute path
62
+ */
63
+ realpath(path: string): Promise<string>;
64
+ /**
65
+ * Rename a file or directory
66
+ */
67
+ rename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void>;
68
+ /**
69
+ * Copy files and directories
70
+ */
71
+ copy(source: string, destination: string, options?: {
72
+ recursive?: boolean;
73
+ overwrite?: boolean;
74
+ }): Promise<void>;
75
+ /**
76
+ * Start watching a file or directory for changes
77
+ */
78
+ watch(path: string, options?: WatchOptions): () => void;
79
+ /**
80
+ * Stop watching a previously watched path
81
+ */
82
+ unwatch(path: string): void;
83
+ /**
84
+ * Open a file and return a file descriptor
85
+ */
86
+ open(path: string, options?: FileOpenOptions): Promise<number>;
87
+ /**
88
+ * Close a file descriptor
89
+ */
90
+ close(fd: number): Promise<void>;
91
+ /**
92
+ * Read data from a file descriptor
93
+ *
94
+ * This method requires special handling due to Comlink transfer requirements.
95
+ * The buffer is transferred to the worker and back, so the original buffer
96
+ * becomes unusable after the call.
97
+ */
98
+ read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number | null | undefined): Promise<{
99
+ bytesRead: number;
100
+ buffer: Uint8Array;
101
+ }>;
102
+ /**
103
+ * Write data to a file descriptor
104
+ */
105
+ write(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null | undefined, emitEvent?: boolean): Promise<number>;
106
+ /**
107
+ * Get file status information by file descriptor
108
+ */
109
+ fstat(fd: number): Promise<FileStat>;
110
+ /**
111
+ * Truncate file to specified size
112
+ */
113
+ ftruncate(fd: number, size?: number): Promise<void>;
114
+ /**
115
+ * Synchronize file data to storage (fsync equivalent)
116
+ */
117
+ fsync(fd: number): Promise<void>;
118
+ /**
119
+ * Dispose of resources and clean up the file system instance
120
+ */
121
+ dispose(): void;
122
+ /**
123
+ * Synchronize the file system with external data
124
+ */
125
+ sync(entries: [string, string | Uint8Array | Blob][], options?: {
126
+ cleanBefore?: boolean;
127
+ }): Promise<void>;
128
+ /**
129
+ * Read a file as text with automatic encoding detection
130
+ */
131
+ readText(path: string, encoding?: Encoding): Promise<string>;
132
+ /**
133
+ * Write text to a file with specified encoding
134
+ */
135
+ writeText(path: string, text: string, encoding?: Encoding): Promise<void>;
136
+ /**
137
+ * Append text to a file with specified encoding
138
+ */
139
+ appendText(path: string, text: string, encoding?: Encoding): Promise<void>;
140
+ }
141
+ //# sourceMappingURL=facade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACR,UAAU,EACV,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,WAAW,EAEX,aAAa,EACb,YAAY,EACf,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,qBAAa,cAAc;;gBAGX,OAAO,CAAC,EAAE,WAAW;IAiBjC;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,WAAW;IAIrC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAI7C;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC;IAiB1F;;OAEG;IACG,SAAS,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,EACvC,QAAQ,CAAC,EAAE,QAAQ,GACpB,OAAO,CAAC,IAAI,CAAC;IAchB;;OAEG;IACG,UAAU,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,U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