@zenfs/core 1.11.4 → 2.1.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/backend.d.ts +19 -15
- package/dist/backends/backend.js +36 -19
- package/dist/backends/cow.d.ts +20 -30
- package/dist/backends/cow.js +83 -192
- package/dist/backends/fetch.d.ts +1 -0
- package/dist/backends/fetch.js +30 -30
- package/dist/backends/index.d.ts +1 -1
- package/dist/backends/index.js +1 -1
- package/dist/backends/memory.d.ts +5 -7
- package/dist/backends/memory.js +2 -3
- package/dist/backends/passthrough.d.ts +19 -23
- package/dist/backends/passthrough.js +98 -288
- package/dist/backends/port.d.ts +220 -0
- package/dist/backends/port.js +328 -0
- package/dist/backends/single_buffer.d.ts +59 -47
- package/dist/backends/single_buffer.js +468 -219
- package/dist/backends/store/fs.d.ts +25 -35
- package/dist/backends/store/fs.js +276 -315
- package/dist/backends/store/store.d.ts +10 -15
- package/dist/backends/store/store.js +11 -10
- package/dist/config.d.ts +3 -12
- package/dist/config.js +17 -19
- package/dist/context.d.ts +8 -21
- package/dist/context.js +33 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/contexts.d.ts +63 -0
- package/dist/internal/contexts.js +15 -0
- package/dist/internal/credentials.d.ts +2 -11
- package/dist/internal/credentials.js +0 -19
- package/dist/internal/devices.d.ts +18 -80
- package/dist/internal/devices.js +103 -316
- package/dist/internal/error.d.ts +9 -204
- package/dist/internal/error.js +19 -288
- package/dist/internal/file_index.d.ts +1 -1
- package/dist/internal/file_index.js +11 -11
- package/dist/internal/filesystem.d.ts +51 -94
- package/dist/internal/filesystem.js +21 -20
- package/dist/internal/index.d.ts +1 -2
- package/dist/internal/index.js +1 -2
- package/dist/internal/index_fs.d.ts +12 -30
- package/dist/internal/index_fs.js +37 -69
- package/dist/internal/inode.d.ts +140 -24
- package/dist/internal/inode.js +515 -66
- package/dist/mixins/async.js +52 -112
- package/dist/mixins/mutexed.d.ts +19 -18
- package/dist/mixins/mutexed.js +62 -64
- package/dist/mixins/readonly.d.ts +7 -6
- package/dist/mixins/readonly.js +24 -18
- package/dist/mixins/sync.js +8 -8
- package/dist/{vfs/path.d.ts → path.d.ts} +3 -4
- package/dist/{vfs/path.js → path.js} +6 -9
- package/dist/polyfills.js +1 -1
- package/dist/readline.d.ts +134 -0
- package/dist/readline.js +623 -0
- package/dist/utils.d.ts +9 -37
- package/dist/utils.js +17 -85
- package/dist/vfs/acl.d.ts +42 -0
- package/dist/vfs/acl.js +268 -0
- package/dist/vfs/async.d.ts +9 -23
- package/dist/vfs/async.js +25 -27
- package/dist/vfs/config.d.ts +6 -18
- package/dist/vfs/config.js +8 -18
- package/dist/vfs/dir.d.ts +3 -3
- package/dist/vfs/dir.js +12 -12
- package/dist/vfs/file.d.ts +106 -0
- package/dist/vfs/file.js +244 -0
- package/dist/vfs/flags.d.ts +19 -0
- package/dist/vfs/flags.js +62 -0
- package/dist/vfs/index.d.ts +4 -10
- package/dist/vfs/index.js +4 -13
- package/dist/vfs/ioctl.d.ts +88 -0
- package/dist/vfs/ioctl.js +409 -0
- package/dist/vfs/promises.d.ts +81 -19
- package/dist/vfs/promises.js +404 -288
- package/dist/vfs/shared.d.ts +7 -37
- package/dist/vfs/shared.js +29 -85
- package/dist/{stats.d.ts → vfs/stats.d.ts} +14 -28
- package/dist/{stats.js → vfs/stats.js} +11 -66
- package/dist/vfs/streams.d.ts +1 -0
- package/dist/vfs/streams.js +32 -27
- package/dist/vfs/sync.d.ts +3 -3
- package/dist/vfs/sync.js +263 -260
- package/dist/vfs/watchers.d.ts +2 -2
- package/dist/vfs/watchers.js +12 -12
- package/dist/vfs/xattr.d.ts +116 -0
- package/dist/vfs/xattr.js +201 -0
- package/package.json +5 -3
- package/readme.md +1 -1
- package/scripts/test.js +2 -2
- package/tests/assignment.ts +1 -1
- package/tests/backend/config.worker.js +4 -1
- package/tests/backend/fetch.test.ts +3 -0
- package/tests/backend/port.test.ts +19 -33
- package/tests/backend/remote.worker.js +4 -1
- package/tests/backend/single-buffer.test.ts +53 -0
- package/tests/backend/single-buffer.worker.js +30 -0
- package/tests/common/context.test.ts +3 -3
- package/tests/common/handle.test.ts +17 -12
- package/tests/common/mutex.test.ts +9 -9
- package/tests/common/path.test.ts +1 -1
- package/tests/common/readline.test.ts +104 -0
- package/tests/common.ts +4 -19
- package/tests/fetch/fetch.ts +2 -2
- package/tests/fs/append.test.ts +4 -4
- package/tests/fs/directory.test.ts +25 -25
- package/tests/fs/errors.test.ts +15 -19
- package/tests/fs/links.test.ts +4 -3
- package/tests/fs/open.test.ts +4 -21
- package/tests/fs/permissions.test.ts +14 -18
- package/tests/fs/read.test.ts +10 -9
- package/tests/fs/readFile.test.ts +10 -26
- package/tests/fs/rename.test.ts +4 -9
- package/tests/fs/stat.test.ts +8 -8
- package/tests/fs/streams.test.ts +2 -11
- package/tests/fs/times.test.ts +7 -7
- package/tests/fs/truncate.test.ts +8 -36
- package/tests/fs/watch.test.ts +10 -10
- package/tests/fs/write.test.ts +77 -13
- package/tests/fs/xattr.test.ts +85 -0
- package/tests/logs.js +22 -0
- package/tests/setup/context.ts +1 -1
- package/tests/setup/index.ts +3 -3
- package/tests/setup/port.ts +7 -1
- package/dist/backends/port/fs.d.ts +0 -84
- package/dist/backends/port/fs.js +0 -151
- package/dist/backends/port/rpc.d.ts +0 -77
- package/dist/backends/port/rpc.js +0 -100
- package/dist/backends/store/simple.d.ts +0 -20
- package/dist/backends/store/simple.js +0 -13
- package/dist/internal/file.d.ts +0 -359
- package/dist/internal/file.js +0 -751
- package/dist/internal/log.d.ts +0 -133
- package/dist/internal/log.js +0 -218
- package/tests/fs/writeFile.test.ts +0 -70
package/dist/mixins/async.js
CHANGED
|
@@ -1,61 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
-
var dispose, inner;
|
|
5
|
-
if (async) {
|
|
6
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
-
dispose = value[Symbol.asyncDispose];
|
|
8
|
-
}
|
|
9
|
-
if (dispose === void 0) {
|
|
10
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
-
dispose = value[Symbol.dispose];
|
|
12
|
-
if (async) inner = dispose;
|
|
13
|
-
}
|
|
14
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
-
}
|
|
18
|
-
else if (async) {
|
|
19
|
-
env.stack.push({ async: true });
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
-
return function (env) {
|
|
25
|
-
function fail(e) {
|
|
26
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
-
env.hasError = true;
|
|
28
|
-
}
|
|
29
|
-
var r, s = 0;
|
|
30
|
-
function next() {
|
|
31
|
-
while (r = env.stack.pop()) {
|
|
32
|
-
try {
|
|
33
|
-
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
-
if (r.dispose) {
|
|
35
|
-
var result = r.dispose.call(r.value);
|
|
36
|
-
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
-
}
|
|
38
|
-
else s |= 1;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
fail(e);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
-
if (env.hasError) throw env.error;
|
|
46
|
-
}
|
|
47
|
-
return next();
|
|
48
|
-
};
|
|
49
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
-
var e = new Error(message);
|
|
51
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
-
});
|
|
1
|
+
import { withErrno } from 'kerium';
|
|
2
|
+
import { crit, debug, err } from 'kerium/log';
|
|
53
3
|
import { getAllPrototypes } from 'utilium';
|
|
54
4
|
import { StoreFS } from '../backends/store/fs.js';
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import { crit, debug, err } from '../internal/log.js';
|
|
58
|
-
import { join } from '../vfs/path.js';
|
|
5
|
+
import { isDirectory } from '../internal/inode.js';
|
|
6
|
+
import { join } from '../path.js';
|
|
59
7
|
/**
|
|
60
8
|
* Async() implements synchronous methods on an asynchronous file system
|
|
61
9
|
*
|
|
@@ -87,8 +35,8 @@ export function Async(FS) {
|
|
|
87
35
|
}
|
|
88
36
|
async ready() {
|
|
89
37
|
await super.ready();
|
|
90
|
-
await this.
|
|
91
|
-
if (this._isInitialized || this.attributes.has('
|
|
38
|
+
await this._promise;
|
|
39
|
+
if (this._isInitialized || this.attributes.has('no_async_preload'))
|
|
92
40
|
return;
|
|
93
41
|
this.checkSync();
|
|
94
42
|
await this._sync.ready();
|
|
@@ -111,83 +59,84 @@ export function Async(FS) {
|
|
|
111
59
|
}
|
|
112
60
|
catch (e) {
|
|
113
61
|
this._isInitialized = false;
|
|
114
|
-
throw crit(e
|
|
62
|
+
throw crit(e);
|
|
115
63
|
}
|
|
116
64
|
}
|
|
117
|
-
checkSync(
|
|
118
|
-
if (this.attributes.has('
|
|
119
|
-
throw
|
|
120
|
-
fs: this,
|
|
121
|
-
});
|
|
65
|
+
checkSync() {
|
|
66
|
+
if (this.attributes.has('no_async_preload')) {
|
|
67
|
+
throw withErrno('ENOTSUP', 'Sync preloading has been disabled for this async file system');
|
|
122
68
|
}
|
|
123
69
|
if (!this._sync) {
|
|
124
|
-
throw crit(
|
|
70
|
+
throw crit(withErrno('ENOTSUP', 'No sync cache is attached to this async file system'));
|
|
125
71
|
}
|
|
126
72
|
}
|
|
127
73
|
renameSync(oldPath, newPath) {
|
|
128
|
-
this.checkSync(
|
|
74
|
+
this.checkSync();
|
|
129
75
|
this._sync.renameSync(oldPath, newPath);
|
|
130
76
|
this._async(this.rename(oldPath, newPath));
|
|
131
77
|
}
|
|
132
78
|
statSync(path) {
|
|
133
|
-
this.checkSync(
|
|
79
|
+
this.checkSync();
|
|
134
80
|
return this._sync.statSync(path);
|
|
135
81
|
}
|
|
136
|
-
|
|
137
|
-
this.checkSync(
|
|
138
|
-
|
|
139
|
-
this._async(this.
|
|
140
|
-
return new LazyFile(this, path, flag, file.statSync());
|
|
82
|
+
touchSync(path, metadata) {
|
|
83
|
+
this.checkSync();
|
|
84
|
+
this._sync.touchSync(path, metadata);
|
|
85
|
+
this._async(this.touch(path, metadata));
|
|
141
86
|
}
|
|
142
|
-
|
|
143
|
-
this.checkSync(
|
|
144
|
-
|
|
145
|
-
return
|
|
87
|
+
createFileSync(path, options) {
|
|
88
|
+
this.checkSync();
|
|
89
|
+
this._async(this.createFile(path, options));
|
|
90
|
+
return this._sync.createFileSync(path, options);
|
|
146
91
|
}
|
|
147
92
|
unlinkSync(path) {
|
|
148
|
-
this.checkSync(
|
|
93
|
+
this.checkSync();
|
|
149
94
|
this._sync.unlinkSync(path);
|
|
150
95
|
this._async(this.unlink(path));
|
|
151
96
|
}
|
|
152
97
|
rmdirSync(path) {
|
|
153
|
-
this.checkSync(
|
|
98
|
+
this.checkSync();
|
|
154
99
|
this._sync.rmdirSync(path);
|
|
155
100
|
this._async(this.rmdir(path));
|
|
156
101
|
}
|
|
157
|
-
mkdirSync(path,
|
|
158
|
-
this.checkSync(
|
|
159
|
-
this.
|
|
160
|
-
this.
|
|
102
|
+
mkdirSync(path, options) {
|
|
103
|
+
this.checkSync();
|
|
104
|
+
this._async(this.mkdir(path, options));
|
|
105
|
+
return this._sync.mkdirSync(path, options);
|
|
161
106
|
}
|
|
162
107
|
readdirSync(path) {
|
|
163
|
-
this.checkSync(
|
|
108
|
+
this.checkSync();
|
|
164
109
|
return this._sync.readdirSync(path);
|
|
165
110
|
}
|
|
166
111
|
linkSync(srcpath, dstpath) {
|
|
167
|
-
this.checkSync(
|
|
112
|
+
this.checkSync();
|
|
168
113
|
this._sync.linkSync(srcpath, dstpath);
|
|
169
114
|
this._async(this.link(srcpath, dstpath));
|
|
170
115
|
}
|
|
171
|
-
|
|
172
|
-
this.checkSync(
|
|
173
|
-
this._sync.syncSync(
|
|
174
|
-
this.
|
|
116
|
+
async sync() {
|
|
117
|
+
this.checkSync();
|
|
118
|
+
this._sync.syncSync();
|
|
119
|
+
await this._promise;
|
|
120
|
+
}
|
|
121
|
+
syncSync() {
|
|
122
|
+
this.checkSync();
|
|
123
|
+
this._sync.syncSync();
|
|
175
124
|
}
|
|
176
125
|
existsSync(path) {
|
|
177
|
-
this.checkSync(
|
|
126
|
+
this.checkSync();
|
|
178
127
|
return this._sync.existsSync(path);
|
|
179
128
|
}
|
|
180
129
|
readSync(path, buffer, offset, end) {
|
|
181
|
-
this.checkSync(
|
|
130
|
+
this.checkSync();
|
|
182
131
|
this._sync.readSync(path, buffer, offset, end);
|
|
183
132
|
}
|
|
184
133
|
writeSync(path, buffer, offset) {
|
|
185
|
-
this.checkSync(
|
|
134
|
+
this.checkSync();
|
|
186
135
|
this._sync.writeSync(path, buffer, offset);
|
|
187
136
|
this._async(this.write(path, buffer, offset));
|
|
188
137
|
}
|
|
189
138
|
streamWrite(path, options) {
|
|
190
|
-
this.checkSync(
|
|
139
|
+
this.checkSync();
|
|
191
140
|
const sync = this._sync.streamWrite(path, options).getWriter();
|
|
192
141
|
const async = super.streamWrite(path, options).getWriter();
|
|
193
142
|
return new WritableStream({
|
|
@@ -206,28 +155,19 @@ export function Async(FS) {
|
|
|
206
155
|
* @internal
|
|
207
156
|
*/
|
|
208
157
|
async crossCopy(path) {
|
|
209
|
-
this.checkSync(
|
|
158
|
+
this.checkSync();
|
|
210
159
|
const stats = await this.stat(path);
|
|
211
|
-
if (!
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
catch (e_1) {
|
|
221
|
-
env_1.error = e_1;
|
|
222
|
-
env_1.hasError = true;
|
|
223
|
-
}
|
|
224
|
-
finally {
|
|
225
|
-
__disposeResources(env_1);
|
|
226
|
-
}
|
|
160
|
+
if (!isDirectory(stats)) {
|
|
161
|
+
this._sync.createFileSync(path, stats);
|
|
162
|
+
const buffer = new Uint8Array(stats.size);
|
|
163
|
+
await this.read(path, buffer, 0, stats.size);
|
|
164
|
+
this._sync.writeSync(path, buffer, 0);
|
|
165
|
+
this._sync.touchSync(path, stats);
|
|
166
|
+
return;
|
|
227
167
|
}
|
|
228
168
|
if (path !== '/') {
|
|
229
|
-
|
|
230
|
-
this._sync.
|
|
169
|
+
this._sync.mkdirSync(path, stats);
|
|
170
|
+
this._sync.touchSync(path, stats);
|
|
231
171
|
}
|
|
232
172
|
const promises = [];
|
|
233
173
|
for (const file of await this.readdir(path)) {
|
|
@@ -263,7 +203,7 @@ export function Async(FS) {
|
|
|
263
203
|
(_c = (_b = this._sync) === null || _b === void 0 ? void 0 : _b[`${key}Sync`]) === null || _c === void 0 ? void 0 : _c.call(_b, ...args);
|
|
264
204
|
}
|
|
265
205
|
catch (e) {
|
|
266
|
-
throw err(
|
|
206
|
+
throw err(withErrno(e.errno, e.message + ' (Out of sync!)'));
|
|
267
207
|
}
|
|
268
208
|
return result;
|
|
269
209
|
};
|
package/dist/mixins/mutexed.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { UUID } from 'node:crypto';
|
|
2
|
+
import type { Concrete } from 'utilium';
|
|
3
|
+
import type { CreationOptions, FileSystem, StreamOptions, UsageInfo } from '../internal/filesystem.js';
|
|
3
4
|
import type { InodeLike } from '../internal/inode.js';
|
|
4
|
-
import type { Stats } from '../stats.js';
|
|
5
|
-
import type { Concrete } from '../utils.js';
|
|
6
5
|
import '../polyfills.js';
|
|
7
6
|
/**
|
|
8
7
|
* @category Internals
|
|
@@ -27,14 +26,16 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
|
27
26
|
* @internal
|
|
28
27
|
*/
|
|
29
28
|
_fs: T;
|
|
30
|
-
get
|
|
29
|
+
get type(): number;
|
|
31
30
|
get name(): string;
|
|
32
31
|
get label(): string | undefined;
|
|
33
32
|
set label(value: string | undefined);
|
|
34
33
|
get attributes(): import("utilium").ConstMap<import("../internal/filesystem.js").FileSystemAttributes, keyof import("../internal/filesystem.js").FileSystemAttributes, void> & Map<string, any>;
|
|
34
|
+
get _uuid(): UUID;
|
|
35
|
+
set _uuid(value: UUID);
|
|
36
|
+
get uuid(): UUID;
|
|
35
37
|
ready(): Promise<void>;
|
|
36
38
|
usage(): UsageInfo;
|
|
37
|
-
metadata(): FileSystemMetadata;
|
|
38
39
|
/**
|
|
39
40
|
* The current locks
|
|
40
41
|
*/
|
|
@@ -48,13 +49,13 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
|
48
49
|
* If the path is currently locked, waits for it to be unlocked.
|
|
49
50
|
* @internal
|
|
50
51
|
*/
|
|
51
|
-
lock(
|
|
52
|
+
lock(): Promise<MutexLock>;
|
|
52
53
|
/**
|
|
53
54
|
* Locks `path` asynchronously.
|
|
54
55
|
* If the path is currently locked, an error will be thrown
|
|
55
56
|
* @internal
|
|
56
57
|
*/
|
|
57
|
-
lockSync(
|
|
58
|
+
lockSync(): MutexLock;
|
|
58
59
|
/**
|
|
59
60
|
* Whether `path` is locked
|
|
60
61
|
* @internal
|
|
@@ -62,26 +63,26 @@ export declare class _MutexedFS<T extends FileSystem> implements FileSystem {
|
|
|
62
63
|
get isLocked(): boolean;
|
|
63
64
|
rename(oldPath: string, newPath: string): Promise<void>;
|
|
64
65
|
renameSync(oldPath: string, newPath: string): void;
|
|
65
|
-
stat(path: string): Promise<
|
|
66
|
-
statSync(path: string):
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
createFile(path: string,
|
|
70
|
-
createFileSync(path: string,
|
|
66
|
+
stat(path: string): Promise<InodeLike>;
|
|
67
|
+
statSync(path: string): InodeLike;
|
|
68
|
+
touch(path: string, metadata: InodeLike): Promise<void>;
|
|
69
|
+
touchSync(path: string, metadata: InodeLike): void;
|
|
70
|
+
createFile(path: string, options: CreationOptions): Promise<InodeLike>;
|
|
71
|
+
createFileSync(path: string, options: CreationOptions): InodeLike;
|
|
71
72
|
unlink(path: string): Promise<void>;
|
|
72
73
|
unlinkSync(path: string): void;
|
|
73
74
|
rmdir(path: string): Promise<void>;
|
|
74
75
|
rmdirSync(path: string): void;
|
|
75
|
-
mkdir(path: string,
|
|
76
|
-
mkdirSync(path: string,
|
|
76
|
+
mkdir(path: string, options: CreationOptions): Promise<InodeLike>;
|
|
77
|
+
mkdirSync(path: string, options: CreationOptions): InodeLike;
|
|
77
78
|
readdir(path: string): Promise<string[]>;
|
|
78
79
|
readdirSync(path: string): string[];
|
|
79
80
|
exists(path: string): Promise<boolean>;
|
|
80
81
|
existsSync(path: string): boolean;
|
|
81
82
|
link(srcpath: string, dstpath: string): Promise<void>;
|
|
82
83
|
linkSync(srcpath: string, dstpath: string): void;
|
|
83
|
-
sync(
|
|
84
|
-
syncSync(
|
|
84
|
+
sync(): Promise<void>;
|
|
85
|
+
syncSync(): void;
|
|
85
86
|
read(path: string, buffer: Uint8Array, offset: number, end: number): Promise<void>;
|
|
86
87
|
readSync(path: string, buffer: Uint8Array, offset: number, end: number): void;
|
|
87
88
|
write(path: string, buffer: Uint8Array, offset: number): Promise<void>;
|