@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.
Files changed (135) hide show
  1. package/dist/backends/backend.d.ts +19 -15
  2. package/dist/backends/backend.js +36 -19
  3. package/dist/backends/cow.d.ts +20 -30
  4. package/dist/backends/cow.js +83 -192
  5. package/dist/backends/fetch.d.ts +1 -0
  6. package/dist/backends/fetch.js +30 -30
  7. package/dist/backends/index.d.ts +1 -1
  8. package/dist/backends/index.js +1 -1
  9. package/dist/backends/memory.d.ts +5 -7
  10. package/dist/backends/memory.js +2 -3
  11. package/dist/backends/passthrough.d.ts +19 -23
  12. package/dist/backends/passthrough.js +98 -288
  13. package/dist/backends/port.d.ts +220 -0
  14. package/dist/backends/port.js +328 -0
  15. package/dist/backends/single_buffer.d.ts +59 -47
  16. package/dist/backends/single_buffer.js +468 -219
  17. package/dist/backends/store/fs.d.ts +25 -35
  18. package/dist/backends/store/fs.js +276 -315
  19. package/dist/backends/store/store.d.ts +10 -15
  20. package/dist/backends/store/store.js +11 -10
  21. package/dist/config.d.ts +3 -12
  22. package/dist/config.js +17 -19
  23. package/dist/context.d.ts +8 -21
  24. package/dist/context.js +33 -10
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +2 -1
  27. package/dist/internal/contexts.d.ts +63 -0
  28. package/dist/internal/contexts.js +15 -0
  29. package/dist/internal/credentials.d.ts +2 -11
  30. package/dist/internal/credentials.js +0 -19
  31. package/dist/internal/devices.d.ts +18 -80
  32. package/dist/internal/devices.js +103 -316
  33. package/dist/internal/error.d.ts +9 -204
  34. package/dist/internal/error.js +19 -288
  35. package/dist/internal/file_index.d.ts +1 -1
  36. package/dist/internal/file_index.js +11 -11
  37. package/dist/internal/filesystem.d.ts +51 -94
  38. package/dist/internal/filesystem.js +21 -20
  39. package/dist/internal/index.d.ts +1 -2
  40. package/dist/internal/index.js +1 -2
  41. package/dist/internal/index_fs.d.ts +12 -30
  42. package/dist/internal/index_fs.js +37 -69
  43. package/dist/internal/inode.d.ts +140 -24
  44. package/dist/internal/inode.js +515 -66
  45. package/dist/mixins/async.js +52 -112
  46. package/dist/mixins/mutexed.d.ts +19 -18
  47. package/dist/mixins/mutexed.js +62 -64
  48. package/dist/mixins/readonly.d.ts +7 -6
  49. package/dist/mixins/readonly.js +24 -18
  50. package/dist/mixins/sync.js +8 -8
  51. package/dist/{vfs/path.d.ts → path.d.ts} +3 -4
  52. package/dist/{vfs/path.js → path.js} +6 -9
  53. package/dist/polyfills.js +1 -1
  54. package/dist/readline.d.ts +134 -0
  55. package/dist/readline.js +623 -0
  56. package/dist/utils.d.ts +9 -37
  57. package/dist/utils.js +17 -85
  58. package/dist/vfs/acl.d.ts +42 -0
  59. package/dist/vfs/acl.js +268 -0
  60. package/dist/vfs/async.d.ts +9 -23
  61. package/dist/vfs/async.js +25 -27
  62. package/dist/vfs/config.d.ts +6 -18
  63. package/dist/vfs/config.js +8 -18
  64. package/dist/vfs/dir.d.ts +3 -3
  65. package/dist/vfs/dir.js +12 -12
  66. package/dist/vfs/file.d.ts +106 -0
  67. package/dist/vfs/file.js +244 -0
  68. package/dist/vfs/flags.d.ts +19 -0
  69. package/dist/vfs/flags.js +62 -0
  70. package/dist/vfs/index.d.ts +4 -10
  71. package/dist/vfs/index.js +4 -13
  72. package/dist/vfs/ioctl.d.ts +88 -0
  73. package/dist/vfs/ioctl.js +409 -0
  74. package/dist/vfs/promises.d.ts +81 -19
  75. package/dist/vfs/promises.js +404 -288
  76. package/dist/vfs/shared.d.ts +7 -37
  77. package/dist/vfs/shared.js +29 -85
  78. package/dist/{stats.d.ts → vfs/stats.d.ts} +14 -28
  79. package/dist/{stats.js → vfs/stats.js} +11 -66
  80. package/dist/vfs/streams.d.ts +1 -0
  81. package/dist/vfs/streams.js +32 -27
  82. package/dist/vfs/sync.d.ts +3 -3
  83. package/dist/vfs/sync.js +263 -260
  84. package/dist/vfs/watchers.d.ts +2 -2
  85. package/dist/vfs/watchers.js +12 -12
  86. package/dist/vfs/xattr.d.ts +116 -0
  87. package/dist/vfs/xattr.js +201 -0
  88. package/package.json +5 -3
  89. package/readme.md +1 -1
  90. package/scripts/test.js +2 -2
  91. package/tests/assignment.ts +1 -1
  92. package/tests/backend/config.worker.js +4 -1
  93. package/tests/backend/fetch.test.ts +3 -0
  94. package/tests/backend/port.test.ts +19 -33
  95. package/tests/backend/remote.worker.js +4 -1
  96. package/tests/backend/single-buffer.test.ts +53 -0
  97. package/tests/backend/single-buffer.worker.js +30 -0
  98. package/tests/common/context.test.ts +3 -3
  99. package/tests/common/handle.test.ts +17 -12
  100. package/tests/common/mutex.test.ts +9 -9
  101. package/tests/common/path.test.ts +1 -1
  102. package/tests/common/readline.test.ts +104 -0
  103. package/tests/common.ts +4 -19
  104. package/tests/fetch/fetch.ts +2 -2
  105. package/tests/fs/append.test.ts +4 -4
  106. package/tests/fs/directory.test.ts +25 -25
  107. package/tests/fs/errors.test.ts +15 -19
  108. package/tests/fs/links.test.ts +4 -3
  109. package/tests/fs/open.test.ts +4 -21
  110. package/tests/fs/permissions.test.ts +14 -18
  111. package/tests/fs/read.test.ts +10 -9
  112. package/tests/fs/readFile.test.ts +10 -26
  113. package/tests/fs/rename.test.ts +4 -9
  114. package/tests/fs/stat.test.ts +8 -8
  115. package/tests/fs/streams.test.ts +2 -11
  116. package/tests/fs/times.test.ts +7 -7
  117. package/tests/fs/truncate.test.ts +8 -36
  118. package/tests/fs/watch.test.ts +10 -10
  119. package/tests/fs/write.test.ts +77 -13
  120. package/tests/fs/xattr.test.ts +85 -0
  121. package/tests/logs.js +22 -0
  122. package/tests/setup/context.ts +1 -1
  123. package/tests/setup/index.ts +3 -3
  124. package/tests/setup/port.ts +7 -1
  125. package/dist/backends/port/fs.d.ts +0 -84
  126. package/dist/backends/port/fs.js +0 -151
  127. package/dist/backends/port/rpc.d.ts +0 -77
  128. package/dist/backends/port/rpc.js +0 -100
  129. package/dist/backends/store/simple.d.ts +0 -20
  130. package/dist/backends/store/simple.js +0 -13
  131. package/dist/internal/file.d.ts +0 -359
  132. package/dist/internal/file.js +0 -751
  133. package/dist/internal/log.d.ts +0 -133
  134. package/dist/internal/log.js +0 -218
  135. package/tests/fs/writeFile.test.ts +0 -70
