@zenfs/core 0.2.1 → 0.2.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/backends/AsyncStore.d.ts +4 -3
- package/dist/backends/AsyncStore.js +6 -0
- package/dist/backends/InMemory.d.ts +3 -9
- package/dist/backends/InMemory.js +4 -17
- package/dist/backends/Overlay.d.ts +110 -0
- package/dist/backends/Overlay.js +544 -0
- package/dist/backends/SyncStore.js +1 -5
- package/dist/backends/backend.d.ts +1 -2
- package/dist/backends/backend.js +4 -1
- package/dist/backends/index.d.ts +1 -1
- package/dist/backends/index.js +1 -1
- package/dist/browser.min.js +5 -5
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/index.d.ts +1 -1
- package/dist/emulation/index.js +1 -1
- package/dist/emulation/shared.d.ts +26 -8
- package/dist/emulation/shared.js +26 -12
- package/dist/filesystem.d.ts +18 -0
- package/dist/filesystem.js +46 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2 -3
- package/dist/utils.d.ts +0 -3
- package/package.json +1 -1
- package/readme.md +40 -108
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cred } from '../cred.js';
|
|
2
2
|
import { PreloadFile, File, FileFlag } from '../file.js';
|
|
3
|
-
import { AsyncFileSystem } from '../filesystem.js';
|
|
3
|
+
import { AsyncFileSystem, type FileSystemMetadata } from '../filesystem.js';
|
|
4
4
|
import { type Ino } from '../inode.js';
|
|
5
5
|
import { Stats } from '../stats.js';
|
|
6
6
|
/**
|
|
@@ -73,7 +73,7 @@ export interface AsyncStoreFileSystemOptions {
|
|
|
73
73
|
/**
|
|
74
74
|
* Promise that resolves to the store
|
|
75
75
|
*/
|
|
76
|
-
store: Promise<AsyncStore
|
|
76
|
+
store: Promise<AsyncStore> | AsyncStore;
|
|
77
77
|
/**
|
|
78
78
|
* The size of the cache. If not provided, no cache will be used
|
|
79
79
|
*/
|
|
@@ -88,12 +88,13 @@ export declare class AsyncStoreFileSystem extends AsyncFileSystem {
|
|
|
88
88
|
private _cache?;
|
|
89
89
|
protected _ready: Promise<this>;
|
|
90
90
|
ready(): Promise<this>;
|
|
91
|
+
get metadata(): FileSystemMetadata;
|
|
91
92
|
constructor({ store, cacheSize }: AsyncStoreFileSystemOptions);
|
|
92
93
|
/**
|
|
93
94
|
* Initializes the file system. Typically called by subclasses' async
|
|
94
95
|
* constructors.
|
|
95
96
|
*/
|
|
96
|
-
protected _initialize(store: Promise<AsyncStore>): Promise<this>;
|
|
97
|
+
protected _initialize(store: Promise<AsyncStore> | AsyncStore): Promise<this>;
|
|
97
98
|
/**
|
|
98
99
|
* Delete all contents stored in the file system.
|
|
99
100
|
*/
|
|
@@ -73,6 +73,12 @@ export class AsyncStoreFileSystem extends AsyncFileSystem {
|
|
|
73
73
|
ready() {
|
|
74
74
|
return this._ready;
|
|
75
75
|
}
|
|
76
|
+
get metadata() {
|
|
77
|
+
return {
|
|
78
|
+
...super.metadata,
|
|
79
|
+
name: this.store.name,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
76
82
|
constructor({ store, cacheSize }) {
|
|
77
83
|
super();
|
|
78
84
|
if (cacheSize > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Ino } from '../inode.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import type { Backend } from './backend.js';
|
|
3
|
+
import { SyncStore, SimpleSyncStore, SyncRWTransaction } from './SyncStore.js';
|
|
4
4
|
/**
|
|
5
5
|
* A simple in-memory store
|
|
6
6
|
*/
|
|
@@ -14,14 +14,8 @@ export declare class InMemoryStore implements SyncStore, SimpleSyncStore {
|
|
|
14
14
|
put(key: Ino, data: Uint8Array, overwrite: boolean): boolean;
|
|
15
15
|
remove(key: Ino): void;
|
|
16
16
|
}
|
|
17
|
-
export declare const InMemory: Backend;
|
|
18
17
|
/**
|
|
19
18
|
* A simple in-memory file system backed by an InMemoryStore.
|
|
20
19
|
* Files are not persisted across page loads.
|
|
21
20
|
*/
|
|
22
|
-
export declare
|
|
23
|
-
static isAvailable(): boolean;
|
|
24
|
-
static create: any;
|
|
25
|
-
static readonly options: {};
|
|
26
|
-
constructor();
|
|
27
|
-
}
|
|
21
|
+
export declare const InMemory: Backend;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import { SimpleSyncRWTransaction, SyncStoreFileSystem } from './SyncStore.js';
|
|
3
|
-
import { createBackend } from './backend.js';
|
|
4
2
|
/**
|
|
5
3
|
* A simple in-memory store
|
|
6
4
|
*/
|
|
@@ -29,6 +27,10 @@ export class InMemoryStore {
|
|
|
29
27
|
this.store.delete(key);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A simple in-memory file system backed by an InMemoryStore.
|
|
32
|
+
* Files are not persisted across page loads.
|
|
33
|
+
*/
|
|
32
34
|
export const InMemory = {
|
|
33
35
|
name: 'InMemory',
|
|
34
36
|
isAvailable() {
|
|
@@ -44,18 +46,3 @@ export const InMemory = {
|
|
|
44
46
|
return new SyncStoreFileSystem({ store: new InMemoryStore(name) });
|
|
45
47
|
},
|
|
46
48
|
};
|
|
47
|
-
/**
|
|
48
|
-
* A simple in-memory file system backed by an InMemoryStore.
|
|
49
|
-
* Files are not persisted across page loads.
|
|
50
|
-
*/
|
|
51
|
-
export class _InMemory extends SyncStoreFileSystem {
|
|
52
|
-
static isAvailable() {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
constructor() {
|
|
56
|
-
super({ store: new InMemoryStore() });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
_a = _InMemory;
|
|
60
|
-
_InMemory.create = createBackend.bind(_a);
|
|
61
|
-
_InMemory.options = {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
2
|
+
import { File, FileFlag } from '../file.js';
|
|
3
|
+
import { Stats } from '../stats.js';
|
|
4
|
+
import LockedFS from './Locked.js';
|
|
5
|
+
import { Cred } from '../cred.js';
|
|
6
|
+
import type { Backend } from './backend.js';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration options for OverlayFS instances.
|
|
9
|
+
*/
|
|
10
|
+
export interface OverlayOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The file system to write modified files to.
|
|
13
|
+
*/
|
|
14
|
+
writable: FileSystem;
|
|
15
|
+
/**
|
|
16
|
+
* The file system that initially populates this file system.
|
|
17
|
+
*/
|
|
18
|
+
readable: FileSystem;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* OverlayFS makes a read-only filesystem writable by storing writes on a second, writable file system.
|
|
22
|
+
* Deletes are persisted via metadata stored on the writable file system.
|
|
23
|
+
*
|
|
24
|
+
* This class contains no locking whatsoever. It is wrapped in a LockedFS to prevent races.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare class UnlockedOverlayFS extends FileSystem {
|
|
29
|
+
ready(): Promise<this>;
|
|
30
|
+
private _writable;
|
|
31
|
+
private _readable;
|
|
32
|
+
private _isInitialized;
|
|
33
|
+
private _deletedFiles;
|
|
34
|
+
private _deleteLog;
|
|
35
|
+
private _deleteLogUpdatePending;
|
|
36
|
+
private _deleteLogUpdateNeeded;
|
|
37
|
+
private _deleteLogError?;
|
|
38
|
+
private _ready;
|
|
39
|
+
constructor({ writable, readable }: OverlayOptions);
|
|
40
|
+
get metadata(): FileSystemMetadata;
|
|
41
|
+
getOverlayedFileSystems(): OverlayOptions;
|
|
42
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
43
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
44
|
+
/**
|
|
45
|
+
* Called once to load up metadata stored on the writable file system.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
_initialize(): Promise<void>;
|
|
49
|
+
getDeletionLog(): string;
|
|
50
|
+
restoreDeletionLog(log: string, cred: Cred): void;
|
|
51
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
52
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
53
|
+
stat(p: string, cred: Cred): Promise<Stats>;
|
|
54
|
+
statSync(p: string, cred: Cred): Stats;
|
|
55
|
+
openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
|
|
56
|
+
openFileSync(path: string, flag: FileFlag, cred: Cred): File;
|
|
57
|
+
createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
|
|
58
|
+
createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
|
|
59
|
+
link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
|
|
60
|
+
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
61
|
+
unlink(p: string, cred: Cred): Promise<void>;
|
|
62
|
+
unlinkSync(p: string, cred: Cred): void;
|
|
63
|
+
rmdir(p: string, cred: Cred): Promise<void>;
|
|
64
|
+
rmdirSync(p: string, cred: Cred): void;
|
|
65
|
+
mkdir(p: string, mode: number, cred: Cred): Promise<void>;
|
|
66
|
+
mkdirSync(p: string, mode: number, cred: Cred): void;
|
|
67
|
+
readdir(p: string, cred: Cred): Promise<string[]>;
|
|
68
|
+
readdirSync(p: string, cred: Cred): string[];
|
|
69
|
+
private deletePath;
|
|
70
|
+
private updateLog;
|
|
71
|
+
private _reparseDeletionLog;
|
|
72
|
+
private checkInitialized;
|
|
73
|
+
private checkPath;
|
|
74
|
+
/**
|
|
75
|
+
* With the given path, create the needed parent directories on the writable storage
|
|
76
|
+
* should they not exist. Use modes from the read-only storage.
|
|
77
|
+
*/
|
|
78
|
+
private createParentDirectoriesSync;
|
|
79
|
+
private createParentDirectories;
|
|
80
|
+
/**
|
|
81
|
+
* Helper function:
|
|
82
|
+
* - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.
|
|
83
|
+
* - Calls f to perform operation on writable.
|
|
84
|
+
*/
|
|
85
|
+
private operateOnWritable;
|
|
86
|
+
private operateOnWritableAsync;
|
|
87
|
+
/**
|
|
88
|
+
* Copy from readable to writable storage.
|
|
89
|
+
* PRECONDITION: File does not exist on writable storage.
|
|
90
|
+
*/
|
|
91
|
+
private copyToWritableSync;
|
|
92
|
+
private copyToWritable;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* OverlayFS makes a read-only filesystem writable by storing writes on a second,
|
|
96
|
+
* writable file system. Deletes are persisted via metadata stored on the writable
|
|
97
|
+
* file system.
|
|
98
|
+
*/
|
|
99
|
+
export declare class OverlayFS extends LockedFS<UnlockedOverlayFS> {
|
|
100
|
+
ready(): Promise<this>;
|
|
101
|
+
/**
|
|
102
|
+
* @param options The options to initialize the OverlayFS with
|
|
103
|
+
*/
|
|
104
|
+
constructor(options: OverlayOptions);
|
|
105
|
+
getOverlayedFileSystems(): OverlayOptions;
|
|
106
|
+
getDeletionLog(): string;
|
|
107
|
+
resDeletionLog(): string;
|
|
108
|
+
unwrap(): UnlockedOverlayFS;
|
|
109
|
+
}
|
|
110
|
+
export declare const Overlay: Backend;
|