@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/mutexed.js
CHANGED
|
@@ -50,8 +50,8 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
50
50
|
var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
-
import {
|
|
54
|
-
import { err } from '
|
|
53
|
+
import { withErrno } from 'kerium';
|
|
54
|
+
import { err } from 'kerium/log';
|
|
55
55
|
import '../polyfills.js';
|
|
56
56
|
/**
|
|
57
57
|
* @category Internals
|
|
@@ -84,8 +84,8 @@ export class MutexLock {
|
|
|
84
84
|
* @category Internals
|
|
85
85
|
*/
|
|
86
86
|
export class _MutexedFS {
|
|
87
|
-
get
|
|
88
|
-
return this._fs.
|
|
87
|
+
get type() {
|
|
88
|
+
return this._fs.type;
|
|
89
89
|
}
|
|
90
90
|
get name() {
|
|
91
91
|
return this._fs.name;
|
|
@@ -99,15 +99,21 @@ export class _MutexedFS {
|
|
|
99
99
|
get attributes() {
|
|
100
100
|
return this._fs.attributes;
|
|
101
101
|
}
|
|
102
|
+
get _uuid() {
|
|
103
|
+
return this._fs._uuid;
|
|
104
|
+
}
|
|
105
|
+
set _uuid(value) {
|
|
106
|
+
this._fs._uuid = value;
|
|
107
|
+
}
|
|
108
|
+
get uuid() {
|
|
109
|
+
return this._fs.uuid;
|
|
110
|
+
}
|
|
102
111
|
async ready() {
|
|
103
112
|
return await this._fs.ready();
|
|
104
113
|
}
|
|
105
114
|
usage() {
|
|
106
115
|
return this._fs.usage();
|
|
107
116
|
}
|
|
108
|
-
metadata() {
|
|
109
|
-
return this._fs.metadata();
|
|
110
|
-
}
|
|
111
117
|
/**
|
|
112
118
|
* Adds a lock for a path
|
|
113
119
|
*/
|
|
@@ -121,15 +127,15 @@ export class _MutexedFS {
|
|
|
121
127
|
* If the path is currently locked, waits for it to be unlocked.
|
|
122
128
|
* @internal
|
|
123
129
|
*/
|
|
124
|
-
async lock(
|
|
130
|
+
async lock() {
|
|
125
131
|
const previous = this.currentLock;
|
|
126
132
|
const lock = this.addLock();
|
|
127
133
|
const stack = new Error().stack;
|
|
128
134
|
setTimeout(() => {
|
|
129
135
|
if (lock.isLocked) {
|
|
130
|
-
const error =
|
|
136
|
+
const error = withErrno('EDEADLK');
|
|
131
137
|
error.stack += stack === null || stack === void 0 ? void 0 : stack.slice('Error'.length);
|
|
132
|
-
throw err(error
|
|
138
|
+
throw err(error);
|
|
133
139
|
}
|
|
134
140
|
}, 5000);
|
|
135
141
|
await (previous === null || previous === void 0 ? void 0 : previous.done());
|
|
@@ -140,10 +146,10 @@ export class _MutexedFS {
|
|
|
140
146
|
* If the path is currently locked, an error will be thrown
|
|
141
147
|
* @internal
|
|
142
148
|
*/
|
|
143
|
-
lockSync(
|
|
149
|
+
lockSync() {
|
|
144
150
|
var _a;
|
|
145
151
|
if ((_a = this.currentLock) === null || _a === void 0 ? void 0 : _a.isLocked) {
|
|
146
|
-
throw err(
|
|
152
|
+
throw err(withErrno('EBUSY'));
|
|
147
153
|
}
|
|
148
154
|
return this.addLock();
|
|
149
155
|
}
|
|
@@ -159,7 +165,7 @@ export class _MutexedFS {
|
|
|
159
165
|
async rename(oldPath, newPath) {
|
|
160
166
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
161
167
|
try {
|
|
162
|
-
const _ = __addDisposableResource(env_1, await this.lock(
|
|
168
|
+
const _ = __addDisposableResource(env_1, await this.lock(), false);
|
|
163
169
|
await this._fs.rename(oldPath, newPath);
|
|
164
170
|
}
|
|
165
171
|
catch (e_1) {
|
|
@@ -173,7 +179,7 @@ export class _MutexedFS {
|
|
|
173
179
|
renameSync(oldPath, newPath) {
|
|
174
180
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
175
181
|
try {
|
|
176
|
-
const _ = __addDisposableResource(env_2, this.lockSync(
|
|
182
|
+
const _ = __addDisposableResource(env_2, this.lockSync(), false);
|
|
177
183
|
return this._fs.renameSync(oldPath, newPath);
|
|
178
184
|
}
|
|
179
185
|
catch (e_2) {
|
|
@@ -187,7 +193,7 @@ export class _MutexedFS {
|
|
|
187
193
|
async stat(path) {
|
|
188
194
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
189
195
|
try {
|
|
190
|
-
const _ = __addDisposableResource(env_3, await this.lock(
|
|
196
|
+
const _ = __addDisposableResource(env_3, await this.lock(), false);
|
|
191
197
|
return await this._fs.stat(path);
|
|
192
198
|
}
|
|
193
199
|
catch (e_3) {
|
|
@@ -201,7 +207,7 @@ export class _MutexedFS {
|
|
|
201
207
|
statSync(path) {
|
|
202
208
|
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
203
209
|
try {
|
|
204
|
-
const _ = __addDisposableResource(env_4, this.lockSync(
|
|
210
|
+
const _ = __addDisposableResource(env_4, this.lockSync(), false);
|
|
205
211
|
return this._fs.statSync(path);
|
|
206
212
|
}
|
|
207
213
|
catch (e_4) {
|
|
@@ -212,13 +218,11 @@ export class _MutexedFS {
|
|
|
212
218
|
__disposeResources(env_4);
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
|
-
async
|
|
221
|
+
async touch(path, metadata) {
|
|
216
222
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
217
223
|
try {
|
|
218
|
-
const _ = __addDisposableResource(env_5, await this.lock(
|
|
219
|
-
|
|
220
|
-
file.fs = this;
|
|
221
|
-
return file;
|
|
224
|
+
const _ = __addDisposableResource(env_5, await this.lock(), false);
|
|
225
|
+
await this._fs.touch(path, metadata);
|
|
222
226
|
}
|
|
223
227
|
catch (e_5) {
|
|
224
228
|
env_5.error = e_5;
|
|
@@ -228,13 +232,11 @@ export class _MutexedFS {
|
|
|
228
232
|
__disposeResources(env_5);
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
|
-
|
|
235
|
+
touchSync(path, metadata) {
|
|
232
236
|
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
233
237
|
try {
|
|
234
|
-
const _ = __addDisposableResource(env_6, this.lockSync(
|
|
235
|
-
|
|
236
|
-
file.fs = this;
|
|
237
|
-
return file;
|
|
238
|
+
const _ = __addDisposableResource(env_6, this.lockSync(), false);
|
|
239
|
+
this._fs.touchSync(path, metadata);
|
|
238
240
|
}
|
|
239
241
|
catch (e_6) {
|
|
240
242
|
env_6.error = e_6;
|
|
@@ -244,13 +246,11 @@ export class _MutexedFS {
|
|
|
244
246
|
__disposeResources(env_6);
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
|
-
async createFile(path,
|
|
249
|
+
async createFile(path, options) {
|
|
248
250
|
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
249
251
|
try {
|
|
250
|
-
const _ = __addDisposableResource(env_7, await this.lock(
|
|
251
|
-
|
|
252
|
-
file.fs = this;
|
|
253
|
-
return file;
|
|
252
|
+
const _ = __addDisposableResource(env_7, await this.lock(), false);
|
|
253
|
+
return await this._fs.createFile(path, options);
|
|
254
254
|
}
|
|
255
255
|
catch (e_7) {
|
|
256
256
|
env_7.error = e_7;
|
|
@@ -260,13 +260,11 @@ export class _MutexedFS {
|
|
|
260
260
|
__disposeResources(env_7);
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
createFileSync(path,
|
|
263
|
+
createFileSync(path, options) {
|
|
264
264
|
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
265
265
|
try {
|
|
266
|
-
const _ = __addDisposableResource(env_8, this.lockSync(
|
|
267
|
-
|
|
268
|
-
file.fs = this;
|
|
269
|
-
return file;
|
|
266
|
+
const _ = __addDisposableResource(env_8, this.lockSync(), false);
|
|
267
|
+
return this._fs.createFileSync(path, options);
|
|
270
268
|
}
|
|
271
269
|
catch (e_8) {
|
|
272
270
|
env_8.error = e_8;
|
|
@@ -279,7 +277,7 @@ export class _MutexedFS {
|
|
|
279
277
|
async unlink(path) {
|
|
280
278
|
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
281
279
|
try {
|
|
282
|
-
const _ = __addDisposableResource(env_9, await this.lock(
|
|
280
|
+
const _ = __addDisposableResource(env_9, await this.lock(), false);
|
|
283
281
|
await this._fs.unlink(path);
|
|
284
282
|
}
|
|
285
283
|
catch (e_9) {
|
|
@@ -293,7 +291,7 @@ export class _MutexedFS {
|
|
|
293
291
|
unlinkSync(path) {
|
|
294
292
|
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
295
293
|
try {
|
|
296
|
-
const _ = __addDisposableResource(env_10, this.lockSync(
|
|
294
|
+
const _ = __addDisposableResource(env_10, this.lockSync(), false);
|
|
297
295
|
return this._fs.unlinkSync(path);
|
|
298
296
|
}
|
|
299
297
|
catch (e_10) {
|
|
@@ -307,7 +305,7 @@ export class _MutexedFS {
|
|
|
307
305
|
async rmdir(path) {
|
|
308
306
|
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
309
307
|
try {
|
|
310
|
-
const _ = __addDisposableResource(env_11, await this.lock(
|
|
308
|
+
const _ = __addDisposableResource(env_11, await this.lock(), false);
|
|
311
309
|
await this._fs.rmdir(path);
|
|
312
310
|
}
|
|
313
311
|
catch (e_11) {
|
|
@@ -321,7 +319,7 @@ export class _MutexedFS {
|
|
|
321
319
|
rmdirSync(path) {
|
|
322
320
|
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
323
321
|
try {
|
|
324
|
-
const _ = __addDisposableResource(env_12, this.lockSync(
|
|
322
|
+
const _ = __addDisposableResource(env_12, this.lockSync(), false);
|
|
325
323
|
return this._fs.rmdirSync(path);
|
|
326
324
|
}
|
|
327
325
|
catch (e_12) {
|
|
@@ -332,11 +330,11 @@ export class _MutexedFS {
|
|
|
332
330
|
__disposeResources(env_12);
|
|
333
331
|
}
|
|
334
332
|
}
|
|
335
|
-
async mkdir(path,
|
|
333
|
+
async mkdir(path, options) {
|
|
336
334
|
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
337
335
|
try {
|
|
338
|
-
const _ = __addDisposableResource(env_13, await this.lock(
|
|
339
|
-
await this._fs.mkdir(path,
|
|
336
|
+
const _ = __addDisposableResource(env_13, await this.lock(), false);
|
|
337
|
+
return await this._fs.mkdir(path, options);
|
|
340
338
|
}
|
|
341
339
|
catch (e_13) {
|
|
342
340
|
env_13.error = e_13;
|
|
@@ -346,11 +344,11 @@ export class _MutexedFS {
|
|
|
346
344
|
__disposeResources(env_13);
|
|
347
345
|
}
|
|
348
346
|
}
|
|
349
|
-
mkdirSync(path,
|
|
347
|
+
mkdirSync(path, options) {
|
|
350
348
|
const env_14 = { stack: [], error: void 0, hasError: false };
|
|
351
349
|
try {
|
|
352
|
-
const _ = __addDisposableResource(env_14, this.lockSync(
|
|
353
|
-
return this._fs.mkdirSync(path,
|
|
350
|
+
const _ = __addDisposableResource(env_14, this.lockSync(), false);
|
|
351
|
+
return this._fs.mkdirSync(path, options);
|
|
354
352
|
}
|
|
355
353
|
catch (e_14) {
|
|
356
354
|
env_14.error = e_14;
|
|
@@ -363,7 +361,7 @@ export class _MutexedFS {
|
|
|
363
361
|
async readdir(path) {
|
|
364
362
|
const env_15 = { stack: [], error: void 0, hasError: false };
|
|
365
363
|
try {
|
|
366
|
-
const _ = __addDisposableResource(env_15, await this.lock(
|
|
364
|
+
const _ = __addDisposableResource(env_15, await this.lock(), false);
|
|
367
365
|
return await this._fs.readdir(path);
|
|
368
366
|
}
|
|
369
367
|
catch (e_15) {
|
|
@@ -377,7 +375,7 @@ export class _MutexedFS {
|
|
|
377
375
|
readdirSync(path) {
|
|
378
376
|
const env_16 = { stack: [], error: void 0, hasError: false };
|
|
379
377
|
try {
|
|
380
|
-
const _ = __addDisposableResource(env_16, this.lockSync(
|
|
378
|
+
const _ = __addDisposableResource(env_16, this.lockSync(), false);
|
|
381
379
|
return this._fs.readdirSync(path);
|
|
382
380
|
}
|
|
383
381
|
catch (e_16) {
|
|
@@ -391,7 +389,7 @@ export class _MutexedFS {
|
|
|
391
389
|
async exists(path) {
|
|
392
390
|
const env_17 = { stack: [], error: void 0, hasError: false };
|
|
393
391
|
try {
|
|
394
|
-
const _ = __addDisposableResource(env_17, await this.lock(
|
|
392
|
+
const _ = __addDisposableResource(env_17, await this.lock(), false);
|
|
395
393
|
return await this._fs.exists(path);
|
|
396
394
|
}
|
|
397
395
|
catch (e_17) {
|
|
@@ -405,7 +403,7 @@ export class _MutexedFS {
|
|
|
405
403
|
existsSync(path) {
|
|
406
404
|
const env_18 = { stack: [], error: void 0, hasError: false };
|
|
407
405
|
try {
|
|
408
|
-
const _ = __addDisposableResource(env_18, this.lockSync(
|
|
406
|
+
const _ = __addDisposableResource(env_18, this.lockSync(), false);
|
|
409
407
|
return this._fs.existsSync(path);
|
|
410
408
|
}
|
|
411
409
|
catch (e_18) {
|
|
@@ -419,7 +417,7 @@ export class _MutexedFS {
|
|
|
419
417
|
async link(srcpath, dstpath) {
|
|
420
418
|
const env_19 = { stack: [], error: void 0, hasError: false };
|
|
421
419
|
try {
|
|
422
|
-
const _ = __addDisposableResource(env_19, await this.lock(
|
|
420
|
+
const _ = __addDisposableResource(env_19, await this.lock(), false);
|
|
423
421
|
await this._fs.link(srcpath, dstpath);
|
|
424
422
|
}
|
|
425
423
|
catch (e_19) {
|
|
@@ -433,7 +431,7 @@ export class _MutexedFS {
|
|
|
433
431
|
linkSync(srcpath, dstpath) {
|
|
434
432
|
const env_20 = { stack: [], error: void 0, hasError: false };
|
|
435
433
|
try {
|
|
436
|
-
const _ = __addDisposableResource(env_20, this.lockSync(
|
|
434
|
+
const _ = __addDisposableResource(env_20, this.lockSync(), false);
|
|
437
435
|
return this._fs.linkSync(srcpath, dstpath);
|
|
438
436
|
}
|
|
439
437
|
catch (e_20) {
|
|
@@ -444,11 +442,11 @@ export class _MutexedFS {
|
|
|
444
442
|
__disposeResources(env_20);
|
|
445
443
|
}
|
|
446
444
|
}
|
|
447
|
-
async sync(
|
|
445
|
+
async sync() {
|
|
448
446
|
const env_21 = { stack: [], error: void 0, hasError: false };
|
|
449
447
|
try {
|
|
450
|
-
const _ = __addDisposableResource(env_21, await this.lock(
|
|
451
|
-
await this._fs.sync(
|
|
448
|
+
const _ = __addDisposableResource(env_21, await this.lock(), false);
|
|
449
|
+
await this._fs.sync();
|
|
452
450
|
}
|
|
453
451
|
catch (e_21) {
|
|
454
452
|
env_21.error = e_21;
|
|
@@ -458,11 +456,11 @@ export class _MutexedFS {
|
|
|
458
456
|
__disposeResources(env_21);
|
|
459
457
|
}
|
|
460
458
|
}
|
|
461
|
-
syncSync(
|
|
459
|
+
syncSync() {
|
|
462
460
|
const env_22 = { stack: [], error: void 0, hasError: false };
|
|
463
461
|
try {
|
|
464
|
-
const _ = __addDisposableResource(env_22, this.lockSync(
|
|
465
|
-
return this._fs.syncSync(
|
|
462
|
+
const _ = __addDisposableResource(env_22, this.lockSync(), false);
|
|
463
|
+
return this._fs.syncSync();
|
|
466
464
|
}
|
|
467
465
|
catch (e_22) {
|
|
468
466
|
env_22.error = e_22;
|
|
@@ -475,7 +473,7 @@ export class _MutexedFS {
|
|
|
475
473
|
async read(path, buffer, offset, end) {
|
|
476
474
|
const env_23 = { stack: [], error: void 0, hasError: false };
|
|
477
475
|
try {
|
|
478
|
-
const _ = __addDisposableResource(env_23, await this.lock(
|
|
476
|
+
const _ = __addDisposableResource(env_23, await this.lock(), false);
|
|
479
477
|
return await this._fs.read(path, buffer, offset, end);
|
|
480
478
|
}
|
|
481
479
|
catch (e_23) {
|
|
@@ -489,7 +487,7 @@ export class _MutexedFS {
|
|
|
489
487
|
readSync(path, buffer, offset, end) {
|
|
490
488
|
const env_24 = { stack: [], error: void 0, hasError: false };
|
|
491
489
|
try {
|
|
492
|
-
const _ = __addDisposableResource(env_24, this.lockSync(
|
|
490
|
+
const _ = __addDisposableResource(env_24, this.lockSync(), false);
|
|
493
491
|
return this._fs.readSync(path, buffer, offset, end);
|
|
494
492
|
}
|
|
495
493
|
catch (e_24) {
|
|
@@ -503,7 +501,7 @@ export class _MutexedFS {
|
|
|
503
501
|
async write(path, buffer, offset) {
|
|
504
502
|
const env_25 = { stack: [], error: void 0, hasError: false };
|
|
505
503
|
try {
|
|
506
|
-
const _ = __addDisposableResource(env_25, await this.lock(
|
|
504
|
+
const _ = __addDisposableResource(env_25, await this.lock(), false);
|
|
507
505
|
return await this._fs.write(path, buffer, offset);
|
|
508
506
|
}
|
|
509
507
|
catch (e_25) {
|
|
@@ -517,7 +515,7 @@ export class _MutexedFS {
|
|
|
517
515
|
writeSync(path, buffer, offset) {
|
|
518
516
|
const env_26 = { stack: [], error: void 0, hasError: false };
|
|
519
517
|
try {
|
|
520
|
-
const _ = __addDisposableResource(env_26, this.lockSync(
|
|
518
|
+
const _ = __addDisposableResource(env_26, this.lockSync(), false);
|
|
521
519
|
return this._fs.writeSync(path, buffer, offset);
|
|
522
520
|
}
|
|
523
521
|
catch (e_26) {
|
|
@@ -531,7 +529,7 @@ export class _MutexedFS {
|
|
|
531
529
|
streamRead(path, options) {
|
|
532
530
|
const env_27 = { stack: [], error: void 0, hasError: false };
|
|
533
531
|
try {
|
|
534
|
-
const _ = __addDisposableResource(env_27, this.lockSync(
|
|
532
|
+
const _ = __addDisposableResource(env_27, this.lockSync(), false);
|
|
535
533
|
return this._fs.streamRead(path, options);
|
|
536
534
|
}
|
|
537
535
|
catch (e_27) {
|
|
@@ -545,7 +543,7 @@ export class _MutexedFS {
|
|
|
545
543
|
streamWrite(path, options) {
|
|
546
544
|
const env_28 = { stack: [], error: void 0, hasError: false };
|
|
547
545
|
try {
|
|
548
|
-
const _ = __addDisposableResource(env_28, this.lockSync(
|
|
546
|
+
const _ = __addDisposableResource(env_28, this.lockSync(), false);
|
|
549
547
|
return this._fs.streamWrite(path, options);
|
|
550
548
|
}
|
|
551
549
|
catch (e_28) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { FileSystem
|
|
2
|
-
import type {
|
|
1
|
+
import type { FileSystem } from '../internal/filesystem.js';
|
|
2
|
+
import type { InodeLike } from '../internal/inode.js';
|
|
3
3
|
import type { Mixin } from './shared.js';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
7
|
export interface ReadonlyMixin {
|
|
8
|
-
metadata(): FileSystemMetadata;
|
|
9
8
|
rename(oldPath: string, newPath: string): Promise<never>;
|
|
10
9
|
renameSync(oldPath: string, newPath: string): never;
|
|
11
10
|
createFile(path: string, flag: string, mode: number): Promise<never>;
|
|
@@ -18,10 +17,12 @@ export interface ReadonlyMixin {
|
|
|
18
17
|
mkdirSync(path: string, mode: number): never;
|
|
19
18
|
link(srcpath: string, dstpath: string): Promise<never>;
|
|
20
19
|
linkSync(srcpath: string, dstpath: string): never;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
touch(path: string, metadata: Readonly<InodeLike>): Promise<never>;
|
|
21
|
+
touchSync(path: string, metadata: Readonly<InodeLike>): never;
|
|
22
|
+
sync(): Promise<never>;
|
|
23
|
+
syncSync(): never;
|
|
23
24
|
write(path: string, buffer: Uint8Array, offset: number): Promise<never>;
|
|
24
|
-
writeSync(path: string, buffer: Uint8Array, offset: number):
|
|
25
|
+
writeSync(path: string, buffer: Uint8Array, offset: number): never;
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
27
28
|
* Implements the non-readonly methods to throw `EROFS`
|
package/dist/mixins/readonly.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withErrno } from 'kerium';
|
|
2
2
|
/**
|
|
3
3
|
* Implements the non-readonly methods to throw `EROFS`
|
|
4
4
|
* @category Internals
|
|
@@ -11,55 +11,61 @@ export function Readonly(FS) {
|
|
|
11
11
|
this.attributes.set('no_write');
|
|
12
12
|
}
|
|
13
13
|
async rename() {
|
|
14
|
-
throw
|
|
14
|
+
throw withErrno('EROFS');
|
|
15
15
|
}
|
|
16
16
|
renameSync() {
|
|
17
|
-
throw
|
|
17
|
+
throw withErrno('EROFS');
|
|
18
18
|
}
|
|
19
19
|
async createFile() {
|
|
20
|
-
throw
|
|
20
|
+
throw withErrno('EROFS');
|
|
21
21
|
}
|
|
22
22
|
createFileSync() {
|
|
23
|
-
throw
|
|
23
|
+
throw withErrno('EROFS');
|
|
24
24
|
}
|
|
25
25
|
async unlink() {
|
|
26
|
-
throw
|
|
26
|
+
throw withErrno('EROFS');
|
|
27
27
|
}
|
|
28
28
|
unlinkSync() {
|
|
29
|
-
throw
|
|
29
|
+
throw withErrno('EROFS');
|
|
30
30
|
}
|
|
31
31
|
async rmdir() {
|
|
32
|
-
throw
|
|
32
|
+
throw withErrno('EROFS');
|
|
33
33
|
}
|
|
34
34
|
rmdirSync() {
|
|
35
|
-
throw
|
|
35
|
+
throw withErrno('EROFS');
|
|
36
36
|
}
|
|
37
37
|
async mkdir() {
|
|
38
|
-
throw
|
|
38
|
+
throw withErrno('EROFS');
|
|
39
39
|
}
|
|
40
40
|
mkdirSync() {
|
|
41
|
-
throw
|
|
41
|
+
throw withErrno('EROFS');
|
|
42
42
|
}
|
|
43
43
|
async link() {
|
|
44
|
-
throw
|
|
44
|
+
throw withErrno('EROFS');
|
|
45
45
|
}
|
|
46
46
|
linkSync() {
|
|
47
|
-
throw
|
|
47
|
+
throw withErrno('EROFS');
|
|
48
|
+
}
|
|
49
|
+
async touch() {
|
|
50
|
+
throw withErrno('EROFS');
|
|
51
|
+
}
|
|
52
|
+
touchSync() {
|
|
53
|
+
throw withErrno('EROFS');
|
|
48
54
|
}
|
|
49
55
|
async sync() {
|
|
50
|
-
throw
|
|
56
|
+
throw withErrno('EROFS');
|
|
51
57
|
}
|
|
52
58
|
syncSync() {
|
|
53
|
-
throw
|
|
59
|
+
throw withErrno('EROFS');
|
|
54
60
|
}
|
|
55
61
|
async write() {
|
|
56
|
-
throw
|
|
62
|
+
throw withErrno('EROFS');
|
|
57
63
|
}
|
|
58
64
|
writeSync() {
|
|
59
|
-
throw
|
|
65
|
+
throw withErrno('EROFS');
|
|
60
66
|
}
|
|
61
67
|
streamWrite() {
|
|
62
|
-
throw
|
|
68
|
+
throw withErrno('EROFS');
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
return ReadonlyFS;
|
package/dist/mixins/sync.js
CHANGED
|
@@ -14,11 +14,11 @@ export function Sync(FS) {
|
|
|
14
14
|
async stat(path) {
|
|
15
15
|
return this.statSync(path);
|
|
16
16
|
}
|
|
17
|
-
async
|
|
18
|
-
return this.
|
|
17
|
+
async touch(path, metadata) {
|
|
18
|
+
return this.touchSync(path, metadata);
|
|
19
19
|
}
|
|
20
|
-
async
|
|
21
|
-
return this.
|
|
20
|
+
async createFile(path, options) {
|
|
21
|
+
return this.createFileSync(path, options);
|
|
22
22
|
}
|
|
23
23
|
async unlink(path) {
|
|
24
24
|
return this.unlinkSync(path);
|
|
@@ -26,8 +26,8 @@ export function Sync(FS) {
|
|
|
26
26
|
async rmdir(path) {
|
|
27
27
|
return this.rmdirSync(path);
|
|
28
28
|
}
|
|
29
|
-
async mkdir(path,
|
|
30
|
-
return this.mkdirSync(path,
|
|
29
|
+
async mkdir(path, options) {
|
|
30
|
+
return this.mkdirSync(path, options);
|
|
31
31
|
}
|
|
32
32
|
async readdir(path) {
|
|
33
33
|
return this.readdirSync(path);
|
|
@@ -35,8 +35,8 @@ export function Sync(FS) {
|
|
|
35
35
|
async link(srcpath, dstpath) {
|
|
36
36
|
return this.linkSync(srcpath, dstpath);
|
|
37
37
|
}
|
|
38
|
-
async sync(
|
|
39
|
-
return this.syncSync(
|
|
38
|
+
async sync() {
|
|
39
|
+
return this.syncSync();
|
|
40
40
|
}
|
|
41
41
|
async read(path, buffer, offset, end) {
|
|
42
42
|
return this.readSync(path, buffer, offset, end);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ParsedPath } from 'node:path';
|
|
2
|
+
import type { V_Context } from './context.js';
|
|
2
3
|
export type AbsolutePath = `/${string}`;
|
|
3
|
-
export declare let cwd: string;
|
|
4
|
-
export declare function cd(path: string): void;
|
|
5
4
|
export declare const sep = "/";
|
|
6
5
|
export declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
|
7
6
|
export declare function formatExt(ext: string): string;
|
|
8
|
-
export declare function resolve(...parts: string[]): AbsolutePath;
|
|
7
|
+
export declare function resolve(this: V_Context, ...parts: (string | undefined)[]): AbsolutePath;
|
|
9
8
|
export declare function normalize(path: string): string;
|
|
10
9
|
export declare function isAbsolute(path: string): path is AbsolutePath;
|
|
11
10
|
export declare function join(...parts: string[]): string;
|
|
12
|
-
export declare function relative(from: string, to: string): string;
|
|
11
|
+
export declare function relative(this: V_Context, from: string, to: string): string;
|
|
13
12
|
export declare function dirname(path: string): string;
|
|
14
13
|
export declare function basename(path: string, suffix?: string): string;
|
|
15
14
|
export declare function extname(path: string): string;
|
|
@@ -20,10 +20,7 @@ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
20
20
|
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
21
21
|
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
export function cd(path) {
|
|
25
|
-
cwd = resolve(cwd, path);
|
|
26
|
-
}
|
|
23
|
+
import { defaultContext } from './internal/contexts.js';
|
|
27
24
|
export const sep = '/';
|
|
28
25
|
function validateObject(str, name) {
|
|
29
26
|
if (typeof str != 'object') {
|
|
@@ -103,11 +100,11 @@ export function formatExt(ext) {
|
|
|
103
100
|
return ext ? `${ext[0] === '.' ? '' : '.'}${ext}` : '';
|
|
104
101
|
}
|
|
105
102
|
export function resolve(...parts) {
|
|
103
|
+
var _a;
|
|
106
104
|
let resolved = '';
|
|
107
|
-
for (const part of [...parts.reverse(),
|
|
108
|
-
if (!part.length)
|
|
105
|
+
for (const part of [...parts.reverse(), (_a = this === null || this === void 0 ? void 0 : this.pwd) !== null && _a !== void 0 ? _a : defaultContext.pwd]) {
|
|
106
|
+
if (!(part === null || part === void 0 ? void 0 : part.length))
|
|
109
107
|
continue;
|
|
110
|
-
}
|
|
111
108
|
resolved = `${part}/${resolved}`;
|
|
112
109
|
if (part.startsWith('/')) {
|
|
113
110
|
break;
|
|
@@ -154,8 +151,8 @@ export function relative(from, to) {
|
|
|
154
151
|
if (from === to)
|
|
155
152
|
return '';
|
|
156
153
|
// Trim leading forward slashes.
|
|
157
|
-
from = resolve(from);
|
|
158
|
-
to = resolve(to);
|
|
154
|
+
from = resolve.call(this, from);
|
|
155
|
+
to = resolve.call(this, to);
|
|
159
156
|
if (from === to)
|
|
160
157
|
return '';
|
|
161
158
|
const fromStart = 1;
|
package/dist/polyfills.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* node:coverage disable */
|
|
2
2
|
var _a, _b, _c;
|
|
3
|
-
import { warn } from '
|
|
3
|
+
import { warn } from 'kerium/log';
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
5
5
|
(_a = Promise.withResolvers) !== null && _a !== void 0 ? _a : (Promise.withResolvers = (warn('Using a polyfill of Promise.withResolvers'),
|
|
6
6
|
function () {
|