@zenfs/core 0.10.0 → 0.11.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/Index.d.ts +3 -3
- package/dist/backends/Index.js +4 -4
- package/dist/backends/backend.js +2 -1
- package/dist/backends/{Fetch.d.ts → fetch.d.ts} +4 -4
- package/dist/backends/{Fetch.js → fetch.js} +6 -7
- package/dist/backends/{Locked.d.ts → locked.d.ts} +2 -2
- package/dist/backends/{Locked.js → locked.js} +4 -5
- package/dist/backends/{InMemory.d.ts → memory.d.ts} +7 -9
- package/dist/backends/memory.js +38 -0
- package/dist/backends/{Overlay.d.ts → overlay.d.ts} +12 -13
- package/dist/backends/{Overlay.js → overlay.js} +98 -103
- package/dist/backends/port/fs.d.ts +15 -16
- package/dist/backends/port/fs.js +20 -22
- package/dist/backends/store/fs.d.ts +169 -0
- package/dist/backends/store/fs.js +743 -0
- package/dist/backends/store/simple.d.ts +64 -0
- package/dist/backends/store/simple.js +111 -0
- package/dist/backends/store/store.d.ts +111 -0
- package/dist/backends/store/store.js +62 -0
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/config.d.ts +1 -1
- package/dist/emulation/shared.js +1 -1
- package/dist/error.d.ts +0 -1
- package/dist/error.js +0 -1
- package/dist/file.js +1 -1
- package/dist/filesystem.d.ts +3 -3
- package/dist/filesystem.js +26 -29
- package/dist/index.d.ts +5 -7
- package/dist/index.js +5 -7
- package/dist/inode.d.ts +1 -1
- package/package.json +1 -1
- package/src/backends/Index.ts +4 -4
- package/src/backends/backend.ts +2 -1
- package/src/backends/{Fetch.ts → fetch.ts} +13 -14
- package/src/backends/{Locked.ts → locked.ts} +5 -6
- package/src/backends/memory.ts +44 -0
- package/src/backends/{Overlay.ts → overlay.ts} +99 -105
- package/src/backends/port/fs.ts +24 -26
- package/src/backends/store/fs.ts +881 -0
- package/src/backends/store/readme.md +9 -0
- package/src/backends/store/simple.ts +144 -0
- package/src/backends/store/store.ts +164 -0
- package/src/config.ts +2 -2
- package/src/emulation/shared.ts +1 -1
- package/src/error.ts +0 -1
- package/src/file.ts +1 -1
- package/src/filesystem.ts +29 -32
- package/src/index.ts +5 -7
- package/src/inode.ts +1 -1
- package/dist/backends/AsyncStore.d.ts +0 -204
- package/dist/backends/AsyncStore.js +0 -509
- package/dist/backends/InMemory.js +0 -49
- package/dist/backends/SyncStore.d.ts +0 -213
- package/dist/backends/SyncStore.js +0 -445
- package/dist/backends/port/store.d.ts +0 -30
- package/dist/backends/port/store.js +0 -142
- package/src/backends/AsyncStore.ts +0 -655
- package/src/backends/InMemory.ts +0 -56
- package/src/backends/SyncStore.ts +0 -589
- package/src/backends/port/store.ts +0 -187
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Cred } from '../../cred.js';
|
|
2
|
+
import { PreloadFile } from '../../file.js';
|
|
3
|
+
import { FileSystem, type FileSystemMetadata } from '../../filesystem.js';
|
|
4
|
+
import { type Ino, Inode } from '../../inode.js';
|
|
5
|
+
import { type Stats, FileType } from '../../stats.js';
|
|
6
|
+
import type { Store, Transaction } from './store.js';
|
|
7
|
+
/**
|
|
8
|
+
* A synchronous key-value file system. Uses a SyncStore to store the data.
|
|
9
|
+
*
|
|
10
|
+
* We use a unique ID for each node in the file system. The root node has a fixed ID.
|
|
11
|
+
* @todo Introduce Node ID caching.
|
|
12
|
+
* @todo Check modes.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare class StoreFS extends FileSystem {
|
|
16
|
+
private $store;
|
|
17
|
+
protected get store(): Store;
|
|
18
|
+
protected _store?: Store;
|
|
19
|
+
private _initialized;
|
|
20
|
+
ready(): Promise<void>;
|
|
21
|
+
constructor($store: Store | Promise<Store>);
|
|
22
|
+
metadata(): FileSystemMetadata;
|
|
23
|
+
/**
|
|
24
|
+
* Delete all contents stored in the file system.
|
|
25
|
+
*/
|
|
26
|
+
empty(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete all contents stored in the file system.
|
|
29
|
+
*/
|
|
30
|
+
emptySync(): void;
|
|
31
|
+
/**
|
|
32
|
+
* @todo Make rename compatible with the cache.
|
|
33
|
+
*/
|
|
34
|
+
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
35
|
+
renameSync(oldPath: string, newPath: string, cred: Cred): void;
|
|
36
|
+
stat(path: string, cred: Cred): Promise<Stats>;
|
|
37
|
+
statSync(path: string, cred: Cred): Stats;
|
|
38
|
+
createFile(path: string, flag: string, mode: number, cred: Cred): Promise<PreloadFile<this>>;
|
|
39
|
+
createFileSync(path: string, flag: string, mode: number, cred: Cred): PreloadFile<this>;
|
|
40
|
+
openFile(path: string, flag: string, cred: Cred): Promise<PreloadFile<this>>;
|
|
41
|
+
openFileSync(path: string, flag: string, cred: Cred): PreloadFile<this>;
|
|
42
|
+
unlink(path: string, cred: Cred): Promise<void>;
|
|
43
|
+
unlinkSync(path: string, cred: Cred): void;
|
|
44
|
+
rmdir(path: string, cred: Cred): Promise<void>;
|
|
45
|
+
rmdirSync(path: string, cred: Cred): void;
|
|
46
|
+
mkdir(path: string, mode: number, cred: Cred): Promise<void>;
|
|
47
|
+
mkdirSync(path: string, mode: number, cred: Cred): void;
|
|
48
|
+
readdir(path: string, cred: Cred): Promise<string[]>;
|
|
49
|
+
readdirSync(path: string, cred: Cred): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Updated the inode and data node at the given path
|
|
52
|
+
* @todo Ensure mtime updates properly, and use that to determine if a data update is required.
|
|
53
|
+
*/
|
|
54
|
+
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Updated the inode and data node at the given path
|
|
57
|
+
* @todo Ensure mtime updates properly, and use that to determine if a data update is required.
|
|
58
|
+
*/
|
|
59
|
+
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
60
|
+
link(existing: string, newpath: string, cred: Cred): Promise<void>;
|
|
61
|
+
linkSync(existing: string, newpath: string, cred: Cred): void;
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the root directory exists. Creates it if it doesn't.
|
|
64
|
+
*/
|
|
65
|
+
private makeRootDirectory;
|
|
66
|
+
/**
|
|
67
|
+
* Checks if the root directory exists. Creates it if it doesn't.
|
|
68
|
+
*/
|
|
69
|
+
protected makeRootDirectorySync(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Helper function for findINode.
|
|
72
|
+
* @param parent The parent directory of the file we are attempting to find.
|
|
73
|
+
* @param filename The filename of the inode we are attempting to find, minus
|
|
74
|
+
* the parent.
|
|
75
|
+
*/
|
|
76
|
+
private _findINode;
|
|
77
|
+
/**
|
|
78
|
+
* Helper function for findINode.
|
|
79
|
+
* @param parent The parent directory of the file we are attempting to find.
|
|
80
|
+
* @param filename The filename of the inode we are attempting to find, minus
|
|
81
|
+
* the parent.
|
|
82
|
+
* @return string The ID of the file's inode in the file system.
|
|
83
|
+
*/
|
|
84
|
+
protected _findINodeSync(tx: Transaction, parent: string, filename: string, visited?: Set<string>): Ino;
|
|
85
|
+
/**
|
|
86
|
+
* Finds the Inode of the given path.
|
|
87
|
+
* @param path The path to look up.
|
|
88
|
+
* @todo memoize/cache
|
|
89
|
+
*/
|
|
90
|
+
private findINode;
|
|
91
|
+
/**
|
|
92
|
+
* Finds the Inode of the given path.
|
|
93
|
+
* @param path The path to look up.
|
|
94
|
+
* @return The Inode of the path p.
|
|
95
|
+
* @todo memoize/cache
|
|
96
|
+
*/
|
|
97
|
+
protected findINodeSync(tx: Transaction, path: string, visited?: Set<string>): Inode;
|
|
98
|
+
/**
|
|
99
|
+
* Given the ID of a node, retrieves the corresponding Inode.
|
|
100
|
+
* @param tx The transaction to use.
|
|
101
|
+
* @param path The corresponding path to the file (used for error messages).
|
|
102
|
+
* @param id The ID to look up.
|
|
103
|
+
*/
|
|
104
|
+
private getINode;
|
|
105
|
+
/**
|
|
106
|
+
* Given the ID of a node, retrieves the corresponding Inode.
|
|
107
|
+
* @param tx The transaction to use.
|
|
108
|
+
* @param path The corresponding path to the file (used for error messages).
|
|
109
|
+
* @param id The ID to look up.
|
|
110
|
+
*/
|
|
111
|
+
protected getINodeSync(tx: Transaction, id: Ino, path: string): Inode;
|
|
112
|
+
/**
|
|
113
|
+
* Given the Inode of a directory, retrieves the corresponding directory
|
|
114
|
+
* listing.
|
|
115
|
+
*/
|
|
116
|
+
private getDirListing;
|
|
117
|
+
/**
|
|
118
|
+
* Given the Inode of a directory, retrieves the corresponding directory listing.
|
|
119
|
+
*/
|
|
120
|
+
protected getDirListingSync(tx: Transaction, inode: Inode, p?: string): {
|
|
121
|
+
[fileName: string]: Ino;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Adds a new node under a random ID. Retries before giving up in
|
|
125
|
+
* the exceedingly unlikely chance that we try to reuse a random ino.
|
|
126
|
+
*/
|
|
127
|
+
private addNew;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a new node under a random ID. Retries before giving up in
|
|
130
|
+
* the exceedingly unlikely chance that we try to reuse a random ino.
|
|
131
|
+
* @return The ino that the data was stored under.
|
|
132
|
+
*/
|
|
133
|
+
protected addNewSync(tx: Transaction, data: Uint8Array, path: string): Ino;
|
|
134
|
+
/**
|
|
135
|
+
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with
|
|
136
|
+
* the given mode.
|
|
137
|
+
* Note: This will commit the transaction.
|
|
138
|
+
* @param path The path to the new file.
|
|
139
|
+
* @param type The type of the new file.
|
|
140
|
+
* @param mode The mode to create the new file with.
|
|
141
|
+
* @param cred The UID/GID to create the file with
|
|
142
|
+
* @param data The data to store at the file's data node.
|
|
143
|
+
*/
|
|
144
|
+
private commitNew;
|
|
145
|
+
/**
|
|
146
|
+
* Commits a new file (well, a FILE or a DIRECTORY) to the file system with the given mode.
|
|
147
|
+
* Note: This will commit the transaction.
|
|
148
|
+
* @param path The path to the new file.
|
|
149
|
+
* @param type The type of the new file.
|
|
150
|
+
* @param mode The mode to create the new file with.
|
|
151
|
+
* @param data The data to store at the file's data node.
|
|
152
|
+
* @return The Inode for the new file.
|
|
153
|
+
*/
|
|
154
|
+
protected commitNewSync(path: string, type: FileType, mode: number, cred: Cred, data?: Uint8Array): Inode;
|
|
155
|
+
/**
|
|
156
|
+
* Remove all traces of the given path from the file system.
|
|
157
|
+
* @param path The path to remove from the file system.
|
|
158
|
+
* @param isDir Does the path belong to a directory, or a file?
|
|
159
|
+
* @todo Update mtime.
|
|
160
|
+
*/
|
|
161
|
+
private remove;
|
|
162
|
+
/**
|
|
163
|
+
* Remove all traces of the given path from the file system.
|
|
164
|
+
* @param path The path to remove from the file system.
|
|
165
|
+
* @param isDir Does the path belong to a directory, or a file?
|
|
166
|
+
* @todo Update mtime.
|
|
167
|
+
*/
|
|
168
|
+
protected removeSync(path: string, isDir: boolean, cred: Cred): void;
|
|
169
|
+
}
|