@zenfs/core 2.3.5 → 2.3.7

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.
@@ -68,7 +68,10 @@ declare const _Port: {
68
68
  name: string;
69
69
  options: {
70
70
  port: {
71
- type: string[];
71
+ type: ({
72
+ new (): EventTarget;
73
+ prototype: EventTarget;
74
+ } | ((e: any) => boolean))[];
72
75
  required: true;
73
76
  };
74
77
  timeout: {
@@ -112,7 +112,12 @@ const _Port = {
112
112
  name: 'Port',
113
113
  options: {
114
114
  port: {
115
- type: ['Worker', 'MessagePort', 'WebSocket'],
115
+ type: [
116
+ EventTarget,
117
+ function EventEmitter(e) {
118
+ return typeof e == 'object' && 'on' in e;
119
+ },
120
+ ],
116
121
  required: true,
117
122
  },
118
123
  timeout: { type: 'number', required: false },
@@ -1,4 +1,4 @@
1
- import { type StructArray } from 'memium';
1
+ import type { ArrayOf } from 'memium';
2
2
  import type { UUID } from 'node:crypto';
3
3
  import { BufferView } from 'utilium/buffer.js';
4
4
  import type { UsageInfo } from '../internal/filesystem.js';
@@ -6,7 +6,8 @@ import { StoreFS } from './store/fs.js';
6
6
  import { SyncMapTransaction, type SyncMapStore } from './store/map.js';
7
7
  import type { Store } from './store/store.js';
8
8
  type Lock = Disposable & (() => void);
9
- declare class MetadataEntry extends BufferView {
9
+ declare const MetadataEntry_base: import("memium").StructConstructor<BufferView<any>>;
10
+ declare class MetadataEntry extends MetadataEntry_base {
10
11
  /** Inode or data ID */
11
12
  accessor id: number;
12
13
  /** Reserved for 64-bit offset expansion */
@@ -17,12 +18,13 @@ declare class MetadataEntry extends BufferView {
17
18
  accessor size: number;
18
19
  toString(): string;
19
20
  }
21
+ declare const MetadataBlock_base: import("memium/decorators").StructFromTypedArray<Int32Array<ArrayBuffer>>;
20
22
  /**
21
23
  * A block of metadata for a single-buffer file system.
22
24
  * This metadata maps IDs (for inodes and data) to actual offsets in the buffer.
23
25
  * This is done since IDs are not guaranteed to be sequential.
24
26
  */
25
- export declare class MetadataBlock extends Int32Array<ArrayBufferLike> {
27
+ export declare class MetadataBlock extends MetadataBlock_base<ArrayBufferLike> {
26
28
  readonly ['constructor']: typeof MetadataBlock;
27
29
  /**
28
30
  * The crc32c checksum for the metadata block.
@@ -37,7 +39,7 @@ export declare class MetadataBlock extends Int32Array<ArrayBufferLike> {
37
39
  get previous(): MetadataBlock | undefined;
38
40
  protected get offsetHex(): string;
39
41
  /** Metadata entries. */
40
- accessor items: StructArray<MetadataEntry>;
42
+ accessor items: ArrayOf<MetadataEntry>;
41
43
  toString(long?: boolean): string;
42
44
  /**
43
45
  * If non-zero, this block is locked for writing.
@@ -50,10 +52,11 @@ export declare class MetadataBlock extends Int32Array<ArrayBufferLike> {
50
52
  waitUnlocked(depth?: number): void;
51
53
  lock(): Lock;
52
54
  }
55
+ declare const SuperBlock_base: import("memium/decorators").StructFromTypedArray<BigUint64Array<ArrayBuffer>>;
53
56
  /**
54
57
  * The super block structure for a single-buffer file system
55
58
  */
56
- export declare class SuperBlock extends BigUint64Array<ArrayBufferLike> {
59
+ export declare class SuperBlock extends SuperBlock_base<ArrayBufferLike> {
57
60
  readonly ['constructor']: typeof SuperBlock;
58
61
  constructor(...args: ConstructorParameters<typeof BigUint64Array<ArrayBufferLike>>);
59
62
  /**
@@ -86,7 +86,8 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
86
86
  });
87
87
  import { withErrno } from 'kerium';
88
88
  import { alert, crit, err, warn } from 'kerium/log';
89
- import { field, offsetof, packed, sizeof, struct, types as t } from 'memium';
89
+ import { array, offsetof, packed, sizeof } from 'memium';
90
+ import { $from, field, struct, types as t } from 'memium/decorators';
90
91
  import { BufferView } from 'utilium/buffer.js';
91
92
  import { crc32c } from 'utilium/checksum.js';
92
93
  import { decodeUUID, encodeUUID } from 'utilium/string.js';
@@ -102,11 +103,11 @@ const { format } = new Intl.NumberFormat('en-US', {
102
103
  });
103
104
  let MetadataEntry = (() => {
104
105
  var _a, _b, _c, _d;
105
- let _classDecorators = [struct(packed, { name: 'MetadataEntry' })];
106
+ let _classDecorators = [struct.packed('MetadataEntry')];
106
107
  let _classDescriptor;
107
108
  let _classExtraInitializers = [];
108
109
  let _classThis;
109
- let _classSuper = BufferView;
110
+ let _classSuper = $from(BufferView);
110
111
  let _id_decorators;
111
112
  let _id_initializers = [];
112
113
  let _id_extraInitializers = [];
@@ -177,11 +178,11 @@ const max_lock_attempts = 5;
177
178
  */
178
179
  let MetadataBlock = (() => {
179
180
  var _a, _b, _c, _d;
180
- let _classDecorators = [struct(packed, { name: 'MetadataBlock' })];
181
+ let _classDecorators = [struct.packed('MetadataBlock')];
181
182
  let _classDescriptor;
182
183
  let _classExtraInitializers = [];
183
184
  let _classThis;
184
- let _classSuper = Int32Array;
185
+ let _classSuper = $from.typed(Int32Array);
185
186
  let _checksum_decorators;
186
187
  let _checksum_initializers = [];
187
188
  let _checksum_extraInitializers = [];
@@ -204,7 +205,7 @@ let MetadataBlock = (() => {
204
205
  _checksum_decorators = [(_a = t).uint32.bind(_a)];
205
206
  _timestamp_decorators = [(_b = t).uint64.bind(_b)];
206
207
  _previous_offset_decorators = [(_c = t).uint32.bind(_c)];
207
- _items_decorators = [field(MetadataEntry, { length: entries_per_block })];
208
+ _items_decorators = [field(array(MetadataEntry, entries_per_block))];
208
209
  _locked_decorators = [(_d = t).int32.bind(_d)];
209
210
  __esDecorate(this, null, _checksum_decorators, { kind: "accessor", name: "checksum", static: false, private: false, access: { has: obj => "checksum" in obj, get: obj => obj.checksum, set: (obj, value) => { obj.checksum = value; } }, metadata: _metadata }, _checksum_initializers, _checksum_extraInitializers);
210
211
  __esDecorate(this, null, _timestamp_decorators, { kind: "accessor", name: "timestamp", static: false, private: false, access: { has: obj => "timestamp" in obj, get: obj => obj.timestamp, set: (obj, value) => { obj.timestamp = value; } }, metadata: _metadata }, _timestamp_initializers, _timestamp_extraInitializers);
@@ -319,11 +320,11 @@ const usedBytes = 2;
319
320
  */
320
321
  let SuperBlock = (() => {
321
322
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
322
- let _classDecorators = [struct(packed, { name: 'SuperBlock' })];
323
+ let _classDecorators = [struct.packed('Superblock')];
323
324
  let _classDescriptor;
324
325
  let _classExtraInitializers = [];
325
326
  let _classThis;
326
- let _classSuper = BigUint64Array;
327
+ let _classSuper = $from.typed(BigUint64Array);
327
328
  let _checksum_decorators;
328
329
  let _checksum_initializers = [];
329
330
  let _checksum_extraInitializers = [];
@@ -136,7 +136,9 @@ export class StoreFS extends FileSystem {
136
136
  async ready() {
137
137
  if (this._initialized)
138
138
  return;
139
- this.checkRootSync();
139
+ if (!this.attributes.has('no_async_preload')) {
140
+ this.checkRootSync();
141
+ }
140
142
  await this.checkRoot();
141
143
  await this._populate();
142
144
  this._initialized = true;
@@ -6,14 +6,14 @@ import { type V_Context } from './contexts.js';
6
6
  * @hidden
7
7
  */
8
8
  export declare const rootIno = 0;
9
+ declare const Attributes_base: import("memium").StructConstructor<BufferView<any>>;
9
10
  /**
10
11
  * Extended attributes
11
12
  * @category Internals
12
13
  * @internal
13
14
  */
14
- export declare class Attributes extends BufferView {
15
+ export declare class Attributes extends Attributes_base {
15
16
  accessor size: number;
16
- ['constructor']: typeof Attributes;
17
17
  get byteSize(): number;
18
18
  has(name: string): boolean;
19
19
  get(name: string): Uint8Array | undefined;
@@ -100,12 +100,13 @@ export declare enum InodeFlags {
100
100
  export declare const userVisibleFlags = 253951;
101
101
  /** User modifiable flags */
102
102
  export declare const userModifiableFlags = 229631;
103
+ declare const Inode_base: import("memium").StructConstructor<BufferView<any>>;
103
104
  /**
104
105
  * Generic inode definition that can easily be serialized.
105
106
  * @category Internals
106
107
  * @internal
107
108
  */
108
- export declare class Inode extends BufferView implements InodeLike {
109
+ export declare class Inode extends Inode_base implements InodeLike {
109
110
  constructor(...args: ConstructorParameters<typeof BufferView> | [Readonly<Partial<InodeLike>>]);
110
111
  accessor data: number;
111
112
  /** For future use */
@@ -193,3 +194,4 @@ export declare function isFIFO(metadata: {
193
194
  * @internal
194
195
  */
195
196
  export declare function hasAccess($: V_Context, inode: Pick<InodeLike, 'mode' | 'uid' | 'gid'>, access: number): boolean;
197
+ export {};
@@ -34,7 +34,8 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
34
34
  };
35
35
  import { withErrno } from 'kerium';
36
36
  import { crit, warn } from 'kerium/log';
37
- import { field, packed, sizeof, struct, types as t } from 'memium';
37
+ import { sizeof } from 'memium';
38
+ import { $from, field, struct, types as t } from 'memium/decorators';
38
39
  import { decodeUTF8, encodeUTF8, pick } from 'utilium';
39
40
  import { BufferView } from 'utilium/buffer.js';
40
41
  import * as c from '../vfs/constants.js';
@@ -49,11 +50,11 @@ export const rootIno = 0;
49
50
  const maxDynamicData = 3968;
50
51
  let Attribute = (() => {
51
52
  var _a, _b;
52
- let _classDecorators = [struct(packed, { name: 'Attribute' })];
53
+ let _classDecorators = [struct.packed('Attribute')];
53
54
  let _classDescriptor;
54
55
  let _classExtraInitializers = [];
55
56
  let _classThis;
56
- let _classSuper = Uint8Array;
57
+ let _classSuper = $from.typed(Uint8Array);
57
58
  let _keySize_decorators;
58
59
  let _keySize_initializers = [];
59
60
  let _keySize_extraInitializers = [];
@@ -120,11 +121,11 @@ let Attribute = (() => {
120
121
  */
121
122
  let Attributes = (() => {
122
123
  var _a;
123
- let _classDecorators = [struct(packed, { name: 'Attributes' })];
124
+ let _classDecorators = [struct.packed('Attributes')];
124
125
  let _classDescriptor;
125
126
  let _classExtraInitializers = [];
126
127
  let _classThis;
127
- let _classSuper = BufferView;
128
+ let _classSuper = $from(BufferView);
128
129
  let _size_decorators;
129
130
  let _size_initializers = [];
130
131
  let _size_extraInitializers = [];
@@ -328,11 +329,11 @@ export const userModifiableFlags = 0x000380ff;
328
329
  */
329
330
  let Inode = (() => {
330
331
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
331
- let _classDecorators = [struct(packed, { name: 'Inode' })];
332
+ let _classDecorators = [struct.packed('Inode')];
332
333
  let _classDescriptor;
333
334
  let _classExtraInitializers = [];
334
335
  let _classThis;
335
- let _classSuper = BufferView;
336
+ let _classSuper = $from(BufferView);
336
337
  let _data_decorators;
337
338
  let _data_initializers = [];
338
339
  let _data_extraInitializers = [];
package/dist/vfs/acl.d.ts CHANGED
@@ -17,12 +17,14 @@ export declare const enum Tag {
17
17
  */
18
18
  _None = 0
19
19
  }
20
- export declare class Entry extends BufferView {
20
+ declare const Entry_base: import("memium").StructConstructor<BufferView<any>>;
21
+ export declare class Entry extends Entry_base {
21
22
  accessor tag: Tag;
22
23
  accessor perm: number;
23
24
  accessor id: number;
24
25
  }
25
- export declare class ACL extends BufferView {
26
+ declare const ACL_base: import("memium").StructConstructor<BufferView<any>>;
27
+ export declare class ACL extends ACL_base {
26
28
  accessor version: number;
27
29
  entries: Entry[];
28
30
  constructor(...args: ConstructorParameters<typeof BufferView>);
@@ -40,3 +42,4 @@ export declare function setChecks(enabled: boolean): void;
40
42
  * @param access The requested access, combination of `W_OK`, `R_OK`, and `X_OK`
41
43
  */
42
44
  export declare function check($: V_Context, inode: InodeLike, access: number): boolean;
45
+ export {};
package/dist/vfs/acl.js CHANGED
@@ -40,7 +40,8 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
40
40
  */
41
41
  import { withErrno } from 'kerium';
42
42
  import { err } from 'kerium/log';
43
- import { packed, sizeof, struct, types as t } from 'memium';
43
+ import { packed, sizeof } from 'memium';
44
+ import { $from, struct, types as t } from 'memium/decorators';
44
45
  import { BufferView } from 'utilium/buffer.js';
45
46
  import { defaultContext } from '../internal/contexts.js';
46
47
  import { Attributes } from '../internal/inode.js';
@@ -67,11 +68,11 @@ export var Tag;
67
68
  })(Tag || (Tag = {}));
68
69
  let Entry = (() => {
69
70
  var _a, _b, _c;
70
- let _classDecorators = [struct(packed, { name: 'Entry' })];
71
+ let _classDecorators = [struct('ACL.Entry', packed)];
71
72
  let _classDescriptor;
72
73
  let _classExtraInitializers = [];
73
74
  let _classThis;
74
- let _classSuper = BufferView;
75
+ let _classSuper = $from(BufferView);
75
76
  let _tag_decorators;
76
77
  let _tag_initializers = [];
77
78
  let _tag_extraInitializers = [];
@@ -115,11 +116,11 @@ let Entry = (() => {
115
116
  export { Entry };
116
117
  let ACL = (() => {
117
118
  var _a;
118
- let _classDecorators = [struct(packed, { name: 'ACL' })];
119
+ let _classDecorators = [struct.packed('ACL')];
119
120
  let _classDescriptor;
120
121
  let _classExtraInitializers = [];
121
122
  let _classThis;
122
- let _classSuper = BufferView;
123
+ let _classSuper = $from(BufferView);
123
124
  let _version_decorators;
124
125
  let _version_initializers = [];
125
126
  let _version_extraInitializers = [];
package/dist/vfs/dir.d.ts CHANGED
@@ -28,7 +28,8 @@ export declare function ifToDt(mode: number): DirType;
28
28
  * @see `DTTOIF` in `dirent.h`
29
29
  */
30
30
  export declare function dtToIf(dt: DirType): number;
31
- export declare class Dirent<Name extends string | Buffer = string, TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends BufferView<TArrayBuffer> implements _Dirent<Name> {
31
+ declare const Dirent_base: import("memium").StructConstructor<BufferView<any>>;
32
+ export declare class Dirent<Name extends string | Buffer = string, TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Dirent_base<TArrayBuffer> implements _Dirent<Name> {
32
33
  protected accessor ino: number;
33
34
  /** Reserved for 64-bit inodes */
34
35
  private accessor _ino;
@@ -100,5 +101,7 @@ export declare class Dir implements _Dir, AsyncIterator<Dirent> {
100
101
  * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
101
102
  */
102
103
  [Symbol.asyncIterator](): this;
104
+ [Symbol.dispose](): void;
103
105
  [Symbol.asyncDispose](): Promise<void>;
104
106
  }
107
+ export {};
package/dist/vfs/dir.js CHANGED
@@ -34,8 +34,9 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
34
34
  };
35
35
  import { Buffer } from 'buffer';
36
36
  import { withErrno } from 'kerium';
37
- import { packed, sizeof, struct, types as t } from 'memium';
38
37
  import { warn } from 'kerium/log';
38
+ import { packed, sizeof } from 'memium';
39
+ import { $from, struct, types as t } from 'memium/decorators';
39
40
  import { encodeUTF8 } from 'utilium';
40
41
  import { BufferView } from 'utilium/buffer.js';
41
42
  import { basename, dirname } from '../path.js';
@@ -72,11 +73,11 @@ export function dtToIf(dt) {
72
73
  }
73
74
  let Dirent = (() => {
74
75
  var _a, _b, _c;
75
- let _classDecorators = [struct(packed, { name: 'Dirent' })];
76
+ let _classDecorators = [struct.packed('Dirent')];
76
77
  let _classDescriptor;
77
78
  let _classExtraInitializers = [];
78
79
  let _classThis;
79
- let _classSuper = BufferView;
80
+ let _classSuper = $from(BufferView);
80
81
  let _ino_decorators;
81
82
  let _ino_initializers = [];
82
83
  let _ino_extraInitializers = [];
@@ -250,7 +251,10 @@ export class Dir {
250
251
  [Symbol.asyncIterator]() {
251
252
  return this;
252
253
  }
253
- [Symbol.asyncDispose]() {
254
- return Promise.resolve();
254
+ [Symbol.dispose]() {
255
+ this.closeSync();
256
+ }
257
+ async [Symbol.asyncDispose]() {
258
+ await this.close();
255
259
  }
256
260
  }
@@ -1,7 +1,8 @@
1
1
  import { BufferView } from 'utilium/buffer.js';
2
2
  import type { V_Context } from '../context.js';
3
3
  import { Inode } from '../internal/inode.js';
4
- declare class fsxattr extends BufferView {
4
+ declare const fsxattr_base: import("memium").StructConstructor<BufferView<any>>;
5
+ declare class fsxattr extends fsxattr_base {
5
6
  /** xflags field value */
6
7
  accessor xflags: number;
7
8
  /** extsize field value */
package/dist/vfs/ioctl.js CHANGED
@@ -39,7 +39,8 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
39
39
  return useValue ? value : void 0;
40
40
  };
41
41
  import { Errno, Exception, setUVMessage, UV } from 'kerium';
42
- import { sizeof, struct, types as t } from 'memium';
42
+ import { sizeof } from 'memium';
43
+ import { $from, struct, types as t } from 'memium/decorators';
43
44
  import { _throw } from 'utilium';
44
45
  import { BufferView } from 'utilium/buffer.js';
45
46
  import { Inode, InodeFlags } from '../internal/inode.js';
@@ -87,11 +88,11 @@ var XFlag;
87
88
  })(XFlag || (XFlag = {}));
88
89
  let fsxattr = (() => {
89
90
  var _a, _b, _c, _d, _e;
90
- let _classDecorators = [struct({ name: 'fsxattr' })];
91
+ let _classDecorators = [struct('fsxattr')];
91
92
  let _classDescriptor;
92
93
  let _classExtraInitializers = [];
93
94
  let _classThis;
94
- let _classSuper = BufferView;
95
+ let _classSuper = $from(BufferView);
95
96
  let _xflags_decorators;
96
97
  let _xflags_initializers = [];
97
98
  let _xflags_extraInitializers = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenfs/core",
3
- "version": "2.3.5",
3
+ "version": "2.3.7",
4
4
  "description": "A filesystem, anywhere",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -67,11 +67,11 @@
67
67
  "prepublishOnly": "npm run build"
68
68
  },
69
69
  "dependencies": {
70
- "@types/node": "^24.0.13",
70
+ "@types/node": "^24.1.0",
71
71
  "buffer": "^6.0.3",
72
72
  "eventemitter3": "^5.0.1",
73
73
  "kerium": "^1.3.4",
74
- "memium": "^0.2.3",
74
+ "memium": "^0.3.7",
75
75
  "readable-stream": "^4.5.2",
76
76
  "utilium": "^2.3.3"
77
77
  },
@@ -0,0 +1,19 @@
1
+ import { suite, test } from 'node:test';
2
+ import { Inode } from '../../dist/internal/inode.js';
3
+ import assert from 'node:assert';
4
+
5
+ suite('Inode manipulation', () => {
6
+ const inode = new Inode();
7
+ inode.mode = 0o40755;
8
+ assert.equal(inode.mode, 0o40755);
9
+
10
+ test('Copy to new Inode using constructor and spread', () => {
11
+ const newInode = new Inode({ ...inode });
12
+ assert.equal(newInode.mode, inode.mode);
13
+ });
14
+
15
+ test('Copy to new Inode using Object.assign', () => {
16
+ const newInode = Object.assign(new Inode(), inode);
17
+ assert.equal(newInode.mode, inode.mode);
18
+ });
19
+ });