@@ -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 { ErrnoError } from '../internal/error.js';
54
- import { err } from '../internal/log.js';
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 id() {
88
- return this._fs.id;
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(path, syscall) {
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 = ErrnoError.With('EDEADLK', path, syscall);
136
+ const error = withErrno('EDEADLK');
131
137
  error.stack += stack === null || stack === void 0 ? void 0 : stack.slice('Error'.length);
132
- throw err(error, { fs: this });
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(path, syscall) {
149
+ lockSync() {
144
150
  var _a;
145
151
  if ((_a = this.currentLock) === null || _a === void 0 ? void 0 : _a.isLocked) {
146
- throw err(ErrnoError.With('EBUSY', path, syscall), { fs: this });
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(oldPath, 'rename'), false);
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(oldPath, 'rename'), false);
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(path, 'stat'), false);
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(path, 'stat'), false);
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 openFile(path, flag) {
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(path, 'openFile'), false);
219
- const file = await this._fs.openFile(path, flag);
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
- openFileSync(path, flag) {
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(path, 'openFile'), false);
235
- const file = this._fs.openFileSync(path, flag);
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, flag, mode, options) {
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(path, 'createFile'), false);
251
- const file = await this._fs.createFile(path, flag, mode, options);
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, flag, mode, options) {
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(path, 'createFile'), false);
267
- const file = this._fs.createFileSync(path, flag, mode, options);
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(path, 'unlink'), false);
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(path, 'unlink'), false);
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(path, 'rmdir'), false);
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(path, 'rmdir'), false);
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, mode, options) {
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(path, 'mkdir'), false);
339
- await this._fs.mkdir(path, mode, options);
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, mode, options) {
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(path, 'mkdir'), false);
353
- return this._fs.mkdirSync(path, mode, options);
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(path, 'readdir'), false);
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(path, 'readdir'), false);
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(path, 'exists'), false);
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(path, 'exists'), false);
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(srcpath, 'link'), false);
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(srcpath, 'link'), false);
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(path, data, stats) {
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(path, 'sync'), false);
451
- await this._fs.sync(path, data, stats);
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(path, data, stats) {
459
+ syncSync() {
462
460
  const env_22 = { stack: [], error: void 0, hasError: false };
463
461
  try {
464
- const _ = __addDisposableResource(env_22, this.lockSync(path, 'sync'), false);
465
- return this._fs.syncSync(path, data, stats);
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(path, 'read'), false);
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(path, 'read'), false);
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(path, 'write'), false);
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(path, 'write'), false);
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(path, 'streamRead'), false);
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(path, 'streamWrite'), false);
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, FileSystemMetadata } from '../internal/filesystem.js';
2
- import type { StatsLike } from '../stats.js';
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
- sync(path: string, data: Uint8Array, stats: Readonly<StatsLike<number>>): Promise<never>;
22
- syncSync(path: string, data: Uint8Array, stats: Readonly<StatsLike<number>>): never;
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): Promise<never>;
25
+ writeSync(path: string, buffer: Uint8Array, offset: number): never;
25
26
  }
