@componentor/fs 3.0.25 → 3.0.26

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  * Type definitions for the VFS-based filesystem.
3
3
  * Mirrors Node.js fs module interfaces.
4
4
  */
5
- type Encoding = 'utf8' | 'utf-8' | 'ascii' | 'base64' | 'hex' | 'binary';
5
+ type Encoding = 'utf8' | 'utf-8' | 'ascii' | 'base64' | 'hex' | 'binary' | 'latin1' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le';
6
6
  interface ReadOptions {
7
7
  encoding?: Encoding | null;
8
8
  flag?: string;
@@ -24,9 +24,56 @@ interface RmOptions {
24
24
  recursive?: boolean;
25
25
  force?: boolean;
26
26
  }
27
+ interface CpOptions {
28
+ /** Dereference symlinks (default: false) */
29
+ dereference?: boolean;
30
+ /** Throw if destination exists (default: false) */
31
+ errorOnExist?: boolean;
32
+ /** Overwrite existing files/directories (default: true) */
33
+ force?: boolean;
34
+ /** Preserve timestamps from source (default: false) */
35
+ preserveTimestamps?: boolean;
36
+ /** Copy directories recursively (required for directories) */
37
+ recursive?: boolean;
38
+ }
27
39
  interface ReaddirOptions {
28
40
  encoding?: Encoding | null;
29
41
  withFileTypes?: boolean;
42
+ recursive?: boolean;
43
+ }
44
+ interface StatOptions {
45
+ bigint?: boolean;
46
+ }
47
+ interface BigIntStats {
48
+ isFile(): boolean;
49
+ isDirectory(): boolean;
50
+ isBlockDevice(): boolean;
51
+ isCharacterDevice(): boolean;
52
+ isSymbolicLink(): boolean;
53
+ isFIFO(): boolean;
54
+ isSocket(): boolean;
55
+ dev: bigint;
56
+ ino: bigint;
57
+ mode: bigint;
58
+ nlink: bigint;
59
+ uid: bigint;
60
+ gid: bigint;
61
+ rdev: bigint;
62
+ size: bigint;
63
+ blksize: bigint;
64
+ blocks: bigint;
65
+ atimeMs: bigint;
66
+ mtimeMs: bigint;
67
+ ctimeMs: bigint;
68
+ birthtimeMs: bigint;
69
+ atime: Date;
70
+ mtime: Date;
71
+ ctime: Date;
72
+ birthtime: Date;
73
+ atimeNs: bigint;
74
+ mtimeNs: bigint;
75
+ ctimeNs: bigint;
76
+ birthtimeNs: bigint;
30
77
  }
31
78
  interface Stats {
32
79
  isFile(): boolean;
@@ -57,6 +104,10 @@ interface Stats {
57
104
  }
58
105
  interface Dirent {
59
106
  name: string;
107
+ /** The directory path that was read (Node 20+). */
108
+ parentPath: string;
109
+ /** @deprecated Alias for `parentPath`. */
110
+ path: string;
60
111
  isFile(): boolean;
61
112
  isDirectory(): boolean;
62
113
  isBlockDevice(): boolean;
@@ -65,6 +116,19 @@ interface Dirent {
65
116
  isFIFO(): boolean;
66
117
  isSocket(): boolean;
67
118
  }
119
+ interface StatFs {
120
+ type: number;
121
+ bsize: number;
122
+ blocks: number;
123
+ bfree: number;
124
+ bavail: number;
125
+ files: number;
126
+ ffree: number;
127
+ }
128
+ interface GlobOptions {
129
+ cwd?: string;
130
+ exclude?: (path: string) => boolean;
131
+ }
68
132
  type PathLike = string;
69
133
  interface ReadStreamOptions {
70
134
  flags?: string;
@@ -112,6 +176,10 @@ interface FileHandle {
112
176
  bytesWritten: number;
113
177
  buffer: Uint8Array;
114
178
  }>;
179
+ write(string: string, position?: number, encoding?: string): Promise<{
180
+ bytesWritten: number;
181
+ buffer: Uint8Array;
182
+ }>;
115
183
  readFile(options?: ReadOptions | Encoding | null): Promise<Uint8Array | string>;
116
184
  writeFile(data: Uint8Array | string, options?: WriteOptions | Encoding): Promise<void>;
117
185
  truncate(len?: number): Promise<void>;
@@ -262,27 +330,35 @@ declare class VFSFileSystem {
262
330
  rmSync(filePath: string, options?: RmOptions): void;
263
331
  unlinkSync(filePath: string): void;
264
332
  readdirSync(filePath: string, options?: ReaddirOptions | Encoding | null): string[] | Dirent[];
265
- statSync(filePath: string): Stats;
266
- lstatSync(filePath: string): Stats;
333
+ globSync(pattern: string, options?: GlobOptions): string[];
334
+ statSync(filePath: string, options?: StatOptions): Stats | BigIntStats;
335
+ lstatSync(filePath: string, options?: StatOptions): Stats | BigIntStats;
267
336
  renameSync(oldPath: string, newPath: string): void;
268
337
  copyFileSync(src: string, dest: string, mode?: number): void;
338
+ cpSync(src: string, dest: string, options?: CpOptions): void;
339
+ cp(src: string, dest: string, options?: CpOptions): Promise<void>;
269
340
  truncateSync(filePath: string, len?: number): void;
270
341
  accessSync(filePath: string, mode?: number): void;
271
342
  realpathSync(filePath: string): string;
272
343
  chmodSync(filePath: string, mode: number): void;
273
344
  chownSync(filePath: string, uid: number, gid: number): void;
274
345
  utimesSync(filePath: string, atime: Date | number, mtime: Date | number): void;
275
- symlinkSync(target: string, linkPath: string): void;
276
- readlinkSync(filePath: string): string;
346
+ symlinkSync(target: string, linkPath: string, type?: string | null): void;
347
+ readlinkSync(filePath: string, options?: {
348
+ encoding?: string | null;
349
+ } | string | null): string | Uint8Array;
277
350
  linkSync(existingPath: string, newPath: string): void;
278
351
  mkdtempSync(prefix: string): string;
279
352
  openSync(filePath: string, flags?: string | number, mode?: number): number;
280
353
  closeSync(fd: number): void;
281
354
  readSync(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null): number;
282
- writeSync(fd: number, buffer: Uint8Array, offset?: number, length?: number, position?: number | null): number;
355
+ writeSync(fd: number, bufferOrString: Uint8Array | string, offsetOrPosition?: number, lengthOrEncoding?: number | string, position?: number | null): number;
283
356
  fstatSync(fd: number): Stats;
284
357
  ftruncateSync(fd: number, len?: number): void;
285
358
  fdatasyncSync(fd: number): void;
359
+ statfsSync(_path?: string): StatFs;
360
+ statfs(path: string, callback: (err: Error | null, stats?: StatFs) => void): void;
361
+ statfs(path: string): Promise<StatFs>;
286
362
  watch(filePath: string, options?: WatchOptions | Encoding, listener?: WatchListener): FSWatcher;
287
363
  watchFile(filePath: string, optionsOrListener?: WatchFileOptions | WatchFileListener, listener?: WatchFileListener): void;
288
364
  unwatchFile(filePath: string, listener?: WatchFileListener): void;
@@ -318,23 +394,28 @@ declare class VFSPromises {
318
394
  rm(filePath: string, options?: RmOptions): Promise<void>;
319
395
  unlink(filePath: string): Promise<void>;
320
396
  readdir(filePath: string, options?: ReaddirOptions | Encoding | null): Promise<string[] | Dirent[]>;
321
- stat(filePath: string): Promise<Stats>;
322
- lstat(filePath: string): Promise<Stats>;
397
+ glob(pattern: string, options?: GlobOptions): Promise<string[]>;
398
+ stat(filePath: string, options?: StatOptions): Promise<BigIntStats | Stats>;
399
+ lstat(filePath: string, options?: StatOptions): Promise<BigIntStats | Stats>;
323
400
  access(filePath: string, mode?: number): Promise<void>;
324
401
  rename(oldPath: string, newPath: string): Promise<void>;
325
402
  copyFile(src: string, dest: string, mode?: number): Promise<void>;
403
+ cp(src: string, dest: string, options?: CpOptions): Promise<void>;
326
404
  truncate(filePath: string, len?: number): Promise<void>;
327
405
  realpath(filePath: string): Promise<string>;
328
406
  exists(filePath: string): Promise<boolean>;
329
407
  chmod(filePath: string, mode: number): Promise<void>;
330
408
  chown(filePath: string, uid: number, gid: number): Promise<void>;
331
409
  utimes(filePath: string, atime: Date | number, mtime: Date | number): Promise<void>;
332
- symlink(target: string, linkPath: string): Promise<void>;
333
- readlink(filePath: string): Promise<string>;
410
+ symlink(target: string, linkPath: string, type?: string | null): Promise<void>;
411
+ readlink(filePath: string, options?: {
412
+ encoding?: string | null;
413
+ } | string | null): Promise<string | Uint8Array<ArrayBufferLike>>;
334
414
  link(existingPath: string, newPath: string): Promise<void>;
335
415
  open(filePath: string, flags?: string | number, mode?: number): Promise<FileHandle>;
336
416
  opendir(filePath: string): Promise<Dir>;
337
417
  mkdtemp(prefix: string): Promise<string>;
418
+ statfs(path: string): Promise<StatFs>;
338
419
  watch(filePath: string, options?: WatchOptions): AsyncIterable<WatchEventType>;
339
420
  flush(): Promise<void>;
340
421
  purge(): Promise<void>;
@@ -527,4 +608,4 @@ declare function getDefaultFS(): VFSFileSystem;
527
608
  /** Async init helper — avoids blocking main thread */
528
609
  declare function init(): Promise<void>;
529
610
 
530
- export { 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 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 };
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 };