@zenfs/core 0.17.0 → 0.18.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 +2 -3
- package/dist/backends/fetch.js +2 -2
- package/dist/backends/file_index.d.ts +14 -15
- package/dist/backends/file_index.js +3 -9
- package/dist/backends/overlay.d.ts +21 -22
- package/dist/backends/overlay.js +111 -114
- package/dist/backends/port/fs.d.ts +21 -22
- package/dist/backends/port/fs.js +23 -23
- package/dist/backends/store/fs.d.ts +20 -21
- package/dist/backends/store/fs.js +70 -138
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/config.js +2 -2
- package/dist/{cred.d.ts → credentials.d.ts} +3 -2
- package/dist/credentials.js +16 -0
- package/dist/emulation/async.d.ts +20 -5
- package/dist/emulation/async.js +57 -9
- package/dist/emulation/dir.d.ts +4 -7
- package/dist/emulation/dir.js +16 -24
- package/dist/emulation/promises.d.ts +3 -3
- package/dist/emulation/promises.js +103 -46
- package/dist/emulation/shared.d.ts +0 -3
- package/dist/emulation/shared.js +0 -6
- package/dist/emulation/sync.d.ts +3 -4
- package/dist/emulation/sync.js +107 -65
- package/dist/emulation/watchers.d.ts +40 -3
- package/dist/emulation/watchers.js +115 -9
- package/dist/error.d.ts +1 -1
- package/dist/error.js +1 -1
- package/dist/filesystem.d.ts +23 -24
- package/dist/filesystem.js +6 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/mixins/async.d.ts +13 -14
- package/dist/mixins/async.js +45 -47
- package/dist/mixins/index.d.ts +4 -0
- package/dist/mixins/index.js +4 -0
- package/dist/mixins/mutexed.d.ts +1 -1
- package/dist/mixins/mutexed.js +61 -53
- package/dist/mixins/readonly.d.ts +14 -15
- package/dist/mixins/readonly.js +12 -12
- package/dist/mixins/sync.js +20 -20
- package/dist/stats.d.ts +12 -5
- package/dist/stats.js +11 -2
- package/dist/utils.d.ts +3 -9
- package/dist/utils.js +7 -24
- package/package.json +4 -3
- package/src/backends/backend.ts +2 -3
- package/src/backends/fetch.ts +2 -2
- package/src/backends/file_index.ts +3 -12
- package/src/backends/overlay.ts +112 -116
- package/src/backends/port/fs.ts +25 -26
- package/src/backends/store/fs.ts +72 -151
- package/src/config.ts +3 -2
- package/src/{cred.ts → credentials.ts} +11 -2
- package/src/emulation/async.ts +76 -18
- package/src/emulation/dir.ts +21 -29
- package/src/emulation/promises.ts +107 -46
- package/src/emulation/shared.ts +0 -8
- package/src/emulation/sync.ts +109 -66
- package/src/emulation/watchers.ts +140 -10
- package/src/error.ts +1 -1
- package/src/filesystem.ts +25 -26
- package/src/index.ts +2 -1
- package/src/mixins/async.ts +54 -55
- package/src/mixins/index.ts +4 -0
- package/src/mixins/mutexed.ts +62 -55
- package/src/mixins/readonly.ts +26 -27
- package/src/mixins/sync.ts +22 -23
- package/src/stats.ts +15 -5
- package/src/utils.ts +9 -34
- package/dist/cred.js +0 -8
package/dist/mixins/mutexed.js
CHANGED
|
@@ -106,9 +106,17 @@ export function Mutexed(FS) {
|
|
|
106
106
|
* If the path is currently locked, waits for it to be unlocked.
|
|
107
107
|
* @internal
|
|
108
108
|
*/
|
|
109
|
-
async lock(path) {
|
|
109
|
+
async lock(path, syscall) {
|
|
110
110
|
const previous = this.locks.get(path);
|
|
111
111
|
const lock = this.addLock(path);
|
|
112
|
+
const stack = new Error().stack;
|
|
113
|
+
setTimeout(() => {
|
|
114
|
+
if (lock.isLocked) {
|
|
115
|
+
const error = ErrnoError.With('EDEADLK', path, syscall);
|
|
116
|
+
error.stack += stack?.slice('Error'.length);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}, 5000);
|
|
112
120
|
await previous?.done();
|
|
113
121
|
return lock;
|
|
114
122
|
}
|
|
@@ -120,7 +128,7 @@ export function Mutexed(FS) {
|
|
|
120
128
|
lockSync(path) {
|
|
121
129
|
if (this.locks.has(path)) {
|
|
122
130
|
// Non-null assertion: we already checked locks has path
|
|
123
|
-
throw ErrnoError.With('EBUSY', path, '
|
|
131
|
+
throw ErrnoError.With('EBUSY', path, 'lock');
|
|
124
132
|
}
|
|
125
133
|
return this.addLock(path);
|
|
126
134
|
}
|
|
@@ -132,12 +140,12 @@ export function Mutexed(FS) {
|
|
|
132
140
|
return !!this.locks.get(path)?.isLocked;
|
|
133
141
|
}
|
|
134
142
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
135
|
-
async rename(oldPath, newPath
|
|
143
|
+
async rename(oldPath, newPath) {
|
|
136
144
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
137
145
|
try {
|
|
138
|
-
const _ = __addDisposableResource(env_1, await this.lock(oldPath), false);
|
|
146
|
+
const _ = __addDisposableResource(env_1, await this.lock(oldPath, 'rename'), false);
|
|
139
147
|
// @ts-expect-error 2513
|
|
140
|
-
await super.rename(oldPath, newPath
|
|
148
|
+
await super.rename(oldPath, newPath);
|
|
141
149
|
}
|
|
142
150
|
catch (e_1) {
|
|
143
151
|
env_1.error = e_1;
|
|
@@ -147,12 +155,12 @@ export function Mutexed(FS) {
|
|
|
147
155
|
__disposeResources(env_1);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
|
-
renameSync(oldPath, newPath
|
|
158
|
+
renameSync(oldPath, newPath) {
|
|
151
159
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
152
160
|
try {
|
|
153
161
|
const _ = __addDisposableResource(env_2, this.lockSync(oldPath), false);
|
|
154
162
|
// @ts-expect-error 2513
|
|
155
|
-
return super.renameSync(oldPath, newPath
|
|
163
|
+
return super.renameSync(oldPath, newPath);
|
|
156
164
|
}
|
|
157
165
|
catch (e_2) {
|
|
158
166
|
env_2.error = e_2;
|
|
@@ -162,12 +170,12 @@ export function Mutexed(FS) {
|
|
|
162
170
|
__disposeResources(env_2);
|
|
163
171
|
}
|
|
164
172
|
}
|
|
165
|
-
async stat(path
|
|
173
|
+
async stat(path) {
|
|
166
174
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
167
175
|
try {
|
|
168
|
-
const _ = __addDisposableResource(env_3, await this.lock(path), false);
|
|
176
|
+
const _ = __addDisposableResource(env_3, await this.lock(path, 'stat'), false);
|
|
169
177
|
// @ts-expect-error 2513
|
|
170
|
-
return await super.stat(path
|
|
178
|
+
return await super.stat(path);
|
|
171
179
|
}
|
|
172
180
|
catch (e_3) {
|
|
173
181
|
env_3.error = e_3;
|
|
@@ -177,12 +185,12 @@ export function Mutexed(FS) {
|
|
|
177
185
|
__disposeResources(env_3);
|
|
178
186
|
}
|
|
179
187
|
}
|
|
180
|
-
statSync(path
|
|
188
|
+
statSync(path) {
|
|
181
189
|
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
182
190
|
try {
|
|
183
191
|
const _ = __addDisposableResource(env_4, this.lockSync(path), false);
|
|
184
192
|
// @ts-expect-error 2513
|
|
185
|
-
return super.statSync(path
|
|
193
|
+
return super.statSync(path);
|
|
186
194
|
}
|
|
187
195
|
catch (e_4) {
|
|
188
196
|
env_4.error = e_4;
|
|
@@ -192,12 +200,12 @@ export function Mutexed(FS) {
|
|
|
192
200
|
__disposeResources(env_4);
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
|
-
async openFile(path, flag
|
|
203
|
+
async openFile(path, flag) {
|
|
196
204
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
197
205
|
try {
|
|
198
|
-
const _ = __addDisposableResource(env_5, await this.lock(path), false);
|
|
206
|
+
const _ = __addDisposableResource(env_5, await this.lock(path, 'openFile'), false);
|
|
199
207
|
// @ts-expect-error 2513
|
|
200
|
-
return await super.openFile(path, flag
|
|
208
|
+
return await super.openFile(path, flag);
|
|
201
209
|
}
|
|
202
210
|
catch (e_5) {
|
|
203
211
|
env_5.error = e_5;
|
|
@@ -207,12 +215,12 @@ export function Mutexed(FS) {
|
|
|
207
215
|
__disposeResources(env_5);
|
|
208
216
|
}
|
|
209
217
|
}
|
|
210
|
-
openFileSync(path, flag
|
|
218
|
+
openFileSync(path, flag) {
|
|
211
219
|
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
212
220
|
try {
|
|
213
221
|
const _ = __addDisposableResource(env_6, this.lockSync(path), false);
|
|
214
222
|
// @ts-expect-error 2513
|
|
215
|
-
return super.openFileSync(path, flag
|
|
223
|
+
return super.openFileSync(path, flag);
|
|
216
224
|
}
|
|
217
225
|
catch (e_6) {
|
|
218
226
|
env_6.error = e_6;
|
|
@@ -222,12 +230,12 @@ export function Mutexed(FS) {
|
|
|
222
230
|
__disposeResources(env_6);
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
|
-
async createFile(path, flag, mode
|
|
233
|
+
async createFile(path, flag, mode) {
|
|
226
234
|
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
227
235
|
try {
|
|
228
|
-
const _ = __addDisposableResource(env_7, await this.lock(path), false);
|
|
236
|
+
const _ = __addDisposableResource(env_7, await this.lock(path, 'createFile'), false);
|
|
229
237
|
// @ts-expect-error 2513
|
|
230
|
-
return await super.createFile(path, flag, mode
|
|
238
|
+
return await super.createFile(path, flag, mode);
|
|
231
239
|
}
|
|
232
240
|
catch (e_7) {
|
|
233
241
|
env_7.error = e_7;
|
|
@@ -237,12 +245,12 @@ export function Mutexed(FS) {
|
|
|
237
245
|
__disposeResources(env_7);
|
|
238
246
|
}
|
|
239
247
|
}
|
|
240
|
-
createFileSync(path, flag, mode
|
|
248
|
+
createFileSync(path, flag, mode) {
|
|
241
249
|
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
242
250
|
try {
|
|
243
251
|
const _ = __addDisposableResource(env_8, this.lockSync(path), false);
|
|
244
252
|
// @ts-expect-error 2513
|
|
245
|
-
return super.createFileSync(path, flag, mode
|
|
253
|
+
return super.createFileSync(path, flag, mode);
|
|
246
254
|
}
|
|
247
255
|
catch (e_8) {
|
|
248
256
|
env_8.error = e_8;
|
|
@@ -252,12 +260,12 @@ export function Mutexed(FS) {
|
|
|
252
260
|
__disposeResources(env_8);
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
|
-
async unlink(path
|
|
263
|
+
async unlink(path) {
|
|
256
264
|
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
257
265
|
try {
|
|
258
|
-
const _ = __addDisposableResource(env_9, await this.lock(path), false);
|
|
266
|
+
const _ = __addDisposableResource(env_9, await this.lock(path, 'unlink'), false);
|
|
259
267
|
// @ts-expect-error 2513
|
|
260
|
-
await super.unlink(path
|
|
268
|
+
await super.unlink(path);
|
|
261
269
|
}
|
|
262
270
|
catch (e_9) {
|
|
263
271
|
env_9.error = e_9;
|
|
@@ -267,12 +275,12 @@ export function Mutexed(FS) {
|
|
|
267
275
|
__disposeResources(env_9);
|
|
268
276
|
}
|
|
269
277
|
}
|
|
270
|
-
unlinkSync(path
|
|
278
|
+
unlinkSync(path) {
|
|
271
279
|
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
272
280
|
try {
|
|
273
281
|
const _ = __addDisposableResource(env_10, this.lockSync(path), false);
|
|
274
282
|
// @ts-expect-error 2513
|
|
275
|
-
return super.unlinkSync(path
|
|
283
|
+
return super.unlinkSync(path);
|
|
276
284
|
}
|
|
277
285
|
catch (e_10) {
|
|
278
286
|
env_10.error = e_10;
|
|
@@ -282,12 +290,12 @@ export function Mutexed(FS) {
|
|
|
282
290
|
__disposeResources(env_10);
|
|
283
291
|
}
|
|
284
292
|
}
|
|
285
|
-
async rmdir(path
|
|
293
|
+
async rmdir(path) {
|
|
286
294
|
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
287
295
|
try {
|
|
288
|
-
const _ = __addDisposableResource(env_11, await this.lock(path), false);
|
|
296
|
+
const _ = __addDisposableResource(env_11, await this.lock(path, 'rmdir'), false);
|
|
289
297
|
// @ts-expect-error 2513
|
|
290
|
-
await super.rmdir(path
|
|
298
|
+
await super.rmdir(path);
|
|
291
299
|
}
|
|
292
300
|
catch (e_11) {
|
|
293
301
|
env_11.error = e_11;
|
|
@@ -297,12 +305,12 @@ export function Mutexed(FS) {
|
|
|
297
305
|
__disposeResources(env_11);
|
|
298
306
|
}
|
|
299
307
|
}
|
|
300
|
-
rmdirSync(path
|
|
308
|
+
rmdirSync(path) {
|
|
301
309
|
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
302
310
|
try {
|
|
303
311
|
const _ = __addDisposableResource(env_12, this.lockSync(path), false);
|
|
304
312
|
// @ts-expect-error 2513
|
|
305
|
-
return super.rmdirSync(path
|
|
313
|
+
return super.rmdirSync(path);
|
|
306
314
|
}
|
|
307
315
|
catch (e_12) {
|
|
308
316
|
env_12.error = e_12;
|
|
@@ -312,12 +320,12 @@ export function Mutexed(FS) {
|
|
|
312
320
|
__disposeResources(env_12);
|
|
313
321
|
}
|
|
314
322
|
}
|
|
315
|
-
async mkdir(path, mode
|
|
323
|
+
async mkdir(path, mode) {
|
|
316
324
|
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
317
325
|
try {
|
|
318
|
-
const _ = __addDisposableResource(env_13, await this.lock(path), false);
|
|
326
|
+
const _ = __addDisposableResource(env_13, await this.lock(path, 'mkdir'), false);
|
|
319
327
|
// @ts-expect-error 2513
|
|
320
|
-
await super.mkdir(path, mode
|
|
328
|
+
await super.mkdir(path, mode);
|
|
321
329
|
}
|
|
322
330
|
catch (e_13) {
|
|
323
331
|
env_13.error = e_13;
|
|
@@ -327,12 +335,12 @@ export function Mutexed(FS) {
|
|
|
327
335
|
__disposeResources(env_13);
|
|
328
336
|
}
|
|
329
337
|
}
|
|
330
|
-
mkdirSync(path, mode
|
|
338
|
+
mkdirSync(path, mode) {
|
|
331
339
|
const env_14 = { stack: [], error: void 0, hasError: false };
|
|
332
340
|
try {
|
|
333
341
|
const _ = __addDisposableResource(env_14, this.lockSync(path), false);
|
|
334
342
|
// @ts-expect-error 2513
|
|
335
|
-
return super.mkdirSync(path, mode
|
|
343
|
+
return super.mkdirSync(path, mode);
|
|
336
344
|
}
|
|
337
345
|
catch (e_14) {
|
|
338
346
|
env_14.error = e_14;
|
|
@@ -342,12 +350,12 @@ export function Mutexed(FS) {
|
|
|
342
350
|
__disposeResources(env_14);
|
|
343
351
|
}
|
|
344
352
|
}
|
|
345
|
-
async readdir(path
|
|
353
|
+
async readdir(path) {
|
|
346
354
|
const env_15 = { stack: [], error: void 0, hasError: false };
|
|
347
355
|
try {
|
|
348
|
-
const _ = __addDisposableResource(env_15, await this.lock(path), false);
|
|
356
|
+
const _ = __addDisposableResource(env_15, await this.lock(path, 'readdir'), false);
|
|
349
357
|
// @ts-expect-error 2513
|
|
350
|
-
return await super.readdir(path
|
|
358
|
+
return await super.readdir(path);
|
|
351
359
|
}
|
|
352
360
|
catch (e_15) {
|
|
353
361
|
env_15.error = e_15;
|
|
@@ -357,12 +365,12 @@ export function Mutexed(FS) {
|
|
|
357
365
|
__disposeResources(env_15);
|
|
358
366
|
}
|
|
359
367
|
}
|
|
360
|
-
readdirSync(path
|
|
368
|
+
readdirSync(path) {
|
|
361
369
|
const env_16 = { stack: [], error: void 0, hasError: false };
|
|
362
370
|
try {
|
|
363
371
|
const _ = __addDisposableResource(env_16, this.lockSync(path), false);
|
|
364
372
|
// @ts-expect-error 2513
|
|
365
|
-
return super.readdirSync(path
|
|
373
|
+
return super.readdirSync(path);
|
|
366
374
|
}
|
|
367
375
|
catch (e_16) {
|
|
368
376
|
env_16.error = e_16;
|
|
@@ -372,11 +380,11 @@ export function Mutexed(FS) {
|
|
|
372
380
|
__disposeResources(env_16);
|
|
373
381
|
}
|
|
374
382
|
}
|
|
375
|
-
async exists(path
|
|
383
|
+
async exists(path) {
|
|
376
384
|
const env_17 = { stack: [], error: void 0, hasError: false };
|
|
377
385
|
try {
|
|
378
|
-
const _ = __addDisposableResource(env_17, await this.lock(path), false);
|
|
379
|
-
return await super.exists(path
|
|
386
|
+
const _ = __addDisposableResource(env_17, await this.lock(path, 'exists'), false);
|
|
387
|
+
return await super.exists(path);
|
|
380
388
|
}
|
|
381
389
|
catch (e_17) {
|
|
382
390
|
env_17.error = e_17;
|
|
@@ -386,11 +394,11 @@ export function Mutexed(FS) {
|
|
|
386
394
|
__disposeResources(env_17);
|
|
387
395
|
}
|
|
388
396
|
}
|
|
389
|
-
existsSync(path
|
|
397
|
+
existsSync(path) {
|
|
390
398
|
const env_18 = { stack: [], error: void 0, hasError: false };
|
|
391
399
|
try {
|
|
392
400
|
const _ = __addDisposableResource(env_18, this.lockSync(path), false);
|
|
393
|
-
return super.existsSync(path
|
|
401
|
+
return super.existsSync(path);
|
|
394
402
|
}
|
|
395
403
|
catch (e_18) {
|
|
396
404
|
env_18.error = e_18;
|
|
@@ -400,12 +408,12 @@ export function Mutexed(FS) {
|
|
|
400
408
|
__disposeResources(env_18);
|
|
401
409
|
}
|
|
402
410
|
}
|
|
403
|
-
async link(srcpath, dstpath
|
|
411
|
+
async link(srcpath, dstpath) {
|
|
404
412
|
const env_19 = { stack: [], error: void 0, hasError: false };
|
|
405
413
|
try {
|
|
406
|
-
const _ = __addDisposableResource(env_19, await this.lock(srcpath), false);
|
|
414
|
+
const _ = __addDisposableResource(env_19, await this.lock(srcpath, 'link'), false);
|
|
407
415
|
// @ts-expect-error 2513
|
|
408
|
-
await super.link(srcpath, dstpath
|
|
416
|
+
await super.link(srcpath, dstpath);
|
|
409
417
|
}
|
|
410
418
|
catch (e_19) {
|
|
411
419
|
env_19.error = e_19;
|
|
@@ -415,12 +423,12 @@ export function Mutexed(FS) {
|
|
|
415
423
|
__disposeResources(env_19);
|
|
416
424
|
}
|
|
417
425
|
}
|
|
418
|
-
linkSync(srcpath, dstpath
|
|
426
|
+
linkSync(srcpath, dstpath) {
|
|
419
427
|
const env_20 = { stack: [], error: void 0, hasError: false };
|
|
420
428
|
try {
|
|
421
429
|
const _ = __addDisposableResource(env_20, this.lockSync(srcpath), false);
|
|
422
430
|
// @ts-expect-error 2513
|
|
423
|
-
return super.linkSync(srcpath, dstpath
|
|
431
|
+
return super.linkSync(srcpath, dstpath);
|
|
424
432
|
}
|
|
425
433
|
catch (e_20) {
|
|
426
434
|
env_20.error = e_20;
|
|
@@ -433,7 +441,7 @@ export function Mutexed(FS) {
|
|
|
433
441
|
async sync(path, data, stats) {
|
|
434
442
|
const env_21 = { stack: [], error: void 0, hasError: false };
|
|
435
443
|
try {
|
|
436
|
-
const _ = __addDisposableResource(env_21, await this.lock(path), false);
|
|
444
|
+
const _ = __addDisposableResource(env_21, await this.lock(path, 'sync'), false);
|
|
437
445
|
// @ts-expect-error 2513
|
|
438
446
|
await super.sync(path, data, stats);
|
|
439
447
|
}
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type File } from '../file.js';
|
|
3
|
-
import { type Stats } from '../stats.js';
|
|
1
|
+
import type { File } from '../file.js';
|
|
4
2
|
import type { FileSystem, FileSystemMetadata } from '../filesystem.js';
|
|
3
|
+
import type { Stats } from '../stats.js';
|
|
5
4
|
import type { Mixin } from './shared.js';
|
|
6
5
|
/**
|
|
7
6
|
* Implements the non-readonly methods to throw `EROFS`
|
|
8
7
|
*/
|
|
9
8
|
export declare function Readonly<T extends typeof FileSystem>(FS: T): Mixin<T, {
|
|
10
9
|
metadata(): FileSystemMetadata;
|
|
11
|
-
rename(oldPath: string, newPath: string
|
|
12
|
-
renameSync(oldPath: string, newPath: string
|
|
13
|
-
createFile(path: string, flag: string, mode: number
|
|
14
|
-
createFileSync(path: string, flag: string, mode: number
|
|
15
|
-
unlink(path: string
|
|
16
|
-
unlinkSync(path: string
|
|
17
|
-
rmdir(path: string
|
|
18
|
-
rmdirSync(path: string
|
|
19
|
-
mkdir(path: string, mode: number
|
|
20
|
-
mkdirSync(path: string, mode: number
|
|
21
|
-
link(srcpath: string, dstpath: string
|
|
22
|
-
linkSync(srcpath: string, dstpath: string
|
|
10
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
11
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
12
|
+
createFile(path: string, flag: string, mode: number): Promise<File>;
|
|
13
|
+
createFileSync(path: string, flag: string, mode: number): File;
|
|
14
|
+
unlink(path: string): Promise<void>;
|
|
15
|
+
unlinkSync(path: string): void;
|
|
16
|
+
rmdir(path: string): Promise<void>;
|
|
17
|
+
rmdirSync(path: string): void;
|
|
18
|
+
mkdir(path: string, mode: number): Promise<void>;
|
|
19
|
+
mkdirSync(path: string, mode: number): void;
|
|
20
|
+
link(srcpath: string, dstpath: string): Promise<void>;
|
|
21
|
+
linkSync(srcpath: string, dstpath: string): void;
|
|
23
22
|
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
24
23
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
25
24
|
}>;
|
package/dist/mixins/readonly.js
CHANGED
|
@@ -9,40 +9,40 @@ export function Readonly(FS) {
|
|
|
9
9
|
return { ...super.metadata(), readonly: true };
|
|
10
10
|
}
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
12
|
-
async rename(oldPath, newPath
|
|
12
|
+
async rename(oldPath, newPath) {
|
|
13
13
|
throw new ErrnoError(Errno.EROFS);
|
|
14
14
|
}
|
|
15
|
-
renameSync(oldPath, newPath
|
|
15
|
+
renameSync(oldPath, newPath) {
|
|
16
16
|
throw new ErrnoError(Errno.EROFS);
|
|
17
17
|
}
|
|
18
|
-
async createFile(path, flag, mode
|
|
18
|
+
async createFile(path, flag, mode) {
|
|
19
19
|
throw new ErrnoError(Errno.EROFS);
|
|
20
20
|
}
|
|
21
|
-
createFileSync(path, flag, mode
|
|
21
|
+
createFileSync(path, flag, mode) {
|
|
22
22
|
throw new ErrnoError(Errno.EROFS);
|
|
23
23
|
}
|
|
24
|
-
async unlink(path
|
|
24
|
+
async unlink(path) {
|
|
25
25
|
throw new ErrnoError(Errno.EROFS);
|
|
26
26
|
}
|
|
27
|
-
unlinkSync(path
|
|
27
|
+
unlinkSync(path) {
|
|
28
28
|
throw new ErrnoError(Errno.EROFS);
|
|
29
29
|
}
|
|
30
|
-
async rmdir(path
|
|
30
|
+
async rmdir(path) {
|
|
31
31
|
throw new ErrnoError(Errno.EROFS);
|
|
32
32
|
}
|
|
33
|
-
rmdirSync(path
|
|
33
|
+
rmdirSync(path) {
|
|
34
34
|
throw new ErrnoError(Errno.EROFS);
|
|
35
35
|
}
|
|
36
|
-
async mkdir(path, mode
|
|
36
|
+
async mkdir(path, mode) {
|
|
37
37
|
throw new ErrnoError(Errno.EROFS);
|
|
38
38
|
}
|
|
39
|
-
mkdirSync(path, mode
|
|
39
|
+
mkdirSync(path, mode) {
|
|
40
40
|
throw new ErrnoError(Errno.EROFS);
|
|
41
41
|
}
|
|
42
|
-
async link(srcpath, dstpath
|
|
42
|
+
async link(srcpath, dstpath) {
|
|
43
43
|
throw new ErrnoError(Errno.EROFS);
|
|
44
44
|
}
|
|
45
|
-
linkSync(srcpath, dstpath
|
|
45
|
+
linkSync(srcpath, dstpath) {
|
|
46
46
|
throw new ErrnoError(Errno.EROFS);
|
|
47
47
|
}
|
|
48
48
|
async sync(path, data, stats) {
|
package/dist/mixins/sync.js
CHANGED
|
@@ -4,35 +4,35 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/require-await */
|
|
5
5
|
export function Sync(FS) {
|
|
6
6
|
class SyncFS extends FS {
|
|
7
|
-
async exists(path
|
|
8
|
-
return this.existsSync(path
|
|
7
|
+
async exists(path) {
|
|
8
|
+
return this.existsSync(path);
|
|
9
9
|
}
|
|
10
|
-
async rename(oldPath, newPath
|
|
11
|
-
return this.renameSync(oldPath, newPath
|
|
10
|
+
async rename(oldPath, newPath) {
|
|
11
|
+
return this.renameSync(oldPath, newPath);
|
|
12
12
|
}
|
|
13
|
-
async stat(path
|
|
14
|
-
return this.statSync(path
|
|
13
|
+
async stat(path) {
|
|
14
|
+
return this.statSync(path);
|
|
15
15
|
}
|
|
16
|
-
async createFile(path, flag, mode
|
|
17
|
-
return this.createFileSync(path, flag, mode
|
|
16
|
+
async createFile(path, flag, mode) {
|
|
17
|
+
return this.createFileSync(path, flag, mode);
|
|
18
18
|
}
|
|
19
|
-
async openFile(path, flag
|
|
20
|
-
return this.openFileSync(path, flag
|
|
19
|
+
async openFile(path, flag) {
|
|
20
|
+
return this.openFileSync(path, flag);
|
|
21
21
|
}
|
|
22
|
-
async unlink(path
|
|
23
|
-
return this.unlinkSync(path
|
|
22
|
+
async unlink(path) {
|
|
23
|
+
return this.unlinkSync(path);
|
|
24
24
|
}
|
|
25
|
-
async rmdir(path
|
|
26
|
-
return this.rmdirSync(path
|
|
25
|
+
async rmdir(path) {
|
|
26
|
+
return this.rmdirSync(path);
|
|
27
27
|
}
|
|
28
|
-
async mkdir(path, mode
|
|
29
|
-
return this.mkdirSync(path, mode
|
|
28
|
+
async mkdir(path, mode) {
|
|
29
|
+
return this.mkdirSync(path, mode);
|
|
30
30
|
}
|
|
31
|
-
async readdir(path
|
|
32
|
-
return this.readdirSync(path
|
|
31
|
+
async readdir(path) {
|
|
32
|
+
return this.readdirSync(path);
|
|
33
33
|
}
|
|
34
|
-
async link(srcpath, dstpath
|
|
35
|
-
return this.linkSync(srcpath, dstpath
|
|
34
|
+
async link(srcpath, dstpath) {
|
|
35
|
+
return this.linkSync(srcpath, dstpath);
|
|
36
36
|
}
|
|
37
37
|
async sync(path, data, stats) {
|
|
38
38
|
return this.syncSync(path, data, stats);
|
package/dist/stats.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type * as Node from 'fs';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Credentials } from './credentials.js';
|
|
4
4
|
import { S_IFDIR, S_IFLNK, S_IFREG } from './emulation/constants.js';
|
|
5
5
|
/**
|
|
6
6
|
* Indicates the type of the given file. Applied to 'mode'.
|
|
@@ -150,12 +150,12 @@ export declare abstract class StatsCommon<T extends number | bigint> implements
|
|
|
150
150
|
* @returns True if the request has access, false if the request does not
|
|
151
151
|
* @internal
|
|
152
152
|
*/
|
|
153
|
-
hasAccess(mode: number, cred:
|
|
153
|
+
hasAccess(mode: number, cred: Credentials): boolean;
|
|
154
154
|
/**
|
|
155
155
|
* Convert the current stats object into a credentials object
|
|
156
156
|
* @internal
|
|
157
157
|
*/
|
|
158
|
-
cred(uid?: number, gid?: number):
|
|
158
|
+
cred(uid?: number, gid?: number): Credentials;
|
|
159
159
|
/**
|
|
160
160
|
* Change the mode of the file. We use this helper function to prevent messing
|
|
161
161
|
* up the type of the file, which is encoded in mode.
|
|
@@ -185,12 +185,19 @@ export declare class Stats extends StatsCommon<number> implements Node.Stats, St
|
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* Stats with bigint
|
|
188
|
-
* @todo Implement with bigint instead of wrapping Stats
|
|
189
|
-
* @internal
|
|
190
188
|
*/
|
|
191
189
|
export declare class BigIntStats extends StatsCommon<bigint> implements Node.BigIntStats, StatsLike {
|
|
192
190
|
protected _isBigint: true;
|
|
193
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Determines if the file stats have changed by comparing relevant properties.
|
|
194
|
+
*
|
|
195
|
+
* @param left The previous stats.
|
|
196
|
+
* @param right The current stats.
|
|
197
|
+
* @returns `true` if stats have changed; otherwise, `false`.
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
export declare function isStatsEqual<T extends number | bigint>(left: StatsCommon<T>, right: StatsCommon<T>): boolean;
|
|
194
201
|
/**
|
|
195
202
|
* @internal
|
|
196
203
|
*/
|
package/dist/stats.js
CHANGED
|
@@ -194,8 +194,6 @@ export class Stats extends StatsCommon {
|
|
|
194
194
|
Stats;
|
|
195
195
|
/**
|
|
196
196
|
* Stats with bigint
|
|
197
|
-
* @todo Implement with bigint instead of wrapping Stats
|
|
198
|
-
* @internal
|
|
199
197
|
*/
|
|
200
198
|
export class BigIntStats extends StatsCommon {
|
|
201
199
|
constructor() {
|
|
@@ -203,6 +201,17 @@ export class BigIntStats extends StatsCommon {
|
|
|
203
201
|
this._isBigint = true;
|
|
204
202
|
}
|
|
205
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Determines if the file stats have changed by comparing relevant properties.
|
|
206
|
+
*
|
|
207
|
+
* @param left The previous stats.
|
|
208
|
+
* @param right The current stats.
|
|
209
|
+
* @returns `true` if stats have changed; otherwise, `false`.
|
|
210
|
+
* @internal
|
|
211
|
+
*/
|
|
212
|
+
export function isStatsEqual(left, right) {
|
|
213
|
+
return left.size == right.size && +left.atime == +right.atime && +left.mtime == +right.mtime && +left.ctime == +right.ctime && left.mode == right.mode;
|
|
214
|
+
}
|
|
206
215
|
/**
|
|
207
216
|
* @internal
|
|
208
217
|
*/
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type * as fs from 'node:fs';
|
|
3
4
|
import type { OptionalTuple } from 'utilium';
|
|
4
|
-
import { ErrnoError } from './error.js';
|
|
5
|
-
import type { Cred } from './cred.js';
|
|
6
5
|
import { type AbsolutePath } from './emulation/path.js';
|
|
6
|
+
import { ErrnoError } from './error.js';
|
|
7
7
|
import type { FileSystem } from './filesystem.js';
|
|
8
|
-
import type * as fs from 'node:fs';
|
|
9
8
|
declare global {
|
|
10
9
|
function atob(data: string): string;
|
|
11
10
|
function btoa(data: string): string;
|
|
@@ -14,7 +13,7 @@ declare global {
|
|
|
14
13
|
* Synchronous recursive makedir.
|
|
15
14
|
* @hidden
|
|
16
15
|
*/
|
|
17
|
-
export declare function mkdirpSync(path: string, mode: number,
|
|
16
|
+
export declare function mkdirpSync(path: string, mode: number, fs: FileSystem): void;
|
|
18
17
|
/**
|
|
19
18
|
* Calculates levenshtein distance.
|
|
20
19
|
* @hidden
|
|
@@ -82,8 +81,3 @@ export declare function normalizeOptions(options: fs.WriteFileOptions | (fs.Enco
|
|
|
82
81
|
flag: string;
|
|
83
82
|
mode: number;
|
|
84
83
|
};
|
|
85
|
-
/**
|
|
86
|
-
* Do nothing
|
|
87
|
-
* @internal
|
|
88
|
-
*/
|
|
89
|
-
export declare function nop(): void;
|
package/dist/utils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ErrnoError, Errno } from './error.js';
|
|
2
1
|
import { dirname, resolve } from './emulation/path.js';
|
|
2
|
+
import { Errno, ErrnoError } from './error.js';
|
|
3
3
|
/**
|
|
4
4
|
* Synchronous recursive makedir.
|
|
5
5
|
* @hidden
|
|
6
6
|
*/
|
|
7
|
-
export function mkdirpSync(path, mode,
|
|
8
|
-
if (!fs.existsSync(path
|
|
9
|
-
mkdirpSync(dirname(path), mode,
|
|
10
|
-
fs.mkdirSync(path, mode
|
|
7
|
+
export function mkdirpSync(path, mode, fs) {
|
|
8
|
+
if (!fs.existsSync(path)) {
|
|
9
|
+
mkdirpSync(dirname(path), mode, fs);
|
|
10
|
+
fs.mkdirSync(path, mode);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
function _min(d0, d1, d2, bx, ay) {
|
|
@@ -114,24 +114,14 @@ export function decode(input) {
|
|
|
114
114
|
* @hidden
|
|
115
115
|
*/
|
|
116
116
|
export function decodeDirListing(data) {
|
|
117
|
-
return JSON.parse(decode(data), (k, v) =>
|
|
118
|
-
if (k == '') {
|
|
119
|
-
return v;
|
|
120
|
-
}
|
|
121
|
-
return BigInt(v);
|
|
122
|
-
});
|
|
117
|
+
return JSON.parse(decode(data), (k, v) => (k == '' ? v : BigInt(v)));
|
|
123
118
|
}
|
|
124
119
|
/**
|
|
125
120
|
* Encodes a directory listing
|
|
126
121
|
* @hidden
|
|
127
122
|
*/
|
|
128
123
|
export function encodeDirListing(data) {
|
|
129
|
-
return encode(JSON.stringify(data, (k, v) =>
|
|
130
|
-
if (k == '') {
|
|
131
|
-
return v;
|
|
132
|
-
}
|
|
133
|
-
return v.toString();
|
|
134
|
-
}));
|
|
124
|
+
return encode(JSON.stringify(data, (k, v) => (k == '' ? v : v.toString())));
|
|
135
125
|
}
|
|
136
126
|
/**
|
|
137
127
|
* converts Date or number to a integer UNIX timestamp
|
|
@@ -219,10 +209,3 @@ export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
|
|
|
219
209
|
mode: normalizeMode('mode' in options ? options?.mode : null, mode),
|
|
220
210
|
};
|
|
221
211
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Do nothing
|
|
224
|
-
* @internal
|
|
225
|
-
*/
|
|
226
|
-
export function nop() {
|
|
227
|
-
// do nothing
|
|
228
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"exports": {
|
|
41
41
|
".": "./dist/index.js",
|
|
42
42
|
"./*": "./dist/*",
|
|
43
|
-
"./promises": "./dist/emulation/promises.js"
|
|
43
|
+
"./promises": "./dist/emulation/promises.js",
|
|
44
|
+
"./mixins": "./dist/mixins/index.js"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"format": "prettier --write .",
|
|
@@ -64,7 +65,7 @@
|
|
|
64
65
|
"eventemitter3": "^5.0.1",
|
|
65
66
|
"minimatch": "^9.0.3",
|
|
66
67
|
"readable-stream": "^4.5.2",
|
|
67
|
-
"utilium": "
|
|
68
|
+
"utilium": ">=0.4.0"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@eslint/js": "^9.8.0",
|