@zenfs/core 1.1.6 → 1.2.1

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 (83) hide show
  1. package/dist/backends/file_index.js +0 -3
  2. package/dist/backends/overlay.js +0 -8
  3. package/dist/backends/store/fs.js +4 -17
  4. package/dist/config.d.ts +24 -1
  5. package/dist/config.js +5 -0
  6. package/dist/devices.js +0 -12
  7. package/dist/emulation/cache.d.ts +21 -0
  8. package/dist/emulation/cache.js +36 -0
  9. package/dist/emulation/config.d.ts +10 -0
  10. package/dist/emulation/config.js +10 -0
  11. package/dist/emulation/promises.d.ts +9 -14
  12. package/dist/emulation/promises.js +71 -47
  13. package/dist/emulation/shared.d.ts +16 -0
  14. package/dist/emulation/sync.d.ts +11 -20
  15. package/dist/emulation/sync.js +44 -22
  16. package/dist/file.d.ts +1 -1
  17. package/dist/file.js +6 -3
  18. package/package.json +4 -2
  19. package/readme.md +1 -1
  20. package/scripts/test.js +19 -1
  21. package/src/backends/backend.ts +160 -0
  22. package/src/backends/fetch.ts +180 -0
  23. package/src/backends/file_index.ts +206 -0
  24. package/src/backends/memory.ts +50 -0
  25. package/src/backends/overlay.ts +560 -0
  26. package/src/backends/port/fs.ts +335 -0
  27. package/src/backends/port/readme.md +54 -0
  28. package/src/backends/port/rpc.ts +167 -0
  29. package/src/backends/readme.md +3 -0
  30. package/src/backends/store/fs.ts +700 -0
  31. package/src/backends/store/readme.md +9 -0
  32. package/src/backends/store/simple.ts +146 -0
  33. package/src/backends/store/store.ts +173 -0
  34. package/src/config.ts +185 -0
  35. package/src/credentials.ts +31 -0
  36. package/src/devices.ts +459 -0
  37. package/src/emulation/async.ts +834 -0
  38. package/src/emulation/cache.ts +44 -0
  39. package/src/emulation/config.ts +11 -0
  40. package/src/emulation/constants.ts +182 -0
  41. package/src/emulation/dir.ts +138 -0
  42. package/src/emulation/index.ts +8 -0
  43. package/src/emulation/path.ts +440 -0
  44. package/src/emulation/promises.ts +1134 -0
  45. package/src/emulation/shared.ts +153 -0
  46. package/src/emulation/streams.ts +34 -0
  47. package/src/emulation/sync.ts +868 -0
  48. package/src/emulation/watchers.ts +193 -0
  49. package/src/error.ts +307 -0
  50. package/src/file.ts +662 -0
  51. package/src/filesystem.ts +174 -0
  52. package/src/index.ts +25 -0
  53. package/src/inode.ts +132 -0
  54. package/src/mixins/async.ts +208 -0
  55. package/src/mixins/index.ts +5 -0
  56. package/src/mixins/mutexed.ts +257 -0
  57. package/src/mixins/readonly.ts +96 -0
  58. package/src/mixins/shared.ts +25 -0
  59. package/src/mixins/sync.ts +58 -0
  60. package/src/polyfills.ts +21 -0
  61. package/src/stats.ts +363 -0
  62. package/src/utils.ts +288 -0
  63. package/tests/common.ts +1 -11
  64. package/tests/fs/directory.test.ts +1 -1
  65. package/tests/fs/errors.test.ts +1 -1
  66. package/tests/fs/links.test.ts +1 -1
  67. package/tests/fs/open.test.ts +1 -1
  68. package/tests/fs/permissions.test.ts +4 -4
  69. package/tests/fs/readdir.test.ts +3 -3
  70. package/tests/fs/rename.test.ts +1 -1
  71. package/tests/fs/stat.test.ts +1 -1
  72. package/tests/fs/times.test.ts +2 -2
  73. package/tests/fs/truncate.test.ts +1 -1
  74. package/tests/port/channel.test.ts +3 -3
  75. package/tests/port/config.test.ts +4 -5
  76. package/tests/port/config.worker.js +5 -0
  77. package/tests/port/remote.test.ts +4 -5
  78. package/tests/port/remote.worker.js +5 -0
  79. package/tests/port/timeout.test.ts +2 -2
  80. package/tests/setup/common.ts +1 -1
  81. package/tests/setup/cow+fetch.ts +1 -1
  82. package/tests/port/config.worker.ts +0 -5
  83. package/tests/port/remote.worker.ts +0 -5
