@zenfs/core 0.3.1 → 0.3.2
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 +3 -3
- package/dist/backends/AsyncMirror.d.ts +16 -15
- package/dist/backends/AsyncMirror.js +4 -5
- package/dist/backends/AsyncStore.d.ts +8 -8
- package/dist/backends/AsyncStore.js +3 -4
- package/dist/backends/InMemory.js +2 -2
- package/dist/backends/Locked.d.ts +1 -1
- package/dist/backends/Locked.js +3 -3
- package/dist/backends/Overlay.d.ts +1 -1
- package/dist/backends/Overlay.js +5 -5
- package/dist/backends/SyncStore.d.ts +8 -8
- package/dist/backends/SyncStore.js +3 -4
- package/dist/browser.min.js +2 -2
- package/dist/browser.min.js.map +3 -3
- package/dist/file.js +6 -6
- package/dist/filesystem.d.ts +4 -4
- package/dist/filesystem.js +7 -7
- package/package.json +1 -1
package/dist/FileIndex.d.ts
CHANGED
|
@@ -154,7 +154,7 @@ export declare class IndexDirInode<T> extends IndexInode<T> {
|
|
|
154
154
|
remove(p: string): IndexInode<T> | null;
|
|
155
155
|
}
|
|
156
156
|
declare const FileIndexFS_base: (abstract new (...args: any[]) => {
|
|
157
|
-
|
|
157
|
+
metadata(): import("./filesystem.js").FileSystemMetadata;
|
|
158
158
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
159
159
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
160
160
|
createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("./file.js").File>;
|
|
@@ -185,7 +185,7 @@ export declare abstract class FileIndexFS<TIndex> extends FileIndexFS_base {
|
|
|
185
185
|
protected abstract fileForFileInodeSync(inode: IndexFileInode<TIndex>): NoSyncFile<this>;
|
|
186
186
|
}
|
|
187
187
|
declare const SyncFileIndexFS_base: (abstract new (...args: any[]) => {
|
|
188
|
-
|
|
188
|
+
metadata(): import("./filesystem.js").FileSystemMetadata;
|
|
189
189
|
ready(): Promise<any>;
|
|
190
190
|
exists(path: string, cred: Cred): Promise<boolean>;
|
|
191
191
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
@@ -215,7 +215,7 @@ export declare abstract class SyncFileIndexFS<TIndex> extends SyncFileIndexFS_ba
|
|
|
215
215
|
protected fileForFileInode(inode: IndexFileInode<TIndex>): Promise<NoSyncFile<this>>;
|
|
216
216
|
}
|
|
217
217
|
declare const AsyncFileIndexFS_base: (abstract new (...args: any[]) => {
|
|
218
|
-
|
|
218
|
+
metadata(): import("./filesystem.js").FileSystemMetadata;
|
|
219
219
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
220
220
|
statSync(path: string, cred: Cred): Stats;
|
|
221
221
|
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("./file.js").File;
|
|
@@ -13,23 +13,21 @@ declare class MirrorFile extends PreloadFile<AsyncMirrorFS> {
|
|
|
13
13
|
close(): Promise<void>;
|
|
14
14
|
closeSync(): void;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Configuration options for the AsyncMirror file system.
|
|
18
|
+
*/
|
|
19
|
+
export interface AsyncMirrorOptions {
|
|
20
|
+
/**
|
|
21
|
+
* The synchronous file system to mirror the asynchronous file system to.
|
|
22
|
+
*/
|
|
23
|
+
sync: FileSystem;
|
|
17
24
|
/**
|
|
18
|
-
*
|
|
25
|
+
* The asynchronous file system to mirror.
|
|
19
26
|
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The synchronous file system to mirror the asynchronous file system to.
|
|
23
|
-
*/
|
|
24
|
-
sync: FileSystem;
|
|
25
|
-
/**
|
|
26
|
-
* The asynchronous file system to mirror.
|
|
27
|
-
*/
|
|
28
|
-
async: FileSystem;
|
|
29
|
-
}
|
|
27
|
+
async: FileSystem;
|
|
30
28
|
}
|
|
31
29
|
declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
|
|
32
|
-
|
|
30
|
+
metadata(): FileSystemMetadata;
|
|
33
31
|
ready(): Promise<any>;
|
|
34
32
|
exists(path: string, cred: Cred): Promise<boolean>;
|
|
35
33
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
@@ -43,6 +41,9 @@ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
|
|
|
43
41
|
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
44
42
|
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
45
43
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
44
|
+
/**
|
|
45
|
+
* Queue of pending asynchronous operations.
|
|
46
|
+
*/
|
|
46
47
|
statSync(path: string, cred: Cred): Stats;
|
|
47
48
|
openFileSync(path: string, flag: FileFlag, cred: Cred): File;
|
|
48
49
|
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
@@ -85,8 +86,8 @@ export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
|
|
|
85
86
|
* @param sync The synchronous file system to mirror the asynchronous file system to.
|
|
86
87
|
* @param async The asynchronous file system to mirror.
|
|
87
88
|
*/
|
|
88
|
-
constructor({ sync, async }:
|
|
89
|
-
|
|
89
|
+
constructor({ sync, async }: AsyncMirrorOptions);
|
|
90
|
+
metadata(): FileSystemMetadata;
|
|
90
91
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
91
92
|
openFileSync(path: string, flag: FileFlag, cred: Cred): File;
|
|
92
93
|
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): MirrorFile;
|
|
@@ -63,13 +63,12 @@ export class AsyncMirrorFS extends Sync(FileSystem) {
|
|
|
63
63
|
this._async = async;
|
|
64
64
|
this._ready = this._initialize();
|
|
65
65
|
}
|
|
66
|
-
|
|
67
|
-
get metadata() {
|
|
66
|
+
metadata() {
|
|
68
67
|
return {
|
|
69
|
-
...super.metadata,
|
|
68
|
+
...super.metadata(),
|
|
70
69
|
name: AsyncMirrorFS.name,
|
|
71
70
|
synchronous: true,
|
|
72
|
-
supportsProperties: this._sync.metadata.supportsProperties && this._async.metadata.supportsProperties,
|
|
71
|
+
supportsProperties: this._sync.metadata().supportsProperties && this._async.metadata().supportsProperties,
|
|
73
72
|
};
|
|
74
73
|
}
|
|
75
74
|
syncSync(path, data, stats) {
|
|
@@ -232,7 +231,7 @@ export const AsyncMirror = {
|
|
|
232
231
|
type: 'object',
|
|
233
232
|
description: 'The synchronous file system to mirror the asynchronous file system to.',
|
|
234
233
|
validator: async (v) => {
|
|
235
|
-
if (!v?.metadata.synchronous) {
|
|
234
|
+
if (!v?.metadata().synchronous) {
|
|
236
235
|
throw new ApiError(ErrorCode.EINVAL, `'sync' option must be a file system that supports synchronous operations`);
|
|
237
236
|
}
|
|
238
237
|
},
|
|
@@ -62,14 +62,14 @@ export interface AsyncRWTransaction extends AsyncROTransaction {
|
|
|
62
62
|
*/
|
|
63
63
|
abort(): Promise<void>;
|
|
64
64
|
}
|
|
65
|
-
export declare class AsyncFile extends PreloadFile<
|
|
66
|
-
constructor(_fs:
|
|
65
|
+
export declare class AsyncFile extends PreloadFile<AsyncStoreFS> {
|
|
66
|
+
constructor(_fs: AsyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
|
|
67
67
|
sync(): Promise<void>;
|
|
68
68
|
syncSync(): void;
|
|
69
69
|
close(): Promise<void>;
|
|
70
70
|
closeSync(): void;
|
|
71
71
|
}
|
|
72
|
-
export interface
|
|
72
|
+
export interface AsyncStoreOptions {
|
|
73
73
|
/**
|
|
74
74
|
* Promise that resolves to the store
|
|
75
75
|
*/
|
|
@@ -79,8 +79,8 @@ export interface AsyncStoreFileSystemOptions {
|
|
|
79
79
|
*/
|
|
80
80
|
cacheSize?: number;
|
|
81
81
|
}
|
|
82
|
-
declare const
|
|
83
|
-
|
|
82
|
+
declare const AsyncStoreFS_base: (abstract new (...args: any[]) => {
|
|
83
|
+
metadata(): FileSystemMetadata;
|
|
84
84
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
85
85
|
statSync(path: string, cred: Cred): Stats;
|
|
86
86
|
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
@@ -96,13 +96,13 @@ declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
|
|
|
96
96
|
* An "Asynchronous key-value file system". Stores data to/retrieves data from
|
|
97
97
|
* an underlying asynchronous key-value store.
|
|
98
98
|
*/
|
|
99
|
-
export declare class
|
|
99
|
+
export declare class AsyncStoreFS extends AsyncStoreFS_base {
|
|
100
100
|
protected store: AsyncStore;
|
|
101
101
|
private _cache?;
|
|
102
102
|
protected _ready: Promise<this>;
|
|
103
103
|
ready(): Promise<this>;
|
|
104
|
-
|
|
105
|
-
constructor({ store, cacheSize }:
|
|
104
|
+
metadata(): FileSystemMetadata;
|
|
105
|
+
constructor({ store, cacheSize }: AsyncStoreOptions);
|
|
106
106
|
/**
|
|
107
107
|
* Initializes the file system. Typically called by subclasses' async
|
|
108
108
|
* constructors.
|
|
@@ -69,14 +69,13 @@ 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
|
|
72
|
+
export class AsyncStoreFS extends Async(FileSystem) {
|
|
73
73
|
ready() {
|
|
74
74
|
return this._ready;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
get metadata() {
|
|
76
|
+
metadata() {
|
|
78
77
|
return {
|
|
79
|
-
...super.metadata,
|
|
78
|
+
...super.metadata(),
|
|
80
79
|
name: this.store.name,
|
|
81
80
|
};
|
|
82
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SimpleSyncRWTransaction,
|
|
1
|
+
import { SimpleSyncRWTransaction, SyncStoreFS } from './SyncStore.js';
|
|
2
2
|
/**
|
|
3
3
|
* A simple in-memory store
|
|
4
4
|
*/
|
|
@@ -43,6 +43,6 @@ export const InMemory = {
|
|
|
43
43
|
},
|
|
44
44
|
},
|
|
45
45
|
create({ name }) {
|
|
46
|
-
return new
|
|
46
|
+
return new SyncStoreFS({ store: new InMemoryStore(name) });
|
|
47
47
|
},
|
|
48
48
|
};
|
|
@@ -17,7 +17,7 @@ export declare class LockedFS<T extends FileSystem> implements FileSystem {
|
|
|
17
17
|
private _mu;
|
|
18
18
|
constructor(fs: T);
|
|
19
19
|
ready(): Promise<this>;
|
|
20
|
-
|
|
20
|
+
metadata(): FileSystemMetadata;
|
|
21
21
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
22
22
|
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
23
23
|
stat(p: string, cred: Cred): Promise<Stats>;
|
package/dist/backends/Locked.js
CHANGED
|
@@ -17,10 +17,10 @@ export class LockedFS {
|
|
|
17
17
|
await this.fs.ready();
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
metadata() {
|
|
21
21
|
return {
|
|
22
|
-
...this.fs.metadata,
|
|
23
|
-
name: 'Locked<' + this.fs.metadata.name + '>',
|
|
22
|
+
...this.fs.metadata(),
|
|
23
|
+
name: 'Locked<' + this.fs.metadata().name + '>',
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
async rename(oldPath, newPath, cred) {
|
|
@@ -37,7 +37,7 @@ export declare class UnlockedOverlayFS extends FileSystem {
|
|
|
37
37
|
private _deleteLogError?;
|
|
38
38
|
private _ready;
|
|
39
39
|
constructor({ writable, readable }: OverlayOptions);
|
|
40
|
-
|
|
40
|
+
metadata(): FileSystemMetadata;
|
|
41
41
|
getOverlayedFileSystems(): OverlayOptions;
|
|
42
42
|
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
43
43
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
package/dist/backends/Overlay.js
CHANGED
|
@@ -64,17 +64,17 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
64
64
|
this._deleteLogUpdateNeeded = false;
|
|
65
65
|
this._writable = writable;
|
|
66
66
|
this._readable = readable;
|
|
67
|
-
if (this._writable.metadata.readonly) {
|
|
67
|
+
if (this._writable.metadata().readonly) {
|
|
68
68
|
throw new ApiError(ErrorCode.EINVAL, 'Writable file system must be writable.');
|
|
69
69
|
}
|
|
70
70
|
this._ready = this._initialize();
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
metadata() {
|
|
73
73
|
return {
|
|
74
|
-
...super.metadata,
|
|
74
|
+
...super.metadata(),
|
|
75
75
|
name: OverlayFS.name,
|
|
76
|
-
synchronous: this._readable.metadata.synchronous && this._writable.metadata.synchronous,
|
|
77
|
-
supportsProperties: this._readable.metadata.supportsProperties && this._writable.metadata.supportsProperties,
|
|
76
|
+
synchronous: this._readable.metadata().synchronous && this._writable.metadata().synchronous,
|
|
77
|
+
supportsProperties: this._readable.metadata().supportsProperties && this._writable.metadata().supportsProperties,
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
getOverlayedFileSystems() {
|
|
@@ -106,21 +106,21 @@ export declare class SimpleSyncRWTransaction implements SyncRWTransaction {
|
|
|
106
106
|
*/
|
|
107
107
|
protected markModified(ino: Ino): void;
|
|
108
108
|
}
|
|
109
|
-
export interface
|
|
109
|
+
export interface SyncStoreOptions {
|
|
110
110
|
/**
|
|
111
111
|
* The actual key-value store to read from/write to.
|
|
112
112
|
*/
|
|
113
113
|
store: SyncStore;
|
|
114
114
|
}
|
|
115
|
-
export declare class SyncStoreFile extends PreloadFile<
|
|
116
|
-
constructor(_fs:
|
|
115
|
+
export declare class SyncStoreFile extends PreloadFile<SyncStoreFS> {
|
|
116
|
+
constructor(_fs: SyncStoreFS, _path: string, _flag: FileFlag, _stat: Stats, contents?: Uint8Array);
|
|
117
117
|
sync(): Promise<void>;
|
|
118
118
|
syncSync(): void;
|
|
119
119
|
close(): Promise<void>;
|
|
120
120
|
closeSync(): void;
|
|
121
121
|
}
|
|
122
|
-
declare const
|
|
123
|
-
|
|
122
|
+
declare const SyncStoreFS_base: (abstract new (...args: any[]) => {
|
|
123
|
+
metadata(): FileSystemMetadata;
|
|
124
124
|
ready(): Promise<any>;
|
|
125
125
|
exists(path: string, cred: Cred): Promise<boolean>;
|
|
126
126
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
@@ -154,10 +154,10 @@ declare const SyncStoreFileSystem_base: (abstract new (...args: any[]) => {
|
|
|
154
154
|
* @todo Introduce Node ID caching.
|
|
155
155
|
* @todo Check modes.
|
|
156
156
|
*/
|
|
157
|
-
export declare class
|
|
157
|
+
export declare class SyncStoreFS extends SyncStoreFS_base {
|
|
158
158
|
protected store: SyncStore;
|
|
159
|
-
constructor(options:
|
|
160
|
-
|
|
159
|
+
constructor(options: SyncStoreOptions);
|
|
160
|
+
metadata(): FileSystemMetadata;
|
|
161
161
|
/**
|
|
162
162
|
* Delete all contents stored in the file system.
|
|
163
163
|
*/
|
|
@@ -105,17 +105,16 @@ export class SyncStoreFile extends PreloadFile {
|
|
|
105
105
|
* @todo Introduce Node ID caching.
|
|
106
106
|
* @todo Check modes.
|
|
107
107
|
*/
|
|
108
|
-
export class
|
|
108
|
+
export class SyncStoreFS 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
|
-
|
|
116
|
-
get metadata() {
|
|
115
|
+
metadata() {
|
|
117
116
|
return {
|
|
118
|
-
...super.metadata,
|
|
117
|
+
...super.metadata(),
|
|
119
118
|
name: this.store.name,
|
|
120
119
|
};
|
|
121
120
|
}
|