|
1 | 1 | declare module '@isomorphic-git/lightning-fs' {
|
2 |
| - export class PromisifiedFS { |
3 |
| - /** |
4 |
| - * |
5 |
| - * @param name This is used to determine the IndexedDb store name. |
6 |
| - * @param options The "filesystem" configuration. |
7 |
| - */ |
8 |
| - init(name: string, options?: FS.Options): void |
9 |
| - |
10 |
| - /** |
11 |
| - * Make directory |
12 |
| - * @param filepath |
13 |
| - * @param options |
14 |
| - */ |
15 |
| - mkdir(filepath: string, options?: FS.MKDirOptions): Promise<void> |
16 |
| - |
17 |
| - /** |
18 |
| - * Remove directory |
19 |
| - * @param filepath |
20 |
| - * @param options |
21 |
| - */ |
22 |
| - rmdir(filepath: string, options?: undefined): Promise<void> |
23 |
| - |
24 |
| - /** |
25 |
| - * Read directory |
26 |
| - * |
27 |
| - * The Promise return value is an Array of strings. NOTE: To save time, it is NOT SORTED. (Fun fact: Node.js' readdir output is not guaranteed to be sorted either. I learned that the hard way.) |
28 |
| - * @param filepath |
29 |
| - * @param options |
30 |
| - * @returns The file list. |
31 |
| - */ |
32 |
| - readdir(filepath: string, options?: undefined): Promise<string[]> |
33 |
| - |
34 |
| - writeFile(filepath: string, data: Uint8Array | string, options?: FS.WriteFileOptions | string): Promise<void> |
35 |
| - |
36 |
| - readFile(filepath: string, options?: FS.ReadFileOptions | string): Promise<Uint8Array> |
37 |
| - |
38 |
| - /** |
39 |
| - * Delete a file |
40 |
| - * @param filepath |
41 |
| - * @param options |
42 |
| - */ |
43 |
| - unlink(filepath: string, options?: undefined): Promise<void> |
44 |
| - |
45 |
| - /** |
46 |
| - * Rename a file or directory |
47 |
| - * @param oldFilepath |
48 |
| - * @param newFilepath |
49 |
| - */ |
50 |
| - rename(oldFilepath: string, newFilepath: string): Promise<void> |
51 |
| - |
52 |
| - /** |
53 |
| - * The result is a Stat object similar to the one used by Node but with fewer and slightly different properties and methods. |
54 |
| - * @param filepath |
55 |
| - * @param options |
56 |
| - */ |
57 |
| - stat(filepath: string, options?: undefined): Promise<FS.Stats> |
58 |
| - |
59 |
| - /** |
60 |
| - * Like fs.stat except that paths to symlinks return the symlink stats not the file stats of the symlink's target. |
61 |
| - * @param filepath |
62 |
| - * @param options |
63 |
| - */ |
64 |
| - lstat(filepath: string, options?: undefined): Promise<FS.Stats> |
65 |
| - |
66 |
| - /** |
67 |
| - * Create a symlink at filepath that points to target. |
68 |
| - * @param target |
69 |
| - * @param filepath |
70 |
| - */ |
71 |
| - symlink(target: string, filepath: string): Promise<void> |
72 |
| - |
73 |
| - /** |
74 |
| - * Read the target of a symlink. |
75 |
| - * @param filepath |
76 |
| - * @param options |
77 |
| - * @returns The link string. |
78 |
| - */ |
79 |
| - readlink(filepath: string, options?: undefined): Promise<string> |
80 |
| - |
81 |
| - /** |
82 |
| - * Create or change the stat data for a file backed by HTTP. Size is fetched with a HEAD request. Useful when using an HTTP backend without urlauto set, as then files will only be readable if they have stat data. Note that stat data is made automatically from the file /.superblock.txt if found on the server. /.superblock.txt can be generated or updated with the included [standalone script](https://github.com/isomorphic-git/lightning-fs/blob/main/src/superblocktxt.js). |
83 |
| - * @param filepath |
84 |
| - * @param options |
85 |
| - */ |
86 |
| - backFile(filepath: string, options?: FS.BackFileOptions): Promise<void> |
87 |
| - |
88 |
| - /** |
89 |
| - * @param filepath |
90 |
| - * @returns The size of a file or directory in bytes. |
91 |
| - */ |
92 |
| - du(filepath: string): Promise<number> |
93 |
| - } |
94 | 2 | class FS {
|
95 | 3 | /**
|
96 | 4 | * You can procrastinate initializing the FS object until later. And, if you're really adventurous, you can re-initialize it with a different name to switch between IndexedDb databases.
|
@@ -204,9 +112,102 @@ declare module '@isomorphic-git/lightning-fs' {
|
204 | 112 | */
|
205 | 113 | du(filepath: string, cb: (err: Error, size: number) => void): void
|
206 | 114 |
|
207 |
| - readonly promises: PromisifiedFS |
| 115 | + readonly promises: FS.PromisifiedFS |
208 | 116 | }
|
209 | 117 | namespace FS {
|
| 118 | + export class PromisifiedFS { |
| 119 | + /** |
| 120 | + * |
| 121 | + * @param name This is used to determine the IndexedDb store name. |
| 122 | + * @param options The "filesystem" configuration. |
| 123 | + */ |
| 124 | + init(name: string, options?: FS.Options): void |
| 125 | + |
| 126 | + /** |
| 127 | + * Make directory |
| 128 | + * @param filepath |
| 129 | + * @param options |
| 130 | + */ |
| 131 | + mkdir(filepath: string, options?: FS.MKDirOptions): Promise<void> |
| 132 | + |
| 133 | + /** |
| 134 | + * Remove directory |
| 135 | + * @param filepath |
| 136 | + * @param options |
| 137 | + */ |
| 138 | + rmdir(filepath: string, options?: undefined): Promise<void> |
| 139 | + |
| 140 | + /** |
| 141 | + * Read directory |
| 142 | + * |
| 143 | + * The Promise return value is an Array of strings. NOTE: To save time, it is NOT SORTED. (Fun fact: Node.js' readdir output is not guaranteed to be sorted either. I learned that the hard way.) |
| 144 | + * @param filepath |
| 145 | + * @param options |
| 146 | + * @returns The file list. |
| 147 | + */ |
| 148 | + readdir(filepath: string, options?: undefined): Promise<string[]> |
| 149 | + |
| 150 | + writeFile(filepath: string, data: Uint8Array | string, options?: FS.WriteFileOptions | string): Promise<void> |
| 151 | + |
| 152 | + readFile(filepath: string, options?: FS.ReadFileOptions | string): Promise<Uint8Array> |
| 153 | + |
| 154 | + /** |
| 155 | + * Delete a file |
| 156 | + * @param filepath |
| 157 | + * @param options |
| 158 | + */ |
| 159 | + unlink(filepath: string, options?: undefined): Promise<void> |
| 160 | + |
| 161 | + /** |
| 162 | + * Rename a file or directory |
| 163 | + * @param oldFilepath |
| 164 | + * @param newFilepath |
| 165 | + */ |
| 166 | + rename(oldFilepath: string, newFilepath: string): Promise<void> |
| 167 | + |
| 168 | + /** |
| 169 | + * The result is a Stat object similar to the one used by Node but with fewer and slightly different properties and methods. |
| 170 | + * @param filepath |
| 171 | + * @param options |
| 172 | + */ |
| 173 | + stat(filepath: string, options?: undefined): Promise<FS.Stats> |
| 174 | + |
| 175 | + /** |
| 176 | + * Like fs.stat except that paths to symlinks return the symlink stats not the file stats of the symlink's target. |
| 177 | + * @param filepath |
| 178 | + * @param options |
| 179 | + */ |
| 180 | + lstat(filepath: string, options?: undefined): Promise<FS.Stats> |
| 181 | + |
| 182 | + /** |
| 183 | + * Create a symlink at filepath that points to target. |
| 184 | + * @param target |
| 185 | + * @param filepath |
| 186 | + */ |
| 187 | + symlink(target: string, filepath: string): Promise<void> |
| 188 | + |
| 189 | + /** |
| 190 | + * Read the target of a symlink. |
| 191 | + * @param filepath |
| 192 | + * @param options |
| 193 | + * @returns The link string. |
| 194 | + */ |
| 195 | + readlink(filepath: string, options?: undefined): Promise<string> |
| 196 | + |
| 197 | + /** |
| 198 | + * Create or change the stat data for a file backed by HTTP. Size is fetched with a HEAD request. Useful when using an HTTP backend without urlauto set, as then files will only be readable if they have stat data. Note that stat data is made automatically from the file /.superblock.txt if found on the server. /.superblock.txt can be generated or updated with the included [standalone script](https://github.com/isomorphic-git/lightning-fs/blob/main/src/superblocktxt.js). |
| 199 | + * @param filepath |
| 200 | + * @param options |
| 201 | + */ |
| 202 | + backFile(filepath: string, options?: FS.BackFileOptions): Promise<void> |
| 203 | + |
| 204 | + /** |
| 205 | + * @param filepath |
| 206 | + * @returns The size of a file or directory in bytes. |
| 207 | + */ |
| 208 | + du(filepath: string): Promise<number> |
| 209 | + } |
| 210 | + |
210 | 211 | export interface Options {
|
211 | 212 | /**
|
212 | 213 | * Delete the database and start with an empty filesystem
|
|
0 commit comments