@zenfs/core 2.0.0 → 2.1.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 (88) hide show
  1. package/dist/backends/backend.js +6 -5
  2. package/dist/backends/cow.d.ts +2 -2
  3. package/dist/backends/cow.js +39 -58
  4. package/dist/backends/fetch.js +27 -29
  5. package/dist/backends/passthrough.d.ts +2 -3
  6. package/dist/backends/passthrough.js +84 -199
  7. package/dist/backends/port.d.ts +16 -3
  8. package/dist/backends/port.js +61 -30
  9. package/dist/backends/single_buffer.d.ts +52 -46
  10. package/dist/backends/single_buffer.js +462 -219
  11. package/dist/backends/store/fs.d.ts +16 -10
  12. package/dist/backends/store/fs.js +227 -242
  13. package/dist/backends/store/store.d.ts +3 -3
  14. package/dist/backends/store/store.js +11 -10
  15. package/dist/config.d.ts +2 -2
  16. package/dist/config.js +10 -11
  17. package/dist/internal/devices.d.ts +2 -2
  18. package/dist/internal/devices.js +39 -49
  19. package/dist/internal/error.d.ts +9 -204
  20. package/dist/internal/error.js +19 -288
  21. package/dist/internal/file_index.d.ts +1 -1
  22. package/dist/internal/file_index.js +9 -9
  23. package/dist/internal/filesystem.d.ts +23 -8
  24. package/dist/internal/index.d.ts +1 -1
  25. package/dist/internal/index.js +1 -1
  26. package/dist/internal/index_fs.d.ts +2 -2
  27. package/dist/internal/index_fs.js +19 -19
  28. package/dist/internal/inode.d.ts +81 -103
  29. package/dist/internal/inode.js +336 -195
  30. package/dist/mixins/async.js +32 -28
  31. package/dist/mixins/mutexed.d.ts +4 -4
  32. package/dist/mixins/mutexed.js +39 -39
  33. package/dist/mixins/readonly.d.ts +2 -2
  34. package/dist/mixins/readonly.js +20 -20
  35. package/dist/mixins/sync.js +2 -2
  36. package/dist/polyfills.js +1 -1
  37. package/dist/readline.js +1 -1
  38. package/dist/utils.d.ts +8 -5
  39. package/dist/utils.js +14 -17
  40. package/dist/vfs/acl.d.ts +8 -8
  41. package/dist/vfs/acl.js +66 -47
  42. package/dist/vfs/async.d.ts +2 -2
  43. package/dist/vfs/async.js +6 -8
  44. package/dist/vfs/dir.d.ts +1 -1
  45. package/dist/vfs/dir.js +3 -4
  46. package/dist/vfs/file.js +33 -24
  47. package/dist/vfs/flags.js +3 -3
  48. package/dist/vfs/ioctl.d.ts +8 -7
  49. package/dist/vfs/ioctl.js +132 -27
  50. package/dist/vfs/promises.d.ts +3 -3
  51. package/dist/vfs/promises.js +200 -235
  52. package/dist/vfs/shared.d.ts +1 -12
  53. package/dist/vfs/shared.js +7 -35
  54. package/dist/vfs/streams.js +9 -9
  55. package/dist/vfs/sync.d.ts +1 -2
  56. package/dist/vfs/sync.js +158 -170
  57. package/dist/vfs/watchers.js +8 -8
  58. package/dist/vfs/xattr.js +89 -106
  59. package/package.json +5 -3
  60. package/scripts/test.js +2 -2
  61. package/tests/assignment.ts +1 -1
  62. package/tests/backend/port.test.ts +4 -4
  63. package/tests/backend/single-buffer.test.ts +39 -10
  64. package/tests/backend/single-buffer.worker.js +30 -0
  65. package/tests/common/context.test.ts +2 -2
  66. package/tests/common/mutex.test.ts +9 -9
  67. package/tests/fetch/fetch.ts +1 -1
  68. package/tests/fetch/run.sh +1 -1
  69. package/tests/fs/append.test.ts +4 -4
  70. package/tests/fs/directory.test.ts +25 -25
  71. package/tests/fs/errors.test.ts +15 -19
  72. package/tests/fs/links.test.ts +3 -2
  73. package/tests/fs/open.test.ts +4 -21
  74. package/tests/fs/permissions.test.ts +8 -13
  75. package/tests/fs/read.test.ts +10 -9
  76. package/tests/fs/readFile.test.ts +8 -24
  77. package/tests/fs/rename.test.ts +4 -9
  78. package/tests/fs/stat.test.ts +2 -2
  79. package/tests/fs/times.test.ts +6 -6
  80. package/tests/fs/truncate.test.ts +8 -36
  81. package/tests/fs/watch.test.ts +10 -10
  82. package/tests/fs/write.test.ts +77 -13
  83. package/tests/fs/xattr.test.ts +7 -7
  84. package/tests/logs.js +2 -2
  85. package/tests/setup/port.ts +6 -0
  86. package/dist/internal/log.d.ts +0 -139
  87. package/dist/internal/log.js +0 -219
  88. package/tests/fs/writeFile.test.ts +0 -70
