@componentor/fs 1.2.7 → 2.0.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/src/types.ts DELETED
@@ -1,289 +0,0 @@
1
- /**
2
- * File system constants matching Node.js fs.constants
3
- */
4
- export interface FSConstants {
5
- F_OK: number
6
- R_OK: number
7
- W_OK: number
8
- X_OK: number
9
- COPYFILE_EXCL: number
10
- COPYFILE_FICLONE: number
11
- COPYFILE_FICLONE_FORCE: number
12
- O_RDONLY: number
13
- O_WRONLY: number
14
- O_RDWR: number
15
- O_CREAT: number
16
- O_EXCL: number
17
- O_TRUNC: number
18
- O_APPEND: number
19
- S_IFMT: number
20
- S_IFREG: number
21
- S_IFDIR: number
22
- S_IFLNK: number
23
- }
24
-
25
- /**
26
- * Configuration options for OPFS instance
27
- */
28
- export interface OPFSOptions {
29
- /** Use synchronous access handles when available (default: true) */
30
- useSync?: boolean
31
- /** Enable verbose logging (default: false) */
32
- verbose?: boolean
33
- /** Enable compression for batch writes (default: false) */
34
- useCompression?: boolean
35
- /** Enable CRC32 checksum for batch writes (default: true) */
36
- useChecksum?: boolean
37
- }
38
-
39
- /**
40
- * Options for readFile operation
41
- */
42
- export interface ReadFileOptions {
43
- /** Text encoding (e.g., 'utf-8'). If not provided, returns Uint8Array */
44
- encoding?: string
45
- }
46
-
47
- /**
48
- * Options for writeFile operation
49
- */
50
- export interface WriteFileOptions {
51
- /** Text encoding for string data */
52
- encoding?: string
53
- }
54
-
55
- /**
56
- * Entry for batch file write operation
57
- */
58
- export interface BatchWriteEntry {
59
- /** File path to write */
60
- path: string
61
- /** Data to write (string or binary) */
62
- data: string | Uint8Array
63
- }
64
-
65
- /**
66
- * Result entry for batch file read operation
67
- */
68
- export interface BatchReadResult {
69
- /** File path */
70
- path: string
71
- /** File data (null if file doesn't exist or error occurred) */
72
- data: Uint8Array | null
73
- /** Error if read failed */
74
- error?: Error
75
- }
76
-
77
- /**
78
- * Options for readdir operation
79
- */
80
- export interface ReaddirOptions {
81
- /** Return Dirent objects instead of strings */
82
- withFileTypes?: boolean
83
- }
84
-
85
- /**
86
- * Directory entry (Dirent-like object)
87
- */
88
- export interface Dirent {
89
- name: string
90
- isFile(): boolean
91
- isDirectory(): boolean
92
- isSymbolicLink(): boolean
93
- }
94
-
95
- /**
96
- * File statistics
97
- */
98
- export interface Stats {
99
- type: 'file' | 'dir' | 'symlink'
100
- size: number
101
- mode: number
102
- ctime: Date
103
- ctimeMs: number
104
- mtime: Date
105
- mtimeMs: number
106
- target?: string
107
- isFile(): boolean
108
- isDirectory(): boolean
109
- isSymbolicLink(): boolean
110
- }
111
-
112
- /**
113
- * Options for rm operation
114
- */
115
- export interface RmOptions {
116
- /** Remove directories and their contents recursively */
117
- recursive?: boolean
118
- /** Ignore if path doesn't exist */
119
- force?: boolean
120
- }
121
-
122
- /**
123
- * Options for cp operation
124
- */
125
- export interface CpOptions {
126
- /** Copy directories recursively */
127
- recursive?: boolean
128
- /** Overwrite existing files */
129
- force?: boolean
130
- /** Throw if destination exists */
131
- errorOnExist?: boolean
132
- }
133
-
134
- /**
135
- * Options for watch operation
136
- */
137
- export interface WatchOptions {
138
- /** Keep the process running while watching (default: true) */
139
- persistent?: boolean
140
- /** Watch subdirectories recursively */
141
- recursive?: boolean
142
- /** Abort signal to stop watching */
143
- signal?: AbortSignal
144
- /** Encoding for filename (default: 'utf8') */
145
- encoding?: string
146
- }
147
-
148
- /**
149
- * Watch event
150
- */
151
- export interface WatchEvent {
152
- eventType: 'rename' | 'change'
153
- filename: string
154
- }
155
-
156
- /**
157
- * File watcher
158
- */
159
- export interface FSWatcher {
160
- close(): void
161
- ref(): FSWatcher
162
- unref(): FSWatcher
163
- [Symbol.asyncIterator](): AsyncIterator<WatchEvent>
164
- }
165
-
166
- /**
167
- * Read stream options
168
- */
169
- export interface ReadStreamOptions {
170
- /** Start reading from this byte position */
171
- start?: number
172
- /** Stop reading at this byte position */
173
- end?: number
174
- /** Chunk size for reading (default: 64KB) */
175
- highWaterMark?: number
176
- }
177
-
178
- /**
179
- * Write stream options
180
- */
181
- export interface WriteStreamOptions {
182
- /** File open flags (default: 'w') */
183
- flags?: string
184
- /** Start writing at this byte position */
185
- start?: number
186
- }
187
-
188
- /**
189
- * Symlink definition for batch operations
190
- */
191
- export interface SymlinkDefinition {
192
- target: string
193
- path: string
194
- }
195
-
196
- /**
197
- * Result of read operation on FileHandle
198
- */
199
- export interface ReadResult {
200
- bytesRead: number
201
- buffer: Uint8Array
202
- }
203
-
204
- /**
205
- * Result of write operation on FileHandle
206
- */
207
- export interface WriteResult {
208
- bytesWritten: number
209
- buffer: Uint8Array
210
- }
211
-
212
- /**
213
- * FileHandle interface (returned by open())
214
- */
215
- export interface FileHandle {
216
- fd: number
217
- read(buffer: Uint8Array, offset?: number, length?: number, position?: number | null): Promise<ReadResult>
218
- write(buffer: Uint8Array, offset?: number, length?: number, position?: number | null): Promise<WriteResult>
219
- close(): Promise<void>
220
- stat(): Promise<Stats>
221
- truncate(len?: number): Promise<void>
222
- sync(): Promise<void>
223
- datasync(): Promise<void>
224
- readFile(options?: ReadFileOptions): Promise<string | Uint8Array>
225
- writeFile(data: string | Uint8Array, options?: WriteFileOptions): Promise<void>
226
- appendFile(data: string | Uint8Array, options?: WriteFileOptions): Promise<void>
227
- [Symbol.asyncDispose](): Promise<void>
228
- }
229
-
230
- /**
231
- * Directory handle (returned by opendir())
232
- */
233
- export interface Dir {
234
- path: string
235
- read(): Promise<Dirent | null>
236
- close(): Promise<void>
237
- [Symbol.asyncIterator](): AsyncIterableIterator<Dirent>
238
- }
239
-
240
- /**
241
- * Disk usage result
242
- */
243
- export interface DiskUsage {
244
- path: string
245
- size: number
246
- }
247
-
248
- /**
249
- * Filesystem statistics (similar to Node.js fs.statfs)
250
- */
251
- export interface StatFs {
252
- /** Filesystem type (always 0 for OPFS) */
253
- type: number
254
- /** Optimal transfer block size (simulated as 4096) */
255
- bsize: number
256
- /** Total blocks in filesystem */
257
- blocks: number
258
- /** Free blocks in filesystem */
259
- bfree: number
260
- /** Available blocks for unprivileged users */
261
- bavail: number
262
- /** Total file nodes (0 - not available in browser) */
263
- files: number
264
- /** Free file nodes (0 - not available in browser) */
265
- ffree: number
266
- /** Bytes used by origin (from Storage API) */
267
- usage: number
268
- /** Total bytes available to origin (from Storage API) */
269
- quota: number
270
- }
271
-
272
- /**
273
- * Internal symlink cache structure
274
- */
275
- export type SymlinkCache = Record<string, string>
276
-
277
- /**
278
- * Watch callback function
279
- */
280
- export type WatchCallback = (eventType: string, filename: string) => void
281
-
282
- /**
283
- * Internal watch registration
284
- */
285
- export interface WatchRegistration {
286
- path: string
287
- callbacks: Set<WatchCallback>
288
- recursive: boolean
289
- }