@componentor/fs 3.0.26 → 3.0.28
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/index.d.mts +308 -60
- package/dist/index.js +951 -164
- package/dist/index.js.map +1 -1
- package/dist/workers/repair.worker.js +1 -2
- package/dist/workers/repair.worker.js.map +1 -1
- package/dist/workers/server.worker.js +1 -2
- package/dist/workers/server.worker.js.map +1 -1
- package/dist/workers/sync-relay.worker.js +14 -5
- package/dist/workers/sync-relay.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6,12 +6,14 @@ type Encoding = 'utf8' | 'utf-8' | 'ascii' | 'base64' | 'hex' | 'binary' | 'lati
|
|
|
6
6
|
interface ReadOptions {
|
|
7
7
|
encoding?: Encoding | null;
|
|
8
8
|
flag?: string;
|
|
9
|
+
signal?: AbortSignal;
|
|
9
10
|
}
|
|
10
11
|
interface WriteOptions {
|
|
11
12
|
encoding?: Encoding;
|
|
12
13
|
mode?: number;
|
|
13
14
|
flag?: string;
|
|
14
15
|
flush?: boolean;
|
|
16
|
+
signal?: AbortSignal;
|
|
15
17
|
}
|
|
16
18
|
interface MkdirOptions {
|
|
17
19
|
recursive?: boolean;
|
|
@@ -23,6 +25,8 @@ interface RmdirOptions {
|
|
|
23
25
|
interface RmOptions {
|
|
24
26
|
recursive?: boolean;
|
|
25
27
|
force?: boolean;
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
retryDelay?: number;
|
|
26
30
|
}
|
|
27
31
|
interface CpOptions {
|
|
28
32
|
/** Dereference symlinks (default: false) */
|
|
@@ -101,6 +105,10 @@ interface Stats {
|
|
|
101
105
|
mtime: Date;
|
|
102
106
|
ctime: Date;
|
|
103
107
|
birthtime: Date;
|
|
108
|
+
atimeNs: number;
|
|
109
|
+
mtimeNs: number;
|
|
110
|
+
ctimeNs: number;
|
|
111
|
+
birthtimeNs: number;
|
|
104
112
|
}
|
|
105
113
|
interface Dirent {
|
|
106
114
|
name: string;
|
|
@@ -129,7 +137,31 @@ interface GlobOptions {
|
|
|
129
137
|
cwd?: string;
|
|
130
138
|
exclude?: (path: string) => boolean;
|
|
131
139
|
}
|
|
132
|
-
type PathLike = string;
|
|
140
|
+
type PathLike = string | Uint8Array | URL;
|
|
141
|
+
interface OpenAsBlobOptions {
|
|
142
|
+
type?: string;
|
|
143
|
+
}
|
|
144
|
+
interface FSReadStream {
|
|
145
|
+
/** The file path being read. */
|
|
146
|
+
path: string;
|
|
147
|
+
/** Total bytes read so far. */
|
|
148
|
+
bytesRead: number;
|
|
149
|
+
/** Whether the stream is still readable. */
|
|
150
|
+
readable: boolean;
|
|
151
|
+
on(event: string, fn: (...args: unknown[]) => void): this;
|
|
152
|
+
addListener(event: string, fn: (...args: unknown[]) => void): this;
|
|
153
|
+
once(event: string, fn: (...args: unknown[]) => void): this;
|
|
154
|
+
off(event: string, fn: (...args: unknown[]) => void): this;
|
|
155
|
+
removeListener(event: string, fn: (...args: unknown[]) => void): this;
|
|
156
|
+
removeAllListeners(event?: string): this;
|
|
157
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
158
|
+
pipe<T>(dest: T): T;
|
|
159
|
+
pause(): this;
|
|
160
|
+
resume(): this;
|
|
161
|
+
read(size?: number): Uint8Array | null;
|
|
162
|
+
setEncoding(encoding: string): this;
|
|
163
|
+
destroy(err?: Error): this;
|
|
164
|
+
}
|
|
133
165
|
interface ReadStreamOptions {
|
|
134
166
|
flags?: string;
|
|
135
167
|
encoding?: Encoding | null;
|
|
@@ -152,6 +184,21 @@ interface WriteStreamOptions {
|
|
|
152
184
|
highWaterMark?: number;
|
|
153
185
|
flush?: boolean;
|
|
154
186
|
}
|
|
187
|
+
interface FSWriteStream {
|
|
188
|
+
writable: boolean;
|
|
189
|
+
bytesWritten: number;
|
|
190
|
+
path: string;
|
|
191
|
+
cork(): void;
|
|
192
|
+
uncork(): void;
|
|
193
|
+
write(chunk: string | Uint8Array, encodingOrCb?: string | Function, cb?: Function): boolean;
|
|
194
|
+
end(chunk?: string | Uint8Array | Function, encodingOrCb?: string | Function, cb?: Function): this;
|
|
195
|
+
on(event: string, fn: Function): this;
|
|
196
|
+
once(event: string, fn: Function): this;
|
|
197
|
+
off(event: string, fn: Function): this;
|
|
198
|
+
removeListener(event: string, fn: Function): this;
|
|
199
|
+
destroy(err?: Error): this;
|
|
200
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
201
|
+
}
|
|
155
202
|
interface WatchOptions {
|
|
156
203
|
persistent?: boolean;
|
|
157
204
|
recursive?: boolean;
|
|
@@ -180,13 +227,25 @@ interface FileHandle {
|
|
|
180
227
|
bytesWritten: number;
|
|
181
228
|
buffer: Uint8Array;
|
|
182
229
|
}>;
|
|
230
|
+
readv(buffers: Uint8Array[], position?: number | null): Promise<{
|
|
231
|
+
bytesRead: number;
|
|
232
|
+
buffers: Uint8Array[];
|
|
233
|
+
}>;
|
|
234
|
+
writev(buffers: Uint8Array[], position?: number | null): Promise<{
|
|
235
|
+
bytesWritten: number;
|
|
236
|
+
buffers: Uint8Array[];
|
|
237
|
+
}>;
|
|
183
238
|
readFile(options?: ReadOptions | Encoding | null): Promise<Uint8Array | string>;
|
|
184
239
|
writeFile(data: Uint8Array | string, options?: WriteOptions | Encoding): Promise<void>;
|
|
185
240
|
truncate(len?: number): Promise<void>;
|
|
186
241
|
stat(): Promise<Stats>;
|
|
242
|
+
appendFile(data: string | Uint8Array, options?: WriteOptions | Encoding): Promise<void>;
|
|
243
|
+
chmod(mode: number): Promise<void>;
|
|
244
|
+
chown(uid: number, gid: number): Promise<void>;
|
|
187
245
|
sync(): Promise<void>;
|
|
188
246
|
datasync(): Promise<void>;
|
|
189
247
|
close(): Promise<void>;
|
|
248
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
190
249
|
}
|
|
191
250
|
interface Dir {
|
|
192
251
|
path: string;
|
|
@@ -321,49 +380,80 @@ declare class VFSFileSystem {
|
|
|
321
380
|
/** Send a sync request via SAB and wait for response */
|
|
322
381
|
private syncRequest;
|
|
323
382
|
private asyncRequest;
|
|
324
|
-
readFileSync(filePath:
|
|
325
|
-
writeFileSync(filePath:
|
|
326
|
-
appendFileSync(filePath:
|
|
327
|
-
existsSync(filePath:
|
|
328
|
-
mkdirSync(filePath:
|
|
329
|
-
rmdirSync(filePath:
|
|
330
|
-
rmSync(filePath:
|
|
331
|
-
unlinkSync(filePath:
|
|
332
|
-
readdirSync(filePath:
|
|
383
|
+
readFileSync(filePath: PathLike, options?: ReadOptions | Encoding | null): string | Uint8Array;
|
|
384
|
+
writeFileSync(filePath: PathLike, data: string | Uint8Array, options?: WriteOptions | Encoding): void;
|
|
385
|
+
appendFileSync(filePath: PathLike, data: string | Uint8Array, options?: WriteOptions | Encoding): void;
|
|
386
|
+
existsSync(filePath: PathLike): boolean;
|
|
387
|
+
mkdirSync(filePath: PathLike, options?: MkdirOptions | number): string | undefined;
|
|
388
|
+
rmdirSync(filePath: PathLike, options?: RmdirOptions): void;
|
|
389
|
+
rmSync(filePath: PathLike, options?: RmOptions): void;
|
|
390
|
+
unlinkSync(filePath: PathLike): void;
|
|
391
|
+
readdirSync(filePath: PathLike, options?: ReaddirOptions | Encoding | null): string[] | Dirent[];
|
|
333
392
|
globSync(pattern: string, options?: GlobOptions): string[];
|
|
334
|
-
statSync(filePath:
|
|
335
|
-
lstatSync(filePath:
|
|
336
|
-
renameSync(oldPath:
|
|
337
|
-
copyFileSync(src:
|
|
338
|
-
cpSync(src:
|
|
339
|
-
|
|
340
|
-
truncateSync(filePath:
|
|
341
|
-
accessSync(filePath:
|
|
342
|
-
realpathSync(filePath:
|
|
343
|
-
chmodSync(filePath:
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
393
|
+
statSync(filePath: PathLike, options?: StatOptions): Stats | BigIntStats;
|
|
394
|
+
lstatSync(filePath: PathLike, options?: StatOptions): Stats | BigIntStats;
|
|
395
|
+
renameSync(oldPath: PathLike, newPath: PathLike): void;
|
|
396
|
+
copyFileSync(src: PathLike, dest: PathLike, mode?: number): void;
|
|
397
|
+
cpSync(src: PathLike, dest: PathLike, options?: CpOptions): void;
|
|
398
|
+
private _cpAsync;
|
|
399
|
+
truncateSync(filePath: PathLike, len?: number): void;
|
|
400
|
+
accessSync(filePath: PathLike, mode?: number): void;
|
|
401
|
+
realpathSync(filePath: PathLike): string;
|
|
402
|
+
chmodSync(filePath: PathLike, mode: number): void;
|
|
403
|
+
/** Like chmodSync but operates on the symlink itself. In this VFS, delegates to chmodSync. */
|
|
404
|
+
lchmodSync(filePath: string, mode: number): void;
|
|
405
|
+
/** chmod on an open file descriptor. No-op in this VFS (permissions are cosmetic). */
|
|
406
|
+
fchmodSync(_fd: number, _mode: number): void;
|
|
407
|
+
chownSync(filePath: PathLike, uid: number, gid: number): void;
|
|
408
|
+
/** Like chownSync but operates on the symlink itself. In this VFS, delegates to chownSync. */
|
|
409
|
+
lchownSync(filePath: string, uid: number, gid: number): void;
|
|
410
|
+
/** chown on an open file descriptor. No-op in this VFS (permissions are cosmetic). */
|
|
411
|
+
fchownSync(_fd: number, _uid: number, _gid: number): void;
|
|
412
|
+
utimesSync(filePath: PathLike, atime: Date | number, mtime: Date | number): void;
|
|
413
|
+
/** Like utimesSync but operates on the symlink itself. In this VFS, delegates to utimesSync. */
|
|
414
|
+
lutimesSync(filePath: string, atime: Date | number, mtime: Date | number): void;
|
|
415
|
+
symlinkSync(target: PathLike, linkPath: PathLike, type?: string | null): void;
|
|
416
|
+
readlinkSync(filePath: PathLike, options?: {
|
|
348
417
|
encoding?: string | null;
|
|
349
418
|
} | string | null): string | Uint8Array;
|
|
350
|
-
linkSync(existingPath:
|
|
419
|
+
linkSync(existingPath: PathLike, newPath: PathLike): void;
|
|
351
420
|
mkdtempSync(prefix: string): string;
|
|
352
|
-
openSync(filePath:
|
|
421
|
+
openSync(filePath: PathLike, flags?: string | number, mode?: number): number;
|
|
353
422
|
closeSync(fd: number): void;
|
|
354
|
-
readSync(fd: number,
|
|
355
|
-
|
|
423
|
+
readSync(fd: number, bufferOrOptions: Uint8Array | {
|
|
424
|
+
buffer: Uint8Array;
|
|
425
|
+
offset?: number;
|
|
426
|
+
length?: number;
|
|
427
|
+
position?: number | null;
|
|
428
|
+
}, offsetOrOptions?: number | {
|
|
429
|
+
offset?: number;
|
|
430
|
+
length?: number;
|
|
431
|
+
position?: number | null;
|
|
432
|
+
}, length?: number, position?: number | null): number;
|
|
433
|
+
writeSync(fd: number, bufferOrString: Uint8Array | string, offsetOrPositionOrOptions?: number | {
|
|
434
|
+
offset?: number;
|
|
435
|
+
length?: number;
|
|
436
|
+
position?: number | null;
|
|
437
|
+
}, lengthOrEncoding?: number | string, position?: number | null): number;
|
|
356
438
|
fstatSync(fd: number): Stats;
|
|
357
439
|
ftruncateSync(fd: number, len?: number): void;
|
|
358
440
|
fdatasyncSync(fd: number): void;
|
|
441
|
+
fsyncSync(fd: number): void;
|
|
442
|
+
readvSync(fd: number, buffers: Uint8Array[], position?: number | null): number;
|
|
443
|
+
writevSync(fd: number, buffers: Uint8Array[], position?: number | null): number;
|
|
444
|
+
readv(fd: number, buffers: Uint8Array[], position: number | null | undefined, callback: (err: Error | null, bytesRead?: number, buffers?: Uint8Array[]) => void): void;
|
|
445
|
+
readv(fd: number, buffers: Uint8Array[], callback: (err: Error | null, bytesRead?: number, buffers?: Uint8Array[]) => void): void;
|
|
446
|
+
writev(fd: number, buffers: Uint8Array[], position: number | null | undefined, callback: (err: Error | null, bytesWritten?: number, buffers?: Uint8Array[]) => void): void;
|
|
447
|
+
writev(fd: number, buffers: Uint8Array[], callback: (err: Error | null, bytesWritten?: number, buffers?: Uint8Array[]) => void): void;
|
|
359
448
|
statfsSync(_path?: string): StatFs;
|
|
360
449
|
statfs(path: string, callback: (err: Error | null, stats?: StatFs) => void): void;
|
|
361
450
|
statfs(path: string): Promise<StatFs>;
|
|
362
|
-
watch(filePath:
|
|
363
|
-
watchFile(filePath:
|
|
364
|
-
unwatchFile(filePath:
|
|
365
|
-
|
|
366
|
-
|
|
451
|
+
watch(filePath: PathLike, options?: WatchOptions | Encoding, listener?: WatchListener): FSWatcher;
|
|
452
|
+
watchFile(filePath: PathLike, optionsOrListener?: WatchFileOptions | WatchFileListener, listener?: WatchFileListener): void;
|
|
453
|
+
unwatchFile(filePath: PathLike, listener?: WatchFileListener): void;
|
|
454
|
+
openAsBlob(filePath: string, options?: OpenAsBlobOptions): Promise<Blob>;
|
|
455
|
+
createReadStream(filePath: PathLike, options?: ReadStreamOptions | string): FSReadStream;
|
|
456
|
+
createWriteStream(filePath: PathLike, options?: WriteStreamOptions | string): FSWriteStream;
|
|
367
457
|
flushSync(): void;
|
|
368
458
|
purgeSync(): void;
|
|
369
459
|
/** The current filesystem mode. Changes to 'opfs' on corruption fallback. */
|
|
@@ -381,46 +471,190 @@ declare class VFSFileSystem {
|
|
|
381
471
|
*
|
|
382
472
|
* Returns a Promise that resolves when the new mode is ready. */
|
|
383
473
|
setMode(newMode: FSMode): Promise<void>;
|
|
474
|
+
readFile(filePath: string, callback: (err: Error | null, data?: Uint8Array | string) => void): void;
|
|
475
|
+
readFile(filePath: string, options: ReadOptions | Encoding | null, callback: (err: Error | null, data?: Uint8Array | string) => void): void;
|
|
476
|
+
writeFile(filePath: string, data: string | Uint8Array, callback: (err: Error | null) => void): void;
|
|
477
|
+
writeFile(filePath: string, data: string | Uint8Array, options: WriteOptions | Encoding, callback: (err: Error | null) => void): void;
|
|
478
|
+
appendFile(filePath: string, data: string | Uint8Array, callback: (err: Error | null) => void): void;
|
|
479
|
+
appendFile(filePath: string, data: string | Uint8Array, options: WriteOptions | Encoding, callback: (err: Error | null) => void): void;
|
|
480
|
+
mkdir(filePath: string, callback: (err: Error | null, path?: string) => void): void;
|
|
481
|
+
mkdir(filePath: string, options: MkdirOptions | number, callback: (err: Error | null, path?: string) => void): void;
|
|
482
|
+
rmdir(filePath: string, callback: (err: Error | null) => void): void;
|
|
483
|
+
rmdir(filePath: string, options: RmdirOptions, callback: (err: Error | null) => void): void;
|
|
484
|
+
rm(filePath: string, callback: (err: Error | null) => void): void;
|
|
485
|
+
rm(filePath: string, options: RmOptions, callback: (err: Error | null) => void): void;
|
|
486
|
+
unlink(filePath: string, callback: (err: Error | null) => void): void;
|
|
487
|
+
readdir(filePath: string, callback: (err: Error | null, files?: string[] | Dirent[]) => void): void;
|
|
488
|
+
readdir(filePath: string, options: ReaddirOptions | Encoding | null, callback: (err: Error | null, files?: string[] | Dirent[]) => void): void;
|
|
489
|
+
stat(filePath: string, callback: (err: Error | null, stats?: Stats | BigIntStats) => void): void;
|
|
490
|
+
stat(filePath: string, options: StatOptions, callback: (err: Error | null, stats?: Stats | BigIntStats) => void): void;
|
|
491
|
+
lstat(filePath: string, callback: (err: Error | null, stats?: Stats | BigIntStats) => void): void;
|
|
492
|
+
lstat(filePath: string, options: StatOptions, callback: (err: Error | null, stats?: Stats | BigIntStats) => void): void;
|
|
493
|
+
access(filePath: string, callback: (err: Error | null) => void): void;
|
|
494
|
+
access(filePath: string, mode: number, callback: (err: Error | null) => void): void;
|
|
495
|
+
rename(oldPath: string, newPath: string, callback: (err: Error | null) => void): void;
|
|
496
|
+
copyFile(src: string, dest: string, callback: (err: Error | null) => void): void;
|
|
497
|
+
copyFile(src: string, dest: string, mode: number, callback: (err: Error | null) => void): void;
|
|
498
|
+
truncate(filePath: string, callback: (err: Error | null) => void): void;
|
|
499
|
+
truncate(filePath: string, len: number, callback: (err: Error | null) => void): void;
|
|
500
|
+
realpath(filePath: string, callback: (err: Error | null, resolvedPath?: string) => void): void;
|
|
501
|
+
chmod(filePath: string, mode: number, callback: (err: Error | null) => void): void;
|
|
502
|
+
chown(filePath: string, uid: number, gid: number, callback: (err: Error | null) => void): void;
|
|
503
|
+
utimes(filePath: string, atime: Date | number, mtime: Date | number, callback: (err: Error | null) => void): void;
|
|
504
|
+
symlink(target: string, linkPath: string, callback: (err: Error | null) => void): void;
|
|
505
|
+
symlink(target: string, linkPath: string, type: string | null, callback: (err: Error | null) => void): void;
|
|
506
|
+
readlink(filePath: string, callback: (err: Error | null, linkString?: string | Uint8Array) => void): void;
|
|
507
|
+
readlink(filePath: string, options: {
|
|
508
|
+
encoding?: string | null;
|
|
509
|
+
} | string | null, callback: (err: Error | null, linkString?: string | Uint8Array) => void): void;
|
|
510
|
+
link(existingPath: string, newPath: string, callback: (err: Error | null) => void): void;
|
|
511
|
+
open(filePath: string, flags: string | number, callback: (err: Error | null, fd?: number) => void): void;
|
|
512
|
+
open(filePath: string, flags: string | number, mode: number, callback: (err: Error | null, fd?: number) => void): void;
|
|
513
|
+
mkdtemp(prefix: string, callback: (err: Error | null, folder?: string) => void): void;
|
|
514
|
+
cp(src: string, dest: string, callback: (err: Error | null) => void): void;
|
|
515
|
+
cp(src: string, dest: string, options: CpOptions, callback: (err: Error | null) => void): void;
|
|
516
|
+
fdatasync(fd: number, callback: (err: Error | null) => void): void;
|
|
517
|
+
fsync(fd: number, callback: (err: Error | null) => void): void;
|
|
518
|
+
exists(filePath: string, callback: (exists: boolean) => void): void;
|
|
384
519
|
}
|
|
385
520
|
declare class VFSPromises {
|
|
386
521
|
private _async;
|
|
387
522
|
private _ns;
|
|
388
523
|
constructor(asyncRequest: AsyncRequestFn, ns: string);
|
|
389
|
-
readFile(filePath:
|
|
390
|
-
writeFile(filePath:
|
|
391
|
-
appendFile(filePath:
|
|
392
|
-
mkdir(filePath:
|
|
393
|
-
rmdir(filePath:
|
|
394
|
-
rm(filePath:
|
|
395
|
-
unlink(filePath:
|
|
396
|
-
readdir(filePath:
|
|
524
|
+
readFile(filePath: PathLike, options?: ReadOptions | Encoding | null): Promise<string | Uint8Array<ArrayBufferLike>>;
|
|
525
|
+
writeFile(filePath: PathLike, data: string | Uint8Array, options?: WriteOptions | Encoding): Promise<void>;
|
|
526
|
+
appendFile(filePath: PathLike, data: string | Uint8Array, options?: WriteOptions | Encoding): Promise<void>;
|
|
527
|
+
mkdir(filePath: PathLike, options?: MkdirOptions | number): Promise<string | undefined>;
|
|
528
|
+
rmdir(filePath: PathLike, options?: RmdirOptions): Promise<void>;
|
|
529
|
+
rm(filePath: PathLike, options?: RmOptions): Promise<void>;
|
|
530
|
+
unlink(filePath: PathLike): Promise<void>;
|
|
531
|
+
readdir(filePath: PathLike, options?: ReaddirOptions | Encoding | null): Promise<string[] | Dirent[]>;
|
|
397
532
|
glob(pattern: string, options?: GlobOptions): Promise<string[]>;
|
|
398
|
-
stat(filePath:
|
|
399
|
-
lstat(filePath:
|
|
400
|
-
access(filePath:
|
|
401
|
-
rename(oldPath:
|
|
402
|
-
copyFile(src:
|
|
403
|
-
cp(src:
|
|
404
|
-
truncate(filePath:
|
|
405
|
-
realpath(filePath:
|
|
406
|
-
exists(filePath:
|
|
407
|
-
chmod(filePath:
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
533
|
+
stat(filePath: PathLike, options?: StatOptions): Promise<BigIntStats | Stats>;
|
|
534
|
+
lstat(filePath: PathLike, options?: StatOptions): Promise<BigIntStats | Stats>;
|
|
535
|
+
access(filePath: PathLike, mode?: number): Promise<void>;
|
|
536
|
+
rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
|
537
|
+
copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
|
|
538
|
+
cp(src: PathLike, dest: PathLike, options?: CpOptions): Promise<void>;
|
|
539
|
+
truncate(filePath: PathLike, len?: number): Promise<void>;
|
|
540
|
+
realpath(filePath: PathLike): Promise<string>;
|
|
541
|
+
exists(filePath: PathLike): Promise<boolean>;
|
|
542
|
+
chmod(filePath: PathLike, mode: number): Promise<void>;
|
|
543
|
+
/** Like chmod but operates on the symlink itself. In this VFS, delegates to chmod. */
|
|
544
|
+
lchmod(filePath: string, mode: number): Promise<void>;
|
|
545
|
+
/** chmod on an open file descriptor. No-op in this VFS (permissions are cosmetic). */
|
|
546
|
+
fchmod(_fd: number, _mode: number): Promise<void>;
|
|
547
|
+
chown(filePath: PathLike, uid: number, gid: number): Promise<void>;
|
|
548
|
+
/** Like chown but operates on the symlink itself. In this VFS, delegates to chown. */
|
|
549
|
+
lchown(filePath: string, uid: number, gid: number): Promise<void>;
|
|
550
|
+
/** chown on an open file descriptor. No-op in this VFS (permissions are cosmetic). */
|
|
551
|
+
fchown(_fd: number, _uid: number, _gid: number): Promise<void>;
|
|
552
|
+
utimes(filePath: PathLike, atime: Date | number, mtime: Date | number): Promise<void>;
|
|
553
|
+
/** Like utimes but operates on the symlink itself. In this VFS, delegates to utimes. */
|
|
554
|
+
lutimes(filePath: string, atime: Date | number, mtime: Date | number): Promise<void>;
|
|
555
|
+
symlink(target: PathLike, linkPath: PathLike, type?: string | null): Promise<void>;
|
|
556
|
+
readlink(filePath: PathLike, options?: {
|
|
412
557
|
encoding?: string | null;
|
|
413
558
|
} | string | null): Promise<string | Uint8Array<ArrayBufferLike>>;
|
|
414
|
-
link(existingPath:
|
|
415
|
-
open(filePath:
|
|
416
|
-
opendir(filePath:
|
|
559
|
+
link(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
|
560
|
+
open(filePath: PathLike, flags?: string | number, mode?: number): Promise<FileHandle>;
|
|
561
|
+
opendir(filePath: PathLike): Promise<Dir>;
|
|
417
562
|
mkdtemp(prefix: string): Promise<string>;
|
|
563
|
+
openAsBlob(filePath: string, options?: OpenAsBlobOptions): Promise<Blob>;
|
|
418
564
|
statfs(path: string): Promise<StatFs>;
|
|
419
565
|
watch(filePath: string, options?: WatchOptions): AsyncIterable<WatchEventType>;
|
|
566
|
+
fsync(_fd: number): Promise<void>;
|
|
567
|
+
fdatasync(_fd: number): Promise<void>;
|
|
420
568
|
flush(): Promise<void>;
|
|
421
569
|
purge(): Promise<void>;
|
|
422
570
|
}
|
|
423
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Minimal Node.js-compatible stream classes for use in browser/OPFS environments.
|
|
574
|
+
*
|
|
575
|
+
* These do NOT depend on Node.js built-ins — they provide just enough API surface
|
|
576
|
+
* for libraries that expect `.on('data')`, `.pipe()`, `.write()`, `.end()`, etc.
|
|
577
|
+
*/
|
|
578
|
+
type Listener = (...args: unknown[]) => void;
|
|
579
|
+
declare class SimpleEventEmitter {
|
|
580
|
+
private _listeners;
|
|
581
|
+
private _onceSet;
|
|
582
|
+
on(event: string, fn: Listener): this;
|
|
583
|
+
addListener(event: string, fn: Listener): this;
|
|
584
|
+
once(event: string, fn: Listener): this;
|
|
585
|
+
off(event: string, fn: Listener): this;
|
|
586
|
+
removeListener(event: string, fn: Listener): this;
|
|
587
|
+
removeAllListeners(event?: string): this;
|
|
588
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
589
|
+
listenerCount(event: string): number;
|
|
590
|
+
}
|
|
591
|
+
declare class NodeReadable extends SimpleEventEmitter {
|
|
592
|
+
private _readFn;
|
|
593
|
+
private _paused;
|
|
594
|
+
private _destroyed;
|
|
595
|
+
private _ended;
|
|
596
|
+
private _reading;
|
|
597
|
+
private _readBuffer;
|
|
598
|
+
private _encoding;
|
|
599
|
+
/** Whether the stream is still readable (not ended or destroyed). */
|
|
600
|
+
readable: boolean;
|
|
601
|
+
/** The file path this stream reads from (set externally). */
|
|
602
|
+
path: string;
|
|
603
|
+
/** Total bytes read so far. */
|
|
604
|
+
bytesRead: number;
|
|
605
|
+
/** Optional cleanup callback invoked on destroy (e.g. close file handle). */
|
|
606
|
+
private _destroyFn;
|
|
607
|
+
constructor(_readFn: () => Promise<{
|
|
608
|
+
done: boolean;
|
|
609
|
+
value?: Uint8Array;
|
|
610
|
+
}>, destroyFn?: () => Promise<void>);
|
|
611
|
+
on(event: string, fn: Listener): this;
|
|
612
|
+
pause(): this;
|
|
613
|
+
resume(): this;
|
|
614
|
+
/**
|
|
615
|
+
* Set the character encoding for data read from this stream.
|
|
616
|
+
* When set, 'data' events emit strings instead of Uint8Array.
|
|
617
|
+
*/
|
|
618
|
+
setEncoding(encoding: string): this;
|
|
619
|
+
/**
|
|
620
|
+
* Non-flowing read — returns the last buffered chunk or null.
|
|
621
|
+
* Node.js has a complex buffer system; we keep it simple here.
|
|
622
|
+
*/
|
|
623
|
+
read(_size?: number): Uint8Array | null;
|
|
624
|
+
/** Destroy the stream, optionally with an error. */
|
|
625
|
+
destroy(err?: Error): this;
|
|
626
|
+
pipe<T extends NodeWritable | WritableStream<Uint8Array>>(dest: T): T;
|
|
627
|
+
private _drain;
|
|
628
|
+
}
|
|
629
|
+
declare class NodeWritable extends SimpleEventEmitter {
|
|
630
|
+
private _writeFn;
|
|
631
|
+
private _closeFn;
|
|
632
|
+
/** Total bytes written so far. */
|
|
633
|
+
bytesWritten: number;
|
|
634
|
+
/** The file path this stream was created for. */
|
|
635
|
+
readonly path: string;
|
|
636
|
+
/** Whether this stream is still writable. */
|
|
637
|
+
writable: boolean;
|
|
638
|
+
private _destroyed;
|
|
639
|
+
private _finished;
|
|
640
|
+
private _writing;
|
|
641
|
+
private _corked;
|
|
642
|
+
constructor(path: string, _writeFn: (chunk: Uint8Array) => Promise<void>, _closeFn: () => Promise<void>);
|
|
643
|
+
/**
|
|
644
|
+
* Buffer all writes until `uncork()` is called.
|
|
645
|
+
* In this minimal implementation we only track the flag for compatibility.
|
|
646
|
+
*/
|
|
647
|
+
cork(): void;
|
|
648
|
+
/**
|
|
649
|
+
* Flush buffered writes (clears the cork flag).
|
|
650
|
+
* In this minimal implementation we only track the flag for compatibility.
|
|
651
|
+
*/
|
|
652
|
+
uncork(): void;
|
|
653
|
+
write(chunk: string | Uint8Array, encodingOrCb?: string | ((...args: unknown[]) => void), cb?: (...args: unknown[]) => void): boolean;
|
|
654
|
+
end(chunk?: string | Uint8Array | ((...args: unknown[]) => void), encodingOrCb?: string | ((...args: unknown[]) => void), cb?: (...args: unknown[]) => void): this;
|
|
655
|
+
destroy(err?: Error): this;
|
|
656
|
+
}
|
|
657
|
+
|
|
424
658
|
/**
|
|
425
659
|
* File system constants matching Node.js fs.constants
|
|
426
660
|
*/
|
|
@@ -439,7 +673,13 @@ declare const constants: {
|
|
|
439
673
|
readonly O_EXCL: 128;
|
|
440
674
|
readonly O_TRUNC: 512;
|
|
441
675
|
readonly O_APPEND: 1024;
|
|
676
|
+
readonly O_NOCTTY: 256;
|
|
677
|
+
readonly O_NONBLOCK: 2048;
|
|
442
678
|
readonly O_SYNC: 4096;
|
|
679
|
+
readonly O_DSYNC: 4096;
|
|
680
|
+
readonly O_DIRECTORY: 65536;
|
|
681
|
+
readonly O_NOFOLLOW: 131072;
|
|
682
|
+
readonly O_NOATIME: 262144;
|
|
443
683
|
readonly S_IFMT: 61440;
|
|
444
684
|
readonly S_IFREG: 32768;
|
|
445
685
|
readonly S_IFDIR: 16384;
|
|
@@ -560,6 +800,13 @@ declare function repairVFS(root?: string, fs?: FsLike): Promise<RepairResult>;
|
|
|
560
800
|
* POSIX path utilities (browser-compatible).
|
|
561
801
|
* No Node.js dependencies.
|
|
562
802
|
*/
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Normalize a PathLike value (string, Uint8Array, or URL) to a plain string.
|
|
806
|
+
* Mirrors Node.js behaviour: Buffer/Uint8Array is decoded as UTF-8,
|
|
807
|
+
* URL must use the file: protocol and the pathname is used.
|
|
808
|
+
*/
|
|
809
|
+
declare function toPathString(p: PathLike): string;
|
|
563
810
|
declare const sep = "/";
|
|
564
811
|
declare const delimiter = ":";
|
|
565
812
|
declare function normalize(p: string): string;
|
|
@@ -597,8 +844,9 @@ declare const path_parse: typeof parse;
|
|
|
597
844
|
declare const path_relative: typeof relative;
|
|
598
845
|
declare const path_resolve: typeof resolve;
|
|
599
846
|
declare const path_sep: typeof sep;
|
|
847
|
+
declare const path_toPathString: typeof toPathString;
|
|
600
848
|
declare namespace path {
|
|
601
|
-
export { path_basename as basename, path_delimiter as delimiter, path_dirname as dirname, path_extname as extname, path_format as format, path_isAbsolute as isAbsolute, path_join as join, path_normalize as normalize, path_parse as parse, path_relative as relative, path_resolve as resolve, path_sep as sep };
|
|
849
|
+
export { path_basename as basename, path_delimiter as delimiter, path_dirname as dirname, path_extname as extname, path_format as format, path_isAbsolute as isAbsolute, path_join as join, path_normalize as normalize, path_parse as parse, path_relative as relative, path_resolve as resolve, path_sep as sep, path_toPathString as toPathString };
|
|
602
850
|
}
|
|
603
851
|
|
|
604
852
|
/** Create a configured VFS instance */
|
|
@@ -608,4 +856,4 @@ declare function getDefaultFS(): VFSFileSystem;
|
|
|
608
856
|
/** Async init helper — avoids blocking main thread */
|
|
609
857
|
declare function init(): Promise<void>;
|
|
610
858
|
|
|
611
|
-
export { type BigIntStats, type CpOptions, type Dir, type Dirent, type Encoding, FSError, type FSMode, type FSWatcher, type FileHandle, type LoadResult, type MkdirOptions, type PathLike, type ReadOptions, type ReadStreamOptions, type ReaddirOptions, type RepairResult, type RmOptions, type RmdirOptions, type StatFs, type StatOptions, type Stats, type UnpackResult, type VFSConfig, VFSFileSystem, type VFSLimits, type WatchEventType, type WatchFileListener, type WatchListener, type WatchOptions, type WriteOptions, type WriteStreamOptions, constants, createError, createFS, getDefaultFS, init, loadFromOPFS, path, repairVFS, statusToError, unpackToOPFS };
|
|
859
|
+
export { type BigIntStats, type CpOptions, type Dir, type Dirent, type Encoding, FSError, type FSMode, type FSReadStream, type FSWatcher, type FSWriteStream, type FileHandle, type LoadResult, type MkdirOptions, NodeReadable, NodeWritable, type OpenAsBlobOptions, type PathLike, type ReadOptions, type ReadStreamOptions, type ReaddirOptions, type RepairResult, type RmOptions, type RmdirOptions, SimpleEventEmitter, type StatFs, type StatOptions, type Stats, type UnpackResult, type VFSConfig, VFSFileSystem, type VFSLimits, type WatchEventType, type WatchFileListener, type WatchListener, type WatchOptions, type WriteOptions, type WriteStreamOptions, constants, createError, createFS, getDefaultFS, init, loadFromOPFS, path, repairVFS, statusToError, unpackToOPFS };
|