@@ -1,3 +1,4 @@
1
+ import { BufferView } from 'utilium/buffer.js';
1
2
  import { Stats, type StatsLike } from '../vfs/stats.js';
2
3
  import { type V_Context } from './contexts.js';
3
4
  /**
@@ -5,32 +6,23 @@ import { type V_Context } from './contexts.js';
5
6
  * @hidden
6
7
  */
7
8
  export declare const rootIno = 0;
8
- declare class Attribute {
9
- protected keySize: number;
10
- protected valueSize: number;
11
- protected _key: string;
12
- get key(): string;
13
- set key(value: string);
14
- protected _value: Uint8Array;
15
- get value(): Uint8Array;
16
- set value(value: Uint8Array);
17
- constructor(key?: string, value?: Uint8Array);
18
- }
19
9
  /**
20
10
  * Extended attributes
21
11
  * @category Internals
22
12
  * @internal
23
13
  */
24
- export declare class Attributes {
25
- size: number;
26
- data: Attribute[];
14
+ export declare class Attributes extends BufferView {
15
+ accessor size: number;
16
+ ['constructor']: typeof Attributes;
17
+ get byteSize(): number;
27
18
  has(name: string): boolean;
28
- get(name: string): Attribute | undefined;
19
+ get(name: string): Uint8Array | undefined;
29
20
  set(name: string, value: Uint8Array): void;
30
21
  remove(name: string): boolean;
31
- keys(): string[];
32
- values(): Uint8Array[];
33
- entries(): [string, Uint8Array][];
22
+ copyFrom(other: Attributes): void;
23
+ keys(): Generator<string, void, unknown>;
24
+ values(): Generator<Uint8Array<ArrayBufferLike>, void, unknown>;
25
+ entries(): Generator<(string | Uint8Array<ArrayBufferLike>)[], void, unknown>;
34
26
  }
35
27
  /**
36
28
  * @internal @hidden
@@ -56,75 +48,53 @@ export declare const _inode_fields: readonly ["ino", "data", "size", "mode", "fl
56
48
  * 1. 58 bytes. The first member was called `ino` but used as the ID for data.
57
49
  * 2. 66 bytes. Renamed the first member from `ino` to `data` and added a separate `ino` field
58
50
  * 3. 72 bytes. Changed the ID fields from 64 to 32 bits and added `flags`.
59
- * 4. (current) Added extended attributes. At least 128 bytes.
51
+ * 4. >= 128 bytes. Added extended attributes.
52
+ * 5. (current) 4 KiB. Changed flags
60
53
  * @internal @hidden
61
54
  */
62
- export declare const _inode_version = 4;
55
+ export declare const _inode_version = 5;
63
56
  /**
64
- * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
65
- * @see `FS_*_FL` in `include/uapi/linux/fs.h` (around L250)
57
+ * Inode flags
58
+ * @see `S_*` in `include/linux/fs.h` (around L2325)
66
59
  * @experimental
67
60
  */
68
61
  export declare enum InodeFlags {
69
- /** Secure deletion */
70
- SecureRm = 1,
71
- /** Undelete */
72
- Undelete = 2,
73
- /** Compress file */
74
- Compress = 4,
75
- /** Synchronous updates */
76
- Sync = 8,
62
+ /** Writes are synced at once */
63
+ Sync = 1,
64
+ /** Do not update access times */
65
+ NoAtime = 2,
66
+ /** Append-only file */
67
+ Append = 4,
77
68
  /** Immutable file */
78
- Immutable = 16,
79
- /** Writes to file may only append */
80
- Append = 32,
81
- /** do not dump file */
82
- NoDump = 64,
83
- /** do not update atime */
84
- NoAtime = 128,
85
- Dirty = 256,
86
- /** One or more compressed clusters */
87
- CompressBlk = 512,
88
- /** Don't compress */
89
- NoCompress = 1024,
90
- /** Encrypted file */
91
- Encrypt = 2048,
92
- /** btree format dir */
93
- Btree = 4096,
94
- /** hash-indexed directory */
95
- Index = 4096,
96
- /** AFS directory */
97
- IMagic = 8192,
98
- /** Reserved for ext3 */
99
- JournalData = 16384,
100
- /** file tail should not be merged */
101
- NoTail = 32768,
102
- /** dirsync behaviour (directories only) */
103
- DirSync = 65536,
104
- /** Top of directory hierarchies*/
105
- TopDir = 131072,
106
- /** Reserved for ext4 */
107
- HugeFile = 262144,
108
- /** Extents */
109
- Extent = 524288,
110
- /** Verity protected inode */
111
- Verity = 1048576,
112
- /** Inode used for large EA */
113
- EaInode = 2097152,
114
- /** Reserved for ext4 */
115
- EofBlocks = 4194304,
116
- /** Do not cow file */
117
- NoCow = 8388608,
118
- /** Inode is DAX */
119
- Dax = 33554432,
120
- /** Reserved for ext4 */
121
- InlineData = 268435456,
122
- /** Create with parents projid */
123
- ProjInherit = 536870912,
124
- /** Folder is case insensitive */
125
- CaseFold = 1073741824,
126
- /** reserved for ext2 lib */
127
- Reserved = 2147483648
69
+ Immutable = 8,
70
+ /** removed, but still open directory */
71
+ Dead = 16,
72
+ /** Inode is not counted to quota */
73
+ NoQuota = 32,
74
+ /** Directory modifications are synchronous */
75
+ Dirsync = 64,
76
+ /** Do not update file c/mtime */
77
+ NoCMtime = 128,
78
+ /** Do not truncate: swapon got its bmaps */
79
+ SwapFile = 256,
80
+ /** Inode is fs-internal */
81
+ Private = 512,
82
+ /** Inode has an associated IMA struct */
83
+ IMA = 1024,
84
+ /** Automount/referral quasi-directory */
85
+ AutoMount = 2048,
86
+ /** no suid or xattr security attributes */
87
+ NoSec = 4096,
88
+ /** Direct Access, avoiding the page cache */
89
+ DAX = 8192,
90
+ /** Encrypted file (using fs/crypto/) */
91
+ Encrypted = 16384,
92
+ /** Casefolded file */
93
+ CaseFold = 32768,
94
+ /** Verity file (using fs/verity/) */
95
+ Verity = 65536,
96
+ /** File is in use by the kernel (eg. fs/cachefiles) */
97
+ KernelFile = 131072
128
98
  }
129
99
  /** User visible flags */
130
100
  export declare const userVisibleFlags = 253951;
@@ -135,40 +105,49 @@ export declare const userModifiableFlags = 229631;
135
105
  * @category Internals
136
106
  * @internal
137
107
  */
138
- export declare class Inode implements InodeLike {
139
- constructor(data?: Uint8Array | Readonly<Partial<InodeLike>>);
140
- data: number;
108
+ export declare class Inode extends BufferView implements InodeLike {
109
+ constructor(...args: ConstructorParameters<typeof BufferView> | [Readonly<Partial<InodeLike>>]);
110
+ accessor data: number;
141
111
  /** For future use */
142
- __data_old: number;
143
- size: number;
144
- mode: number;
145
- nlink: number;
146
- uid: number;
147
- gid: number;
148
- atimeMs: number;
149
- birthtimeMs: number;
150
- mtimeMs: number;
112
+ accessor __data_old: number;
113
+ accessor size: number;
114
+ accessor mode: number;
115
+ accessor nlink: number;
116
+ accessor uid: number;
117
+ accessor gid: number;
118
+ accessor atimeMs: number;
119
+ accessor birthtimeMs: number;
120
+ accessor mtimeMs: number;
151
121
  /**
152
122
  * The time the inode was changed.
153
123
  *
154
124
  * This is automatically updated whenever changed are made using `update()`.
155
125
  */
156
- ctimeMs: number;
157
- ino: number;
126
+ accessor ctimeMs: number;
127
+ accessor ino: number;
158
128
  /** For future use */
159
- __ino_old: number;
160
- flags: number;
129
+ accessor __ino_old: number;
130
+ accessor flags: number;
161
131
  /** For future use */
162
- protected __after_flags: number;
132
+ protected accessor __after_flags: number;
163
133
  /**
164
134
  * The "version" of the inode/data.
165
- *
166
135
  * Unrelated to the inode format!
167
136
  */
168
- version: number;
169
- /** Pad to 128 bytes */
170
- protected __padding: never[];
171
- attributes: Attributes;
137
+ accessor version: number;
138
+ /**
139
+ * Padding up to 128 bytes.
140
+ * This ensures there is enough room for expansion without breaking the ABI.
141
+ * @internal
142
+ */
143
+ protected accessor __padding: Uint8Array;
144
+ accessor attributes: Attributes;
145
+ /**
146
+ * Since the attribute data uses dynamic arrays,
147
+ * it is necessary to add this so attributes can be added.
148
+ * @internal @hidden
149
+ */
150
+ protected accessor __data: Uint8Array;
172
151
  toString(): string;
173
152
  toJSON(): InodeLike;
174
153
  /**
@@ -214,4 +193,3 @@ export declare function isFIFO(metadata: {
214
193
  * @internal
215
194
  */
216
195
  export declare function hasAccess($: V_Context, inode: Pick<InodeLike, 'mode' | 'uid' | 'gid'>, access: number): boolean;
217
- export {};