@zenfs/core 0.17.1 → 0.18.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 (76) hide show
  1. package/dist/backends/backend.d.ts +2 -3
  2. package/dist/backends/fetch.js +2 -2
  3. package/dist/backends/file_index.d.ts +14 -15
  4. package/dist/backends/file_index.js +3 -9
  5. package/dist/backends/overlay.d.ts +23 -26
  6. package/dist/backends/overlay.js +117 -120
  7. package/dist/backends/port/fs.d.ts +22 -24
  8. package/dist/backends/port/fs.js +25 -26
  9. package/dist/backends/store/fs.d.ts +20 -21
  10. package/dist/backends/store/fs.js +70 -138
  11. package/dist/browser.min.js +4 -4
  12. package/dist/browser.min.js.map +4 -4
  13. package/dist/config.js +2 -2
  14. package/dist/{cred.d.ts → credentials.d.ts} +3 -2
  15. package/dist/credentials.js +16 -0
  16. package/dist/emulation/async.d.ts +19 -4
  17. package/dist/emulation/async.js +55 -8
  18. package/dist/emulation/dir.d.ts +4 -7
  19. package/dist/emulation/dir.js +16 -24
  20. package/dist/emulation/promises.d.ts +3 -3
  21. package/dist/emulation/promises.js +102 -46
  22. package/dist/emulation/shared.d.ts +0 -3
  23. package/dist/emulation/shared.js +0 -6
  24. package/dist/emulation/sync.d.ts +3 -4
  25. package/dist/emulation/sync.js +106 -65
  26. package/dist/emulation/watchers.d.ts +40 -3
  27. package/dist/emulation/watchers.js +115 -9
  28. package/dist/error.d.ts +1 -1
  29. package/dist/error.js +1 -1
  30. package/dist/file.d.ts +22 -13
  31. package/dist/file.js +16 -7
  32. package/dist/filesystem.d.ts +20 -21
  33. package/dist/filesystem.js +4 -4
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/mixins/async.d.ts +13 -14
  37. package/dist/mixins/async.js +45 -47
  38. package/dist/mixins/mutexed.d.ts +72 -10
  39. package/dist/mixins/mutexed.js +375 -371
  40. package/dist/mixins/readonly.d.ts +12 -13
  41. package/dist/mixins/readonly.js +12 -12
  42. package/dist/mixins/shared.d.ts +1 -0
  43. package/dist/mixins/shared.js +1 -0
  44. package/dist/mixins/sync.js +20 -20
  45. package/dist/stats.d.ts +12 -6
  46. package/dist/stats.js +15 -6
  47. package/dist/utils.d.ts +5 -5
  48. package/dist/utils.js +7 -17
  49. package/package.json +2 -2
  50. package/readme.md +1 -1
  51. package/src/backends/backend.ts +2 -3
  52. package/src/backends/fetch.ts +2 -2
  53. package/src/backends/file_index.ts +3 -12
  54. package/src/backends/overlay.ts +118 -124
  55. package/src/backends/port/fs.ts +29 -30
  56. package/src/backends/store/fs.ts +72 -151
  57. package/src/config.ts +3 -2
  58. package/src/{cred.ts → credentials.ts} +11 -2
  59. package/src/emulation/async.ts +72 -16
  60. package/src/emulation/dir.ts +21 -29
  61. package/src/emulation/promises.ts +106 -46
  62. package/src/emulation/shared.ts +0 -8
  63. package/src/emulation/sync.ts +108 -66
  64. package/src/emulation/watchers.ts +140 -10
  65. package/src/error.ts +1 -1
  66. package/src/file.ts +16 -11
  67. package/src/filesystem.ts +22 -23
  68. package/src/index.ts +1 -1
  69. package/src/mixins/async.ts +54 -55
  70. package/src/mixins/mutexed.ts +194 -182
  71. package/src/mixins/readonly.ts +24 -25
  72. package/src/mixins/shared.ts +3 -2
  73. package/src/mixins/sync.ts +21 -22
  74. package/src/stats.ts +17 -8
  75. package/src/utils.ts +12 -27
  76. package/dist/cred.js +0 -8
