@zenfs/core 1.9.2 → 1.9.4

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.
Files changed (60) hide show
  1. package/dist/backends/backend.d.ts +16 -2
  2. package/dist/backends/backend.js +9 -2
  3. package/dist/backends/fetch.d.ts +9 -0
  4. package/dist/backends/fetch.js +13 -3
  5. package/dist/backends/memory.d.ts +2 -0
  6. package/dist/backends/memory.js +2 -0
  7. package/dist/backends/overlay.d.ts +2 -0
  8. package/dist/backends/overlay.js +1 -0
  9. package/dist/backends/passthrough.d.ts +4 -0
  10. package/dist/backends/port/fs.d.ts +8 -2
  11. package/dist/backends/port/fs.js +6 -0
  12. package/dist/backends/store/fs.d.ts +2 -4
  13. package/dist/backends/store/fs.js +2 -4
  14. package/dist/backends/store/map.d.ts +6 -0
  15. package/dist/backends/store/map.js +4 -0
  16. package/dist/backends/store/simple.d.ts +3 -0
  17. package/dist/backends/store/simple.js +1 -0
  18. package/dist/backends/store/store.d.ts +12 -1
  19. package/dist/backends/store/store.js +5 -1
  20. package/dist/config.d.ts +9 -15
  21. package/dist/config.js +8 -5
  22. package/dist/context.d.ts +3 -4
  23. package/dist/context.js +1 -1
  24. package/dist/internal/credentials.d.ts +9 -0
  25. package/dist/internal/credentials.js +7 -0
  26. package/dist/internal/devices.d.ts +14 -0
  27. package/dist/internal/devices.js +10 -0
  28. package/dist/internal/error.d.ts +6 -0
  29. package/dist/internal/error.js +3 -0
  30. package/dist/internal/file.d.ts +23 -0
  31. package/dist/internal/file.js +23 -1
  32. package/dist/internal/file_index.d.ts +2 -1
  33. package/dist/internal/file_index.js +2 -1
  34. package/dist/internal/filesystem.d.ts +9 -0
  35. package/dist/internal/filesystem.js +1 -0
  36. package/dist/internal/index_fs.d.ts +3 -1
  37. package/dist/internal/index_fs.js +7 -3
  38. package/dist/internal/inode.d.ts +8 -0
  39. package/dist/internal/inode.js +1 -0
  40. package/dist/mixins/async.d.ts +6 -2
  41. package/dist/mixins/async.js +1 -1
  42. package/dist/mixins/mutexed.d.ts +6 -0
  43. package/dist/mixins/mutexed.js +6 -0
  44. package/dist/mixins/readonly.d.ts +1 -0
  45. package/dist/mixins/readonly.js +1 -0
  46. package/dist/mixins/shared.d.ts +3 -0
  47. package/dist/mixins/sync.d.ts +1 -0
  48. package/dist/mixins/sync.js +1 -0
  49. package/dist/vfs/promises.d.ts +2 -2
  50. package/dist/vfs/promises.js +71 -78
  51. package/dist/vfs/shared.d.ts +14 -1
  52. package/dist/vfs/shared.js +4 -6
  53. package/dist/vfs/sync.d.ts +2 -2
  54. package/dist/vfs/sync.js +48 -48
  55. package/dist/vfs/types.d.ts +1 -13
  56. package/package.json +1 -1
  57. package/readme.md +4 -0
  58. package/tests/backend/fetch.test.ts +3 -2
  59. package/dist/vfs/cache.d.ts +0 -46
  60. package/dist/vfs/cache.js +0 -75
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Credentials used for various operations.
3
3
  * Similar to Linux's cred struct.
4
+ * @category Internals
4
5
  * @see https://github.com/torvalds/linux/blob/master/include/linux/cred.h
5
6
  */
