@zenfs/core 0.2.3 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { type FileSystem, SyncFileSystem, FileSystemMetadata } from '../filesystem.js';
1
+ import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
2
  import { File, FileFlag, PreloadFile } from '../file.js';
3
3
  import { Stats } from '../stats.js';
4
4
  import { Cred } from '../cred.js';
@@ -28,6 +28,32 @@ export declare namespace AsyncMirror {
28
28
  async: FileSystem;
29
29
  }
30
30
  }
31
+ declare const AsyncMirrorFS_base: (abstract new (...args: any[]) => {
32
+ readonly metadata: FileSystemMetadata;
33
+ ready(): Promise<any>;
34
+ exists(path: string, cred: Cred): Promise<boolean>;
35
+ rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
36
+ stat(path: string, cred: Cred): Promise<Stats>;
37
+ createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
38
+ openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
39
+ unlink(path: string, cred: Cred): Promise<void>;
40
+ rmdir(path: string, cred: Cred): Promise<void>;
41
+ mkdir(path: string, mode: number, cred: Cred): Promise<void>;
42
+ readdir(path: string, cred: Cred): Promise<string[]>;
43
+ link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
44
+ sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
45
+ renameSync(oldPath: string, newPath: string, cred: Cred): void;
46
+ statSync(path: string, cred: Cred): Stats;
47
+ openFileSync(path: string, flag: FileFlag, cred: Cred): File;
48
+ createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
49
+ unlinkSync(path: string, cred: Cred): void;
50
+ rmdirSync(path: string, cred: Cred): void;
51
+ mkdirSync(path: string, mode: number, cred: Cred): void;
52
+ readdirSync(path: string, cred: Cred): string[];
53
+ existsSync(path: string, cred: Cred): boolean;
54
+ linkSync(srcpath: string, dstpath: string, cred: Cred): void;
55
+ syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
56
+ }) & typeof FileSystem;
31
57
  /**
32
58
  * AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem
33
59
  * by:
@@ -41,7 +67,7 @@ export declare namespace AsyncMirror {
41
67
  * in-memory filesystem with an asynchronous backing store.
42
68
  *
43
69
  */