@@ -84,10 +84,9 @@ export declare function checkOptions<T extends Backend>(backend: T, opts: Record
84
84
  /**
85
85
  * Specifies a file system backend type and its options.
86
86
  *
87
- * Individual options can recursively contain BackendConfig objects for
88
- * option values that require file systems.
87
+ * Individual options can recursively contain BackendConfiguration objects for values that require file systems.
89
88
  *
90
- * The option object for each file system corresponds to that file system's option object passed to its `Create()` method.
89
+ * The configuration for each file system corresponds to that file system's option object passed to its `create()` method.
91
90
  */
92
91
  export type BackendConfiguration<T extends Backend> = OptionsOf<T> & Partial<SharedConfig> & {
93
92
  backend: T;
@@ -80,10 +80,10 @@ export class FetchFS extends IndexFS {
80
80
  preload(path, buffer) {
81
81
  const stats = this.index.get(path);
82
82
  if (!stats) {
83
- throw ErrnoError.With('ENOENT', path, 'preloadFile');
83
+ throw ErrnoError.With('ENOENT', path, 'preload');
84
84
  }
85
85
  if (!stats.isFile()) {
86
- throw ErrnoError.With('EISDIR', path, 'preloadFile');
86
+ throw ErrnoError.With('EISDIR', path, 'preload');
87
87
  }
88
88
  stats.size = buffer.length;
89
89
  stats.fileData = buffer;
@@ -1,4 +1,3 @@
1
- import type { Cred } from '../cred.js';
2
1
  import { NoSyncFile } from '../file.js';
3
2
  import { FileSystem } from '../filesystem.js';
4
3
  import type { StatsLike } from '../stats.js';
@@ -45,18 +44,18 @@ export declare class Index extends Map<string, Stats> {
45
44
  }
46
45
  declare const IndexFS_base: import("../mixins/shared.js").Mixin<typeof FileSystem, {
47
46
  metadata(): import("../filesystem.js").FileSystemMetadata;
48
- rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
49
- renameSync(oldPath: string, newPath: string, cred: Cred): void;
50
- createFile(path: string, flag: string, mode: number, cred: Cred): Promise<import("../file.js").File>;
51
- createFileSync(path: string, flag: string, mode: number, cred: Cred): import("../file.js").File;
52
- unlink(path: string, cred: Cred): Promise<void>;
53
- unlinkSync(path: string, cred: Cred): void;
54
- rmdir(path: string, cred: Cred): Promise<void>;
55
- rmdirSync(path: string, cred: Cred): void;
56
- mkdir(path: string, mode: number, cred: Cred): Promise<void>;
57
- mkdirSync(path: string, mode: number, cred: Cred): void;
58
- link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
59
- linkSync(srcpath: string, dstpath: string, cred: Cred): void;
47
+ rename(oldPath: string, newPath: string): Promise<void>;
48
+ renameSync(oldPath: string, newPath: string): void;
49
+ createFile(path: string, flag: string, mode: number): Promise<import("../file.js").File>;
50
+ createFileSync(path: string, flag: string, mode: number): import("../file.js").File;
51
+ unlink(path: string): Promise<void>;
52
+ unlinkSync(path: string): void;
53
+ rmdir(path: string): Promise<void>;
54
+ rmdirSync(path: string): void;
55
+ mkdir(path: string, mode: number): Promise<void>;
56
+ mkdirSync(path: string, mode: number): void;
57
+ link(srcpath: string, dstpath: string): Promise<void>;
58
+ linkSync(srcpath: string, dstpath: string): void;
60
59
  sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
61
60
  syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
62
61
  }>;
@@ -70,8 +69,8 @@ export declare abstract class IndexFS extends IndexFS_base {
70
69
  reloadFilesSync(): void;
71
70
  stat(path: string): Promise<Stats>;
72
71
  statSync(path: string): Stats;
73
- openFile(path: string, flag: string, cred: Cred): Promise<NoSyncFile<this>>;
74
- openFileSync(path: string, flag: string, cred: Cred): NoSyncFile<this>;
72
+ openFile(path: string, flag: string): Promise<NoSyncFile<this>>;
73
+ openFileSync(path: string, flag: string): NoSyncFile<this>;
75
74
  readdir(path: string): Promise<string[]>;
76
75
  readdirSync(path: string): string[];
77
76
  protected abstract getData(path: string, stats: Stats): Promise<Uint8Array>;
@@ -2,7 +2,7 @@
2
2
  import { isJSON } from 'utilium';
3
3
  import { basename, dirname } from '../emulation/path.js';
4
4
  import { Errno, ErrnoError } from '../error.js';
5
- import { NoSyncFile, flagToMode, isWriteable } from '../file.js';
5
+ import { NoSyncFile, isWriteable } from '../file.js';
6
6
  import { FileSystem } from '../filesystem.js';
7
7
  import { Readonly } from '../mixins/readonly.js';
8
8
  import { Stats } from '../stats.js';
@@ -118,7 +118,7 @@ export class IndexFS extends Readonly(FileSystem) {
118
118
  }
119
119
  return this.index.get(path);
120
120
  }
121
- async openFile(path, flag, cred) {
121
+ async openFile(path, flag) {
122
122
  if (isWriteable(flag)) {
123
123
  // You can't write to files on this file system.
124
124
  throw new ErrnoError(Errno.EPERM, path);
@@ -128,12 +128,9 @@ export class IndexFS extends Readonly(FileSystem) {
128
128
  if (!stats) {
129
129
  throw ErrnoError.With('ENOENT', path, 'openFile');
130
130
  }
131
- if (!stats.hasAccess(flagToMode(flag), cred)) {
132
- throw ErrnoError.With('EACCES', path, 'openFile');
133
- }
134
131
  return new NoSyncFile(this, path, flag, stats, stats.isDirectory() ? stats.fileData : await this.getData(path, stats));
135
132
  }
136
- openFileSync(path, flag, cred) {
133
+ openFileSync(path, flag) {
137
134
  if (isWriteable(flag)) {
138
135
  // You can't write to files on this file system.
139
136
  throw new ErrnoError(Errno.EPERM, path);
@@ -143,9 +140,6 @@ export class IndexFS extends Readonly(FileSystem) {
143
140
  if (!stats) {
144
141
  throw ErrnoError.With('ENOENT', path, 'openFile');
145
142
  }
146
- if (!stats.hasAccess(flagToMode(flag), cred)) {
147
- throw ErrnoError.With('EACCES', path, 'openFile');
148
- }
149
143
  return new NoSyncFile(this, path, flag, stats, stats.isDirectory() ? stats.fileData : this.getDataSync(path, stats));
150
144
  }
151
145
  readdir(path) {
@@ -1,8 +1,7 @@
1
+ import type { File } from '../file.js';
1
2
  import type { FileSystemMetadata } from '../filesystem.js';
2
3
  import { FileSystem } from '../filesystem.js';
3
- import type { File } from '../file.js';
4
4
  import { Stats } from '../stats.js';
5
- import type { Cred } from '../cred.js';
6
5
  /**
7
6
  * Configuration options for OverlayFS instances.
8
7
  */
@@ -45,25 +44,25 @@ export declare class UnmutexedOverlayFS extends FileSystem {
45
44
  */
46
45
  _initialize(): Promise<void>;
47
46
  getDeletionLog(): string;
48
- restoreDeletionLog(log: string, cred: Cred): Promise<void>;
49
- rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
50
- renameSync(oldPath: string, newPath: string, cred: Cred): void;
51
- stat(path: string, cred: Cred): Promise<Stats>;
52
- statSync(path: string, cred: Cred): Stats;
53
- openFile(path: string, flag: string, cred: Cred): Promise<File>;
54
- openFileSync(path: string, flag: string, cred: Cred): File;
55
- createFile(path: string, flag: string, mode: number, cred: Cred): Promise<File>;
56
- createFileSync(path: string, flag: string, mode: number, cred: Cred): File;
57
- link(srcpath: string, dstpath: string, cred: Cred): Promise<void>;
58
- linkSync(srcpath: string, dstpath: string, cred: Cred): void;
59
- unlink(path: string, cred: Cred): Promise<void>;
60
- unlinkSync(path: string, cred: Cred): void;
61
- rmdir(path: string, cred: Cred): Promise<void>;
62
- rmdirSync(path: string, cred: Cred): void;
63
- mkdir(path: string, mode: number, cred: Cred): Promise<void>;
64
- mkdirSync(path: string, mode: number, cred: Cred): void;
65
- readdir(path: string, cred: Cred): Promise<string[]>;
66
- readdirSync(path: string, cred: Cred): string[];
47
+ restoreDeletionLog(log: string): Promise<void>;
48
+ rename(oldPath: string, newPath: string): Promise<void>;
49
+ renameSync(oldPath: string, newPath: string): void;
50
+ stat(path: string): Promise<Stats>;
51
+ statSync(path: string): Stats;
52
+ openFile(path: string, flag: string): Promise<File>;
53
+ openFileSync(path: string, flag: string): File;
54
+ createFile(path: string, flag: string, mode: number): Promise<File>;
55
+ createFileSync(path: string, flag: string, mode: number): File;
56
+ link(srcpath: string, dstpath: string): Promise<void>;
57
+ linkSync(srcpath: string, dstpath: string): void;
58
+ unlink(path: string): Promise<void>;
59
+ unlinkSync(path: string): void;
60
+ rmdir(path: string): Promise<void>;
61
+ rmdirSync(path: string): void;
62
+ mkdir(path: string, mode: number): Promise<void>;
63
+ mkdirSync(path: string, mode: number): void;
64
+ readdir(path: string): Promise<string[]>;
65
+ readdirSync(path: string): string[];
67
66
  private deletePath;
68
67
  private updateLog;
69
68
  private _reparseDeletionLog;
@@ -89,11 +88,9 @@ export declare class UnmutexedOverlayFS extends FileSystem {
89
88
  private copyToWritableSync;
90
89
  private copyToWritable;
91
90
  }
92
- declare const OverlayFS_base: import("../mixins/shared.js").Mixin<typeof UnmutexedOverlayFS, {
93
- lock(path: string): Promise<import("../mixins/mutexed.js").MutexLock>;
94
- lockSync(path: string): import("../mixins/mutexed.js").MutexLock;
95
- isLocked(path: string): boolean;
96
- }>;
91
+ declare const OverlayFS_base: {
92
+ new (): import("../mixins/mutexed.js").__MutexedFS<UnmutexedOverlayFS>;
93
+ } & (new (args_0: OverlayOptions) => import("../mixins/mutexed.js").__MutexedFS<UnmutexedOverlayFS>);
97
94
  /**
98
95
  * OverlayFS makes a read-only filesystem writable by storing writes on a second,
99
96
  * writable file system. Deletes are persisted via metadata stored on the writable