@zenfs/core 0.0.12 → 0.2.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 (54) hide show
  1. package/dist/ApiError.d.ts +52 -15
  2. package/dist/ApiError.js +77 -50
  3. package/dist/FileIndex.d.ts +32 -35
  4. package/dist/FileIndex.js +93 -109
  5. package/dist/backends/AsyncMirror.d.ts +42 -43
  6. package/dist/backends/AsyncMirror.js +154 -147
  7. package/dist/backends/AsyncStore.d.ts +29 -28
  8. package/dist/backends/AsyncStore.js +375 -482
  9. package/dist/backends/FolderAdapter.js +8 -19
  10. package/dist/backends/InMemory.d.ts +16 -13
  11. package/dist/backends/InMemory.js +29 -14
  12. package/dist/backends/Locked.d.ts +8 -28
  13. package/dist/backends/Locked.js +74 -224
  14. package/dist/backends/OverlayFS.d.ts +26 -34
  15. package/dist/backends/OverlayFS.js +303 -511
  16. package/dist/backends/SyncStore.d.ts +54 -72
  17. package/dist/backends/SyncStore.js +159 -161
  18. package/dist/backends/backend.d.ts +45 -29
  19. package/dist/backends/backend.js +83 -13
  20. package/dist/backends/index.d.ts +6 -7
  21. package/dist/backends/index.js +5 -6
  22. package/dist/browser.min.js +21 -6
  23. package/dist/browser.min.js.map +4 -4
  24. package/dist/emulation/callbacks.d.ts +119 -113
  25. package/dist/emulation/callbacks.js +129 -92
  26. package/dist/emulation/constants.js +1 -1
  27. package/dist/emulation/dir.d.ts +55 -0
  28. package/dist/emulation/dir.js +104 -0
  29. package/dist/emulation/fs.d.ts +1 -2
  30. package/dist/emulation/fs.js +0 -1
  31. package/dist/emulation/index.d.ts +3 -0
  32. package/dist/emulation/index.js +3 -0
  33. package/dist/emulation/promises.d.ts +265 -145
  34. package/dist/emulation/promises.js +526 -383
  35. package/dist/emulation/shared.d.ts +20 -6
  36. package/dist/emulation/shared.js +22 -23
  37. package/dist/emulation/streams.d.ts +102 -0
  38. package/dist/emulation/streams.js +55 -0
  39. package/dist/emulation/sync.d.ts +98 -69
  40. package/dist/emulation/sync.js +280 -133
  41. package/dist/file.d.ts +175 -173
  42. package/dist/file.js +257 -273
  43. package/dist/filesystem.d.ts +71 -244
  44. package/dist/filesystem.js +67 -472
  45. package/dist/index.d.ts +7 -44
  46. package/dist/index.js +22 -75
  47. package/dist/inode.d.ts +37 -28
  48. package/dist/inode.js +123 -65
  49. package/dist/stats.d.ts +91 -36
  50. package/dist/stats.js +138 -110
  51. package/dist/utils.d.ts +26 -13
  52. package/dist/utils.js +79 -107
  53. package/package.json +7 -4
  54. package/readme.md +2 -40
@@ -1,9 +1,9 @@
1
- import { type FileSystem, BaseFileSystem, FileSystemMetadata } from '../filesystem.js';
2
- import { File, FileFlag, PreloadFile } from '../file.js';
1
+ import { FileSystem, FileSystemMetadata } from '../filesystem.js';
2
+ import { File, FileFlag } from '../file.js';
3
3
  import { Stats } from '../stats.js';
4
4
  import LockedFS from './Locked.js';
5
5
  import { Cred } from '../cred.js';
