@zenfs/core 1.3.6 → 1.4.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/memory.d.ts +4 -4
- package/dist/backends/memory.js +4 -4
- package/dist/backends/overlay.d.ts +5 -2
- package/dist/backends/overlay.js +7 -10
- package/dist/backends/port/fs.js +1 -4
- package/dist/config.js +4 -8
- package/dist/context.d.ts +32 -0
- package/dist/context.js +23 -0
- package/dist/credentials.d.ts +5 -5
- package/dist/credentials.js +10 -6
- package/dist/emulation/async.d.ts +90 -89
- package/dist/emulation/async.js +76 -75
- package/dist/emulation/dir.d.ts +3 -1
- package/dist/emulation/dir.js +6 -7
- package/dist/emulation/index.d.ts +1 -1
- package/dist/emulation/index.js +1 -1
- package/dist/emulation/promises.d.ts +50 -48
- package/dist/emulation/promises.js +78 -77
- package/dist/emulation/shared.d.ts +35 -8
- package/dist/emulation/shared.js +37 -11
- package/dist/emulation/sync.d.ts +63 -62
- package/dist/emulation/sync.js +72 -73
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/stats.d.ts +2 -1
- package/dist/stats.js +5 -4
- package/package.json +3 -5
- package/scripts/test.js +78 -17
- package/tests/assignment.ts +1 -1
- package/tests/common/context.test.ts +19 -0
- package/tests/{devices.test.ts → common/devices.test.ts} +3 -3
- package/tests/{handle.test.ts → common/handle.test.ts} +1 -1
- package/tests/common/mounts.test.ts +36 -0
- package/tests/{mutex.test.ts → common/mutex.test.ts} +3 -3
- package/tests/common/path.test.ts +34 -0
- package/tests/common.ts +4 -3
- package/tests/fs/dir.test.ts +11 -11
- package/tests/fs/directory.test.ts +17 -17
- package/tests/fs/errors.test.ts +29 -39
- package/tests/fs/watch.test.ts +2 -2
- package/tests/setup/context.ts +9 -0
- package/tests/setup/cow+fetch.ts +1 -1
- package/tests/setup/memory.ts +1 -1
- package/tests/{setup/common.ts → setup.ts} +6 -5
- package/src/backends/backend.ts +0 -161
- package/src/backends/fetch.ts +0 -180
- package/src/backends/file_index.ts +0 -206
- package/src/backends/memory.ts +0 -45
- package/src/backends/overlay.ts +0 -560
- package/src/backends/port/fs.ts +0 -329
- package/src/backends/port/readme.md +0 -54
- package/src/backends/port/rpc.ts +0 -167
- package/src/backends/readme.md +0 -3
- package/src/backends/store/fs.ts +0 -667
- package/src/backends/store/readme.md +0 -9
- package/src/backends/store/simple.ts +0 -154
- package/src/backends/store/store.ts +0 -189
- package/src/config.ts +0 -227
- package/src/credentials.ts +0 -49
- package/src/devices.ts +0 -521
- package/src/emulation/async.ts +0 -834
- package/src/emulation/cache.ts +0 -86
- package/src/emulation/config.ts +0 -21
- package/src/emulation/constants.ts +0 -182
- package/src/emulation/dir.ts +0 -138
- package/src/emulation/index.ts +0 -8
- package/src/emulation/path.ts +0 -440
- package/src/emulation/promises.ts +0 -1140
- package/src/emulation/shared.ts +0 -172
- package/src/emulation/streams.ts +0 -34
- package/src/emulation/sync.ts +0 -863
- package/src/emulation/watchers.ts +0 -194
- package/src/error.ts +0 -307
- package/src/file.ts +0 -631
- package/src/filesystem.ts +0 -174
- package/src/index.ts +0 -35
- package/src/inode.ts +0 -128
- package/src/mixins/async.ts +0 -230
- package/src/mixins/index.ts +0 -5
- package/src/mixins/mutexed.ts +0 -257
- package/src/mixins/readonly.ts +0 -96
- package/src/mixins/shared.ts +0 -25
- package/src/mixins/sync.ts +0 -58
- package/src/polyfills.ts +0 -21
- package/src/stats.ts +0 -405
- package/src/utils.ts +0 -276
- package/tests/mounts.test.ts +0 -18
- package/tests/path.test.ts +0 -34
|
@@ -10,10 +10,6 @@ export declare class InMemoryStore extends Map<bigint, Uint8Array> implements Si
|
|
|
10
10
|
clearSync(): void;
|
|
11
11
|
transaction(): SimpleTransaction;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* A simple in-memory file system backed by an InMemoryStore.
|
|
15
|
-
* Files are not persisted across page loads.
|
|
16
|
-
*/
|
|
17
13
|
declare const _InMemory: {
|
|
18
14
|
readonly name: "InMemory";
|
|
19
15
|
readonly isAvailable: () => boolean;
|
|
@@ -30,5 +26,9 @@ declare const _InMemory: {
|
|
|
30
26
|
type _InMemory = typeof _InMemory;
|
|
31
27
|
export interface InMemory extends _InMemory {
|
|
32
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* A simple in-memory file system backed by an InMemoryStore.
|
|
31
|
+
* Files are not persisted across page loads.
|
|
32
|
+
*/
|
|
33
33
|
export declare const InMemory: InMemory;
|
|
34
34
|
export {};
|
package/dist/backends/memory.js
CHANGED
|
@@ -16,10 +16,6 @@ export class InMemoryStore extends Map {
|
|
|
16
16
|
return new SimpleTransaction(this);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* A simple in-memory file system backed by an InMemoryStore.
|
|
21
|
-
* Files are not persisted across page loads.
|
|
22
|
-
*/
|
|
23
19
|
const _InMemory = {
|
|
24
20
|
name: 'InMemory',
|
|
25
21
|
isAvailable() {
|
|
@@ -34,4 +30,8 @@ const _InMemory = {
|
|
|
34
30
|
return fs;
|
|
35
31
|
},
|
|
36
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* A simple in-memory file system backed by an InMemoryStore.
|
|
35
|
+
* Files are not persisted across page loads.
|
|
36
|
+
*/
|
|
37
37
|
export const InMemory = _InMemory;
|
|
@@ -109,12 +109,10 @@ declare const _Overlay: {
|
|
|
109
109
|
readonly writable: {
|
|
110
110
|
readonly type: "object";
|
|
111
111
|
readonly required: true;
|
|
112
|
-
readonly description: "The file system to write modified files to.";
|
|
113
112
|
};
|
|
114
113
|
readonly readable: {
|
|
115
114
|
readonly type: "object";
|
|
116
115
|
readonly required: true;
|
|
117
|
-
readonly description: "The file system that initially populates this file system.";
|
|
118
116
|
};
|
|
119
117
|
};
|
|
120
118
|
readonly isAvailable: () => boolean;
|
|
@@ -123,5 +121,10 @@ declare const _Overlay: {
|
|
|
123
121
|
type _Overlay = typeof _Overlay;
|
|
124
122
|
export interface Overlay extends _Overlay {
|
|
125
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Overlay makes a read-only filesystem writable by storing writes on a second, writable file system.
|
|
126
|
+
* Deletes are persisted via metadata stored on the writable file system.
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
126
129
|
export declare const Overlay: Overlay;
|
|
127
130
|
export {};
|
package/dist/backends/overlay.js
CHANGED
|
@@ -529,16 +529,8 @@ export class OverlayFS extends Mutexed(UnmutexedOverlayFS) {
|
|
|
529
529
|
const _Overlay = {
|
|
530
530
|
name: 'Overlay',
|
|
531
531
|
options: {
|
|
532
|
-
writable: {
|
|
533
|
-
|
|
534
|
-
required: true,
|
|
535
|
-
description: 'The file system to write modified files to.',
|
|
536
|
-
},
|
|
537
|
-
readable: {
|
|
538
|
-
type: 'object',
|
|
539
|
-
required: true,
|
|
540
|
-
description: 'The file system that initially populates this file system.',
|
|
541
|
-
},
|
|
532
|
+
writable: { type: 'object', required: true },
|
|
533
|
+
readable: { type: 'object', required: true },
|
|
542
534
|
},
|
|
543
535
|
isAvailable() {
|
|
544
536
|
return true;
|
|
@@ -547,4 +539,9 @@ const _Overlay = {
|
|
|
547
539
|
return new OverlayFS(options);
|
|
548
540
|
},
|
|
549
541
|
};
|
|
542
|
+
/**
|
|
543
|
+
* Overlay makes a read-only filesystem writable by storing writes on a second, writable file system.
|
|
544
|
+
* Deletes are persisted via metadata stored on the writable file system.
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
550
547
|
export const Overlay = _Overlay;
|
package/dist/backends/port/fs.js
CHANGED
package/dist/config.js
CHANGED
|
@@ -94,20 +94,16 @@ export async function configure(configuration) {
|
|
|
94
94
|
config.updateOnRead = !configuration.disableUpdateOnRead;
|
|
95
95
|
config.syncImmediately = !configuration.onlySyncOnClose;
|
|
96
96
|
if (configuration.mounts) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
for (const [_point, mountConfig] of Object.entries(configuration.mounts)) {
|
|
97
|
+
// sort to make sure any root replacement is done first
|
|
98
|
+
for (const [_point, mountConfig] of Object.entries(configuration.mounts).sort(([a], [b]) => (a.length > b.length ? 1 : -1))) {
|
|
100
99
|
const point = _point.startsWith('/') ? _point : '/' + _point;
|
|
101
100
|
if (isBackendConfig(mountConfig)) {
|
|
102
101
|
mountConfig.disableAsyncCache ?? (mountConfig.disableAsyncCache = configuration.disableAsyncCache || false);
|
|
103
102
|
}
|
|
104
103
|
if (point == '/')
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
fs.umount('/');
|
|
105
|
+
await mount(point, await resolveMountConfig(mountConfig));
|
|
107
106
|
}
|
|
108
|
-
if (unmountRoot)
|
|
109
|
-
fs.umount('/');
|
|
110
|
-
await Promise.all(toMount.map(([point, fs]) => mount(point, fs)));
|
|
111
107
|
}
|
|
112
108
|
if (configuration.addDevices) {
|
|
113
109
|
const devfs = new DeviceFS();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ExtractProperties } from 'utilium';
|
|
2
|
+
import { type CredentialInit, type Credentials } from './credentials.js';
|
|
3
|
+
import * as fs from './emulation/index.js';
|
|
4
|
+
type Fn_FS = Omit<ExtractProperties<typeof fs, (...args: any[]) => any>, 'mountObject'>;
|
|
5
|
+
type Fn_Promises = ExtractProperties<typeof fs.promises, (...args: any[]) => any>;
|
|
6
|
+
/**
|
|
7
|
+
* Represents some context used for FS operations
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
export interface FSContext {
|
|
11
|
+
root: string;
|
|
12
|
+
readonly credentials: Credentials;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* maybe an FS context
|
|
16
|
+
* @experimental @hidden
|
|
17
|
+
*/
|
|
18
|
+
export type V_Context = void | (Partial<FSContext> & object);
|
|
19
|
+
/**
|
|
20
|
+
* Allows you to restrict operations to a specific root path and set of credentials.
|
|
21
|
+
* @experimental
|
|
22
|
+
*/
|
|
23
|
+
export interface BoundContext extends Fn_FS, FSContext {
|
|
24
|
+
promises: Fn_Promises;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Allows you to restrict operations to a specific root path and set of credentials.
|
|
28
|
+
* Note that the credentials of a bound context are copied.
|
|
29
|
+
* @experimental
|
|
30
|
+
*/
|
|
31
|
+
export declare function bindContext(root: string, credentials?: CredentialInit): BoundContext;
|
|
32
|
+
export {};
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createCredentials, credentials as defaultCredentials } from './credentials.js';
|
|
2
|
+
import * as fs from './emulation/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Binds a this value for all of the functions in an object (not recursive)
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
function _bindFunctions(fns, thisValue) {
|
|
8
|
+
return Object.fromEntries(Object.entries(fns).map(([k, v]) => [k, typeof v == 'function' ? v.bind(thisValue) : v]));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Allows you to restrict operations to a specific root path and set of credentials.
|
|
12
|
+
* Note that the credentials of a bound context are copied.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
export function bindContext(root, credentials = structuredClone(defaultCredentials)) {
|
|
16
|
+
const ctx = {
|
|
17
|
+
root,
|
|
18
|
+
credentials: createCredentials(credentials),
|
|
19
|
+
};
|
|
20
|
+
const fn_fs = _bindFunctions(fs, ctx);
|
|
21
|
+
const fn_promises = _bindFunctions(fs.promises, ctx);
|
|
22
|
+
return { ...ctx, ...fn_fs, promises: fn_promises };
|
|
23
|
+
}
|
package/dist/credentials.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ export interface Credentials {
|
|
|
16
16
|
groups: number[];
|
|
17
17
|
}
|
|
18
18
|
export declare const credentials: Credentials;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Initialization for a set of credentials
|
|
21
|
+
*/
|
|
22
|
+
export interface CredentialInit extends Partial<Credentials> {
|
|
20
23
|
uid: number;
|
|
21
24
|
gid: number;
|
|
22
|
-
suid?: number;
|
|
23
|
-
sgid?: number;
|
|
24
|
-
euid?: number;
|
|
25
|
-
egid?: number;
|
|
26
25
|
}
|
|
26
|
+
export declare function createCredentials(source: CredentialInit): Credentials;
|
|
27
27
|
/**
|
|
28
28
|
* Uses credentials from the provided uid and gid.
|
|
29
29
|
*/
|
package/dist/credentials.js
CHANGED
|
@@ -7,15 +7,19 @@ export const credentials = {
|
|
|
7
7
|
egid: 0,
|
|
8
8
|
groups: [],
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
export function useCredentials(source) {
|
|
14
|
-
Object.assign(credentials, {
|
|
10
|
+
export function createCredentials(source) {
|
|
11
|
+
return {
|
|
15
12
|
suid: source.uid,
|
|
16
13
|
sgid: source.gid,
|
|
17
14
|
euid: source.uid,
|
|
18
15
|
egid: source.gid,
|
|
16
|
+
groups: [],
|
|
19
17
|
...source,
|
|
20
|
-
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Uses credentials from the provided uid and gid.
|
|
22
|
+
*/
|
|
23
|
+
export function useCredentials(source) {
|
|
24
|
+
Object.assign(credentials, createCredentials(source));
|
|
21
25
|
}
|
|
@@ -8,40 +8,41 @@ import type { Dir } from './dir.js';
|
|
|
8
8
|
import * as promises from './promises.js';
|
|
9
9
|
import { ReadStream, WriteStream } from './streams.js';
|
|
10
10
|
import { FSWatcher } from './watchers.js';
|
|
11
|
+
import type { V_Context } from '../context.js';
|
|
11
12
|
/**
|
|
12
13
|
* Asynchronous rename. No arguments other than a possible exception are given to the completion callback.
|
|
13
14
|
*/
|
|
14
|
-
export declare function rename(oldPath: fs.PathLike, newPath: fs.PathLike, cb?: Callback): void;
|
|
15
|
+
export declare function rename(this: V_Context, oldPath: fs.PathLike, newPath: fs.PathLike, cb?: Callback): void;
|
|
15
16
|
/**
|
|
16
17
|
* Test whether or not `path` exists by checking with the file system.
|
|
17
18
|
* Then call the callback argument with either true or false.
|
|
18
19
|
* @deprecated Use {@link stat} or {@link access} instead.
|
|
19
20
|
*/
|
|
20
|
-
export declare function exists(path: fs.PathLike, cb?: (exists: boolean) => unknown): void;
|
|
21
|
-
export declare function stat(path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
22
|
-
export declare function stat(path: fs.PathLike, options: {
|
|
21
|
+
export declare function exists(this: V_Context, path: fs.PathLike, cb?: (exists: boolean) => unknown): void;
|
|
22
|
+
export declare function stat(this: V_Context, path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
23
|
+
export declare function stat(this: V_Context, path: fs.PathLike, options: {
|
|
23
24
|
bigint?: false;
|
|
24
25
|
}, callback: Callback<[Stats]>): void;
|
|
25
|
-
export declare function stat(path: fs.PathLike, options: {
|
|
26
|
+
export declare function stat(this: V_Context, path: fs.PathLike, options: {
|
|
26
27
|
bigint: true;
|
|
27
28
|
}, callback: Callback<[BigIntStats]>): void;
|
|
28
|
-
export declare function stat(path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats] | [BigIntStats]>): void;
|
|
29
|
+
export declare function stat(this: V_Context, path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats] | [BigIntStats]>): void;
|
|
29
30
|
/**
|
|
30
31
|
* Asynchronous `lstat`.
|
|
31
32
|
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
32
33
|
* then the link itself is stat-ed, not the file that it refers to.
|
|
33
34
|
*/
|
|
34
|
-
export declare function lstat(path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
35
|
-
export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
|
|
35
|
+
export declare function lstat(this: V_Context, path: fs.PathLike, callback: Callback<[Stats]>): void;
|
|
36
|
+
export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions & {
|
|
36
37
|
bigint?: false;
|
|
37
38
|
}, callback: Callback<[Stats]>): void;
|
|
38
|
-
export declare function lstat(path: fs.PathLike, options: fs.StatOptions & {
|
|
39
|
+
export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions & {
|
|
39
40
|
bigint: true;
|
|
40
41
|
}, callback: Callback<[BigIntStats]>): void;
|
|
41
|
-
export declare function lstat(path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
|
|
42
|
-
export declare function truncate(path: fs.PathLike, cb?: Callback): void;
|
|
43
|
-
export declare function truncate(path: fs.PathLike, len: number, cb?: Callback): void;
|
|
44
|
-
export declare function unlink(path: fs.PathLike, cb?: Callback): void;
|
|
42
|
+
export declare function lstat(this: V_Context, path: fs.PathLike, options: fs.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
|
|
43
|
+
export declare function truncate(this: V_Context, path: fs.PathLike, cb?: Callback): void;
|
|
44
|
+
export declare function truncate(this: V_Context, path: fs.PathLike, len: number, cb?: Callback): void;
|
|
45
|
+
export declare function unlink(this: V_Context, path: fs.PathLike, cb?: Callback): void;
|
|
45
46
|
/**
|
|
46
47
|
* Asynchronous file open.
|
|
47
48
|
* Exclusive mode ensures that path is newly created.
|
|
@@ -64,19 +65,19 @@ export declare function unlink(path: fs.PathLike, cb?: Callback): void;
|
|
|
64
65
|
*
|
|
65
66
|
* @see http://www.manpagez.com/man/2/open/
|
|
66
67
|
*/
|
|
67
|
-
export declare function open(path: fs.PathLike, flag: string, cb?: Callback<[number]>): void;
|
|
68
|
-
export declare function open(path: fs.PathLike, flag: string, mode: number | string, cb?: Callback<[number]>): void;
|
|
68
|
+
export declare function open(this: V_Context, path: fs.PathLike, flag: string, cb?: Callback<[number]>): void;
|
|
69
|
+
export declare function open(this: V_Context, path: fs.PathLike, flag: string, mode: number | string, cb?: Callback<[number]>): void;
|
|
69
70
|
/**
|
|
70
71
|
* Asynchronously reads the entire contents of a file.
|
|
71
72
|
* @option encoding The string encoding for the file contents. Defaults to `null`.
|
|
72
73
|
* @option flag Defaults to `'r'`.
|
|
73
74
|
* @param cb If no encoding is specified, then the raw buffer is returned.
|
|
74
75
|
*/
|
|
75
|
-
export declare function readFile(filename: fs.PathLike, cb: Callback<[Uint8Array]>): void;
|
|
76
|
-
export declare function readFile(filename: fs.PathLike, options: {
|
|
76
|
+
export declare function readFile(this: V_Context, filename: fs.PathLike, cb: Callback<[Uint8Array]>): void;
|
|
77
|
+
export declare function readFile(this: V_Context, filename: fs.PathLike, options: {
|
|
77
78
|
flag?: string;
|
|
78
79
|
}, callback?: Callback<[Uint8Array]>): void;
|
|
79
|
-
export declare function readFile(filename: fs.PathLike, options: {
|
|
80
|
+
export declare function readFile(this: V_Context, filename: fs.PathLike, options: {
|
|
80
81
|
encoding: BufferEncoding;
|
|
81
82
|
flag?: string;
|
|
82
83
|
} | BufferEncoding, cb: Callback<[string]>): void;
|
|
@@ -90,9 +91,9 @@ export declare function readFile(filename: fs.PathLike, options: {
|
|
|
90
91
|
* @option mode Defaults to `0644`.
|
|
91
92
|
* @option flag Defaults to `'w'`.
|
|
92
93
|
*/
|
|
93
|
-
export declare function writeFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
94
|
-
export declare function writeFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
95
|
-
export declare function writeFile(filename: fs.PathLike, data: FileContents, options?: fs.WriteFileOptions, cb?: Callback): void;
|
|
94
|
+
export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
95
|
+
export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
96
|
+
export declare function writeFile(this: V_Context, filename: fs.PathLike, data: FileContents, options?: fs.WriteFileOptions, cb?: Callback): void;
|
|
96
97
|
/**
|
|
97
98
|
* Asynchronously append data to a file, creating the file if it not yet
|
|
98
99
|
* exists.
|
|
@@ -101,28 +102,28 @@ export declare function writeFile(filename: fs.PathLike, data: FileContents, opt
|
|
|
101
102
|
* @option mode Defaults to `0644`.
|
|
102
103
|
* @option flag Defaults to `'a'`.
|
|
103
104
|
*/
|
|
104
|
-
export declare function appendFile(filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
105
|
-
export declare function appendFile(filename: fs.PathLike, data: FileContents, options?: fs.EncodingOption & {
|
|
105
|
+
export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, cb?: Callback): void;
|
|
106
|
+
export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, options?: fs.EncodingOption & {
|
|
106
107
|
mode?: fs.Mode;
|
|
107
108
|
flag?: fs.OpenMode;
|
|
108
109
|
}, cb?: Callback): void;
|
|
109
|
-
export declare function appendFile(filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
110
|
+
export declare function appendFile(this: V_Context, filename: fs.PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
110
111
|
/**
|
|
111
112
|
* Asynchronous `fstat`.
|
|
112
113
|
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is specified by the file descriptor `fd`.
|
|
113
114
|
*/
|
|
114
|
-
export declare function fstat(fd: number, cb: Callback<[Stats]>): void;
|
|
115
|
-
export declare function fstat(fd: number, options: fs.StatOptions & {
|
|
115
|
+
export declare function fstat(this: V_Context, fd: number, cb: Callback<[Stats]>): void;
|
|
116
|
+
export declare function fstat(this: V_Context, fd: number, options: fs.StatOptions & {
|
|
116
117
|
bigint?: false;
|
|
117
118
|
}, cb: Callback<[Stats]>): void;
|
|
118
|
-
export declare function fstat(fd: number, options: fs.StatOptions & {
|
|
119
|
+
export declare function fstat(this: V_Context, fd: number, options: fs.StatOptions & {
|
|
119
120
|
bigint: true;
|
|
120
121
|
}, cb: Callback<[BigIntStats]>): void;
|
|
121
|
-
export declare function close(fd: number, cb?: Callback): void;
|
|
122
|
-
export declare function ftruncate(fd: number, cb?: Callback): void;
|
|
123
|
-
export declare function ftruncate(fd: number, len?: number, cb?: Callback): void;
|
|
124
|
-
export declare function fsync(fd: number, cb?: Callback): void;
|
|
125
|
-
export declare function fdatasync(fd: number, cb?: Callback): void;
|
|
122
|
+
export declare function close(this: V_Context, fd: number, cb?: Callback): void;
|
|
123
|
+
export declare function ftruncate(this: V_Context, fd: number, cb?: Callback): void;
|
|
124
|
+
export declare function ftruncate(this: V_Context, fd: number, len?: number, cb?: Callback): void;
|
|
125
|
+
export declare function fsync(this: V_Context, fd: number, cb?: Callback): void;
|
|
126
|
+
export declare function fdatasync(this: V_Context, fd: number, cb?: Callback): void;
|
|
126
127
|
/**
|
|
127
128
|
* Write buffer to the file specified by `fd`.
|
|
128
129
|
* Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback.
|
|
@@ -133,11 +134,11 @@ export declare function fdatasync(fd: number, cb?: Callback): void;
|
|
|
133
134
|
* If position is null, the data will be written at the current position.
|
|
134
135
|
* @param cb The number specifies the number of bytes written into the file.
|
|
135
136
|
*/
|
|
136
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
137
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
138
|
-
export declare function write(fd: number, data: FileContents, cb?: Callback<[number, string]>): void;
|
|
139
|
-
export declare function write(fd: number, data: FileContents, position?: number, cb?: Callback<[number, string]>): void;
|
|
140
|
-
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
|
|
137
|
+
export declare function write(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
138
|
+
export declare function write(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
139
|
+
export declare function write(this: V_Context, fd: number, data: FileContents, cb?: Callback<[number, string]>): void;
|
|
140
|
+
export declare function write(this: V_Context, fd: number, data: FileContents, position?: number, cb?: Callback<[number, string]>): void;
|
|
141
|
+
export declare function write(this: V_Context, fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
|
|
141
142
|
/**
|
|
142
143
|
* Read data from the file specified by `fd`.
|
|
143
144
|
* @param buffer The buffer that the data will be written to.
|
|
@@ -147,64 +148,64 @@ export declare function write(fd: number, data: FileContents, position: number |
|
|
|
147
148
|
* If position is null, data will be read from the current file position.
|
|
148
149
|
* @param cb The number is the number of bytes read
|
|
149
150
|
*/
|
|
150
|
-
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
151
|
-
export declare function fchown(fd: number, uid: number, gid: number, cb?: Callback): void;
|
|
152
|
-
export declare function fchmod(fd: number, mode: string | number, cb: Callback): void;
|
|
151
|
+
export declare function read(this: V_Context, fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
152
|
+
export declare function fchown(this: V_Context, fd: number, uid: number, gid: number, cb?: Callback): void;
|
|
153
|
+
export declare function fchmod(this: V_Context, fd: number, mode: string | number, cb: Callback): void;
|
|
153
154
|
/**
|
|
154
155
|
* Change the file timestamps of a file referenced by the supplied file descriptor.
|
|
155
156
|
*/
|
|
156
|
-
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
157
|
-
export declare function rmdir(path: fs.PathLike, cb?: Callback): void;
|
|
157
|
+
export declare function futimes(this: V_Context, fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
158
|
+
export declare function rmdir(this: V_Context, path: fs.PathLike, cb?: Callback): void;
|
|
158
159
|
/**
|
|
159
160
|
* Asynchronous `mkdir`.
|
|
160
161
|
* @param mode defaults to `0777`
|
|
161
162
|
*/
|
|
162
|
-
export declare function mkdir(path: fs.PathLike, mode?: fs.Mode, cb?: Callback): void;
|
|
163
|
+
export declare function mkdir(this: V_Context, path: fs.PathLike, mode?: fs.Mode, cb?: Callback): void;
|
|
163
164
|
/**
|
|
164
165
|
* Asynchronous `readdir`. Reads the contents of a directory.
|
|
165
166
|
* The callback gets two arguments `(err, files)` where `files` is an array of
|
|
166
167
|
* the names of the files in the directory excluding `'.'` and `'..'`.
|
|
167
168
|
*/
|
|
168
|
-
export declare function readdir(path: fs.PathLike, cb: Callback<[string[]]>): void;
|
|
169
|
-
export declare function readdir(path: fs.PathLike, options: {
|
|
169
|
+
export declare function readdir(this: V_Context, path: fs.PathLike, cb: Callback<[string[]]>): void;
|
|
170
|
+
export declare function readdir(this: V_Context, path: fs.PathLike, options: {
|
|
170
171
|
withFileTypes?: false;
|
|
171
172
|
}, cb: Callback<[string[]]>): void;
|
|
172
|
-
export declare function readdir(path: fs.PathLike, options: {
|
|
173
|
+
export declare function readdir(this: V_Context, path: fs.PathLike, options: {
|
|
173
174
|
withFileTypes: true;
|
|
174
175
|
}, cb: Callback<[Dirent[]]>): void;
|
|
175
|
-
export declare function link(existing: fs.PathLike, newpath: fs.PathLike, cb?: Callback): void;
|
|
176
|
+
export declare function link(this: V_Context, existing: fs.PathLike, newpath: fs.PathLike, cb?: Callback): void;
|
|
176
177
|
/**
|
|
177
178
|
* Asynchronous `symlink`.
|
|
178
179
|
* @param target target path
|
|
179
180
|
* @param path link path
|
|
180
181
|
* Type defaults to file
|
|
181
182
|
*/
|
|
182
|
-
export declare function symlink(target: fs.PathLike, path: fs.PathLike, cb?: Callback): void;
|
|
183
|
-
export declare function symlink(target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type, cb?: Callback): void;
|
|
184
|
-
export declare function readlink(path: fs.PathLike, callback: Callback<[string]>): void;
|
|
185
|
-
export declare function readlink(path: fs.PathLike, options: fs.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
|
|
186
|
-
export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
|
|
187
|
-
export declare function readlink(path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string]>): void;
|
|
188
|
-
export declare function chown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
189
|
-
export declare function lchown(path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
190
|
-
export declare function chmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
191
|
-
export declare function lchmod(path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
183
|
+
export declare function symlink(this: V_Context, target: fs.PathLike, path: fs.PathLike, cb?: Callback): void;
|
|
184
|
+
export declare function symlink(this: V_Context, target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type, cb?: Callback): void;
|
|
185
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, callback: Callback<[string]>): void;
|
|
186
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
|
|
187
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
|
|
188
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, callback: Callback<[string]>): void;
|
|
189
|
+
export declare function chown(this: V_Context, path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
190
|
+
export declare function lchown(this: V_Context, path: fs.PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
191
|
+
export declare function chmod(this: V_Context, path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
192
|
+
export declare function lchmod(this: V_Context, path: fs.PathLike, mode: number | string, cb?: Callback): void;
|
|
192
193
|
/**
|
|
193
194
|
* Change file timestamps of the file referenced by the supplied path.
|
|
194
195
|
*/
|
|
195
|
-
export declare function utimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
196
|
+
export declare function utimes(this: V_Context, path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
196
197
|
/**
|
|
197
198
|
* Change file timestamps of the file referenced by the supplied path.
|
|
198
199
|
*/
|
|
199
|
-
export declare function lutimes(path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
200
|
+
export declare function lutimes(this: V_Context, path: fs.PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
200
201
|
/**
|
|
201
202
|
* Asynchronous `realpath`. The callback gets two arguments
|
|
202
203
|
* `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
|
203
204
|
*/
|
|
204
|
-
export declare function realpath(path: fs.PathLike, cb?: Callback<[string]>): void;
|
|
205
|
-
export declare function realpath(path: fs.PathLike, options: fs.EncodingOption, cb: Callback<[string]>): void;
|
|
206
|
-
export declare function access(path: fs.PathLike, cb: Callback): void;
|
|
207
|
-
export declare function access(path: fs.PathLike, mode: number, cb: Callback): void;
|
|
205
|
+
export declare function realpath(this: V_Context, path: fs.PathLike, cb?: Callback<[string]>): void;
|
|
206
|
+
export declare function realpath(this: V_Context, path: fs.PathLike, options: fs.EncodingOption, cb: Callback<[string]>): void;
|
|
207
|
+
export declare function access(this: V_Context, path: fs.PathLike, cb: Callback): void;
|
|
208
|
+
export declare function access(this: V_Context, path: fs.PathLike, mode: number, cb: Callback): void;
|
|
208
209
|
/**
|
|
209
210
|
* Watch for changes on a file. The callback listener will be called each time the file is accessed.
|
|
210
211
|
*
|
|
@@ -216,8 +217,8 @@ export declare function access(path: fs.PathLike, mode: number, cb: Callback): v
|
|
|
216
217
|
* @param options Optional options object specifying `persistent` and `interval`.
|
|
217
218
|
* @param listener The callback listener to be called when the file changes.
|
|
218
219
|
*/
|
|
219
|
-
export declare function watchFile(path: fs.PathLike, listener: (curr: Stats, prev: Stats) => void): void;
|
|
220
|
-
export declare function watchFile(path: fs.PathLike, options: {
|
|
220
|
+
export declare function watchFile(this: V_Context, path: fs.PathLike, listener: (curr: Stats, prev: Stats) => void): void;
|
|
221
|
+
export declare function watchFile(this: V_Context, path: fs.PathLike, options: {
|
|
221
222
|
persistent?: boolean;
|
|
222
223
|
interval?: number;
|
|
223
224
|
}, listener: (curr: Stats, prev: Stats) => void): void;
|
|
@@ -230,9 +231,9 @@ export declare function watchFile(path: fs.PathLike, options: {
|
|
|
230
231
|
* @param path The path to the file to stop watching.
|
|
231
232
|
* @param listener Optional listener to remove.
|
|
232
233
|
*/
|
|
233
|
-
export declare function unwatchFile(path: fs.PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
234
|
-
export declare function watch(path: fs.PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
|
|
235
|
-
export declare function watch(path: fs.PathLike, options: {
|
|
234
|
+
export declare function unwatchFile(this: V_Context, path: fs.PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
|
|
235
|
+
export declare function watch(this: V_Context, path: fs.PathLike, listener?: (event: string, filename: string) => any): FSWatcher;
|
|
236
|
+
export declare function watch(this: V_Context, path: fs.PathLike, options: {
|
|
236
237
|
persistent?: boolean;
|
|
237
238
|
}, listener?: (event: string, filename: string) => any): FSWatcher;
|
|
238
239
|
interface StreamOptions {
|
|
@@ -270,7 +271,7 @@ interface WriteStreamOptions extends StreamOptions {
|
|
|
270
271
|
* @param options Options for the ReadStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
|
|
271
272
|
* @returns A ReadStream object for interacting with the file's contents.
|
|
272
273
|
*/
|
|
273
|
-
export declare function createReadStream(path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
|
|
274
|
+
export declare function createReadStream(this: V_Context, path: fs.PathLike, options?: BufferEncoding | ReadStreamOptions): ReadStream;
|
|
274
275
|
/**
|
|
275
276
|
* Opens a file in write mode and creates a Node.js-like WriteStream.
|
|
276
277
|
*
|
|
@@ -278,34 +279,34 @@ export declare function createReadStream(path: fs.PathLike, options?: BufferEnco
|
|
|
278
279
|
* @param options Options for the WriteStream and file opening (e.g., `encoding`, `highWaterMark`, `mode`).
|
|
279
280
|
* @returns A WriteStream object for writing to the file.
|
|
280
281
|
*/
|
|
281
|
-
export declare function createWriteStream(path: fs.PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
|
|
282
|
-
export declare function rm(path: fs.PathLike, callback: Callback): void;
|
|
283
|
-
export declare function rm(path: fs.PathLike, options: fs.RmOptions, callback: Callback): void;
|
|
282
|
+
export declare function createWriteStream(this: V_Context, path: fs.PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
|
|
283
|
+
export declare function rm(this: V_Context, path: fs.PathLike, callback: Callback): void;
|
|
284
|
+
export declare function rm(this: V_Context, path: fs.PathLike, options: fs.RmOptions, callback: Callback): void;
|
|
284
285
|
/**
|
|
285
286
|
* Asynchronously creates a unique temporary directory.
|
|
286
287
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
287
288
|
*/
|
|
288
|
-
export declare function mkdtemp(prefix: string, callback: Callback<[string]>): void;
|
|
289
|
-
export declare function mkdtemp(prefix: string, options: fs.EncodingOption, callback: Callback<[string]>): void;
|
|
290
|
-
export declare function mkdtemp(prefix: string, options: fs.BufferEncodingOption, callback: Callback<[Buffer]>): void;
|
|
291
|
-
export declare function copyFile(src: fs.PathLike, dest: fs.PathLike, callback: Callback): void;
|
|
292
|
-
export declare function copyFile(src: fs.PathLike, dest: fs.PathLike, flags: number, callback: Callback): void;
|
|
289
|
+
export declare function mkdtemp(this: V_Context, prefix: string, callback: Callback<[string]>): void;
|
|
290
|
+
export declare function mkdtemp(this: V_Context, prefix: string, options: fs.EncodingOption, callback: Callback<[string]>): void;
|
|
291
|
+
export declare function mkdtemp(this: V_Context, prefix: string, options: fs.BufferEncodingOption, callback: Callback<[Buffer]>): void;
|
|
292
|
+
export declare function copyFile(this: V_Context, src: fs.PathLike, dest: fs.PathLike, callback: Callback): void;
|
|
293
|
+
export declare function copyFile(this: V_Context, src: fs.PathLike, dest: fs.PathLike, flags: number, callback: Callback): void;
|
|
293
294
|
type readvCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
|
|
294
|
-
export declare function readv(fd: number, buffers: NodeJS.ArrayBufferView[], cb: readvCb): void;
|
|
295
|
-
export declare function readv(fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: readvCb): void;
|
|
295
|
+
export declare function readv(this: V_Context, fd: number, buffers: NodeJS.ArrayBufferView[], cb: readvCb): void;
|
|
296
|
+
export declare function readv(this: V_Context, fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: readvCb): void;
|
|
296
297
|
type writevCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
|
|
297
|
-
export declare function writev(fd: number, buffers: Uint8Array[], cb: writevCb): void;
|
|
298
|
-
export declare function writev(fd: number, buffers: Uint8Array[], position: number, cb: writevCb): void;
|
|
299
|
-
export declare function opendir(path: fs.PathLike, cb: Callback<[Dir]>): void;
|
|
300
|
-
export declare function opendir(path: fs.PathLike, options: fs.OpenDirOptions, cb: Callback<[Dir]>): void;
|
|
301
|
-
export declare function cp(source: fs.PathLike, destination: fs.PathLike, callback: Callback): void;
|
|
302
|
-
export declare function cp(source: fs.PathLike, destination: fs.PathLike, opts: fs.CopyOptions, callback: Callback): void;
|
|
303
|
-
export declare function statfs(path: fs.PathLike, callback: Callback<[fs.StatsFs]>): void;
|
|
304
|
-
export declare function statfs(path: fs.PathLike, options: fs.StatFsOptions & {
|
|
298
|
+
export declare function writev(this: V_Context, fd: number, buffers: Uint8Array[], cb: writevCb): void;
|
|
299
|
+
export declare function writev(this: V_Context, fd: number, buffers: Uint8Array[], position: number, cb: writevCb): void;
|
|
300
|
+
export declare function opendir(this: V_Context, path: fs.PathLike, cb: Callback<[Dir]>): void;
|
|
301
|
+
export declare function opendir(this: V_Context, path: fs.PathLike, options: fs.OpenDirOptions, cb: Callback<[Dir]>): void;
|
|
302
|
+
export declare function cp(this: V_Context, source: fs.PathLike, destination: fs.PathLike, callback: Callback): void;
|
|
303
|
+
export declare function cp(this: V_Context, source: fs.PathLike, destination: fs.PathLike, opts: fs.CopyOptions, callback: Callback): void;
|
|
304
|
+
export declare function statfs(this: V_Context, path: fs.PathLike, callback: Callback<[fs.StatsFs]>): void;
|
|
305
|
+
export declare function statfs(this: V_Context, path: fs.PathLike, options: fs.StatFsOptions & {
|
|
305
306
|
bigint?: false;
|
|
306
307
|
}, callback: Callback<[fs.StatsFs]>): void;
|
|
307
|
-
export declare function statfs(path: fs.PathLike, options: fs.StatFsOptions & {
|
|
308
|
+
export declare function statfs(this: V_Context, path: fs.PathLike, options: fs.StatFsOptions & {
|
|
308
309
|
bigint: true;
|
|
309
310
|
}, callback: Callback<[fs.BigIntStatsFs]>): void;
|
|
310
|
-
export declare function openAsBlob(path: fs.PathLike, options?: fs.OpenAsBlobOptions): Promise<Blob>;
|
|
311
|
+
export declare function openAsBlob(this: V_Context, path: fs.PathLike, options?: fs.OpenAsBlobOptions): Promise<Blob>;
|
|
311
312
|
export {};
|