@zenfs/core 1.11.4 → 2.1.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/dist/backends/backend.d.ts +19 -15
- package/dist/backends/backend.js +36 -19
- package/dist/backends/cow.d.ts +20 -30
- package/dist/backends/cow.js +83 -192
- package/dist/backends/fetch.d.ts +1 -0
- package/dist/backends/fetch.js +30 -30
- package/dist/backends/index.d.ts +1 -1
- package/dist/backends/index.js +1 -1
- package/dist/backends/memory.d.ts +5 -7
- package/dist/backends/memory.js +2 -3
- package/dist/backends/passthrough.d.ts +19 -23
- package/dist/backends/passthrough.js +98 -288
- package/dist/backends/port.d.ts +220 -0
- package/dist/backends/port.js +328 -0
- package/dist/backends/single_buffer.d.ts +59 -47
- package/dist/backends/single_buffer.js +468 -219
- package/dist/backends/store/fs.d.ts +25 -35
- package/dist/backends/store/fs.js +276 -315
- package/dist/backends/store/store.d.ts +10 -15
- package/dist/backends/store/store.js +11 -10
- package/dist/config.d.ts +3 -12
- package/dist/config.js +17 -19
- package/dist/context.d.ts +8 -21
- package/dist/context.js +33 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/contexts.d.ts +63 -0
- package/dist/internal/contexts.js +15 -0
- package/dist/internal/credentials.d.ts +2 -11
- package/dist/internal/credentials.js +0 -19
- package/dist/internal/devices.d.ts +18 -80
- package/dist/internal/devices.js +103 -316
- package/dist/internal/error.d.ts +9 -204
- package/dist/internal/error.js +19 -288
- package/dist/internal/file_index.d.ts +1 -1
- package/dist/internal/file_index.js +11 -11
- package/dist/internal/filesystem.d.ts +51 -94
- package/dist/internal/filesystem.js +21 -20
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +1 -2
- package/dist/internal/index_fs.d.ts +12 -30
- package/dist/internal/index_fs.js +37 -69
- package/dist/internal/inode.d.ts +140 -24
- package/dist/internal/inode.js +515 -66
- package/dist/mixins/async.js +52 -112
- package/dist/mixins/mutexed.d.ts +19 -18
- package/dist/mixins/mutexed.js +62 -64
- package/dist/mixins/readonly.d.ts +7 -6
- package/dist/mixins/readonly.js +24 -18
- package/dist/mixins/sync.js +8 -8
- package/dist/{vfs/path.d.ts → path.d.ts} +3 -4
- package/dist/{vfs/path.js → path.js} +6 -9
- package/dist/polyfills.js +1 -1
- package/dist/readline.d.ts +134 -0
- package/dist/readline.js +623 -0
- package/dist/utils.d.ts +9 -37
- package/dist/utils.js +17 -85
- package/dist/vfs/acl.d.ts +42 -0
- package/dist/vfs/acl.js +268 -0
- package/dist/vfs/async.d.ts +9 -23
- package/dist/vfs/async.js +25 -27
- package/dist/vfs/config.d.ts +6 -18
- package/dist/vfs/config.js +8 -18
- package/dist/vfs/dir.d.ts +3 -3
- package/dist/vfs/dir.js +12 -12
- package/dist/vfs/file.d.ts +106 -0
- package/dist/vfs/file.js +244 -0
- package/dist/vfs/flags.d.ts +19 -0
- package/dist/vfs/flags.js +62 -0
- package/dist/vfs/index.d.ts +4 -10
- package/dist/vfs/index.js +4 -13
- package/dist/vfs/ioctl.d.ts +88 -0
- package/dist/vfs/ioctl.js +409 -0
- package/dist/vfs/promises.d.ts +81 -19
- package/dist/vfs/promises.js +404 -288
- package/dist/vfs/shared.d.ts +7 -37
- package/dist/vfs/shared.js +29 -85
- package/dist/{stats.d.ts → vfs/stats.d.ts} +14 -28
- package/dist/{stats.js → vfs/stats.js} +11 -66
- package/dist/vfs/streams.d.ts +1 -0
- package/dist/vfs/streams.js +32 -27
- package/dist/vfs/sync.d.ts +3 -3
- package/dist/vfs/sync.js +263 -260
- package/dist/vfs/watchers.d.ts +2 -2
- package/dist/vfs/watchers.js +12 -12
- package/dist/vfs/xattr.d.ts +116 -0
- package/dist/vfs/xattr.js +201 -0
- package/package.json +5 -3
- package/readme.md +1 -1
- package/scripts/test.js +2 -2
- package/tests/assignment.ts +1 -1
- package/tests/backend/config.worker.js +4 -1
- package/tests/backend/fetch.test.ts +3 -0
- package/tests/backend/port.test.ts +19 -33
- package/tests/backend/remote.worker.js +4 -1
- package/tests/backend/single-buffer.test.ts +53 -0
- package/tests/backend/single-buffer.worker.js +30 -0
- package/tests/common/context.test.ts +3 -3
- package/tests/common/handle.test.ts +17 -12
- package/tests/common/mutex.test.ts +9 -9
- package/tests/common/path.test.ts +1 -1
- package/tests/common/readline.test.ts +104 -0
- package/tests/common.ts +4 -19
- package/tests/fetch/fetch.ts +2 -2
- package/tests/fs/append.test.ts +4 -4
- package/tests/fs/directory.test.ts +25 -25
- package/tests/fs/errors.test.ts +15 -19
- package/tests/fs/links.test.ts +4 -3
- package/tests/fs/open.test.ts +4 -21
- package/tests/fs/permissions.test.ts +14 -18
- package/tests/fs/read.test.ts +10 -9
- package/tests/fs/readFile.test.ts +10 -26
- package/tests/fs/rename.test.ts +4 -9
- package/tests/fs/stat.test.ts +8 -8
- package/tests/fs/streams.test.ts +2 -11
- package/tests/fs/times.test.ts +7 -7
- package/tests/fs/truncate.test.ts +8 -36
- package/tests/fs/watch.test.ts +10 -10
- package/tests/fs/write.test.ts +77 -13
- package/tests/fs/xattr.test.ts +85 -0
- package/tests/logs.js +22 -0
- package/tests/setup/context.ts +1 -1
- package/tests/setup/index.ts +3 -3
- package/tests/setup/port.ts +7 -1
- package/dist/backends/port/fs.d.ts +0 -84
- package/dist/backends/port/fs.js +0 -151
- package/dist/backends/port/rpc.d.ts +0 -77
- package/dist/backends/port/rpc.js +0 -100
- package/dist/backends/store/simple.d.ts +0 -20
- package/dist/backends/store/simple.js +0 -13
- package/dist/internal/file.d.ts +0 -359
- package/dist/internal/file.js +0 -751
- package/dist/internal/log.d.ts +0 -133
- package/dist/internal/log.js +0 -218
- package/tests/fs/writeFile.test.ts +0 -70
package/dist/vfs/promises.d.ts
CHANGED
|
@@ -1,30 +1,57 @@
|
|
|
1
1
|
import type * as fs from 'node:fs';
|
|
2
2
|
import type * as promises from 'node:fs/promises';
|
|
3
|
-
import type { Interface as ReadlineInterface } from 'node:readline';
|
|
4
3
|
import type { Stream } from 'node:stream';
|
|
5
4
|
import type { ReadableStream as NodeReadableStream } from 'node:stream/web';
|
|
6
5
|
import type { V_Context } from '../context.js';
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
6
|
+
import type { FileSystem, StreamOptions } from '../internal/filesystem.js';
|
|
7
|
+
import type { InodeLike } from '../internal/inode.js';
|
|
8
|
+
import type { Interface as ReadlineInterface } from '../readline.js';
|
|
9
9
|
import type { FileContents, NullEnc, ReaddirOptions, ReaddirOptsI, ReaddirOptsU } from './types.js';
|
|
10
10
|
import { Buffer } from 'buffer';
|
|
11
11
|
import '../polyfills.js';
|
|
12
|
-
import { BigIntStats } from '../stats.js';
|
|
13
12
|
import { Dir, Dirent } from './dir.js';
|
|
13
|
+
import { BigIntStats, Stats } from './stats.js';
|
|
14
14
|
import { ReadStream, WriteStream } from './streams.js';
|
|
15
15
|
export * as constants from './constants.js';
|
|
16
16
|
export declare class FileHandle implements promises.FileHandle {
|
|
17
|
-
protected context
|
|
17
|
+
protected context: V_Context;
|
|
18
|
+
readonly fd: number;
|
|
19
|
+
protected _buffer?: Uint8Array;
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* Current position
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
protected _position: number;
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
+
* Get the current file position.
|
|
26
|
+
*
|
|
27
|
+
* We emulate the following bug mentioned in the Node documentation:
|
|
28
|
+
*
|
|
29
|
+
* On Linux, positional writes don't work when the file is opened in append mode.
|
|
30
|
+
* The kernel ignores the position argument and always appends the data to the end of the file.
|
|
31
|
+
* @returns The current file position.
|
|
32
|
+
*/
|
|
33
|
+
get position(): number;
|
|
34
|
+
set position(value: number);
|
|
35
|
+
/**
|
|
36
|
+
* Whether the file has changes which have not been written to the FS
|
|
25
37
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
protected dirty: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the file is open or closed
|
|
41
|
+
*/
|
|
42
|
+
protected closed: boolean;
|
|
43
|
+
/** The path relative to the context's root */
|
|
44
|
+
readonly path: string;
|
|
45
|
+
/** The internal FS associated with the handle */
|
|
46
|
+
protected readonly fs: FileSystem;
|
|
47
|
+
/** The path relative to the `FileSystem`'s root */
|
|
48
|
+
readonly internalPath: string;
|
|
49
|
+
/** The flag the handle was opened with */
|
|
50
|
+
readonly flag: number;
|
|
51
|
+
/** Stats for the handle */
|
|
52
|
+
readonly inode: InodeLike;
|
|
53
|
+
constructor(context: V_Context, fd: number);
|
|
54
|
+
private get _isSync();
|
|
28
55
|
private _emitChange;
|
|
29
56
|
/**
|
|
30
57
|
* Asynchronous fchown(2) - Change ownership of a file.
|
|
@@ -47,7 +74,7 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
47
74
|
* Asynchronous ftruncate(2) - Truncate a file to a specified length.
|
|
48
75
|
* @param length If not specified, defaults to `0`.
|
|
49
76
|
*/
|
|
50
|
-
truncate(length?: number
|
|
77
|
+
truncate(length?: number): Promise<void>;
|
|
51
78
|
/**
|
|
52
79
|
* Asynchronously change file timestamps of the file.
|
|
53
80
|
* @param atime The last access time. If a string is provided, it will be coerced to number.
|
|
@@ -64,6 +91,18 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
64
91
|
* - `flag` defaults to `'a'`.
|
|
65
92
|
*/
|
|
66
93
|
appendFile(data: string | Uint8Array, _options?: (fs.ObjectEncodingOptions & promises.FlagAndOpenMode) | BufferEncoding): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Read data from the file.
|
|
96
|
+
* @param buffer The buffer that the data will be written to.
|
|
97
|
+
* @param offset The offset within the buffer where writing will start.
|
|
98
|
+
* @param length An integer specifying the number of bytes to read.
|
|
99
|
+
* @param position An integer specifying where to begin reading from in the file.
|
|
100
|
+
* If position is unset, data will be read from the current file position.
|
|
101
|
+
*/
|
|
102
|
+
protected _read<TBuffer extends ArrayBufferView>(buffer: TBuffer, offset?: number, length?: number, position?: number): Promise<{
|
|
103
|
+
bytesRead: number;
|
|
104
|
+
buffer: TBuffer;
|
|
105
|
+
}>;
|
|
67
106
|
/**
|
|
68
107
|
* Asynchronously reads data from the file.
|
|
69
108
|
* The `FileHandle` must have been opened for reading.
|
|
@@ -89,9 +128,19 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
89
128
|
* Read file data using a `ReadableStream`.
|
|
90
129
|
* The handle will not be closed automatically.
|
|
91
130
|
*/
|
|
92
|
-
readableWebStream(options?: promises.ReadableWebStreamOptions): NodeReadableStream<Uint8Array>;
|
|
131
|
+
readableWebStream(options?: promises.ReadableWebStreamOptions & StreamOptions): NodeReadableStream<Uint8Array>;
|
|
132
|
+
/**
|
|
133
|
+
* Not part of the Node.js API!
|
|
134
|
+
*
|
|
135
|
+
* Write file data using a `WritableStream`.
|
|
136
|
+
* The handle will not be closed automatically.
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
writableWebStream(options?: promises.ReadableWebStreamOptions & StreamOptions): WritableStream;
|
|
93
140
|
/**
|
|
94
|
-
*
|
|
141
|
+
* Creates a readline Interface object that allows reading the file line by line
|
|
142
|
+
* @param options Options for creating a read stream
|
|
143
|
+
* @returns A readline interface for reading the file line by line
|
|
95
144
|
*/
|
|
96
145
|
readLines(options?: promises.CreateReadStreamOptions): ReadlineInterface;
|
|
97
146
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -102,6 +151,15 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
102
151
|
stat(opts?: fs.StatOptions & {
|
|
103
152
|
bigint?: false;
|
|
104
153
|
}): Promise<Stats>;
|
|
154
|
+
/**
|
|
155
|
+
* Write buffer to the file.
|
|
156
|
+
* @param buffer Uint8Array containing the data to write to the file.
|
|
157
|
+
* @param offset Offset in the buffer to start reading data from.
|
|
158
|
+
* @param length The amount of bytes to write to the file.
|
|
159
|
+
* @param position Offset from the beginning of the file where this data should be written.
|
|
160
|
+
* If position is null, the data will be written at the current position.
|
|
161
|
+
*/
|
|
162
|
+
protected _write(buffer: Uint8Array, offset?: number, length?: number, position?: number): Promise<number>;
|
|
105
163
|
/**
|
|
106
164
|
* Asynchronously writes `string` to the file.
|
|
107
165
|
* The `FileHandle` must have been opened for writing.
|
|
@@ -131,6 +189,10 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
131
189
|
* Asynchronous close(2) - close a `FileHandle`.
|
|
132
190
|
*/
|
|
133
191
|
close(): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Cleans up. This will *not* sync the file data to the FS
|
|
194
|
+
*/
|
|
195
|
+
protected dispose(force?: boolean): void;
|
|
134
196
|
/**
|
|
135
197
|
* Asynchronous `writev`. Writes from multiple buffers.
|
|
136
198
|
* @param buffers An array of Uint8Array buffers.
|
|
@@ -181,8 +243,8 @@ export declare function truncate(this: V_Context, path: fs.PathLike, len?: numbe
|
|
|
181
243
|
export declare function unlink(this: V_Context, path: fs.PathLike): Promise<void>;
|
|
182
244
|
/**
|
|
183
245
|
* Asynchronous file open.
|
|
184
|
-
* @see
|
|
185
|
-
* @param flag
|
|
246
|
+
* @see https://nodejs.org/api/fs.html#fspromisesopenpath-flags-mode
|
|
247
|
+
* @param flag {@link https://nodejs.org/api/fs.html#file-system-flags}
|
|
186
248
|
* @param mode Mode to use to open the file. Can be ignored if the filesystem doesn't support permissions.
|
|
187
249
|
*/
|
|
188
250
|
export declare function open(this: V_Context, path: fs.PathLike, flag?: fs.OpenMode, mode?: fs.Mode): Promise<FileHandle>;
|
|
@@ -260,14 +322,14 @@ export declare function readdir(this: V_Context, path: fs.PathLike, options: Rea
|
|
|
260
322
|
withFileTypes: true;
|
|
261
323
|
}>): Promise<Dirent[]>;
|
|
262
324
|
export declare function readdir(this: V_Context, path: fs.PathLike, options?: ReaddirOptsU<fs.BufferEncodingOption> | NullEnc): Promise<string[] | Dirent[] | Buffer[]>;
|
|
263
|
-
export declare function link(this: V_Context,
|
|
325
|
+
export declare function link(this: V_Context, path: fs.PathLike, dest: fs.PathLike): Promise<void>;
|
|
264
326
|
/**
|
|
265
327
|
* `symlink`.
|
|
266
|
-
* @param
|
|
328
|
+
* @param dest target path
|
|
267
329
|
* @param path link path
|
|
268
330
|
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
269
331
|
*/
|
|
270
|
-
export declare function symlink(this: V_Context,
|
|
332
|
+
export declare function symlink(this: V_Context, dest: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | string | null): Promise<void>;
|
|
271
333
|
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Promise<Buffer>;
|
|
272
334
|
export declare function readlink(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | null): Promise<string>;
|
|
273
335
|
export declare function readlink(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption | fs.EncodingOption | string | null): Promise<string | Buffer>;
|