@zenfs/core 0.2.2 → 0.3.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/FileIndex.d.ts +139 -34
- package/dist/FileIndex.js +166 -84
- package/dist/backends/AsyncMirror.d.ts +31 -2
- package/dist/backends/AsyncMirror.js +3 -11
- package/dist/backends/AsyncStore.d.ts +29 -2
- package/dist/backends/AsyncStore.js +2 -2
- package/dist/backends/Locked.d.ts +1 -1
- package/dist/backends/Locked.js +1 -1
- package/dist/backends/Overlay.d.ts +1 -1
- package/dist/backends/Overlay.js +1 -1
- package/dist/backends/SyncStore.d.ts +29 -2
- package/dist/backends/SyncStore.js +3 -2
- package/dist/browser.min.js +5 -5
- package/dist/browser.min.js.map +3 -3
- package/dist/file.d.ts +2 -2
- package/dist/file.js +2 -2
- package/dist/filesystem.d.ts +164 -12
- package/dist/filesystem.js +131 -118
- package/dist/utils.d.ts +1 -6
- package/dist/utils.js +5 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
2
2
|
import { File, FileFlag, PreloadFile } from '../file.js';
|
|
3
3
|
import { Stats } from '../stats.js';
|
|
4
4
|
import { Cred } from '../cred.js';
|
|
@@ -28,6 +28,35 @@ export declare namespace AsyncMirror {
|
|
|
28
28
|
async: FileSystem;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
|
|
32
|
+
readonly metadata: FileSystemMetadata;
|
|
33
|
+
ready(): Promise<any>;
|
|
34
|
+
exists(path: string, cred: Cred): Promise<boolean>;
|
|
35
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
36
|
+
stat(path: string, cred: Cred): Promise<Stats>;
|
|
37
|
+
createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
|
|
42
|
+
unlink(path: string, cred: Cred): Promise<void>;
|
|
43
|
+
rmdir(path: string, cred: Cred): Promise<void>;
|
|
44
|
+
mkdir(path: string, mode: number, cred: Cred): Promise<void>;
|
|
45
|
+
readdir(path: string, cred: Cred): Promise<string[]>;
|
|
46
|
+
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
47
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
48
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
49
|
+
statSync(path: string, cred: Cred): Stats;
|
|
50
|
+
openFileSync(path: string, flag: FileFlag, cred: Cred): File;
|
|
51
|
+
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
52
|
+
unlinkSync(path: string, cred: Cred): void;
|
|
53
|
+
rmdirSync(path: string, cred: Cred): void;
|
|
54
|
+
mkdirSync(path: string, mode: number, cred: Cred): void;
|
|
55
|
+
readdirSync(path: string, cred: Cred): string[];
|
|
56
|
+
existsSync(path: string, cred: Cred): boolean;
|
|
57
|
+
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
58
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
59
|
+
}) & typeof FileSystem;
|
|
31
60
|
/**
|
|
32
61
|
* AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem
|
|
33
62
|
* by:
|
|
@@ -41,7 +70,7 @@ export declare namespace AsyncMirror {
|
|
|
41
70
|
* in-memory filesystem with an asynchronous backing store.
|
|
42
71
|
*
|
|
43
72
|
*/
|
|
44
|
-
export declare class AsyncMirrorFS extends
|
|
73
|
+
export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
|
|
45
74
|
/**
|
|
46
75
|
* Queue of pending asynchronous operations.
|
|
47
76
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSystem, Sync } from '../filesystem.js';
|
|
2
2
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
3
3
|
import { FileFlag, PreloadFile } from '../file.js';
|
|
4
4
|
import { join } from '../emulation/path.js';
|
|
@@ -39,7 +39,7 @@ class MirrorFile extends PreloadFile {
|
|
|
39
39
|
* in-memory filesystem with an asynchronous backing store.
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
|
-
export class AsyncMirrorFS extends
|
|
42
|
+
export class AsyncMirrorFS extends Sync(FileSystem) {
|
|
43
43
|
async ready() {
|
|
44
44
|
await this._ready;
|
|
45
45
|
return this;
|
|
@@ -63,6 +63,7 @@ export class AsyncMirrorFS extends SyncFileSystem {
|
|
|
63
63
|
this._async = async;
|
|
64
64
|
this._ready = this._initialize();
|
|
65
65
|
}
|
|
66
|
+
// @ts-expect-error 2611
|
|
66
67
|
get metadata() {
|
|
67
68
|
return {
|
|
68
69
|
...super.metadata,
|
|
@@ -71,15 +72,6 @@ export class AsyncMirrorFS extends SyncFileSystem {
|
|
|
71
72
|
supportsProperties: this._sync.metadata.supportsProperties && this._async.metadata.supportsProperties,
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
|
-
/*public _syncSync(file: PreloadFile<AsyncMirror>, cred: Cred) {
|
|
75
|
-
const sync = this._sync.openFileSync(file.path, FileFlag.FromString('w'), cred);
|
|
76
|
-
sync.writeSync(file.buffer);
|
|
77
|
-
|
|
78
|
-
this.enqueue({
|
|
79
|
-
apiMethod: 'writeFile',
|
|
80
|
-
arguments: [file.path, file.buffer, file.flag, file.stats.mode, cred],
|
|
81
|
-
});
|
|
82
|
-
}*/
|
|
83
75
|
syncSync(path, data, stats) {
|
|
84
76
|
this._sync.syncSync(path, data, stats);
|
|
85
77
|
this.enqueue({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cred } from '../cred.js';
|
|
2
2
|
import { PreloadFile, File, FileFlag } from '../file.js';
|
|
3
|
-
import {
|
|
3
|
+
import { FileSystem, type FileSystemMetadata } from '../filesystem.js';
|
|
4
4
|
import { type Ino } from '../inode.js';
|
|
5
5
|
import { Stats } from '../stats.js';
|
|
6
6
|
/**
|
|
@@ -79,11 +79,37 @@ export interface AsyncStoreFileSystemOptions {
|
|
|
79
79
|
*/
|
|
80
80
|
cacheSize?: number;
|
|
81
81
|
}
|
|
82
|
+
declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
|
|
83
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
84
|
+
statSync(path: string, cred: Cred): Stats;
|
|
85
|
+
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
86
|
+
openFileSync(path: string, flag: FileFlag, cred: Cred): File;
|
|
87
|
+
unlinkSync(path: string, cred: Cred): void;
|
|
88
|
+
rmdirSync(path: string, cred: Cred): void;
|
|
89
|
+
mkdirSync(path: string, mode: number, cred: Cred): void;
|
|
90
|
+
readdirSync(path: string, cred: Cred): string[];
|
|
91
|
+
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
92
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
93
|
+
readonly metadata: FileSystemMetadata;
|
|
94
|
+
ready(): Promise<any>;
|
|
95
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
96
|
+
stat(path: string, cred: Cred): Promise<Stats>;
|
|
97
|
+
openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
|
|
98
|
+
createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
|
|
99
|
+
unlink(path: string, cred: Cred): Promise<void>;
|
|
100
|
+
rmdir(path: string, cred: Cred): Promise<void>;
|
|
101
|
+
mkdir(path: string, mode: number, cred: Cred): Promise<void>;
|
|
102
|
+
readdir(path: string, cred: Cred): Promise<string[]>;
|
|
103
|
+
exists(path: string, cred: Cred): Promise<boolean>;
|
|
104
|
+
existsSync(path: string, cred: Cred): boolean;
|
|
105
|
+
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
106
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
107
|
+
}) & typeof FileSystem;
|
|
82
108
|
/**
|
|
83
109
|
* An "Asynchronous key-value file system". Stores data to/retrieves data from
|
|
84
110
|
* an underlying asynchronous key-value store.
|
|
85
111
|
*/
|
|
86
|
-
export declare class AsyncStoreFileSystem extends
|
|
112
|
+
export declare class AsyncStoreFileSystem extends AsyncStoreFileSystem_base {
|
|
87
113
|
protected store: AsyncStore;
|
|
88
114
|
private _cache?;
|
|
89
115
|
protected _ready: Promise<this>;
|
|
@@ -175,3 +201,4 @@ export declare class AsyncStoreFileSystem extends AsyncFileSystem {
|
|
|
175
201
|
*/
|
|
176
202
|
private removeEntry;
|
|
177
203
|
}
|
|
204
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { dirname, basename, join, resolve } from '../emulation/path.js';
|
|
|
2
2
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
3
3
|
import { W_OK, R_OK } from '../emulation/constants.js';
|
|
4
4
|
import { PreloadFile } from '../file.js';
|
|
5
|
-
import {
|
|
5
|
+
import { Async, FileSystem } from '../filesystem.js';
|
|
6
6
|
import { randomIno, Inode } from '../inode.js';
|
|
7
7
|
import { FileType } from '../stats.js';
|
|
8
8
|
import { encode, decodeDirListing, encodeDirListing } from '../utils.js';
|
|
@@ -69,7 +69,7 @@ export class AsyncFile extends PreloadFile {
|
|
|
69
69
|
* An "Asynchronous key-value file system". Stores data to/retrieves data from
|
|
70
70
|
* an underlying asynchronous key-value store.
|
|
71
71
|
*/
|
|
72
|
-
export class AsyncStoreFileSystem extends
|
|
72
|
+
export class AsyncStoreFileSystem extends Async(FileSystem) {
|
|
73
73
|
ready() {
|
|
74
74
|
return this._ready;
|
|
75
75
|
}
|
|
@@ -12,7 +12,7 @@ import { Cred } from '../cred.js';
|
|
|
12
12
|
* LockedFS to avoid having to reason about the correctness of
|
|
13
13
|
* multiple requests interleaving.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export declare class LockedFS<T extends FileSystem> implements FileSystem {
|
|
16
16
|
readonly fs: T;
|
|
17
17
|
private _mu;
|
|
18
18
|
constructor(fs: T);
|
package/dist/backends/Locked.js
CHANGED
|
@@ -8,7 +8,7 @@ import Mutex from '../mutex.js';
|
|
|
8
8
|
* LockedFS to avoid having to reason about the correctness of
|
|
9
9
|
* multiple requests interleaving.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export class LockedFS {
|
|
12
12
|
constructor(fs) {
|
|
13
13
|
this.fs = fs;
|
|
14
14
|
this._mu = new Mutex();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
2
2
|
import { File, FileFlag } from '../file.js';
|
|
3
3
|
import { Stats } from '../stats.js';
|
|
4
|
-
import LockedFS from './Locked.js';
|
|
4
|
+
import { LockedFS } from './Locked.js';
|
|
5
5
|
import { Cred } from '../cred.js';
|
|
6
6
|
import type { Backend } from './backend.js';
|
|
7
7
|
/**
|
package/dist/backends/Overlay.js
CHANGED
|
@@ -2,7 +2,7 @@ import { FileSystem } from '../filesystem.js';
|
|
|
2
2
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
3
3
|
import { FileFlag, PreloadFile } from '../file.js';
|
|
4
4
|
import { Stats } from '../stats.js';
|
|
5
|
-
import LockedFS from './Locked.js';
|
|
5
|
+
import { LockedFS } from './Locked.js';
|
|
6
6
|
import { dirname } from '../emulation/path.js';
|
|
7
7
|
import { Cred } from '../cred.js';
|
|
8
8
|
import { decode, encode } from '../utils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cred } from '../cred.js';
|
|
2
2
|
import { FileFlag, PreloadFile } from '../file.js';
|
|
3
|
-
import {
|
|
3
|
+
import { type FileSystemMetadata, FileSystem } from '../filesystem.js';
|
|
4
4
|
import { type Ino, Inode } from '../inode.js';
|
|
5
5
|
import { Stats, FileType } from '../stats.js';
|
|
6
6
|
/**
|
|
@@ -119,6 +119,32 @@ export declare class SyncStoreFile extends PreloadFile<SyncStoreFileSystem> {
|
|
|
119
119
|
close(): Promise<void>;
|
|
120
120
|
closeSync(): void;
|
|
121
121
|
}
|
|
122
|
+
declare const SyncStoreFileSystem_base: (abstract new (...args: any[]) => {
|
|
123
|
+
readonly metadata: FileSystemMetadata;
|
|
124
|
+
ready(): Promise<any>;
|
|
125
|
+
exists(path: string, cred: Cred): Promise<boolean>;
|
|
126
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
127
|
+
stat(path: string, cred: Cred): Promise<Stats>;
|
|
128
|
+
createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("../file.js").File>;
|
|
129
|
+
openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("../file.js").File>;
|
|
130
|
+
unlink(path: string, cred: Cred): Promise<void>;
|
|
131
|
+
rmdir(path: string, cred: Cred): Promise<void>;
|
|
132
|
+
mkdir(path: string, mode: number, cred: Cred): Promise<void>;
|
|
133
|
+
readdir(path: string, cred: Cred): Promise<string[]>;
|
|
134
|
+
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
135
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
136
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
137
|
+
statSync(path: string, cred: Cred): Stats;
|
|
138
|
+
openFileSync(path: string, flag: FileFlag, cred: Cred): import("../file.js").File;
|
|
139
|
+
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("../file.js").File;
|
|
140
|
+
unlinkSync(path: string, cred: Cred): void;
|
|
141
|
+
rmdirSync(path: string, cred: Cred): void;
|
|
142
|
+
mkdirSync(path: string, mode: number, cred: Cred): void;
|
|
143
|
+
readdirSync(path: string, cred: Cred): string[];
|
|
144
|
+
existsSync(path: string, cred: Cred): boolean;
|
|
145
|
+
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
146
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
147
|
+
}) & typeof FileSystem;
|
|
122
148
|
/**
|
|
123
149
|
* A "Synchronous key-value file system". Stores data to/retrieves data from an
|
|
124
150
|
* underlying key-value store.
|
|
@@ -128,7 +154,7 @@ export declare class SyncStoreFile extends PreloadFile<SyncStoreFileSystem> {
|
|
|
128
154
|
* @todo Introduce Node ID caching.
|
|
129
155
|
* @todo Check modes.
|
|
130
156
|
*/
|
|
131
|
-
export declare class SyncStoreFileSystem extends
|
|
157
|
+
export declare class SyncStoreFileSystem extends SyncStoreFileSystem_base {
|
|
132
158
|
protected store: SyncStore;
|
|
133
159
|
constructor(options: SyncStoreFileSystemOptions);
|
|
134
160
|
get metadata(): FileSystemMetadata;
|
|
@@ -202,3 +228,4 @@ export declare class SyncStoreFileSystem extends SyncFileSystem {
|
|
|
202
228
|
*/
|
|
203
229
|
protected removeEntry(p: string, isDir: boolean, cred: Cred): void;
|
|
204
230
|
}
|
|
231
|
+
export {};
|
|
@@ -2,7 +2,7 @@ import { dirname, basename, join, resolve, sep } from '../emulation/path.js';
|
|
|
2
2
|
import { ApiError, ErrorCode } from '../ApiError.js';
|
|
3
3
|
import { W_OK, R_OK } from '../emulation/constants.js';
|
|
4
4
|
import { PreloadFile } from '../file.js';
|
|
5
|
-
import {
|
|
5
|
+
import { FileSystem, Sync } from '../filesystem.js';
|
|
6
6
|
import { randomIno, Inode } from '../inode.js';
|
|
7
7
|
import { FileType } from '../stats.js';
|
|
8
8
|
import { decodeDirListing, encode, encodeDirListing } from '../utils.js';
|
|
@@ -105,13 +105,14 @@ export class SyncStoreFile extends PreloadFile {
|
|
|
105
105
|
* @todo Introduce Node ID caching.
|
|
106
106
|
* @todo Check modes.
|
|
107
107
|
*/
|
|
108
|
-
export class SyncStoreFileSystem extends
|
|
108
|
+
export class SyncStoreFileSystem extends Sync(FileSystem) {
|
|
109
109
|
constructor(options) {
|
|
110
110
|
super();
|
|
111
111
|
this.store = options.store;
|
|
112
112
|
// INVARIANT: Ensure that the root exists.
|
|
113
113
|
this.makeRootDirectory();
|
|
114
114
|
}
|
|
115
|
+
// @ts-expect-error 2611
|
|
115
116
|
get metadata() {
|
|
116
117
|
return {
|
|
117
118
|
...super.metadata,
|