@zenfs/core 0.7.11 → 0.8.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/ApiError.d.ts +137 -55
- package/dist/ApiError.js +206 -67
- package/dist/FileIndex.d.ts +31 -59
- package/dist/FileIndex.js +5 -5
- package/dist/backends/AsyncStore.d.ts +8 -2
- package/dist/backends/Overlay.js +0 -1
- package/dist/backends/backend.d.ts +1 -1
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +3 -3
- package/dist/emulation/async.d.ts +82 -81
- package/dist/emulation/async.js +2 -2
- package/dist/emulation/dir.d.ts +3 -3
- package/dist/emulation/streams.d.ts +3 -3
- package/dist/filesystem.d.ts +2 -10
- package/dist/filesystem.js +2 -2
- package/dist/utils.d.ts +4 -23
- package/dist/utils.js +0 -9
- package/package.json +3 -2
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
/// <reference types="node" resolution-mode="require"/>
|
|
4
4
|
import type * as Node from 'fs';
|
|
5
|
-
import { FileContents
|
|
5
|
+
import type { FileContents } from '../filesystem.js';
|
|
6
6
|
import { BigIntStats, type BigIntStatsFs, type Stats, type StatsFs } from '../stats.js';
|
|
7
|
+
import type { Callback } from '../utils.js';
|
|
7
8
|
import { Dirent, type Dir } from './dir.js';
|
|
8
9
|
import { PathLike } from './shared.js';
|
|
9
10
|
import { ReadStream, WriteStream } from './streams.js';
|
|
@@ -14,7 +15,7 @@ import { ReadStream, WriteStream } from './streams.js';
|
|
|
14
15
|
* @param newPath
|
|
15
16
|
* @param callback
|
|
16
17
|
*/
|
|
17
|
-
export declare function rename(oldPath: PathLike, newPath: PathLike, cb?:
|
|
18
|
+
export declare function rename(oldPath: PathLike, newPath: PathLike, cb?: Callback): void;
|
|
18
19
|
/**
|
|
19
20
|
* Test whether or not the given path exists by checking with the file system.
|
|
20
21
|
* Then call the callback argument with either true or false.
|
|
@@ -28,14 +29,14 @@ export declare function exists(path: PathLike, cb?: (exists: boolean) => unknown
|
|
|
28
29
|
* @param path
|
|
29
30
|
* @param callback
|
|
30
31
|
*/
|
|
31
|
-
export declare function stat(path: PathLike, callback:
|
|
32
|
-
export declare function stat(path: PathLike, options:
|
|
32
|
+
export declare function stat(path: PathLike, callback: Callback<[Stats]>): void;
|
|
33
|
+
export declare function stat(path: PathLike, options: {
|
|
33
34
|
bigint?: false;
|
|
34
|
-
}, callback:
|
|
35
|
-
export declare function stat(path: PathLike, options:
|
|
35
|
+
}, callback: Callback<[Stats]>): void;
|
|
36
|
+
export declare function stat(path: PathLike, options: {
|
|
36
37
|
bigint: true;
|
|
37
|
-
}, callback:
|
|
38
|
-
export declare function stat(path: PathLike, options: Node.StatOptions, callback:
|
|
38
|
+
}, callback: Callback<[BigIntStats]>): void;
|
|
39
|
+
export declare function stat(path: PathLike, options: Node.StatOptions, callback: Callback<[Stats] | [BigIntStats]>): void;
|
|
39
40
|
/**
|
|
40
41
|
* Asynchronous `lstat`.
|
|
41
42
|
* `lstat()` is identical to `stat()`, except that if path is a symbolic link,
|
|
@@ -43,28 +44,28 @@ export declare function stat(path: PathLike, options: Node.StatOptions, callback
|
|
|
43
44
|
* @param path
|
|
44
45
|
* @param callback
|
|
45
46
|
*/
|
|
46
|
-
export declare function lstat(path: PathLike, callback:
|
|
47
|
+
export declare function lstat(path: PathLike, callback: Callback<[Stats]>): void;
|
|
47
48
|
export declare function lstat(path: PathLike, options: Node.StatOptions & {
|
|
48
49
|
bigint?: false;
|
|
49
|
-
}, callback:
|
|
50
|
+
}, callback: Callback<[Stats]>): void;
|
|
50
51
|
export declare function lstat(path: PathLike, options: Node.StatOptions & {
|
|
51
52
|
bigint: true;
|
|
52
|
-
}, callback:
|
|
53
|
-
export declare function lstat(path: PathLike, options: Node.StatOptions, callback:
|
|
53
|
+
}, callback: Callback<[BigIntStats]>): void;
|
|
54
|
+
export declare function lstat(path: PathLike, options: Node.StatOptions, callback: Callback<[Stats | BigIntStats]>): void;
|
|
54
55
|
/**
|
|
55
56
|
* Asynchronous `truncate`.
|
|
56
57
|
* @param path
|
|
57
58
|
* @param len
|
|
58
59
|
* @param callback
|
|
59
60
|
*/
|
|
60
|
-
export declare function truncate(path: PathLike, cb?:
|
|
61
|
-
export declare function truncate(path: PathLike, len: number, cb?:
|
|
61
|
+
export declare function truncate(path: PathLike, cb?: Callback): void;
|
|
62
|
+
export declare function truncate(path: PathLike, len: number, cb?: Callback): void;
|
|
62
63
|
/**
|
|
63
64
|
* Asynchronous `unlink`.
|
|
64
65
|
* @param path
|
|
65
66
|
* @param callback
|
|
66
67
|
*/
|
|
67
|
-
export declare function unlink(path: PathLike, cb?:
|
|
68
|
+
export declare function unlink(path: PathLike, cb?: Callback): void;
|
|
68
69
|
/**
|
|
69
70
|
* Asynchronous file open.
|
|
70
71
|
* Exclusive mode ensures that path is newly created.
|
|
@@ -90,8 +91,8 @@ export declare function unlink(path: PathLike, cb?: NoArgCallback): void;
|
|
|
90
91
|
* @param mode defaults to `0644`
|
|
91
92
|
* @param callback
|
|
92
93
|
*/
|
|
93
|
-
export declare function open(path: PathLike, flag: string, cb?:
|
|
94
|
-
export declare function open(path: PathLike, flag: string, mode: number | string, cb?:
|
|
94
|
+
export declare function open(path: PathLike, flag: string, cb?: Callback<[number]>): void;
|
|
95
|
+
export declare function open(path: PathLike, flag: string, mode: number | string, cb?: Callback<[number]>): void;
|
|
95
96
|
/**
|
|
96
97
|
* Asynchronously reads the entire contents of a file.
|
|
97
98
|
* @param filename
|
|
@@ -100,14 +101,14 @@ export declare function open(path: PathLike, flag: string, mode: number | string
|
|
|
100
101
|
* @option options flag Defaults to `'r'`.
|
|
101
102
|
* @param callback If no encoding is specified, then the raw buffer is returned.
|
|
102
103
|
*/
|
|
103
|
-
export declare function readFile(filename: PathLike, cb:
|
|
104
|
+
export declare function readFile(filename: PathLike, cb: Callback<[Uint8Array]>): void;
|
|
104
105
|
export declare function readFile(filename: PathLike, options: {
|
|
105
106
|
flag?: string;
|
|
106
|
-
}, callback?:
|
|
107
|
+
}, callback?: Callback<[Uint8Array]>): void;
|
|
107
108
|
export declare function readFile(filename: PathLike, options: {
|
|
108
109
|
encoding: BufferEncoding;
|
|
109
110
|
flag?: string;
|
|
110
|
-
} | BufferEncoding, cb:
|
|
111
|
+
} | BufferEncoding, cb: Callback<[string]>): void;
|
|
111
112
|
/**
|
|
112
113
|
* Asynchronously writes data to a file, replacing the file if it already
|
|
113
114
|
* exists.
|
|
@@ -122,9 +123,9 @@ export declare function readFile(filename: PathLike, options: {
|
|
|
122
123
|
* @option flag Defaults to `'w'`.
|
|
123
124
|
* @param callback
|
|
124
125
|
*/
|
|
125
|
-
export declare function writeFile(filename: PathLike, data: FileContents, cb?:
|
|
126
|
-
export declare function writeFile(filename: PathLike, data: FileContents, encoding?: BufferEncoding, cb?:
|
|
127
|
-
export declare function writeFile(filename: PathLike, data: FileContents, options?: Node.WriteFileOptions, cb?:
|
|
126
|
+
export declare function writeFile(filename: PathLike, data: FileContents, cb?: Callback): void;
|
|
127
|
+
export declare function writeFile(filename: PathLike, data: FileContents, encoding?: BufferEncoding, cb?: Callback): void;
|
|
128
|
+
export declare function writeFile(filename: PathLike, data: FileContents, options?: Node.WriteFileOptions, cb?: Callback): void;
|
|
128
129
|
/**
|
|
129
130
|
* Asynchronously append data to a file, creating the file if it not yet
|
|
130
131
|
* exists.
|
|
@@ -137,13 +138,13 @@ export declare function writeFile(filename: PathLike, data: FileContents, option
|
|
|
137
138
|
* @option flag Defaults to `'a'`.
|
|
138
139
|
* @param callback
|
|
139
140
|
*/
|
|
140
|
-
export declare function appendFile(filename: PathLike, data: FileContents, cb?:
|
|
141
|
+
export declare function appendFile(filename: PathLike, data: FileContents, cb?: Callback): void;
|
|
141
142
|
export declare function appendFile(filename: PathLike, data: FileContents, options?: {
|
|
142
143
|
encoding?: string;
|
|
143
144
|
mode?: number | string;
|
|
144
145
|
flag?: string;
|
|
145
|
-
}, cb?:
|
|
146
|
-
export declare function appendFile(filename: PathLike, data: FileContents, encoding?: string, cb?:
|
|
146
|
+
}, cb?: Callback): void;
|
|
147
|
+
export declare function appendFile(filename: PathLike, data: FileContents, encoding?: string, cb?: Callback): void;
|
|
147
148
|
/**
|
|
148
149
|
* Asynchronous `fstat`.
|
|
149
150
|
* `fstat()` is identical to `stat()`, except that the file to be stat-ed is
|
|
@@ -151,39 +152,39 @@ export declare function appendFile(filename: PathLike, data: FileContents, encod
|
|
|
151
152
|
* @param fd
|
|
152
153
|
* @param callback
|
|
153
154
|
*/
|
|
154
|
-
export declare function fstat(fd: number, cb:
|
|
155
|
+
export declare function fstat(fd: number, cb: Callback<[Stats]>): void;
|
|
155
156
|
export declare function fstat(fd: number, options: Node.StatOptions & {
|
|
156
157
|
bigint?: false;
|
|
157
|
-
}, cb:
|
|
158
|
+
}, cb: Callback<[Stats]>): void;
|
|
158
159
|
export declare function fstat(fd: number, options: Node.StatOptions & {
|
|
159
160
|
bigint: true;
|
|
160
|
-
}, cb:
|
|
161
|
+
}, cb: Callback<[BigIntStats]>): void;
|
|
161
162
|
/**
|
|
162
163
|
* Asynchronous close.
|
|
163
164
|
* @param fd
|
|
164
165
|
* @param callback
|
|
165
166
|
*/
|
|
166
|
-
export declare function close(fd: number, cb?:
|
|
167
|
+
export declare function close(fd: number, cb?: Callback): void;
|
|
167
168
|
/**
|
|
168
169
|
* Asynchronous ftruncate.
|
|
169
170
|
* @param fd
|
|
170
171
|
* @param len
|
|
171
172
|
* @param callback
|
|
172
173
|
*/
|
|
173
|
-
export declare function ftruncate(fd: number, cb?:
|
|
174
|
-
export declare function ftruncate(fd: number, len?: number, cb?:
|
|
174
|
+
export declare function ftruncate(fd: number, cb?: Callback): void;
|
|
175
|
+
export declare function ftruncate(fd: number, len?: number, cb?: Callback): void;
|
|
175
176
|
/**
|
|
176
177
|
* Asynchronous fsync.
|
|
177
178
|
* @param fd
|
|
178
179
|
* @param callback
|
|
179
180
|
*/
|
|
180
|
-
export declare function fsync(fd: number, cb?:
|
|
181
|
+
export declare function fsync(fd: number, cb?: Callback): void;
|
|
181
182
|
/**
|
|
182
183
|
* Asynchronous fdatasync.
|
|
183
184
|
* @param fd
|
|
184
185
|
* @param callback
|
|
185
186
|
*/
|
|
186
|
-
export declare function fdatasync(fd: number, cb?:
|
|
187
|
+
export declare function fdatasync(fd: number, cb?: Callback): void;
|
|
187
188
|
/**
|
|
188
189
|
* Write buffer to the file specified by `fd`.
|
|
189
190
|
* Note that it is unsafe to use fs.write multiple times on the same file
|
|
@@ -198,11 +199,11 @@ export declare function fdatasync(fd: number, cb?: NoArgCallback): void;
|
|
|
198
199
|
* the current position.
|
|
199
200
|
* @param callback The number specifies the number of bytes written into the file.
|
|
200
201
|
*/
|
|
201
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?:
|
|
202
|
-
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?:
|
|
203
|
-
export declare function write(fd: number, data: FileContents, cb?:
|
|
204
|
-
export declare function write(fd: number, data: FileContents, position?: number, cb?:
|
|
205
|
-
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?:
|
|
202
|
+
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
203
|
+
export declare function write(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
204
|
+
export declare function write(fd: number, data: FileContents, cb?: Callback<[number, string]>): void;
|
|
205
|
+
export declare function write(fd: number, data: FileContents, position?: number, cb?: Callback<[number, string]>): void;
|
|
206
|
+
export declare function write(fd: number, data: FileContents, position: number | null, encoding: BufferEncoding, cb?: Callback<[number, string]>): void;
|
|
206
207
|
/**
|
|
207
208
|
* Read data from the file specified by `fd`.
|
|
208
209
|
* @param buffer The buffer that the data will be
|
|
@@ -215,7 +216,7 @@ export declare function write(fd: number, data: FileContents, position: number |
|
|
|
215
216
|
* position.
|
|
216
217
|
* @param callback The number is the number of bytes read
|
|
217
218
|
*/
|
|
218
|
-
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?:
|
|
219
|
+
export declare function read(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number, cb?: Callback<[number, Uint8Array]>): void;
|
|
219
220
|
/**
|
|
220
221
|
* Asynchronous `fchown`.
|
|
221
222
|
* @param fd
|
|
@@ -223,14 +224,14 @@ export declare function read(fd: number, buffer: Uint8Array, offset: number, len
|
|
|
223
224
|
* @param gid
|
|
224
225
|
* @param callback
|
|
225
226
|
*/
|
|
226
|
-
export declare function fchown(fd: number, uid: number, gid: number, cb?:
|
|
227
|
+
export declare function fchown(fd: number, uid: number, gid: number, cb?: Callback): void;
|
|
227
228
|
/**
|
|
228
229
|
* Asynchronous `fchmod`.
|
|
229
230
|
* @param fd
|
|
230
231
|
* @param mode
|
|
231
232
|
* @param callback
|
|
232
233
|
*/
|
|
233
|
-
export declare function fchmod(fd: number, mode: string | number, cb:
|
|
234
|
+
export declare function fchmod(fd: number, mode: string | number, cb: Callback): void;
|
|
234
235
|
/**
|
|
235
236
|
* Change the file timestamps of a file referenced by the supplied file
|
|
236
237
|
* descriptor.
|
|
@@ -239,20 +240,20 @@ export declare function fchmod(fd: number, mode: string | number, cb: NoArgCallb
|
|
|
239
240
|
* @param mtime
|
|
240
241
|
* @param callback
|
|
241
242
|
*/
|
|
242
|
-
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?:
|
|
243
|
+
export declare function futimes(fd: number, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
243
244
|
/**
|
|
244
245
|
* Asynchronous `rmdir`.
|
|
245
246
|
* @param path
|
|
246
247
|
* @param callback
|
|
247
248
|
*/
|
|
248
|
-
export declare function rmdir(path: PathLike, cb?:
|
|
249
|
+
export declare function rmdir(path: PathLike, cb?: Callback): void;
|
|
249
250
|
/**
|
|
250
251
|
* Asynchronous `mkdir`.
|
|
251
252
|
* @param path
|
|
252
253
|
* @param mode defaults to `0777`
|
|
253
254
|
* @param callback
|
|
254
255
|
*/
|
|
255
|
-
export declare function mkdir(path: PathLike, mode?: Node.Mode, cb?:
|
|
256
|
+
export declare function mkdir(path: PathLike, mode?: Node.Mode, cb?: Callback): void;
|
|
256
257
|
/**
|
|
257
258
|
* Asynchronous `readdir`. Reads the contents of a directory.
|
|
258
259
|
* The callback gets two arguments `(err, files)` where `files` is an array of
|
|
@@ -260,20 +261,20 @@ export declare function mkdir(path: PathLike, mode?: Node.Mode, cb?: NoArgCallba
|
|
|
260
261
|
* @param path
|
|
261
262
|
* @param callback
|
|
262
263
|
*/
|
|
263
|
-
export declare function readdir(path: PathLike, cb:
|
|
264
|
+
export declare function readdir(path: PathLike, cb: Callback<[string[]]>): void;
|
|
264
265
|
export declare function readdir(path: PathLike, options: {
|
|
265
266
|
withFileTypes?: false;
|
|
266
|
-
}, cb:
|
|
267
|
+
}, cb: Callback<[string[]]>): void;
|
|
267
268
|
export declare function readdir(path: PathLike, options: {
|
|
268
269
|
withFileTypes: true;
|
|
269
|
-
}, cb:
|
|
270
|
+
}, cb: Callback<[Dirent[]]>): void;
|
|
270
271
|
/**
|
|
271
272
|
* Asynchronous `link`.
|
|
272
273
|
* @param existing
|
|
273
274
|
* @param newpath
|
|
274
275
|
* @param callback
|
|
275
276
|
*/
|
|
276
|
-
export declare function link(existing: PathLike, newpath: PathLike, cb?:
|
|
277
|
+
export declare function link(existing: PathLike, newpath: PathLike, cb?: Callback): void;
|
|
277
278
|
/**
|
|
278
279
|
* Asynchronous `symlink`.
|
|
279
280
|
* @param target target path
|
|
@@ -281,17 +282,17 @@ export declare function link(existing: PathLike, newpath: PathLike, cb?: NoArgCa
|
|
|
281
282
|
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
282
283
|
* @param callback
|
|
283
284
|
*/
|
|
284
|
-
export declare function symlink(target: PathLike, path: PathLike, cb?:
|
|
285
|
-
export declare function symlink(target: PathLike, path: PathLike, type?: Node.symlink.Type, cb?:
|
|
285
|
+
export declare function symlink(target: PathLike, path: PathLike, cb?: Callback): void;
|
|
286
|
+
export declare function symlink(target: PathLike, path: PathLike, type?: Node.symlink.Type, cb?: Callback): void;
|
|
286
287
|
/**
|
|
287
288
|
* Asynchronous readlink.
|
|
288
289
|
* @param path
|
|
289
290
|
* @param callback
|
|
290
291
|
*/
|
|
291
|
-
export declare function readlink(path: PathLike, callback:
|
|
292
|
-
export declare function readlink(path: PathLike, options: Node.BufferEncodingOption, callback:
|
|
293
|
-
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback:
|
|
294
|
-
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback:
|
|
292
|
+
export declare function readlink(path: PathLike, callback: Callback<[string]> & any): void;
|
|
293
|
+
export declare function readlink(path: PathLike, options: Node.BufferEncodingOption, callback: Callback<[Uint8Array]>): void;
|
|
294
|
+
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback: Callback<[string | Uint8Array]>): void;
|
|
295
|
+
export declare function readlink(path: PathLike, options: Node.EncodingOption, callback: Callback<[string]>): void;
|
|
295
296
|
/**
|
|
296
297
|
* Asynchronous `chown`.
|
|
297
298
|
* @param path
|
|
@@ -299,7 +300,7 @@ export declare function readlink(path: PathLike, options: Node.EncodingOption, c
|
|
|
299
300
|
* @param gid
|
|
300
301
|
* @param callback
|
|
301
302
|
*/
|
|
302
|
-
export declare function chown(path: PathLike, uid: number, gid: number, cb?:
|
|
303
|
+
export declare function chown(path: PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
303
304
|
/**
|
|
304
305
|
* Asynchronous `lchown`.
|
|
305
306
|
* @param path
|
|
@@ -307,21 +308,21 @@ export declare function chown(path: PathLike, uid: number, gid: number, cb?: NoA
|
|
|
307
308
|
* @param gid
|
|
308
309
|
* @param callback
|
|
309
310
|
*/
|
|
310
|
-
export declare function lchown(path: PathLike, uid: number, gid: number, cb?:
|
|
311
|
+
export declare function lchown(path: PathLike, uid: number, gid: number, cb?: Callback): void;
|
|
311
312
|
/**
|
|
312
313
|
* Asynchronous `chmod`.
|
|
313
314
|
* @param path
|
|
314
315
|
* @param mode
|
|
315
316
|
* @param callback
|
|
316
317
|
*/
|
|
317
|
-
export declare function chmod(path: PathLike, mode: number | string, cb?:
|
|
318
|
+
export declare function chmod(path: PathLike, mode: number | string, cb?: Callback): void;
|
|
318
319
|
/**
|
|
319
320
|
* Asynchronous `lchmod`.
|
|
320
321
|
* @param path
|
|
321
322
|
* @param mode
|
|
322
323
|
* @param callback
|
|
323
324
|
*/
|
|
324
|
-
export declare function lchmod(path: PathLike, mode: number | string, cb?:
|
|
325
|
+
export declare function lchmod(path: PathLike, mode: number | string, cb?: Callback): void;
|
|
325
326
|
/**
|
|
326
327
|
* Change file timestamps of the file referenced by the supplied path.
|
|
327
328
|
* @param path
|
|
@@ -329,7 +330,7 @@ export declare function lchmod(path: PathLike, mode: number | string, cb?: NoArg
|
|
|
329
330
|
* @param mtime
|
|
330
331
|
* @param callback
|
|
331
332
|
*/
|
|
332
|
-
export declare function utimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?:
|
|
333
|
+
export declare function utimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
333
334
|
/**
|
|
334
335
|
* Change file timestamps of the file referenced by the supplied path.
|
|
335
336
|
* @param path
|
|
@@ -337,7 +338,7 @@ export declare function utimes(path: PathLike, atime: number | Date, mtime: numb
|
|
|
337
338
|
* @param mtime
|
|
338
339
|
* @param callback
|
|
339
340
|
*/
|
|
340
|
-
export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?:
|
|
341
|
+
export declare function lutimes(path: PathLike, atime: number | Date, mtime: number | Date, cb?: Callback): void;
|
|
341
342
|
/**
|
|
342
343
|
* Asynchronous `realpath`. The callback gets two arguments
|
|
343
344
|
* `(err, resolvedPath)`. May use `process.cwd` to resolve relative paths.
|
|
@@ -345,16 +346,16 @@ export declare function lutimes(path: PathLike, atime: number | Date, mtime: num
|
|
|
345
346
|
* @param path
|
|
346
347
|
* @param callback
|
|
347
348
|
*/
|
|
348
|
-
export declare function realpath(path: PathLike, cb?:
|
|
349
|
-
export declare function realpath(path: PathLike, options: Node.EncodingOption, cb:
|
|
349
|
+
export declare function realpath(path: PathLike, cb?: Callback<[string]>): void;
|
|
350
|
+
export declare function realpath(path: PathLike, options: Node.EncodingOption, cb: Callback<[string]>): void;
|
|
350
351
|
/**
|
|
351
352
|
* Asynchronous `access`.
|
|
352
353
|
* @param path
|
|
353
354
|
* @param mode
|
|
354
355
|
* @param callback
|
|
355
356
|
*/
|
|
356
|
-
export declare function access(path: PathLike, cb:
|
|
357
|
-
export declare function access(path: PathLike, mode: number, cb:
|
|
357
|
+
export declare function access(path: PathLike, cb: Callback): void;
|
|
358
|
+
export declare function access(path: PathLike, mode: number, cb: Callback): void;
|
|
358
359
|
/**
|
|
359
360
|
* @todo Implement
|
|
360
361
|
*/
|
|
@@ -393,33 +394,33 @@ export declare function createWriteStream(path: PathLike, options?: {
|
|
|
393
394
|
fd?: number;
|
|
394
395
|
mode?: number;
|
|
395
396
|
}): WriteStream;
|
|
396
|
-
export declare function rm(path: PathLike, callback:
|
|
397
|
-
export declare function rm(path: PathLike, options: Node.RmOptions, callback:
|
|
397
|
+
export declare function rm(path: PathLike, callback: Callback): void;
|
|
398
|
+
export declare function rm(path: PathLike, options: Node.RmOptions, callback: Callback): void;
|
|
398
399
|
/**
|
|
399
400
|
* Asynchronously creates a unique temporary directory.
|
|
400
401
|
* Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
|
|
401
402
|
*/
|
|
402
|
-
export declare function mkdtemp(prefix: string, callback:
|
|
403
|
-
export declare function mkdtemp(prefix: string, options: Node.EncodingOption, callback:
|
|
404
|
-
export declare function mkdtemp(prefix: string, options: Node.BufferEncodingOption, callback:
|
|
405
|
-
export declare function copyFile(src: PathLike, dest: PathLike, callback:
|
|
406
|
-
export declare function copyFile(src: PathLike, dest: PathLike, flags: number, callback:
|
|
407
|
-
type readvCb =
|
|
403
|
+
export declare function mkdtemp(prefix: string, callback: Callback<[string]>): void;
|
|
404
|
+
export declare function mkdtemp(prefix: string, options: Node.EncodingOption, callback: Callback<[string]>): void;
|
|
405
|
+
export declare function mkdtemp(prefix: string, options: Node.BufferEncodingOption, callback: Callback<[Buffer]>): void;
|
|
406
|
+
export declare function copyFile(src: PathLike, dest: PathLike, callback: Callback): void;
|
|
407
|
+
export declare function copyFile(src: PathLike, dest: PathLike, flags: number, callback: Callback): void;
|
|
408
|
+
type readvCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
|
|
408
409
|
export declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], cb: readvCb): void;
|
|
409
410
|
export declare function readv(fd: number, buffers: readonly NodeJS.ArrayBufferView[], position: number, cb: readvCb): void;
|
|
410
|
-
type writevCb =
|
|
411
|
+
type writevCb = Callback<[number, NodeJS.ArrayBufferView[]]>;
|
|
411
412
|
export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], cb: writevCb): void;
|
|
412
413
|
export declare function writev(fd: number, buffers: NodeJS.ArrayBufferView[], position: number, cb: writevCb): void;
|
|
413
|
-
export declare function opendir(path: PathLike, cb:
|
|
414
|
-
export declare function opendir(path: PathLike, options: Node.OpenDirOptions, cb:
|
|
415
|
-
export declare function cp(source: PathLike, destination: PathLike, callback:
|
|
416
|
-
export declare function cp(source: PathLike, destination: PathLike, opts: Node.CopyOptions, callback:
|
|
417
|
-
export declare function statfs(path: PathLike, callback:
|
|
414
|
+
export declare function opendir(path: PathLike, cb: Callback<[Dir]>): void;
|
|
415
|
+
export declare function opendir(path: PathLike, options: Node.OpenDirOptions, cb: Callback<[Dir]>): void;
|
|
416
|
+
export declare function cp(source: PathLike, destination: PathLike, callback: Callback): void;
|
|
417
|
+
export declare function cp(source: PathLike, destination: PathLike, opts: Node.CopyOptions, callback: Callback): void;
|
|
418
|
+
export declare function statfs(path: PathLike, callback: Callback<[StatsFs]>): void;
|
|
418
419
|
export declare function statfs(path: PathLike, options: Node.StatFsOptions & {
|
|
419
420
|
bigint?: false;
|
|
420
|
-
}, callback:
|
|
421
|
+
}, callback: Callback<[StatsFs]>): void;
|
|
421
422
|
export declare function statfs(path: PathLike, options: Node.StatFsOptions & {
|
|
422
423
|
bigint: true;
|
|
423
|
-
}, callback:
|
|
424
|
+
}, callback: Callback<[BigIntStatsFs]>): void;
|
|
424
425
|
export declare function openAsBlob(path: PathLike, options?: Node.OpenAsBlobOptions): Promise<Blob>;
|
|
425
426
|
export {};
|
package/dist/emulation/async.js
CHANGED
|
@@ -35,7 +35,7 @@ export function stat(path, options, callback = nop) {
|
|
|
35
35
|
callback = typeof options == 'function' ? options : callback;
|
|
36
36
|
promises
|
|
37
37
|
.stat(path, typeof options != 'function' ? options : {})
|
|
38
|
-
.then(stats => callback(null, stats))
|
|
38
|
+
.then((stats) => callback(null, stats))
|
|
39
39
|
.catch(callback);
|
|
40
40
|
}
|
|
41
41
|
stat;
|
|
@@ -105,7 +105,7 @@ export function fstat(fd, options, cb = nop) {
|
|
|
105
105
|
cb = typeof options == 'function' ? options : cb;
|
|
106
106
|
fd2file(fd)
|
|
107
107
|
.stat()
|
|
108
|
-
.then(stats => cb(null,
|
|
108
|
+
.then(stats => cb(null, typeof options == 'object' && options?.bigint ? new BigIntStats(stats) : stats))
|
|
109
109
|
.catch(cb);
|
|
110
110
|
}
|
|
111
111
|
fstat;
|
package/dist/emulation/dir.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { Dirent as _Dirent, Dir as _Dir } from 'fs';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Callback } from '../utils.js';
|
|
4
4
|
import type { Stats } from '../stats.js';
|
|
5
5
|
export declare class Dirent implements _Dirent {
|
|
6
6
|
path: string;
|
|
@@ -29,7 +29,7 @@ export declare class Dir implements _Dir {
|
|
|
29
29
|
* Subsequent reads will result in errors.
|
|
30
30
|
*/
|
|
31
31
|
close(): Promise<void>;
|
|
32
|
-
close(cb:
|
|
32
|
+
close(cb: Callback): void;
|
|
33
33
|
/**
|
|
34
34
|
* Synchronously close the directory's underlying resource handle.
|
|
35
35
|
* Subsequent reads will result in errors.
|
|
@@ -42,7 +42,7 @@ export declare class Dir implements _Dir {
|
|
|
42
42
|
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
43
43
|
*/
|
|
44
44
|
read(): Promise<Dirent | null>;
|
|
45
|
-
read(cb:
|
|
45
|
+
read(cb: Callback<[Dirent | null]>): void;
|
|
46
46
|
/**
|
|
47
47
|
* Synchronously read the next directory entry via `readdir(3)` as a `Dirent`.
|
|
48
48
|
* If there are no more directory entries to read, null will be returned.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import type * as Node from 'fs';
|
|
4
4
|
import { Readable, Writable } from 'readable-stream';
|
|
5
|
-
import {
|
|
5
|
+
import { Callback } from '../utils.js';
|
|
6
6
|
export declare class ReadStream extends Readable implements Node.ReadStream {
|
|
7
|
-
close(callback?:
|
|
7
|
+
close(callback?: Callback): void;
|
|
8
8
|
bytesRead: number;
|
|
9
9
|
path: string | Buffer;
|
|
10
10
|
pending: boolean;
|
|
@@ -55,7 +55,7 @@ export declare class ReadStream extends Readable implements Node.ReadStream {
|
|
|
55
55
|
prependOnceListener(event: 'resume', listener: () => void): this;
|
|
56
56
|
}
|
|
57
57
|
export declare class WriteStream extends Writable implements Node.WriteStream {
|
|
58
|
-
close(callback?:
|
|
58
|
+
close(callback?: Callback): void;
|
|
59
59
|
bytesWritten: number;
|
|
60
60
|
path: string | Buffer;
|
|
61
61
|
pending: boolean;
|
package/dist/filesystem.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { ApiError } from './ApiError.js';
|
|
2
|
-
import type { Stats } from './stats.js';
|
|
3
|
-
import { type File } from './file.js';
|
|
4
1
|
import { type Cred } from './cred.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type ThreeArgCallback<T, U> = (e?: ApiError, arg1?: T, arg2?: U) => unknown;
|
|
2
|
+
import { type File } from './file.js';
|
|
3
|
+
import type { Stats } from './stats.js';
|
|
8
4
|
export type FileContents = Uint8Array | string;
|
|
9
5
|
/**
|
|
10
6
|
* Metadata about a FileSystem
|
|
@@ -18,10 +14,6 @@ export interface FileSystemMetadata {
|
|
|
18
14
|
* Wheter the FS is readonly or not
|
|
19
15
|
*/
|
|
20
16
|
readonly: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Does the FS support properties
|
|
23
|
-
*/
|
|
24
|
-
supportsProperties: boolean;
|
|
25
17
|
/**
|
|
26
18
|
* The total space
|
|
27
19
|
*/
|
package/dist/filesystem.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ApiError, ErrorCode } from './ApiError.js';
|
|
2
|
-
import { PreloadFile, parseFlag } from './file.js';
|
|
3
2
|
import { rootCred } from './cred.js';
|
|
4
3
|
import { join } from './emulation/path.js';
|
|
4
|
+
import { PreloadFile, parseFlag } from './file.js';
|
|
5
5
|
/**
|
|
6
6
|
* Structure for a filesystem. All ZenFS FileSystems must implement this.
|
|
7
7
|
*
|
|
@@ -20,7 +20,6 @@ export class FileSystem {
|
|
|
20
20
|
return {
|
|
21
21
|
name: this.constructor.name,
|
|
22
22
|
readonly: false,
|
|
23
|
-
supportsProperties: false,
|
|
24
23
|
totalSpace: 0,
|
|
25
24
|
freeSpace: 0,
|
|
26
25
|
};
|
|
@@ -125,6 +124,7 @@ export function Async(FS) {
|
|
|
125
124
|
this._isInitialized = false;
|
|
126
125
|
}
|
|
127
126
|
async ready() {
|
|
127
|
+
await this._sync.ready();
|
|
128
128
|
if (this._isInitialized) {
|
|
129
129
|
return this;
|
|
130
130
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OptionalTuple } from 'utilium';
|
|
2
|
+
import { ApiError } from './ApiError.js';
|
|
2
3
|
import { Cred } from './cred.js';
|
|
4
|
+
import { FileSystem } from './filesystem.js';
|
|
3
5
|
declare global {
|
|
4
6
|
function atob(data: string): string;
|
|
5
7
|
function btoa(data: string): string;
|
|
@@ -14,11 +16,6 @@ export declare function mkdirpSync(p: string, mode: number, cred: Cred, fs: File
|
|
|
14
16
|
* @hidden
|
|
15
17
|
*/
|
|
16
18
|
export declare function levenshtein(a: string, b: string): number;
|
|
17
|
-
/**
|
|
18
|
-
* Waits n ms.
|
|
19
|
-
* @hidden
|
|
20
|
-
*/
|
|
21
|
-
export declare function wait(ms: number): Promise<void>;
|
|
22
19
|
/**
|
|
23
20
|
* @hidden
|
|
24
21
|
*/
|
|
@@ -43,20 +40,4 @@ export declare function decodeDirListing(data: Uint8Array): Record<string, bigin
|
|
|
43
40
|
* @hidden
|
|
44
41
|
*/
|
|
45
42
|
export declare function encodeDirListing(data: Record<string, bigint>): Uint8Array;
|
|
46
|
-
|
|
47
|
-
* Extracts an object of properties assignable to P from an object T
|
|
48
|
-
* @hidden
|
|
49
|
-
*/
|
|
50
|
-
export type ExtractProperties<T, P> = {
|
|
51
|
-
[K in keyof T as T[K] extends infer Prop ? (Prop extends P ? K : never) : never]: T[K];
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Extract a the keys in T which are required properties
|
|
55
|
-
* @hidden
|
|
56
|
-
* @see https://stackoverflow.com/a/55247867/17637456
|
|
57
|
-
*/
|
|
58
|
-
export type RequiredKeys<T> = {
|
|
59
|
-
[K in keyof T]-?: {} extends {
|
|
60
|
-
[P in K]: T[K];
|
|
61
|
-
} ? never : K;
|
|
62
|
-
}[keyof T];
|
|
43
|
+
export type Callback<Args extends unknown[] = []> = (e?: ApiError, ...args: OptionalTuple<Args>) => unknown;
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "A filesystem in your browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist",
|
|
@@ -57,7 +57,8 @@
|
|
|
57
57
|
"@types/readable-stream": "^4.0.10",
|
|
58
58
|
"buffer": "^6.0.3",
|
|
59
59
|
"minimatch": "^9.0.3",
|
|
60
|
-
"readable-stream": "^4.5.2"
|
|
60
|
+
"readable-stream": "^4.5.2",
|
|
61
|
+
"utilium": "^0.2.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
|