26
27
  /**
27
28
  * Implements the non-readonly methods to throw `EROFS`
@@ -1,4 +1,4 @@
1
- import { Errno, ErrnoError } from '../internal/error.js';
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 new ErrnoError(Errno.EROFS);
14
+ throw withErrno('EROFS');
15
15
  }
16
16
  renameSync() {
17
- throw new ErrnoError(Errno.EROFS);
17
+ throw withErrno('EROFS');
18
18
  }
19
19
  async createFile() {
20
- throw new ErrnoError(Errno.EROFS);
20
+ throw withErrno('EROFS');
21
21
  }
22
22
  createFileSync() {
23
- throw new ErrnoError(Errno.EROFS);
23
+ throw withErrno('EROFS');
24
24
  }
25
25
  async unlink() {
26
- throw new ErrnoError(Errno.EROFS);
26
+ throw withErrno('EROFS');
27
27
  }
28
28
  unlinkSync() {
29
- throw new ErrnoError(Errno.EROFS);
29
+ throw withErrno('EROFS');
30
30
  }
31
31
  async rmdir() {
32
- throw new ErrnoError(Errno.EROFS);
32
+ throw withErrno('EROFS');
33
33
  }
34
34
  rmdirSync() {
35
- throw new ErrnoError(Errno.EROFS);
35
+ throw withErrno('EROFS');
36
36
  }
37
37
  async mkdir() {
38
- throw new ErrnoError(Errno.EROFS);
38
+ throw withErrno('EROFS');
39
39
  }
40
40
  mkdirSync() {
41
- throw new ErrnoError(Errno.EROFS);
41
+ throw withErrno('EROFS');
42
42
  }
43
43
  async link() {
44
- throw new ErrnoError(Errno.EROFS);
44
+ throw withErrno('EROFS');
45
45
  }
46
46
  linkSync() {
47
- throw new ErrnoError(Errno.EROFS);
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 new ErrnoError(Errno.EROFS);
56
+ throw withErrno('EROFS');
51
57
  }
52
58
  syncSync() {
53
- throw new ErrnoError(Errno.EROFS);
59
+ throw withErrno('EROFS');
54
60
  }
55
61
  async write() {
56
- throw new ErrnoError(Errno.EROFS);
62
+ throw withErrno('EROFS');
57
63
  }
58
64
  writeSync() {
59
- throw new ErrnoError(Errno.EROFS);
65
+ throw withErrno('EROFS');
60
66
  }
61
67
  streamWrite() {
62
- throw new ErrnoError(Errno.EROFS);
68
+ throw withErrno('EROFS');
63
69
  }
64
70
  }
65
71
  return ReadonlyFS;
@@ -14,11 +14,11 @@ export function Sync(FS) {
14
14
  async stat(path) {
15
15
  return this.statSync(path);
16
16
  }
17
- async createFile(path, flag, mode, options) {
18
- return this.createFileSync(path, flag, mode, options);
17
+ async touch(path, metadata) {
18
+ return this.touchSync(path, metadata);
19
19
  }
20
- async openFile(path, flag) {
21
- return this.openFileSync(path, flag);
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, mode, options) {
30
- return this.mkdirSync(path, mode, options);
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(path, data, stats) {
39
- return this.syncSync(path, data, stats);
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
- export let cwd = '/';
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(), cwd]) {
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 './internal/log.js';
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 () {