44
- export declare class AsyncMirrorFS extends SyncFileSystem {
70
+ export declare class AsyncMirrorFS extends AsyncMirrorFS_base {
45
71
  /**
46
72
  * Queue of pending asynchronous operations.
47
73
  */
@@ -1,4 +1,4 @@
1
- import { SyncFileSystem } from '../filesystem.js';
1
+ import { FileSystem, Sync } from '../filesystem.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { FileFlag, PreloadFile } from '../file.js';
4
4
  import { join } from '../emulation/path.js';
@@ -39,7 +39,7 @@ class MirrorFile extends PreloadFile {
39
39
  * in-memory filesystem with an asynchronous backing store.
40
40
  *
41
41
  */
42
- export class AsyncMirrorFS extends SyncFileSystem {
42
+ export class AsyncMirrorFS extends Sync(FileSystem) {
43
43
  async ready() {
44
44
  await this._ready;
45
45
  return this;
@@ -63,6 +63,7 @@ export class AsyncMirrorFS extends SyncFileSystem {
63
63
  this._async = async;
64
64
  this._ready = this._initialize();
65
65
  }
66
+ // @ts-expect-error 2611
66
67
  get metadata() {
67
68
  return {
68
69
  ...super.metadata,
@@ -71,15 +72,6 @@ export class AsyncMirrorFS extends SyncFileSystem {
71
72
  supportsProperties: this._sync.metadata.supportsProperties && this._async.metadata.supportsProperties,
72
73
  };
73
74
  }
74
- /*public _syncSync(file: PreloadFile<AsyncMirror>, cred: Cred) {
75
- const sync = this._sync.openFileSync(file.path, FileFlag.FromString('w'), cred);
76
- sync.writeSync(file.buffer);
77
-
78
- this.enqueue({
79
- apiMethod: 'writeFile',
80
- arguments: [file.path, file.buffer, file.flag, file.stats.mode, cred],
81
- });
82
- }*/
83
75
  syncSync(path, data, stats) {
84
76
  this._sync.syncSync(path, data, stats);
85
77
  this.enqueue({
@@ -1,6 +1,6 @@
1
1
  import { Cred } from '../cred.js';
2
2
  import { PreloadFile, File, FileFlag } from '../file.js';
3
- import { AsyncFileSystem, type FileSystemMetadata } from '../filesystem.js';
3
+ import { FileSystem, type FileSystemMetadata } from '../filesystem.js';
4
4
  import { type Ino } from '../inode.js';
5
5
  import { Stats } from '../stats.js';
6
6
  /**
@@ -79,11 +79,24 @@ export interface AsyncStoreFileSystemOptions {
79
79
  */
80
80
  cacheSize?: number;
81
81
  }
82
+ declare const AsyncStoreFileSystem_base: (abstract new (...args: any[]) => {
83
+ readonly metadata: FileSystemMetadata;
84
+ renameSync(oldPath: string, newPath: string, cred: Cred): void;
85
+ statSync(path: string, cred: Cred): Stats;
86
+ createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
87
+ openFileSync(path: string, flag: FileFlag, cred: Cred): File;
88
+ unlinkSync(path: string, cred: Cred): void;
89
+ rmdirSync(path: string, cred: Cred): void;
90
+ mkdirSync(path: string, mode: number, cred: Cred): void;
91
+ readdirSync(path: string, cred: Cred): string[];
92
+ linkSync(srcpath: string, dstpath: string, cred: Cred): void;
93
+ syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
94
+ }) & typeof FileSystem;
82
95
  /**
83
96
  * An "Asynchronous key-value file system". Stores data to/retrieves data from
84
97
  * an underlying asynchronous key-value store.
85
98
  */
86
- export declare class AsyncStoreFileSystem extends AsyncFileSystem {
99
+ export declare class AsyncStoreFileSystem extends AsyncStoreFileSystem_base {
87
100
  protected store: AsyncStore;
88
101
  private _cache?;
89
102
  protected _ready: Promise<this>;
@@ -175,3 +188,4 @@ export declare class AsyncStoreFileSystem extends AsyncFileSystem {
175
188
  */
176
189
  private removeEntry;
177
190
  }
191
+ export {};
@@ -2,7 +2,7 @@ import { dirname, basename, join, resolve } from '../emulation/path.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { W_OK, R_OK } from '../emulation/constants.js';
4
4
  import { PreloadFile } from '../file.js';
5
- import { AsyncFileSystem } from '../filesystem.js';
5
+ import { Async, FileSystem } from '../filesystem.js';
6
6
  import { randomIno, Inode } from '../inode.js';
7
7
  import { FileType } from '../stats.js';
8
8
  import { encode, decodeDirListing, encodeDirListing } from '../utils.js';
@@ -69,10 +69,11 @@ export class AsyncFile extends PreloadFile {
69
69
  * An "Asynchronous key-value file system". Stores data to/retrieves data from
70
70
  * an underlying asynchronous key-value store.
71
71
  */
72
- export class AsyncStoreFileSystem extends AsyncFileSystem {
72
+ export class AsyncStoreFileSystem extends Async(FileSystem) {
73
73
  ready() {
74
74
  return this._ready;
75
75
  }
76
+ // @ts-expect-error 2611
76
77
  get metadata() {
77
78
  return {
78
79
  ...super.metadata,
@@ -12,7 +12,7 @@ import { Cred } from '../cred.js';
12
12
  * LockedFS to avoid having to reason about the correctness of
13
13
  * multiple requests interleaving.
14
14
  */
15
- export default class LockedFS<T extends FileSystem> implements FileSystem {
15
+ export declare class LockedFS<T extends FileSystem> implements FileSystem {
16
16
  readonly fs: T;
17
17
  private _mu;
18
18
  constructor(fs: T);
@@ -8,7 +8,7 @@ import Mutex from '../mutex.js';
8
8
  * LockedFS to avoid having to reason about the correctness of
9
9
  * multiple requests interleaving.
10
10
  */
11
- export default class LockedFS {
11
+ export class LockedFS {
12
12
  constructor(fs) {
13
13
  this.fs = fs;
14
14
  this._mu = new Mutex();
@@ -1,7 +1,7 @@
1
1
  import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
2
  import { File, FileFlag } from '../file.js';
3
3
  import { Stats } from '../stats.js';
4
- import LockedFS from './Locked.js';
4
+ import { LockedFS } from './Locked.js';
5
5
  import { Cred } from '../cred.js';
6
6
  import type { Backend } from './backend.js';
7
7
  /**
@@ -2,7 +2,7 @@ import { FileSystem } from '../filesystem.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { FileFlag, PreloadFile } from '../file.js';
4
4
  import { Stats } from '../stats.js';
5
- import LockedFS from './Locked.js';
5
+ import { LockedFS } from './Locked.js';
6
6
  import { dirname } from '../emulation/path.js';
7
7
  import { Cred } from '../cred.js';
8
8
  import { decode, encode } from '../utils.js';
@@ -1,6 +1,6 @@
1
1
  import { Cred } from '../cred.js';
2
2
  import { FileFlag, PreloadFile } from '../file.js';
3
- import { SyncFileSystem, type FileSystemMetadata } from '../filesystem.js';
3
+ import { type FileSystemMetadata, FileSystem } from '../filesystem.js';
4
4
  import { type Ino, Inode } from '../inode.js';
5
5
  import { Stats, FileType } from '../stats.js';
6
6
  /**
@@ -119,6 +119,32 @@ export declare class SyncStoreFile extends PreloadFile<SyncStoreFileSystem> {
119
119
  close(): Promise<void>;
120
120
  closeSync(): void;
121
121
  }
122
+ declare const SyncStoreFileSystem_base: (abstract new (...args: any[]) => {
123
+ readonly metadata: FileSystemMetadata;
124
+ ready(): Promise<any>;
125
+ exists(path: string, cred: Cred): Promise<boolean>;
126
+ rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
127
+ stat(path: string, cred: Cred): Promise<Stats>;
128
+ createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<import("../file.js").File>;
129
+ openFile(path: string, flag: FileFlag, cred: Cred): Promise<import("../file.js").File>;
130
+ unlink(path: string, cred: Cred): Promise<void>;
131
+ rmdir(path: string, cred: Cred): Promise<void>;
132
+ mkdir(path: string, mode: number, cred: Cred): Promise<void>;
133
+ readdir(path: string, cred: Cred): Promise<string[]>;
134
+ link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
135
+ sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
136
+ renameSync(oldPath: string, newPath: string, cred: Cred): void;
137
+ statSync(path: string, cred: Cred): Stats;
138
+ openFileSync(path: string, flag: FileFlag, cred: Cred): import("../file.js").File;
139
+ createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): import("../file.js").File;
140
+ unlinkSync(path: string, cred: Cred): void;
141
+ rmdirSync(path: string, cred: Cred): void;
142
+ mkdirSync(path: string, mode: number, cred: Cred): void;
143
+ readdirSync(path: string, cred: Cred): string[];
144
+ existsSync(path: string, cred: Cred): boolean;
145
+ linkSync(srcpath: string, dstpath: string, cred: Cred): void;
146
+ syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
147
+ }) & typeof FileSystem;
122
148
  /**
123
149
  * A "Synchronous key-value file system". Stores data to/retrieves data from an
124
150
  * underlying key-value store.
@@ -128,7 +154,7 @@ export declare class SyncStoreFile extends PreloadFile<SyncStoreFileSystem> {
128
154
  * @todo Introduce Node ID caching.
129
155
  * @todo Check modes.
130
156
  */
131
- export declare class SyncStoreFileSystem extends SyncFileSystem {
157
+ export declare class SyncStoreFileSystem extends SyncStoreFileSystem_base {
132
158
  protected store: SyncStore;
133
159
  constructor(options: SyncStoreFileSystemOptions);
134
160
  get metadata(): FileSystemMetadata;
@@ -202,3 +228,4 @@ export declare class SyncStoreFileSystem extends SyncFileSystem {
202
228
  */
203
229
  protected removeEntry(p: string, isDir: boolean, cred: Cred): void;
204
230
  }
231
+ export {};
@@ -2,7 +2,7 @@ import { dirname, basename, join, resolve, sep } from '../emulation/path.js';
2
2
  import { ApiError, ErrorCode } from '../ApiError.js';
3
3
  import { W_OK, R_OK } from '../emulation/constants.js';
4
4
  import { PreloadFile } from '../file.js';
5
- import { SyncFileSystem } from '../filesystem.js';
5
+ import { FileSystem, Sync } from '../filesystem.js';
6
6
  import { randomIno, Inode } from '../inode.js';
7
7
  import { FileType } from '../stats.js';
8
8
  import { decodeDirListing, encode, encodeDirListing } from '../utils.js';
@@ -105,13 +105,14 @@ export class SyncStoreFile extends PreloadFile {
105
105
  * @todo Introduce Node ID caching.
106
106
  * @todo Check modes.
107
107
  */
108
- export class SyncStoreFileSystem extends SyncFileSystem {
108
+ export class SyncStoreFileSystem extends Sync(FileSystem) {
109
109
  constructor(options) {
110
110
  super();
111
111
  this.store = options.store;
112
112
  // INVARIANT: Ensure that the root exists.
113
113
  this.makeRootDirectory();
114
114
  }
115
+ // @ts-expect-error 2611
115
116
  get metadata() {
116
117
  return {
117
118
  ...super.metadata,