6
7
  export interface Credentials {
@@ -15,16 +16,24 @@ export interface Credentials {
15
16
  */
16
17
  groups: number[];
17
18
  }
19
+ /**
20
+ * @category Internals
21
+ */
18
22
  export declare const credentials: Credentials;
19
23
  /**
20
24
  * Initialization for a set of credentials
25
+ * @category Internals
21
26
  */
22
27
  export interface CredentialInit extends Partial<Credentials> {
23
28
  uid: number;
24
29
  gid: number;
25
30
  }
31
+ /**
32
+ * @category Internals
33
+ */
26
34
  export declare function createCredentials(source: CredentialInit): Credentials;
27
35
  /**
28
36
  * Uses credentials from the provided uid and gid.
37
+ * @category Internals
29
38
  */
30
39
  export declare function useCredentials(source: CredentialInit): void;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @category Internals
3
+ */
1
4
  export const credentials = {
2
5
  uid: 0,
3
6
  gid: 0,
@@ -7,6 +10,9 @@ export const credentials = {
7
10
  egid: 0,
8
11
  groups: [],
9
12
  };
13
+ /**
14
+ * @category Internals
15
+ */
10
16
  export function createCredentials(source) {
11
17
  return {
12
18
  suid: source.uid,
@@ -19,6 +25,7 @@ export function createCredentials(source) {
19
25
  }
20
26
  /**
21
27
  * Uses credentials from the provided uid and gid.
28
+ * @category Internals
22
29
  */
23
30
  export function useCredentials(source) {
24
31
  Object.assign(credentials, createCredentials(source));
@@ -8,6 +8,7 @@ import { Inode } from './inode.js';
8
8
  /**
9
9
  * A device
10
10
  * @todo Maybe add some other device information, like a UUID?
11
+ * @category Internals
11
12
  * @privateRemarks
12
13
  * UUIDs were considered, however they don't make sense without an easy mechanism for persistence
13
14
  */
@@ -34,6 +35,9 @@ export interface Device<TData = any> {
34
35
  */
35
36
  minor: number;
36
37
  }
38
+ /**
39
+ * @category Internals
40
+ */
37
41
  export interface DeviceInit<TData = any> {
38
42
  data?: TData;
39
43
  minor?: number;
@@ -42,6 +46,7 @@ export interface DeviceInit<TData = any> {
42
46
  }
43
47
  /**
44
48
  * A device driver
49
+ * @category Internals
45
50
  */
46
51
  export interface DeviceDriver<TData = any> {
47
52
  /**
@@ -108,6 +113,8 @@ export interface DeviceDriver<TData = any> {
108
113
  * This class only does some simple things:
109
114
  * It implements `truncate` using `write` and it has non-device methods throw.
110
115
  * It is up to device drivers to implement the rest of the functionality.
116
+ * @category Internals
117
+ * @internal
111
118
  */
112
119
  export declare class DeviceFile<TData = any> extends File {
113
120
  fs: DeviceFS;
@@ -137,6 +144,7 @@ export declare class DeviceFile<TData = any> extends File {
137
144
  }
138
145
  /**
139
146
  * A temporary file system that manages and interfaces with devices
147
+ * @category Internals
140
148
  */
141
149
  export declare class DeviceFS extends StoreFS<InMemoryStore> {
142
150
  protected readonly devices: Map<string, Device<any>>;
@@ -184,6 +192,7 @@ export declare class DeviceFS extends StoreFS<InMemoryStore> {
184
192
  * Simulates the `/dev/null` device.
185
193
  * - Reads return 0 bytes (EOF).
186
194
  * - Writes discard data, advancing the file position.
195
+ * @category Internals
187
196
  * @internal
188
197
  */
189
198
  export declare const nullDevice: DeviceDriver;
@@ -195,6 +204,7 @@ export declare const nullDevice: DeviceDriver;
195
204
  * - Reads fill the buffer with zeroes.
196
205
  * - Writes discard data but update the file position.
197
206
  * - Provides basic file metadata, treating it as a character device.
207
+ * @category Internals
198
208
  * @internal
199
209
  */
200
210
  export declare const zeroDevice: DeviceDriver;
@@ -202,6 +212,7 @@ export declare const zeroDevice: DeviceDriver;
202
212
  * Simulates the `/dev/full` device.
203
213
  * - Reads behave like `/dev/zero` (returns zeroes).
204
214
  * - Writes always fail with ENOSPC (no space left on device).
215
+ * @category Internals
205
216
  * @internal
206
217
  */
207
218
  export declare const fullDevice: DeviceDriver;
@@ -209,11 +220,14 @@ export declare const fullDevice: DeviceDriver;
209
220
  * Simulates the `/dev/random` device.
210
221
  * - Reads return random bytes.
211
222
  * - Writes discard data, advancing the file position.
223
+ * @category Internals
212
224
  * @internal
213
225
  */
214
226
  export declare const randomDevice: DeviceDriver;
215
227
  /**
216
228
  * Shortcuts for importing.
229
+ * @category Internals
230
+ * @internal
217
231
  */
218
232
  export declare const devices: {
219
233
  null: DeviceDriver<any>;
@@ -69,6 +69,8 @@ import { alert, debug, err, info, log_deprecated } from './log.js';
69
69
  * This class only does some simple things:
70
70
  * It implements `truncate` using `write` and it has non-device methods throw.
71
71
  * It is up to device drivers to implement the rest of the functionality.
72
+ * @category Internals
73
+ * @internal
72
74
  */
73
75
  export class DeviceFile extends File {
74
76
  constructor(fs, path, device) {
@@ -162,6 +164,7 @@ export class DeviceFile extends File {
162
164
  }
163
165
  /**
164
166
  * A temporary file system that manages and interfaces with devices
167
+ * @category Internals
165
168
  */
166
169
  export class DeviceFS extends StoreFS {
167
170
  /* node:coverage disable */
@@ -439,6 +442,7 @@ const emptyBuffer = new Uint8Array();
439
442
  * Simulates the `/dev/null` device.
440
443
  * - Reads return 0 bytes (EOF).
441
444
  * - Writes discard data, advancing the file position.
445
+ * @category Internals
442
446
  * @internal
443
447
  */
444
448
  export const nullDevice = {
@@ -463,6 +467,7 @@ export const nullDevice = {
463
467
  * - Reads fill the buffer with zeroes.
464
468
  * - Writes discard data but update the file position.
465
469
  * - Provides basic file metadata, treating it as a character device.
470
+ * @category Internals
466
471
  * @internal
467
472
  */
468
473
  export const zeroDevice = {
@@ -480,6 +485,7 @@ export const zeroDevice = {
480
485
  * Simulates the `/dev/full` device.
481
486
  * - Reads behave like `/dev/zero` (returns zeroes).
482
487
  * - Writes always fail with ENOSPC (no space left on device).
488
+ * @category Internals
483
489
  * @internal
484
490
  */
485
491
  export const fullDevice = {
@@ -502,6 +508,7 @@ export const fullDevice = {
502
508
  * Simulates the `/dev/random` device.
503
509
  * - Reads return random bytes.
504
510
  * - Writes discard data, advancing the file position.
511
+ * @category Internals
505
512
  * @internal
506
513
  */
507
514
  export const randomDevice = {
@@ -519,6 +526,7 @@ export const randomDevice = {
519
526
  };
520
527
  /**
521
528
  * Simulates the `/dev/console` device.
529
+ * @category Internals
522
530
  * @experimental @internal
523
531
  */
524
532
  const consoleDevice = {
@@ -537,6 +545,8 @@ const consoleDevice = {
537
545
  };
538
546
  /**
539
547
  * Shortcuts for importing.
548
+ * @category Internals
549
+ * @internal
540
550
  */
541
551
  export const devices = {
542
552
  null: nullDevice,
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Standard libc error codes. More will be added to this enum and error strings as they are
3
3
  * needed.
4
+ * @category Internals
4
5
  * @see https://en.wikipedia.org/wiki/Errno.h
5
6
  */
6
7
  export declare enum Errno {
@@ -155,11 +156,15 @@ export declare enum Errno {
155
156
  }
156
157
  /**
157
158
  * Strings associated with each error code.
159
+ * @category Internals
158
160
  * @internal
159
161
  */
160
162
  export declare const errorMessages: {
161
163
  [K in Errno]: string;
162
164
  };
165
+ /**
166
+ * @category Internals
167
+ */
163
168
  export interface ErrnoErrorJSON {
164
169
  errno: Errno;
165
170
  message: string;
@@ -170,6 +175,7 @@ export interface ErrnoErrorJSON {
170
175
  }
171
176
  /**
172
177
  * An error with additional information about what happened
178
+ * @category Internals
173
179
  */
174
180
  export declare class ErrnoError extends Error implements NodeJS.ErrnoException {
175
181
  /**
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Standard libc error codes. More will be added to this enum and error strings as they are
3
3
  * needed.
4
+ * @category Internals
4
5
  * @see https://en.wikipedia.org/wiki/Errno.h
5
6
  */
6
7
  export var Errno;
@@ -156,6 +157,7 @@ export var Errno;
156
157
  })(Errno || (Errno = {}));
157
158
  /**
158
159
  * Strings associated with each error code.
160
+ * @category Internals
159
161
  * @internal
160
162
  */
161
163
  export const errorMessages = {
@@ -236,6 +238,7 @@ export const errorMessages = {
236
238
  };
237
239
  /**
238
240
  * An error with additional information about what happened
241
+ * @category Internals
239
242
  */
240
243
  export class ErrnoError extends Error {
241
244
  static fromJSON(json) {
@@ -1,24 +1,44 @@
1
1
  import { Stats, type StatsLike } from '../stats.js';
2
2
  import type { FileSystem } from './filesystem.js';
3
3
  import '../polyfills.js';
4
+ /**
5
+ * @internal @hidden
6
+ */
4
7
  export declare function parseFlag(flag: string | number): string;
8
+ /**
9
+ * @internal @hidden
10
+ */
5
11
  export declare function flagToString(flag: number): string;
12
+ /**
13
+ * @internal @hidden
14
+ */
6
15
  export declare function flagToNumber(flag: string): number;
7
16
  /**
8
17
  * Parses a flag as a mode (W_OK, R_OK, and/or X_OK)
9
18
  * @param flag the flag to parse
19
+ * @internal @hidden
10
20
  */
11
21
  export declare function flagToMode(flag: string): number;
22
+ /** @hidden */
12
23
  export declare function isReadable(flag: string): boolean;
24
+ /** @hidden */
13
25
  export declare function isWriteable(flag: string): boolean;
26
+ /** @hidden */
14
27
  export declare function isTruncating(flag: string): boolean;
28
+ /** @hidden */
15
29
  export declare function isAppendable(flag: string): boolean;
30
+ /** @hidden */
16
31
  export declare function isSynchronous(flag: string): boolean;
32
+ /** @hidden */
17
33
  export declare function isExclusive(flag: string): boolean;
34
+ /** @hidden */
18
35
  export interface FileReadResult<T extends ArrayBufferView> {
19
36
  bytesRead: number;
20
37
  buffer: T;
21
38
  }
39
+ /**
40
+ * @category Internals
41
+ */
22
42
  export declare abstract class File<FS extends FileSystem = FileSystem> {
23
43
  /**
24
44
  * @internal
@@ -108,6 +128,7 @@ export declare abstract class File<FS extends FileSystem = FileSystem> {
108
128
  /**
109
129
  * An implementation of `File` that operates completely in-memory.
110
130
  * `PreloadFile`s are backed by a `Uint8Array`.
131
+ * @category Internals
111
132
  */
112
133
  export declare class PreloadFile<FS extends FileSystem> extends File<FS> {
113
134
  readonly flag: string;
@@ -217,6 +238,7 @@ export declare class PreloadFile<FS extends FileSystem> extends File<FS> {
217
238
  }
218
239
  /**
219
240
  * For the file systems which do not sync to anything.
241
+ * @category Internals
220
242
  * @deprecated
221
243
  */
222
244
  export declare class NoSyncFile<T extends FileSystem> extends PreloadFile<T> {
@@ -228,6 +250,7 @@ export declare class NoSyncFile<T extends FileSystem> extends PreloadFile<T> {
228
250
  }
229
251
  /**
230
252
  * An implementation of `File` that uses the FS
253
+ * @category Internals
231
254
  */
232
255
  export declare class LazyFile<FS extends FileSystem> extends File<FS> {
233
256
  readonly flag: string;
@@ -5,8 +5,11 @@ import * as c from '../vfs/constants.js';
5
5
  import { Errno, ErrnoError } from './error.js';
6
6
  import { log_deprecated } from './log.js';
7
7
  import '../polyfills.js';
8
- const maxByteLength = 0x100000; // 1 MiB
8
+ const maxByteLength = 0xffff; // 64 KiB
9
9
  const validFlags = ['r', 'r+', 'rs', 'rs+', 'w', 'wx', 'w+', 'wx+', 'a', 'ax', 'a+', 'ax+'];
10
+ /**
11
+ * @internal @hidden
12
+ */
10
13
  export function parseFlag(flag) {
11
14
  if (typeof flag === 'number') {
12
15
  return flagToString(flag);
@@ -16,6 +19,9 @@ export function parseFlag(flag) {
16
19
  }
17
20
  return flag;
18
21
  }
22
+ /**
23
+ * @internal @hidden
24
+ */
19
25
  export function flagToString(flag) {
20
26
  switch (flag) {
21
27
  case c.O_RDONLY:
@@ -46,6 +52,9 @@ export function flagToString(flag) {
46
52
  throw new Error('Invalid flag number: ' + flag);
47
53
  }
48
54
  }
55
+ /**
56
+ * @internal @hidden
57
+ */
49
58
  export function flagToNumber(flag) {
50
59
  switch (flag) {
51
60
  case 'r':
@@ -79,6 +88,7 @@ export function flagToNumber(flag) {
79
88
  /**
80
89
  * Parses a flag as a mode (W_OK, R_OK, and/or X_OK)
81
90
  * @param flag the flag to parse
91
+ * @internal @hidden
82
92
  */
83
93
  export function flagToMode(flag) {
84
94
  let mode = 0;
@@ -89,24 +99,33 @@ export function flagToMode(flag) {
89
99
  mode <<= 1;
90
100
  return mode;
91
101
  }
102
+ /** @hidden */
92
103
  export function isReadable(flag) {
93
104
  return flag.indexOf('r') !== -1 || flag.indexOf('+') !== -1;
94
105
  }
106
+ /** @hidden */
95
107
  export function isWriteable(flag) {
96
108
  return flag.indexOf('w') !== -1 || flag.indexOf('a') !== -1 || flag.indexOf('+') !== -1;
97
109
  }
110
+ /** @hidden */
98
111
  export function isTruncating(flag) {
99
112
  return flag.indexOf('w') !== -1;
100
113
  }
114
+ /** @hidden */
101
115
  export function isAppendable(flag) {
102
116
  return flag.indexOf('a') !== -1;
103
117
  }
118
+ /** @hidden */
104
119
  export function isSynchronous(flag) {
105
120
  return flag.indexOf('s') !== -1;
106
121
  }
122
+ /** @hidden */
107
123
  export function isExclusive(flag) {
108
124
  return flag.indexOf('x') !== -1;
109
125
  }
126
+ /**
127
+ * @category Internals
128
+ */
110
129
  export class File {
111
130
  constructor(
112
131
  /**
@@ -139,6 +158,7 @@ export class File {
139
158
  /**
140
159
  * An implementation of `File` that operates completely in-memory.
141
160
  * `PreloadFile`s are backed by a `Uint8Array`.
161
+ * @category Internals
142
162
  */
143
163
  export class PreloadFile extends File {
144
164
  /**
@@ -437,6 +457,7 @@ export class PreloadFile extends File {
437
457
  /* node:coverage disable */
438
458
  /**
439
459
  * For the file systems which do not sync to anything.
460
+ * @category Internals
440
461
  * @deprecated
441
462
  */
442
463
  export class NoSyncFile extends PreloadFile {
@@ -456,6 +477,7 @@ export class NoSyncFile extends PreloadFile {
456
477
  /* node:coverage enable */
457
478
  /**
458
479
  * An implementation of `File` that uses the FS
480
+ * @category Internals
459
481
  */
460
482
  export class LazyFile extends File {
461
483
  /**
@@ -10,7 +10,8 @@ export interface IndexData {
10
10
  }
11
11
  export declare const version = 1;
12
12
  /**
13
- * An index of files
13
+ * An index of file metadata
14
+ * @category Internals
14
15
  * @internal
15
16
  */
16
17
  export declare class Index extends Map<string, Inode> {
@@ -6,7 +6,8 @@ import { Errno, ErrnoError } from './error.js';
6
6
  import { Inode } from './inode.js';
7
7
  export const version = 1;
8
8
  /**
9
- * An index of files
9
+ * An index of file metadata
10
+ * @category Internals
10
11
  * @internal
11
12
  */
12
13
  export class Index extends Map {
@@ -3,6 +3,8 @@ import type { Stats, StatsLike } from '../stats.js';
3
3
  import type { File } from './file.js';
4
4
  /**
5
5
  * Usage information about a file system
6
+ * @category Internals
7
+ * @internal
6
8
  */
7
9
  export interface UsageInfo {
8
10
  /**
@@ -29,6 +31,7 @@ export interface UsageInfo {
29
31
  }
30
32
  /**
31
33
  * Metadata about a FileSystem
34
+ * @category Internals
32
35
  * @deprecated
33
36
  */
34
37
  export interface FileSystemMetadata extends UsageInfo {
@@ -69,6 +72,8 @@ export interface FileSystemMetadata extends UsageInfo {
69
72
  /**
70
73
  * Attributes that control how the file system interacts with the VFS.
71
74
  * No options are set by default.
75
+ * @category Internals
76
+ * @internal
72
77
  */
73
78
  export type FileSystemAttributes = {
74
79
  /** The FS supports setuid and setgid when creating files and directories. */
@@ -96,6 +101,7 @@ export type FileSystemAttributes = {
96
101
  * Options used when creating files and directories.
97
102
  * This weird naming and such is to preserve backward compatibility.
98
103
  * @todo [BREAKING] Move the `mode` parameter of `createFile` and `mkdir` into this
104
+ * @category Internals
99
105
  * @internal
100
106
  */
101
107
  export interface CreationOptions {
@@ -116,6 +122,8 @@ export interface CreationOptions {
116
122
  }
117
123
  /**
118
124
  * This is the correct type that will be used when the API is updated in a breaking release
125
+ * @category Internals
126
+ * @internal
119
127
  */
120
128
  export interface PureCreationOptions extends CreationOptions {
121
129
  /**
@@ -127,6 +135,7 @@ export interface PureCreationOptions extends CreationOptions {
127
135
  * Provides a consistent and easy to use internal API.
128
136
  * Default implementations for `exists` and `existsSync` are included.
129
137
  * If you are extending this class, note that every path is an absolute path and all arguments are present.
138
+ * @category Internals
130
139
  * @internal
131
140
  */
132
141
  export declare abstract class FileSystem {
@@ -2,6 +2,7 @@
2
2
  * Provides a consistent and easy to use internal API.
3
3
  * Default implementations for `exists` and `existsSync` are included.
4
4
  * If you are extending this class, note that every path is an absolute path and all arguments are present.
5
+ * @category Internals
5
6
  * @internal
6
7
  */
7
8
  export class FileSystem {
@@ -4,7 +4,9 @@ import { Index } from './file_index.js';
4
4
  import { FileSystem, type CreationOptions, type PureCreationOptions } from './filesystem.js';
5
5
  import { Inode, type InodeLike } from './inode.js';
6
6
  /**
7
- * Uses an `Index` for metadata.
7
+ * A file system that uses an `Index` for metadata.
8
+ * @category Internals
9
+ * @internal
8
10
  */
9
11
  export declare abstract class IndexFS extends FileSystem {
10
12
  readonly index: Index;
@@ -9,7 +9,9 @@ import { Index } from './file_index.js';
9
9
  import { FileSystem } from './filesystem.js';
10
10
  import { Inode } from './inode.js';
11
11
  /**
12
- * Uses an `Index` for metadata.
12
+ * A file system that uses an `Index` for metadata.
13
+ * @category Internals
14
+ * @internal
13
15
  */
14
16
  export class IndexFS extends FileSystem {
15
17
  constructor(id, name, index = new Index()) {
@@ -34,8 +36,6 @@ export class IndexFS extends FileSystem {
34
36
  * Finds all the paths in the index that need to be moved for a rename
35
37
  */
36
38
  pathsForRename(oldPath, newPath) {
37
- if (newPath === oldPath)
38
- return [];
39
39
  if (!this.index.has(oldPath))
40
40
  throw ErrnoError.With('ENOENT', oldPath, 'rename');
41
41
  if ((dirname(newPath) + '/').startsWith(oldPath + '/'))
@@ -53,6 +53,8 @@ export class IndexFS extends FileSystem {
53
53
  return toRename;
54
54
  }
55
55
  async rename(oldPath, newPath) {
56
+ if (oldPath == newPath)
57
+ return;
56
58
  for (const { from, to, inode } of this.pathsForRename(oldPath, newPath)) {
57
59
  const data = new Uint8Array(inode.size);
58
60
  await this.read(from, data, 0, inode.size);
@@ -63,6 +65,8 @@ export class IndexFS extends FileSystem {
63
65
  await this.remove(oldPath);
64
66
  }
65
67
  renameSync(oldPath, newPath) {
68
+ if (oldPath == newPath)
69
+ return;
66
70
  for (const { from, to, inode } of this.pathsForRename(oldPath, newPath)) {
67
71
  const data = new Uint8Array(inode.size);
68
72
  this.readSync(from, data, 0, inode.size);
@@ -4,10 +4,17 @@ import { Stats, type StatsLike } from '../stats.js';
4
4
  * @hidden
5
5
  */
6
6
  export declare const rootIno = 0;
7
+ /**
8
+ * @internal @hidden
9
+ */
7
10
  export interface InodeFields {
8
11
  data?: number;
9
12
  flags?: number;
10
13
  }
14
+ /**
15
+ * @category Internals
16
+ * @internal
17
+ */
11
18
  export interface InodeLike extends StatsLike<number>, InodeFields {
12
19
  }
13
20
  /**
@@ -16,6 +23,7 @@ export interface InodeLike extends StatsLike<number>, InodeFields {
16
23
  export declare const _inode_fields: readonly ["ino", "data", "size", "mode", "flags", "nlink", "uid", "gid", "atimeMs", "birthtimeMs", "mtimeMs", "ctimeMs"];
17
24
  /**
18
25
  * Generic inode definition that can easily be serialized.
26
+ * @category Internals
19
27
  * @internal
20
28
  * @todo [BREAKING] Remove 58 byte Inode upgrade path
21
29
  */
@@ -51,6 +51,7 @@ export const rootIno = 0;
51
51
  export const _inode_fields = ['ino', 'data', 'size', 'mode', 'flags', 'nlink', 'uid', 'gid', 'atimeMs', 'birthtimeMs', 'mtimeMs', 'ctimeMs'];
52
52
  /**
53
53
  * Generic inode definition that can easily be serialized.
54
+ * @category Internals
54
55
  * @internal
55
56
  * @todo [BREAKING] Remove 58 byte Inode upgrade path
56
57
  */
@@ -1,11 +1,15 @@
1
1
  import type { FileSystem } from '../internal/filesystem.js';
2
2
  import type { _SyncFSKeys, AsyncFSMethods, Mixin } from './shared.js';
3
- /** @internal */
3
+ /**
4
+ * @internal
5
+ * @category Internals
6
+ */
4
7
  export type AsyncOperation = {
5
8
  [K in keyof AsyncFSMethods]: [K, ...Parameters<FileSystem[K]>];
6
9
  }[keyof AsyncFSMethods];
7
10
  /**
8
11
  * @internal
12
+ * @category Internals
9
13
  */
10
14
  export interface AsyncMixin extends Pick<FileSystem, Exclude<_SyncFSKeys, 'existsSync'>> {
11
15
  /**
@@ -23,6 +27,6 @@ export interface AsyncMixin extends Pick<FileSystem, Exclude<_SyncFSKeys, 'exist
23
27
  * Synchronous methods on an asynchronous FS are implemented by performing operations over the in-memory copy,
24
28
  * while asynchronously pipelining them to the backing store.
25
29
  * During loading, the contents of the async file system are preloaded into the synchronous store.
26
- *
30
+ * @category Internals
27
31
  */
28
32
  export declare function Async<const T extends abstract new (...args: any[]) => FileSystem>(FS: T): Mixin<T, AsyncMixin>;
@@ -63,7 +63,7 @@ import { join } from '../vfs/path.js';
63
63
  * Synchronous methods on an asynchronous FS are implemented by performing operations over the in-memory copy,
64
64
  * while asynchronously pipelining them to the backing store.
65
65
  * During loading, the contents of the async file system are preloaded into the synchronous store.
66
- *
66
+ * @category Internals
67
67
  */
68
68
  export function Async(FS) {
69
69
  class AsyncFS extends FS {
@@ -4,6 +4,10 @@ import type { InodeLike } from '../internal/inode.js';
4
4
  import type { Stats } from '../stats.js';
5
5
  import type { Concrete } from '../utils.js';
6
6
  import '../polyfills.js';
7
+ /**
8
+ * @category Internals
9
+ * @internal
10
+ */
7
11
  export declare class MutexLock {
8
12
  protected readonly previous?: MutexLock | undefined;
9
13
  protected current: PromiseWithResolvers<void>;
@@ -16,6 +20,7 @@ export declare class MutexLock {
16
20
  }
17
21
  /**
18
22
  * @hidden
23
+ * @category Internals
19
24
  */
20
25
  export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
21
26
  /**
@@ -99,6 +104,7 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
99
104
  * `MutexedFS` implements it in order to make sure all of the methods are passed through
100
105
  *
101
106
  * @todo Change `using _` to `using void` pending https://github.com/tc39/proposal-discard-binding
107
+ * @category Internals
102
108
  * @internal
103
109
  */
104
110
  export declare function Mutexed<const T extends Concrete<typeof FileSystem>>(FS: T): typeof _MutexedFS<InstanceType<T>> & {
@@ -53,6 +53,10 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
53
53
  import { ErrnoError } from '../internal/error.js';
54
54
  import { err } from '../internal/log.js';
55
55
  import '../polyfills.js';
56
+ /**
57
+ * @category Internals
58
+ * @internal
59
+ */
56
60
  export class MutexLock {
57
61
  get isLocked() {
58
62
  return this._isLocked;
@@ -77,6 +81,7 @@ export class MutexLock {
77
81
  }
78
82
  /**
79
83
  * @hidden
84
+ * @category Internals
80
85
  */
81
86
  export class _MutexedFS {
82
87
  get id() {
@@ -541,6 +546,7 @@ export class _MutexedFS {
541
546
  * `MutexedFS` implements it in order to make sure all of the methods are passed through
542
547
  *
543
548
  * @todo Change `using _` to `using void` pending https://github.com/tc39/proposal-discard-binding
549
+ * @category Internals
544
550
  * @internal
545
551
  */
546
552
  export function Mutexed(FS) {
@@ -25,5 +25,6 @@ export interface ReadonlyMixin {
25
25
  }
26
26
  /**
27
27
  * Implements the non-readonly methods to throw `EROFS`
28
+ * @category Internals
28
29
  */
29
30
  export declare function Readonly<T extends abstract new (...args: any[]) => FileSystem>(FS: T): Mixin<T, ReadonlyMixin>;