@zenfs/core 2.4.0 → 2.4.2

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 (100) hide show
  1. package/COPYING.md +18 -0
  2. package/{readme.md → README.md} +16 -74
  3. package/dist/backends/fetch.js +1 -1
  4. package/dist/backends/memory.js +1 -1
  5. package/dist/backends/passthrough.d.ts +1 -2
  6. package/dist/backends/single_buffer.js +1 -1
  7. package/dist/backends/store/fs.js +4 -4
  8. package/dist/config.js +15 -15
  9. package/dist/context.js +3 -2
  10. package/dist/index.d.ts +9 -3
  11. package/dist/index.js +9 -4
  12. package/dist/internal/contexts.d.ts +5 -4
  13. package/dist/internal/devices.js +1 -1
  14. package/dist/internal/error.d.ts +11 -2
  15. package/dist/internal/error.js +38 -2
  16. package/dist/internal/file_index.js +1 -1
  17. package/dist/internal/index.d.ts +1 -0
  18. package/dist/internal/index.js +2 -1
  19. package/dist/internal/index_fs.js +1 -1
  20. package/dist/internal/inode.d.ts +51 -2
  21. package/dist/internal/inode.js +18 -2
  22. package/dist/mixins/shared.js +1 -1
  23. package/dist/node/async.d.ts +278 -0
  24. package/dist/node/async.js +518 -0
  25. package/dist/node/compat.d.ts +4 -0
  26. package/dist/node/compat.js +6 -0
  27. package/dist/node/dir.d.ts +78 -0
  28. package/dist/node/dir.js +150 -0
  29. package/dist/node/index.d.ts +8 -0
  30. package/dist/node/index.js +8 -0
  31. package/dist/{vfs → node}/promises.d.ts +10 -66
  32. package/dist/{vfs → node}/promises.js +141 -478
  33. package/dist/{vfs → node}/stats.d.ts +0 -4
  34. package/dist/{vfs → node}/stats.js +1 -16
  35. package/dist/{vfs → node}/streams.js +2 -2
  36. package/dist/node/sync.d.ts +252 -0
  37. package/dist/node/sync.js +682 -0
  38. package/dist/node/types.d.ts +21 -0
  39. package/dist/path.js +3 -25
  40. package/dist/utils.d.ts +1 -7
  41. package/dist/utils.js +0 -6
  42. package/dist/vfs/acl.js +1 -1
  43. package/dist/vfs/async.d.ts +22 -278
  44. package/dist/vfs/async.js +212 -501
  45. package/dist/vfs/dir.d.ts +5 -82
  46. package/dist/vfs/dir.js +5 -233
  47. package/dist/vfs/file.d.ts +52 -13
  48. package/dist/vfs/file.js +167 -25
  49. package/dist/vfs/flags.js +1 -1
  50. package/dist/vfs/index.d.ts +2 -5
  51. package/dist/vfs/index.js +2 -5
  52. package/dist/vfs/shared.d.ts +25 -1
  53. package/dist/vfs/shared.js +6 -4
  54. package/dist/vfs/sync.d.ts +17 -245
  55. package/dist/vfs/sync.js +129 -773
  56. package/dist/vfs/watchers.d.ts +1 -1
  57. package/dist/vfs/watchers.js +2 -2
  58. package/dist/vfs/xattr.js +1 -1
  59. package/eslint.shared.js +1 -0
  60. package/package.json +7 -5
  61. package/scripts/make-index.js +5 -29
  62. package/scripts/test.js +59 -51
  63. package/tests/backend/fetch.test.ts +2 -2
  64. package/tests/backend/port.test.ts +2 -3
  65. package/tests/backend/single-buffer.test.ts +1 -1
  66. package/tests/common/casefold.test.ts +1 -1
  67. package/tests/common/context.test.ts +11 -4
  68. package/tests/common/devices.test.ts +3 -3
  69. package/tests/common/handle.test.ts +4 -3
  70. package/tests/common/inode.test.ts +2 -2
  71. package/tests/common/mounts.test.ts +1 -3
  72. package/tests/common/mutex.test.ts +1 -3
  73. package/tests/common/path.test.ts +2 -2
  74. package/tests/common/readline.test.ts +1 -1
  75. package/tests/common.ts +5 -4
  76. package/tests/fetch/fetch.ts +1 -1
  77. package/tests/fs/dir.test.ts +3 -43
  78. package/tests/fs/directory.test.ts +4 -4
  79. package/tests/fs/errors.test.ts +2 -2
  80. package/tests/fs/links.test.ts +1 -1
  81. package/tests/fs/permissions.test.ts +3 -3
  82. package/tests/fs/read.test.ts +1 -1
  83. package/tests/fs/scaling.test.ts +1 -1
  84. package/tests/fs/stat.test.ts +1 -2
  85. package/tests/fs/times.test.ts +1 -1
  86. package/tests/fs/watch.test.ts +3 -2
  87. package/tests/setup/context.ts +1 -2
  88. package/tests/setup/cow.ts +1 -1
  89. package/tests/setup/index.ts +2 -2
  90. package/tests/setup/port.ts +1 -1
  91. package/tests/setup/single-buffer.ts +1 -1
  92. package/tests/setup.ts +4 -3
  93. package/dist/vfs/types.d.ts +0 -24
  94. package/tests/assignment.ts +0 -21
  95. /package/dist/{vfs/constants.d.ts → constants.d.ts} +0 -0
  96. /package/dist/{vfs/constants.js → constants.js} +0 -0
  97. /package/dist/{readline.d.ts → node/readline.d.ts} +0 -0
  98. /package/dist/{readline.js → node/readline.js} +0 -0
  99. /package/dist/{vfs → node}/streams.d.ts +0 -0
  100. /package/dist/{vfs → node}/types.js +0 -0
