@zenfs/core 1.0.10 → 1.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 +4 -8
- package/dist/backends/backend.js +7 -11
- package/dist/backends/fetch.d.ts +2 -4
- package/dist/backends/fetch.js +1 -3
- package/dist/backends/file_index.js +3 -3
- package/dist/backends/memory.d.ts +1 -1
- package/dist/backends/overlay.d.ts +7 -3
- package/dist/backends/overlay.js +13 -9
- package/dist/backends/port/fs.d.ts +12 -17
- package/dist/backends/port/fs.js +5 -8
- package/dist/backends/port/rpc.d.ts +1 -1
- package/dist/backends/store/fs.d.ts +13 -15
- package/dist/backends/store/fs.js +35 -54
- package/dist/backends/store/simple.d.ts +1 -1
- package/dist/backends/store/simple.js +1 -1
- package/dist/backends/store/store.d.ts +7 -13
- package/dist/config.d.ts +13 -5
- package/dist/config.js +36 -26
- package/dist/devices.d.ts +158 -0
- package/dist/devices.js +423 -0
- package/dist/emulation/async.d.ts +21 -176
- package/dist/emulation/async.js +17 -111
- package/dist/emulation/constants.d.ts +5 -0
- package/dist/emulation/constants.js +5 -0
- package/dist/emulation/dir.d.ts +0 -1
- package/dist/emulation/path.d.ts +0 -4
- package/dist/emulation/path.js +4 -8
- package/dist/emulation/promises.d.ts +31 -121
- package/dist/emulation/promises.js +30 -97
- package/dist/emulation/shared.d.ts +7 -3
- package/dist/emulation/shared.js +11 -7
- package/dist/emulation/streams.d.ts +0 -3
- package/dist/emulation/sync.d.ts +25 -178
- package/dist/emulation/sync.js +36 -129
- package/dist/emulation/watchers.d.ts +0 -4
- package/dist/error.d.ts +11 -11
- package/dist/error.js +8 -10
- package/dist/file.d.ts +50 -171
- package/dist/file.js +34 -117
- package/dist/filesystem.d.ts +10 -62
- package/dist/filesystem.js +5 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/inode.d.ts +0 -5
- package/dist/inode.js +0 -5
- package/dist/mixins/async.d.ts +4 -6
- package/dist/mixins/async.js +3 -1
- package/dist/mixins/mutexed.d.ts +4 -4
- package/dist/mixins/mutexed.js +7 -5
- package/dist/mixins/readonly.js +14 -15
- package/dist/mixins/shared.d.ts +5 -5
- package/dist/mixins/sync.d.ts +2 -2
- package/dist/stats.d.ts +21 -37
- package/dist/stats.js +10 -23
- package/dist/utils.d.ts +15 -7
- package/dist/utils.js +28 -6
- package/package.json +4 -4
- package/readme.md +58 -2
- package/src/backends/backend.ts +7 -11
- package/src/backends/fetch.ts +2 -4
- package/src/backends/file_index.ts +3 -3
- package/src/backends/memory.ts +1 -1
- package/src/backends/overlay.ts +11 -9
- package/src/backends/port/fs.ts +11 -14
- package/src/backends/port/rpc.ts +1 -0
- package/src/backends/store/fs.ts +40 -55
- package/src/backends/store/simple.ts +1 -1
- package/src/backends/store/store.ts +7 -13
- package/src/config.ts +48 -26
- package/src/devices.ts +469 -0
- package/src/emulation/async.ts +28 -178
- package/src/emulation/constants.ts +6 -0
- package/src/emulation/path.ts +4 -11
- package/src/emulation/promises.ts +34 -116
- package/src/emulation/shared.ts +11 -8
- package/src/emulation/sync.ts +41 -185
- package/src/error.ts +7 -11
- package/src/file.ts +48 -182
- package/src/filesystem.ts +14 -65
- package/src/index.ts +2 -0
- package/src/inode.ts +0 -6
- package/src/mixins/async.ts +4 -6
- package/src/mixins/mutexed.ts +4 -4
- package/src/mixins/readonly.ts +15 -15
- package/src/mixins/shared.ts +5 -5
- package/src/mixins/sync.ts +3 -3
- package/src/stats.ts +22 -40
- package/src/utils.ts +33 -6
|
@@ -72,15 +72,13 @@ export type OptionsOf<T extends Backend> = T extends Backend<FileSystem, infer T
|
|
|
72
72
|
* @internal
|
|
73
73
|
*/
|
|
74
74
|
export type FilesystemOf<T extends Backend> = T extends Backend<infer FS> ? FS : never;
|
|
75
|
-
/**
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
75
|
+
/** @internal */
|
|
78
76
|
export declare function isBackend(arg: unknown): arg is Backend;
|
|
79
77
|
/**
|
|
80
|
-
* Checks that
|
|
78
|
+
* Checks that `options` object is valid for the file system options.
|
|
81
79
|
* @internal
|
|
82
80
|
*/
|
|
83
|
-
export declare function checkOptions<T extends Backend>(backend: T,
|
|
81
|
+
export declare function checkOptions<T extends Backend>(backend: T, options: Record<string, unknown>): Promise<void>;
|
|
84
82
|
/**
|
|
85
83
|
* Specifies a file system backend type and its options.
|
|
86
84
|
*
|
|
@@ -91,8 +89,6 @@ export declare function checkOptions<T extends Backend>(backend: T, opts: Record
|
|
|
91
89
|
export type BackendConfiguration<T extends Backend> = OptionsOf<T> & Partial<SharedConfig> & {
|
|
92
90
|
backend: T;
|
|
93
91
|
};
|
|
94
|
-
/**
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
92
|
+
/** @internal */
|
|
97
93
|
export declare function isBackendConfig<T extends Backend>(arg: unknown): arg is BackendConfiguration<T>;
|
|
98
94
|
export {};
|
package/dist/backends/backend.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { ErrnoError, Errno } from '../error.js';
|
|
2
2
|
import { levenshtein } from '../utils.js';
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
3
|
+
/** @internal */
|
|
6
4
|
export function isBackend(arg) {
|
|
7
5
|
return arg != null && typeof arg == 'object' && 'isAvailable' in arg && typeof arg.isAvailable == 'function' && 'create' in arg && typeof arg.create == 'function';
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
10
|
-
* Checks that
|
|
8
|
+
* Checks that `options` object is valid for the file system options.
|
|
11
9
|
* @internal
|
|
12
10
|
*/
|
|
13
|
-
export async function checkOptions(backend,
|
|
14
|
-
if (typeof
|
|
11
|
+
export async function checkOptions(backend, options) {
|
|
12
|
+
if (typeof options != 'object' || options === null) {
|
|
15
13
|
throw new ErrnoError(Errno.EINVAL, 'Invalid options');
|
|
16
14
|
}
|
|
17
15
|
// Check for required options.
|
|
18
16
|
for (const [optName, opt] of Object.entries(backend.options)) {
|
|
19
|
-
const providedValue =
|
|
17
|
+
const providedValue = options?.[optName];
|
|
20
18
|
if (providedValue === undefined || providedValue === null) {
|
|
21
19
|
if (!opt.required) {
|
|
22
20
|
continue;
|
|
@@ -24,7 +22,7 @@ export async function checkOptions(backend, opts) {
|
|
|
24
22
|
/* Required option not provided.
|
|
25
23
|
if any incorrect options provided, which ones are close to the provided one?
|
|
26
24
|
(edit distance 5 === close)*/
|
|
27
|
-
const incorrectOptions = Object.keys(
|
|
25
|
+
const incorrectOptions = Object.keys(options)
|
|
28
26
|
.filter(o => !(o in backend.options))
|
|
29
27
|
.map((a) => {
|
|
30
28
|
return { str: a, distance: levenshtein(optName, a) };
|
|
@@ -44,9 +42,7 @@ export async function checkOptions(backend, opts) {
|
|
|
44
42
|
// Otherwise: All good!
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
/**
|
|
48
|
-
* @internal
|
|
49
|
-
*/
|
|
45
|
+
/** @internal */
|
|
50
46
|
export function isBackendConfig(arg) {
|
|
51
47
|
return arg != null && typeof arg == 'object' && 'backend' in arg && isBackend(arg.backend);
|
|
52
48
|
}
|
package/dist/backends/fetch.d.ts
CHANGED
|
@@ -41,9 +41,7 @@ export declare class FetchFS extends IndexFS {
|
|
|
41
41
|
constructor({ index, baseUrl }: FetchOptions);
|
|
42
42
|
metadata(): FileSystemMetadata;
|
|
43
43
|
/**
|
|
44
|
-
* Preload the
|
|
45
|
-
* @param path
|
|
46
|
-
* @param buffer
|
|
44
|
+
* Preload the `path` into the index.
|
|
47
45
|
*/
|
|
48
46
|
preload(path: string, buffer: Uint8Array): void;
|
|
49
47
|
/**
|
|
@@ -70,7 +68,7 @@ declare const _Fetch: {
|
|
|
70
68
|
readonly create: (options: FetchOptions) => FetchFS;
|
|
71
69
|
};
|
|
72
70
|
type _Fetch = typeof _Fetch;
|
|
73
|
-
interface Fetch extends _Fetch {
|
|
71
|
+
export interface Fetch extends _Fetch {
|
|
74
72
|
}
|
|
75
73
|
export declare const Fetch: Fetch;
|
|
76
74
|
export {};
|
package/dist/backends/fetch.js
CHANGED
|
@@ -6,7 +6,7 @@ import { NoSyncFile, isWriteable } from '../file.js';
|
|
|
6
6
|
import { FileSystem } from '../filesystem.js';
|
|
7
7
|
import { Readonly } from '../mixins/readonly.js';
|
|
8
8
|
import { Stats } from '../stats.js';
|
|
9
|
-
import {
|
|
9
|
+
import { decodeUTF8, encodeUTF8 } from '../utils.js';
|
|
10
10
|
export const version = 1;
|
|
11
11
|
/**
|
|
12
12
|
* An index of files
|
|
@@ -64,7 +64,7 @@ export class Index extends Map {
|
|
|
64
64
|
for (const [path, data] of Object.entries(json.entries)) {
|
|
65
65
|
const stats = new Stats(data);
|
|
66
66
|
if (stats.isDirectory()) {
|
|
67
|
-
stats.fileData =
|
|
67
|
+
stats.fileData = encodeUTF8(JSON.stringify(this.dirEntries(path)));
|
|
68
68
|
}
|
|
69
69
|
this.set(path, stats);
|
|
70
70
|
}
|
|
@@ -154,7 +154,7 @@ export class IndexFS extends Readonly(FileSystem) {
|
|
|
154
154
|
if (!stats.isDirectory()) {
|
|
155
155
|
throw ErrnoError.With('ENOTDIR', path, 'readdir');
|
|
156
156
|
}
|
|
157
|
-
const content = JSON.parse(
|
|
157
|
+
const content = JSON.parse(decodeUTF8(stats.fileData));
|
|
158
158
|
if (!Array.isArray(content)) {
|
|
159
159
|
throw ErrnoError.With('ENODATA', path, 'readdir');
|
|
160
160
|
}
|
|
@@ -69,10 +69,14 @@ export declare class UnmutexedOverlayFS extends FileSystem {
|
|
|
69
69
|
private checkInitialized;
|
|
70
70
|
private checkPath;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
72
|
+
* Create the needed parent directories on the writable storage should they not exist.
|
|
73
|
+
* Use modes from the read-only storage.
|
|
74
74
|
*/
|
|
75
75
|
private createParentDirectoriesSync;
|
|
76
|
+
/**
|
|
77
|
+
* Create the needed parent directories on the writable storage should they not exist.
|
|
78
|
+
* Use modes from the read-only storage.
|
|
79
|
+
*/
|
|
76
80
|
private createParentDirectories;
|
|
77
81
|
/**
|
|
78
82
|
* Helper function:
|
|
@@ -117,7 +121,7 @@ declare const _Overlay: {
|
|
|
117
121
|
readonly create: (options: OverlayOptions) => OverlayFS;
|
|
118
122
|
};
|
|
119
123
|
type _Overlay = typeof _Overlay;
|
|
120
|
-
interface Overlay extends _Overlay {
|
|
124
|
+
export interface Overlay extends _Overlay {
|
|
121
125
|
}
|
|
122
126
|
export declare const Overlay: Overlay;
|
|
123
127
|
export {};
|
package/dist/backends/overlay.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
2
|
if (value !== null && value !== void 0) {
|
|
3
3
|
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose;
|
|
4
|
+
var dispose, inner;
|
|
5
5
|
if (async) {
|
|
6
6
|
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
7
|
dispose = value[Symbol.asyncDispose];
|
|
@@ -9,8 +9,10 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function
|
|
|
9
9
|
if (dispose === void 0) {
|
|
10
10
|
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
11
|
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
12
13
|
}
|
|
13
14
|
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
14
16
|
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
15
17
|
}
|
|
16
18
|
else if (async) {
|
|
@@ -49,10 +51,8 @@ import { PreloadFile, parseFlag } from '../file.js';
|
|
|
49
51
|
import { FileSystem } from '../filesystem.js';
|
|
50
52
|
import { Mutexed } from '../mixins/mutexed.js';
|
|
51
53
|
import { Stats } from '../stats.js';
|
|
52
|
-
import {
|
|
53
|
-
/**
|
|
54
|
-
* @internal
|
|
55
|
-
*/
|
|
54
|
+
import { decodeUTF8, encodeUTF8 } from '../utils.js';
|
|
55
|
+
/** @internal */
|
|
56
56
|
const deletionLogPath = '/.deleted';
|
|
57
57
|
/**
|
|
58
58
|
* OverlayFS makes a read-only filesystem writable by storing writes on a second, writable file system.
|
|
@@ -115,7 +115,7 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
115
115
|
const file = await this.writable.openFile(deletionLogPath, parseFlag('r'));
|
|
116
116
|
const { size } = await file.stat();
|
|
117
117
|
const { buffer } = await file.read(new Uint8Array(size));
|
|
118
|
-
this._deleteLog =
|
|
118
|
+
this._deleteLog = decodeUTF8(buffer);
|
|
119
119
|
}
|
|
120
120
|
catch (err) {
|
|
121
121
|
if (err.errno !== Errno.ENOENT) {
|
|
@@ -379,7 +379,7 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
379
379
|
this._deleteLogUpdatePending = true;
|
|
380
380
|
const log = await this.writable.openFile(deletionLogPath, parseFlag('w'));
|
|
381
381
|
try {
|
|
382
|
-
await log.write(
|
|
382
|
+
await log.write(encodeUTF8(this._deleteLog));
|
|
383
383
|
if (this._deleteLogUpdateNeeded) {
|
|
384
384
|
this._deleteLogUpdateNeeded = false;
|
|
385
385
|
await this.updateLog('');
|
|
@@ -419,8 +419,8 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
/**
|
|
422
|
-
*
|
|
423
|
-
*
|
|
422
|
+
* Create the needed parent directories on the writable storage should they not exist.
|
|
423
|
+
* Use modes from the read-only storage.
|
|
424
424
|
*/
|
|
425
425
|
createParentDirectoriesSync(path) {
|
|
426
426
|
let parent = dirname(path);
|
|
@@ -433,6 +433,10 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
433
433
|
this.writable.mkdirSync(path, this.statSync(path).mode);
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Create the needed parent directories on the writable storage should they not exist.
|
|
438
|
+
* Use modes from the read-only storage.
|
|
439
|
+
*/
|
|
436
440
|
async createParentDirectories(path) {
|
|
437
441
|
let parent = dirname(path);
|
|
438
442
|
const toCreate = [];
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import type { FileReadResult } from 'node:fs/promises';
|
|
4
2
|
import type { ExtractProperties } from 'utilium';
|
|
5
3
|
import { type MountConfiguration } from '../../config.js';
|
|
@@ -10,7 +8,8 @@ import type { Backend, FilesystemOf } from '../backend.js';
|
|
|
10
8
|
import * as RPC from './rpc.js';
|
|
11
9
|
type FileMethods = Omit<ExtractProperties<File, (...args: any[]) => Promise<any>>, typeof Symbol.asyncDispose>;
|
|
12
10
|
type FileMethod = keyof FileMethods;
|
|
13
|
-
|
|
11
|
+
/** @internal */
|
|
12
|
+
export interface FileRequest<TMethod extends FileMethod = FileMethod> extends RPC.Request {
|
|
14
13
|
fd: number;
|
|
15
14
|
scope: 'file';
|
|
16
15
|
method: TMethod;
|
|
@@ -46,13 +45,14 @@ export declare class PortFile extends File {
|
|
|
46
45
|
}
|
|
47
46
|
type FSMethods = ExtractProperties<FileSystem, (...args: any[]) => Promise<any> | FileSystemMetadata>;
|
|
48
47
|
type FSMethod = keyof FSMethods;
|
|
49
|
-
|
|
48
|
+
/** @internal */
|
|
49
|
+
export interface FSRequest<TMethod extends FSMethod = FSMethod> extends RPC.Request {
|
|
50
50
|
scope: 'fs';
|
|
51
51
|
method: TMethod;
|
|
52
52
|
args: Parameters<FSMethods[TMethod]>;
|
|
53
53
|
}
|
|
54
54
|
declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, {
|
|
55
|
-
_sync?: FileSystem
|
|
55
|
+
_sync?: FileSystem;
|
|
56
56
|
queueDone(): Promise<void>;
|
|
57
57
|
ready(): Promise<void>;
|
|
58
58
|
renameSync(oldPath: string, newPath: string): void;
|
|
@@ -67,10 +67,10 @@ declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, {
|
|
|
67
67
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
68
68
|
}>;
|
|
69
69
|
/**
|
|
70
|
-
* PortFS lets you access
|
|
70
|
+
* PortFS lets you access an FS instance that is running in a port, or the other way around.
|
|
71
71
|
*
|
|
72
|
-
* Note that synchronous operations are not permitted on the PortFS,
|
|
73
|
-
* of the configuration option of the remote FS.
|
|
72
|
+
* Note that *direct* synchronous operations are not permitted on the PortFS,
|
|
73
|
+
* regardless of the configuration option of the remote FS.
|
|
74
74
|
*/
|
|
75
75
|
export declare class PortFS extends PortFS_base {
|
|
76
76
|
readonly options: RPC.Options;
|
|
@@ -80,8 +80,7 @@ export declare class PortFS extends PortFS_base {
|
|
|
80
80
|
*/
|
|
81
81
|
_sync: import("../store/fs.js").StoreFS<import("../memory.js").InMemoryStore>;
|
|
82
82
|
/**
|
|
83
|
-
* Constructs a new PortFS instance that connects with
|
|
84
|
-
* the specified port.
|
|
83
|
+
* Constructs a new PortFS instance that connects with the FS running on `options.port`.
|
|
85
84
|
*/
|
|
86
85
|
constructor(options: RPC.Options);
|
|
87
86
|
metadata(): FileSystemMetadata;
|
|
@@ -99,13 +98,9 @@ export declare class PortFS extends PortFS_base {
|
|
|
99
98
|
exists(path: string): Promise<boolean>;
|
|
100
99
|
link(srcpath: string, dstpath: string): Promise<void>;
|
|
101
100
|
}
|
|
102
|
-
/**
|
|
103
|
-
* @internal
|
|
104
|
-
*/
|
|
101
|
+
/** @internal */
|
|
105
102
|
export type FileOrFSRequest = FSRequest | FileRequest;
|
|
106
|
-
/**
|
|
107
|
-
* @internal
|
|
108
|
-
*/
|
|
103
|
+
/** @internal */
|
|
109
104
|
export declare function handleRequest(port: RPC.Port, fs: FileSystem, request: FileOrFSRequest): Promise<void>;
|
|
110
105
|
export declare function attachFS(port: RPC.Port, fs: FileSystem): void;
|
|
111
106
|
export declare function detachFS(port: RPC.Port, fs: FileSystem): void;
|
|
@@ -128,7 +123,7 @@ declare const _Port: {
|
|
|
128
123
|
create(options: RPC.Options): PortFS;
|
|
129
124
|
};
|
|
130
125
|
type _Port = typeof _Port;
|
|
131
|
-
interface Port extends _Port {
|
|
126
|
+
export interface Port extends _Port {
|
|
132
127
|
}
|
|
133
128
|
export declare const Port: Port;
|
|
134
129
|
export declare function resolveRemoteMount<T extends Backend>(port: RPC.Port, config: MountConfiguration<T>, _depth?: number): Promise<FilesystemOf<T>>;
|
package/dist/backends/port/fs.js
CHANGED
|
@@ -87,15 +87,14 @@ export class PortFile extends File {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* PortFS lets you access
|
|
90
|
+
* PortFS lets you access an FS instance that is running in a port, or the other way around.
|
|
91
91
|
*
|
|
92
|
-
* Note that synchronous operations are not permitted on the PortFS,
|
|
93
|
-
* of the configuration option of the remote FS.
|
|
92
|
+
* Note that *direct* synchronous operations are not permitted on the PortFS,
|
|
93
|
+
* regardless of the configuration option of the remote FS.
|
|
94
94
|
*/
|
|
95
95
|
export class PortFS extends Async(FileSystem) {
|
|
96
96
|
/**
|
|
97
|
-
* Constructs a new PortFS instance that connects with
|
|
98
|
-
* the specified port.
|
|
97
|
+
* Constructs a new PortFS instance that connects with the FS running on `options.port`.
|
|
99
98
|
*/
|
|
100
99
|
constructor(options) {
|
|
101
100
|
super();
|
|
@@ -160,9 +159,7 @@ export class PortFS extends Async(FileSystem) {
|
|
|
160
159
|
}
|
|
161
160
|
let nextFd = 0;
|
|
162
161
|
const descriptors = new Map();
|
|
163
|
-
/**
|
|
164
|
-
* @internal
|
|
165
|
-
*/
|
|
162
|
+
/** @internal */
|
|
166
163
|
export async function handleRequest(port, fs, request) {
|
|
167
164
|
if (!RPC.isMessage(request)) {
|
|
168
165
|
return;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { type ErrnoErrorJSON } from '../../error.js';
|
|
3
2
|
import type { Backend, FilesystemOf } from '../backend.js';
|
|
4
3
|
import { type PortFS } from './fs.js';
|
|
5
4
|
type _MessageEvent<T = any> = T | {
|
|
6
5
|
data: T;
|
|
7
6
|
};
|
|
7
|
+
/** @internal */
|
|
8
8
|
export interface Port {
|
|
9
9
|
postMessage(value: unknown): void;
|
|
10
10
|
on?(event: 'message', listener: (value: unknown) => void): this;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PreloadFile } from '../../file.js';
|
|
2
1
|
import { FileSystem, type FileSystemMetadata } from '../../filesystem.js';
|
|
3
2
|
import { type Ino, Inode } from '../../inode.js';
|
|
4
3
|
import type { FileType, Stats } from '../../stats.js';
|
|
5
4
|
import type { Store, Transaction } from './store.js';
|
|
5
|
+
import type { File } from '../../file.js';
|
|
6
6
|
/**
|
|
7
7
|
* A file system which uses a key-value store.
|
|
8
8
|
*
|
|
@@ -34,10 +34,10 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
34
34
|
renameSync(oldPath: string, newPath: string): void;
|
|
35
35
|
stat(path: string): Promise<Stats>;
|
|
36
36
|
statSync(path: string): Stats;
|
|
37
|
-
createFile(path: string, flag: string, mode: number): Promise<
|
|
38
|
-
createFileSync(path: string, flag: string, mode: number):
|
|
39
|
-
openFile(path: string, flag: string): Promise<
|
|
40
|
-
openFileSync(path: string, flag: string):
|
|
37
|
+
createFile(path: string, flag: string, mode: number): Promise<File>;
|
|
38
|
+
createFileSync(path: string, flag: string, mode: number): File;
|
|
39
|
+
openFile(path: string, flag: string): Promise<File>;
|
|
40
|
+
openFileSync(path: string, flag: string): File;
|
|
41
41
|
unlink(path: string): Promise<void>;
|
|
42
42
|
unlinkSync(path: string): void;
|
|
43
43
|
rmdir(path: string): Promise<void>;
|
|
@@ -47,12 +47,12 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
47
47
|
readdir(path: string): Promise<string[]>;
|
|
48
48
|
readdirSync(path: string): string[];
|
|
49
49
|
/**
|
|
50
|
-
* Updated the inode and data node at
|
|
50
|
+
* Updated the inode and data node at `path`
|
|
51
51
|
* @todo Ensure mtime updates properly, and use that to determine if a data update is required.
|
|
52
52
|
*/
|
|
53
53
|
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
54
54
|
/**
|
|
55
|
-
* Updated the inode and data node at
|
|
55
|
+
* Updated the inode and data node at `path`
|
|
56
56
|
* @todo Ensure mtime updates properly, and use that to determine if a data update is required.
|
|
57
57
|
*/
|
|
58
58
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
@@ -82,13 +82,13 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
82
82
|
*/
|
|
83
83
|
protected _findINodeSync(tx: Transaction, parent: string, filename: string, visited?: Set<string>): Ino;
|
|
84
84
|
/**
|
|
85
|
-
* Finds the Inode of
|
|
85
|
+
* Finds the Inode of `path`.
|
|
86
86
|
* @param path The path to look up.
|
|
87
87
|
* @todo memoize/cache
|
|
88
88
|
*/
|
|
89
89
|
private findINode;
|
|
90
90
|
/**
|
|
91
|
-
* Finds the Inode of
|
|
91
|
+
* Finds the Inode of `path`.
|
|
92
92
|
* @param path The path to look up.
|
|
93
93
|
* @return The Inode of the path p.
|
|
94
94
|
* @todo memoize/cache
|
|
@@ -131,18 +131,16 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
131
131
|
*/
|
|
132
132
|
protected addNewSync(tx: Transaction, data: Uint8Array, path: string): Ino;
|
|
133
133
|
/**
|
|
134
|
-
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with
|
|
135
|
-
* the given mode.
|
|
134
|
+
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with `mode`.
|
|
136
135
|
* Note: This will commit the transaction.
|
|
137
136
|
* @param path The path to the new file.
|
|
138
137
|
* @param type The type of the new file.
|
|
139
138
|
* @param mode The mode to create the new file with.
|
|
140
|
-
* @param cred The UID/GID to create the file with
|
|
141
139
|
* @param data The data to store at the file's data node.
|
|
142
140
|
*/
|
|
143
141
|
private commitNew;
|
|
144
142
|
/**
|
|
145
|
-
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with
|
|
143
|
+
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with `mode`.
|
|
146
144
|
* Note: This will commit the transaction.
|
|
147
145
|
* @param path The path to the new file.
|
|
148
146
|
* @param type The type of the new file.
|
|
@@ -152,14 +150,14 @@ export declare class StoreFS<T extends Store = Store> extends FileSystem {
|
|
|
152
150
|
*/
|
|
153
151
|
protected commitNewSync(path: string, type: FileType, mode: number, data?: Uint8Array): Inode;
|
|
154
152
|
/**
|
|
155
|
-
* Remove all traces of
|
|
153
|
+
* Remove all traces of `path` from the file system.
|
|
156
154
|
* @param path The path to remove from the file system.
|
|
157
155
|
* @param isDir Does the path belong to a directory, or a file?
|
|
158
156
|
* @todo Update mtime.
|
|
159
157
|
*/
|
|
160
158
|
private remove;
|
|
161
159
|
/**
|
|
162
|
-
* Remove all traces of
|
|
160
|
+
* Remove all traces of `path` from the file system.
|
|
163
161
|
* @param path The path to remove from the file system.
|
|
164
162
|
* @param isDir Does the path belong to a directory, or a file?
|
|
165
163
|
* @todo Update mtime.
|