6
- import { type BackendOptions } from './backend.js';
6
+ import type { Backend } from './backend.js';
7
7
  export declare namespace OverlayFS {
8
8
  /**
9
9
  * Configuration options for OverlayFS instances.
@@ -20,13 +20,15 @@ export declare namespace OverlayFS {
20
20
  }
21
21
  }
22
22
  /**
23
- * *INTERNAL, DO NOT USE DIRECTLY!*
23
+ * OverlayFS makes a read-only filesystem writable by storing writes on a second, writable file system.
24
+ * Deletes are persisted via metadata stored on the writable file system.
24
25
  *
25
- * Core OverlayFS class that contains no locking whatsoever. We wrap these objects
26
- * in a LockedFS to prevent races.
26
+ * This class contains no locking whatsoever. It is wrapped in a LockedFS to prevent races.
27
+ *
28
+ * @internal
27
29
  */
28
- export declare class UnlockedOverlayFS extends BaseFileSystem {
29
- static isAvailable(): boolean;
30
+ export declare class UnlockedOverlayFS extends FileSystem {
31
+ ready(): Promise<this>;
30
32
  private _writable;
31
33
  private _readable;
32
34
  private _isInitialized;
@@ -34,19 +36,16 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
34
36
  private _deleteLog;
35
37
  private _deleteLogUpdatePending;
36
38
  private _deleteLogUpdateNeeded;
37
- private _deleteLogError;
39
+ private _deleteLogError?;
40
+ private _ready;
38
41
  constructor({ writable, readable }: OverlayFS.Options);
39
42
  get metadata(): FileSystemMetadata;
40
- getOverlayedFileSystems(): {
41
- readable: FileSystem;
42
- writable: FileSystem;
43
- };
44
- _syncAsync(file: PreloadFile<UnlockedOverlayFS>): Promise<void>;
45
- _syncSync(file: PreloadFile<UnlockedOverlayFS>): void;
43
+ getOverlayedFileSystems(): OverlayFS.Options;
44
+ sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
45
+ syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
46
46
  /**
47
- * **INTERNAL METHOD**
48
- *
49
47
  * Called once to load up metadata stored on the writable file system.
48
+ * @internal
50
49
  */
51
50
  _initialize(): Promise<void>;
52
51
  getDeletionLog(): string;
@@ -55,8 +54,12 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
55
54
  renameSync(oldPath: string, newPath: string, cred: Cred): void;
56
55
  stat(p: string, cred: Cred): Promise<Stats>;
57
56
  statSync(p: string, cred: Cred): Stats;
58
- open(p: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
59
- openSync(p: string, flag: FileFlag, mode: number, cred: Cred): File;
57
+ openFile(path: string, flag: FileFlag, cred: Cred): Promise<File>;
58
+ openFileSync(path: string, flag: FileFlag, cred: Cred): File;
59
+ createFile(path: string, flag: FileFlag, mode: number, cred: Cred): Promise<File>;
60
+ createFileSync(path: string, flag: FileFlag, mode: number, cred: Cred): File;
61
+ link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
62
+ linkSync(srcpath: string, dstpath: string, cred: Cred): void;
60
63
  unlink(p: string, cred: Cred): Promise<void>;
61
64
  unlinkSync(p: string, cred: Cred): void;
62
65
  rmdir(p: string, cred: Cred): Promise<void>;
@@ -65,14 +68,6 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
65
68
  mkdirSync(p: string, mode: number, cred: Cred): void;
66
69
  readdir(p: string, cred: Cred): Promise<string[]>;
67
70
  readdirSync(p: string, cred: Cred): string[];
68
- exists(p: string, cred: Cred): Promise<boolean>;
69
- existsSync(p: string, cred: Cred): boolean;
70
- chmod(p: string, mode: number, cred: Cred): Promise<void>;
71
- chmodSync(p: string, mode: number, cred: Cred): void;
72
- chown(p: string, new_uid: number, new_gid: number, cred: Cred): Promise<void>;
73
- chownSync(p: string, new_uid: number, new_gid: number, cred: Cred): void;
74
- utimes(p: string, atime: Date, mtime: Date, cred: Cred): Promise<void>;
75
- utimesSync(p: string, atime: Date, mtime: Date, cred: Cred): void;
76
71
  private deletePath;
77
72
  private updateLog;
78
73
  private _reparseDeletionLog;
@@ -82,8 +77,8 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
82
77
  * With the given path, create the needed parent directories on the writable storage
83
78
  * should they not exist. Use modes from the read-only storage.
84
79
  */
80
+ private createParentDirectoriesSync;
85
81
  private createParentDirectories;
86
- private createParentDirectoriesAsync;
87
82
  /**
88
83
  * Helper function:
89
84
  * - Ensures p is on writable before proceeding. Throws an error if it doesn't exist.
@@ -95,8 +90,8 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
95
90
  * Copy from readable to writable storage.
96
91
  * PRECONDITION: File does not exist on writable storage.
97
92
  */
93
+ private copyToWritableSync;
98
94
  private copyToWritable;
99
- private copyToWritableAsync;
100
95
  }
101
96
  /**
102
97
  * OverlayFS makes a read-only filesystem writable by storing writes on a second,
@@ -104,10 +99,7 @@ export declare class UnlockedOverlayFS extends BaseFileSystem {
104
99
  * file system.
105
100
  */
106
101
  export declare class OverlayFS extends LockedFS<UnlockedOverlayFS> {
107
- static readonly Name = "OverlayFS";
108
- static Create: any;
109
- static readonly Options: BackendOptions;
110
- static isAvailable(): boolean;
102
+ ready(): Promise<this>;
111
103
  /**
112
104
  * @param options The options to initialize the OverlayFS with
113
105
  */
@@ -116,5 +108,5 @@ export declare class OverlayFS extends LockedFS<UnlockedOverlayFS> {
116
108
  getDeletionLog(): string;
117
109
  resDeletionLog(): string;
118
110
  unwrap(): UnlockedOverlayFS;
119
- private _initialize;
120
111
  }
112
+ export declare const Overlay: Backend;