@@ -67,9 +67,9 @@ suite('readdir and readdirSync', () => {
67
67
 
68
68
  test('readdir returns Dirent recursively', async () => {
69
69
  const entries = await fs.promises.readdir(testDir, { recursive: true, withFileTypes: true });
70
- assert.equal(entries[0].path, 'file1.txt');
71
- assert.equal(entries[4].path, 'subdir1/file4.txt');
72
- assert.equal(entries[entries.length - 1].path, 'subdir2/file5.txt');
70
+ assert(entries.find(entry => entry.path === 'file1.txt'));
71
+ assert(entries.find(entry => entry.path === 'subdir1/file4.txt'));
72
+ assert(entries.find(entry => entry.path === 'subdir2/file5.txt'));
73
73
  });
74
74
 
75
75
  // New test for readdirSync with recursive: true
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { ErrnoError } from '../../src/error.js';
3
+ import { ErrnoError } from '../../dist/error.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Rename', () => {
@@ -1,6 +1,6 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import { Stats } from '../../src/stats.js';
3
+ import { Stats } from '../../dist/stats.js';
4
4
  import { fs } from '../common.js';
5
5
 
6
6
  suite('Stats', () => {
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
3
  import { wait } from 'utilium';
4
- import { ErrnoError } from '../../src/error.js';
5
- import { _toUnixTimestamp } from '../../src/utils.js';
4
+ import { ErrnoError } from '../../dist/error.js';
5
+ import { _toUnixTimestamp } from '../../dist/utils.js';
6
6
  import { fs } from '../common.js';
7
7
 
8
8
  suite('times', () => {
@@ -1,7 +1,7 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
- import type { FileHandle } from '../../src/emulation/promises.js';
4
3
  import { fs } from '../common.js';
4
+ import type { FileHandle } from '../../dist/emulation/promises.js';
5
5
 
6
6
  const path: string = 'truncate-file.txt',
7
7
  size = 1024 * 16,
@@ -1,9 +1,9 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
3
  import { MessageChannel } from 'node:worker_threads';
4
- import { Port, attachFS } from '../../src/backends/port/fs.js';
5
- import type { StoreFS } from '../../src/index.js';
6
- import { InMemory, configureSingle, fs, resolveMountConfig, type InMemoryStore } from '../../src/index.js';
4
+ import { Port, attachFS } from '../../dist/backends/port/fs.js';
5
+ import type { StoreFS } from '../../dist/index.js';
6
+ import { InMemory, configureSingle, fs, resolveMountConfig, type InMemoryStore } from '../../dist/index.js';
7
7
 
8
8
  const { port1, port2 } = new MessageChannel(),
9
9
  content = 'FS is in a port';
@@ -2,14 +2,13 @@ import assert from 'node:assert';
2
2
  import { dirname } from 'node:path';
3
3
  import { suite, test } from 'node:test';
4
4
  import { fileURLToPath } from 'node:url';
5
- import type { Worker } from 'node:worker_threads';
6
- import { Port } from '../../src/backends/port/fs.js';
7
- import { configureSingle, fs } from '../../src/index.js';
8
- import { createTSWorker } from '../common.js';
5
+ import { Worker } from 'node:worker_threads';
6
+ import { Port } from '../../dist/backends/port/fs.js';
7
+ import { configureSingle, fs } from '../../dist/index.js';
9
8
 
10
9
  const dir = dirname(fileURLToPath(import.meta.url));
11
10
 
12
- const port: Worker = createTSWorker(dir + '/config.worker.ts');
11
+ const port = new Worker(dir + '/config.worker.js');
13
12
 
14
13
  await suite('Remote FS with resolveRemoteMount', () => {
15
14
  const content = 'FS is in a port';
@@ -0,0 +1,5 @@
1
+ import { parentPort } from 'node:worker_threads';
2
+ import { resolveRemoteMount } from '../../dist/backends/port/fs.js';
3
+ import { InMemory } from '../../dist/backends/memory.js';
4
+
5
+ await resolveRemoteMount(parentPort, { backend: InMemory });
@@ -2,14 +2,13 @@ import assert from 'node:assert';
2
2
  import { dirname } from 'node:path';
3
3
  import { suite, test } from 'node:test';
4
4
  import { fileURLToPath } from 'node:url';
5
- import type { Worker } from 'node:worker_threads';
6
- import { Port } from '../../src/backends/port/fs.js';
7
- import { configureSingle, fs } from '../../src/index.js';
8
- import { createTSWorker } from '../common.js';
5
+ import { Worker } from 'node:worker_threads';
6
+ import { Port } from '../../dist/backends/port/fs.js';
7
+ import { configureSingle, fs } from '../../dist/index.js';
9
8
 
10
9
  const dir = dirname(fileURLToPath(import.meta.url));
11
10
 
12
- const port: Worker = createTSWorker(dir + '/remote.worker.js');
11
+ const port = new Worker(dir + '/remote.worker.js');
13
12
 
14
13
  await suite('Remote FS', () => {
15
14
  const content = 'FS is in a port';
@@ -0,0 +1,5 @@
1
+ import { parentPort } from 'node:worker_threads';
2
+ import { attachFS } from '../../dist/backends/port/fs.js';
3
+ import { mounts } from '../../dist/index.js';
4
+
5
+ attachFS(parentPort, mounts.get('/'));
@@ -1,8 +1,8 @@
1
1
  import assert from 'node:assert';
2
2
  import { suite, test } from 'node:test';
3
3
  import { MessageChannel } from 'node:worker_threads';
4
- import { Port } from '../../src/backends/port/fs.js';
5
- import { ErrnoError, InMemory, configure, configureSingle, fs } from '../../src/index.js';
4
+ import { Port } from '../../dist/backends/port/fs.js';
5
+ import { ErrnoError, InMemory, configure, configureSingle, fs } from '../../dist/index.js';
6
6
 
7
7
  /**
8
8
  * Tests a mis-configured PortFS using a MessageChannel
@@ -1,6 +1,6 @@
1
1
  import { join, relative } from 'node:path';
2
2
  import { statSync, readFileSync, readdirSync, existsSync, mkdirSync } from 'node:fs';
3
- import { fs } from '../../src/index.js';
3
+ import { fs } from '../../dist/index.js';
4
4
 
5
5
  export const data = join(import.meta.dirname, '../data');
6
6
 
@@ -2,7 +2,7 @@ import { execSync } from 'node:child_process';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { createServer } from 'node:http';
4
4
  import { join } from 'node:path';
5
- import { configureSingle, Fetch, InMemory, Overlay } from '../../src/index.js';
5
+ import { configureSingle, Fetch, InMemory, Overlay } from '../../dist/index.js';
6
6
  import { data, tmp } from './common.js';
7
7
 
8
8
  const port = 26514,
@@ -1,5 +0,0 @@
1
- import { parentPort } from 'node:worker_threads';
2
- import { resolveRemoteMount } from '../../src/backends/port/fs.js';
3
- import { InMemory } from '../../src/backends/memory.js';
4
-
5
- await resolveRemoteMount(parentPort!, { backend: InMemory });
@@ -1,5 +0,0 @@
1
- import { parentPort } from 'node:worker_threads';
2
- import { attachFS } from '../../src/backends/port/fs.js';
3
- import { mounts } from '../../src/index.js';
4
-
5
- attachFS(parentPort!, mounts.get('/')!);