@@ -20,7 +20,7 @@ suite('Error messages', () => {
20
20
  test('open', async () => await assert.rejects(() => fs.promises.open(path, 'r'), missing));
21
21
  test('readdir', async () => await assert.rejects(() => fs.promises.readdir(path), missing));
22
22
  test('unlink', async () => await assert.rejects(() => fs.promises.unlink(path), missing));
23
- test('link', async () => await assert.rejects(() => fs.promises.link(path, 'foo'), missing));
23
+ test('link', async () => await assert.rejects(() => fs.promises.link(path, 'foo'), { code: 'ENOENT', path: '/foo' }));
24
24
  test('chmod', async () => await assert.rejects(() => fs.promises.chmod(path, 0o666), missing));
25
25
  test('lstat', async () => await assert.rejects(() => fs.promises.lstat(path), missing));
26
26
  test('readlink', async () => await assert.rejects(() => fs.promises.readlink(path), missing));
@@ -32,7 +32,7 @@ suite('Error messages', () => {
32
32
  test('openSync', () => assert.throws(() => fs.openSync(path, 'r'), missing));
33
33
  test('readdirSync', () => assert.throws(() => fs.readdirSync(path), missing));
34
34
  test('unlinkSync', () => assert.throws(() => fs.unlinkSync(path), missing));
35
- test('linkSync', () => assert.throws(() => fs.linkSync(path, 'foo'), missing));
35
+ test('linkSync', () => assert.throws(() => fs.linkSync(path, 'foo'), { code: 'ENOENT', path: '/foo' }));
36
36
  test('chmodSync', () => assert.throws(() => fs.chmodSync(path, 0o666), missing));
37
37
  test('lstatSync', () => assert.throws(() => fs.lstatSync(path), missing));
38
38
  test('readlinkSync', () => assert.throws(() => fs.readlinkSync(path), missing));
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { join } from '@zenfs/core/path';
2
3
  import type { Exception } from 'kerium';
3
4
  import assert from 'node:assert/strict';
4
5
  import { suite, test } from 'node:test';
5
- import { join } from '../../dist/path.js';
6
6
  import { fs } from '../common.js';
7
7
 
8
8
  suite('Links', () => {
@@ -3,9 +3,9 @@ import { Exception } from 'kerium';
3
3
  import assert from 'node:assert/strict';
4
4
  import { suite, test } from 'node:test';
5
5
  import { encodeUTF8 } from 'utilium';
6
- import { defaultContext } from '../../dist/internal/contexts.js';
7
- import { join } from '../../dist/path.js';
8
- import { R_OK, W_OK, X_OK } from '../../dist/vfs/constants.js';
6
+ import { defaultContext } from '@zenfs/core/internal/contexts.js';
7
+ import { join } from '@zenfs/core/path';
8
+ import { R_OK, W_OK, X_OK } from '@zenfs/core/constants';
9
9
  import { fs } from '../common.js';
10
10
 
11
11
  const asyncMode = 0o777;
@@ -1,10 +1,10 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { sync } from '@zenfs/core';
2
3
  import { Buffer } from 'buffer';
3
4
  import assert from 'node:assert/strict';
4
5
  import type { OpenMode, PathLike } from 'node:fs';
5
6
  import { suite, test } from 'node:test';
6
7
  import { promisify } from 'node:util';
7
- import { sync } from '../../dist/config.js';
8
8
  import { fs } from '../common.js';
9
9
 
10
10
  const filepath = 'x.txt';
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { sync } from '@zenfs/core';
2
3
  import assert from 'node:assert/strict';
3
4
  import { suite, test } from 'node:test';
4
- import { sync } from '../../dist/config.js';
5
5
  import { fs } from '../common.js';
6
6
 
7
7
  const n_files = 130;
@@ -1,8 +1,7 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { defaultContext, Stats } from '@zenfs/core';
2
3
  import assert from 'node:assert/strict';
3
4
  import { suite, test } from 'node:test';
4
- import { defaultContext } from '../../dist/internal/contexts.js';
5
- import { Stats } from '../../dist/vfs/stats.js';
6
5
  import { fs } from '../common.js';
7
6
 
8
7
  suite('Stats', () => {
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import type { StatsLike } from '@zenfs/core';
2
3
  import { Exception } from 'kerium';
3
4
  import assert from 'node:assert/strict';
4
5
  import { suite, test } from 'node:test';
5
6
  import { wait } from 'utilium';
6
- import type { StatsLike } from '../../dist/vfs/stats.js';
7
7
  import { fs } from '../common.js';
8
8
 
9
9
  const path = 'x.txt';
@@ -1,7 +1,8 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import type { Stats } from '@zenfs/core';
2
3
  import assert from 'node:assert/strict';
3
4
  import { suite, test } from 'node:test';
4
- import { fs, type Stats } from '../common.js';
5
+ import { fs } from '../common.js';
5
6
 
6
7
  const testDir = '/test-watch-dir';
7
8
  const testFile = testDir + '/test.txt';
@@ -12,7 +13,7 @@ await fs.promises.writeFile(testFile, 'Initial content');
12
13
  /**
13
14
  * @todo convert `using watcher = ...` to void discards pending ES proposal
14
15
  */
15
- suite('Watch', async () => {
16
+ suite('Watch', () => {
16
17
  test('Events emitted on file change', async () => {
17
18
  const { promise, resolve } = Promise.withResolvers<[string, string]>();
18
19
 
@@ -1,5 +1,4 @@
1
- import { bindContext } from '../../dist/context.js';
2
- import { fs as _fs } from '../../dist/index.js';
1
+ import { fs as _fs, bindContext } from '@zenfs/core';
3
2
  import { copySync, data } from '../setup.js';
4
3
 
5
4
  _fs.mkdirSync('/new_root');
@@ -1,4 +1,4 @@
1
- import { configureSingle, InMemory, CopyOnWrite, resolveMountConfig, fs } from '../../dist/index.js';
1
+ import { configureSingle, CopyOnWrite, fs, InMemory, resolveMountConfig } from '@zenfs/core';
2
2
  import { copySync, data } from '../setup.js';
3
3
 
4
4
  fs.umount('/');
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path/posix';
3
- import { configureSingle, CopyOnWrite, InMemory, InMemoryStore, mounts, Readonly, StoreFS } from '../../dist/index.js';
4
- import { S_IFDIR } from '../../dist/vfs/constants.js';
3
+ import { configureSingle, CopyOnWrite, InMemory, InMemoryStore, mounts, Readonly, StoreFS } from '@zenfs/core';
4
+ import { S_IFDIR } from '@zenfs/core/constants';
5
5
  import { copySync, data } from '../setup.js';
6
6
 
7
7
  copySync(data);
@@ -1,6 +1,6 @@
1
+ import { InMemory, Port, configureSingle, fs, resolveMountConfig, resolveRemoteMount, sync } from '@zenfs/core';
1
2
  import { after, afterEach } from 'node:test';
2
3
  import { MessageChannel } from 'node:worker_threads';
3
- import { InMemory, Port, configureSingle, fs, resolveMountConfig, resolveRemoteMount, sync } from '../../dist/index.js';
4
4
  import { copySync, data } from '../setup.js';
5
5
 
6
6
  const { port1: localPort, port2: remotePort } = new MessageChannel();
@@ -1,4 +1,4 @@
1
- import { SingleBuffer, configureSingle } from '../../dist/index.js';
1
+ import { SingleBuffer, configureSingle } from '@zenfs/core';
2
2
  import { copySync, data } from '../setup.js';
3
3
 
4
4
  await configureSingle({
package/tests/setup.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  // SPDX-License-Identifier: LGPL-3.0-or-later
2
+ import { fs as _fs } from '@zenfs/core';
2
3
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from 'node:fs';
3
4
  import { join, relative } from 'node:path';
4
- import { fs as _fs } from '../dist/index.js';
5
+ import type { NodeFS } from '@zenfs/core/node/types.js';
5
6
 
6
7
  export const data = join(import.meta.dirname, 'data');
7
8
 
@@ -9,7 +10,7 @@ export const tmp = join(import.meta.dirname, 'tmp');
9
10
 
10
11
  if (!existsSync(tmp)) mkdirSync(tmp);
11
12
 
12
- export async function copyAsync(_path: string, fs: typeof _fs = _fs): Promise<void> {
13
+ export async function copyAsync(_path: string, fs: NodeFS = _fs): Promise<void> {
13
14
  const path = relative(data, _path) || '/';
14
15
  const stats = statSync(_path);
15
16
 
@@ -26,7 +27,7 @@ export async function copyAsync(_path: string, fs: typeof _fs = _fs): Promise<vo
26
27
  }
27
28
  }
28
29
 
29
- export function copySync(_path: string, fs: typeof _fs = _fs): void {
30
+ export function copySync(_path: string, fs: NodeFS = _fs): void {
30
31
  const path = relative(data, _path) || '/';
31
32
  const stats = statSync(_path);
32
33
 
@@ -1,24 +0,0 @@
1
- import type * as fs from 'node:fs';
2
- export type FileContents = ArrayBufferView | string;
3
- /**
4
- * @internal @hidden Used for the internal `_open` functions
5
- */
6
- export interface OpenOptions {
7
- flag: fs.OpenMode;
8
- mode?: fs.Mode | null;
9
- /**
10
- * If true, do not resolve symlinks
11
- */
12
- preserveSymlinks?: boolean;
13
- /**
14
- * If true, allows opening directories
15
- */
16
- allowDirectory?: boolean;
17
- }
18
- export type ReaddirOptions = {
19
- withFileTypes?: boolean;
20
- recursive?: boolean;
21
- encoding?: BufferEncoding | 'buffer' | null;
22
- } | BufferEncoding | 'buffer' | null;
23
- /** Helper union @hidden */
24
- export type GlobOptionsU = fs.GlobOptionsWithFileTypes | fs.GlobOptionsWithoutFileTypes | fs.GlobOptions;
@@ -1,21 +0,0 @@
1
- // SPDX-License-Identifier: LGPL-3.0-or-later
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
3
-
4
- /*
5
- This test assigns the exported fs module from ZenFS with the one exported from Node.
6
- This ensures anything new that is added will be caught
7
-
8
- Notes on omissions and exclusions:
9
- - __promisify__ is omitted as it is metadata
10
- - native is omitted as zenfs isn't native
11
- - ReadStream and WriteStream are excluded since they are polyfilled from another module
12
- */
13
-
14
- import type * as node from 'node:fs';
15
- import { fs as zen } from '../src/index.js';
16
-
17
- type Mock = {
18
- [K in Exclude<keyof typeof node, 'ReadStream' | 'WriteStream'>]: Omit<(typeof node)[K], '__promisify__' | 'native'>;
19
- };
20
-
21
- const _module: Mock = zen;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes