@zenfs/core 2.2.3 → 2.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.
- package/dist/backends/backend.js +6 -9
- package/dist/backends/cow.js +4 -4
- package/dist/backends/fetch.js +8 -6
- package/dist/backends/memory.js +4 -2
- package/dist/backends/passthrough.js +2 -0
- package/dist/backends/port.d.ts +16 -89
- package/dist/backends/port.js +35 -171
- package/dist/backends/single_buffer.d.ts +2 -2
- package/dist/backends/single_buffer.js +165 -198
- package/dist/backends/store/fs.js +50 -73
- package/dist/backends/store/map.js +1 -2
- package/dist/backends/store/store.js +23 -27
- package/dist/config.js +2 -3
- package/dist/context.js +2 -2
- package/dist/internal/devices.js +7 -10
- package/dist/internal/file_index.js +3 -8
- package/dist/internal/filesystem.js +19 -12
- package/dist/internal/index_fs.js +3 -4
- package/dist/internal/inode.js +144 -187
- package/dist/internal/rpc.d.ts +143 -0
- package/dist/internal/rpc.js +251 -0
- package/dist/mixins/async.js +5 -6
- package/dist/mixins/mutexed.js +16 -10
- package/dist/path.js +3 -4
- package/dist/polyfills.js +51 -22
- package/dist/readline.js +32 -30
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +11 -5
- package/dist/vfs/acl.js +44 -68
- package/dist/vfs/async.js +4 -4
- package/dist/vfs/dir.js +12 -8
- package/dist/vfs/file.js +22 -18
- package/dist/vfs/ioctl.js +39 -62
- package/dist/vfs/promises.js +48 -39
- package/dist/vfs/shared.js +4 -5
- package/dist/vfs/stats.js +104 -77
- package/dist/vfs/streams.js +11 -8
- package/dist/vfs/sync.js +23 -26
- package/dist/vfs/watchers.js +9 -3
- package/dist/vfs/xattr.js +6 -12
- package/package.json +2 -2
- package/scripts/test.js +16 -7
- package/tests/backend/fetch.test.ts +14 -14
- package/tests/backend/port.test.ts +25 -17
- package/tests/common/handle.test.ts +5 -3
- package/tests/fetch/run.sh +2 -1
- package/tests/fs/scaling.test.ts +32 -0
- package/tests/fs/watch.test.ts +2 -5
- package/tests/setup/single-buffer.ts +1 -1
- package/tests/tsconfig.json +3 -2
- package/types/uint8array.d.ts +64 -0
package/dist/readline.js
CHANGED
|
@@ -3,55 +3,57 @@
|
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { warn } from 'kerium/log';
|
|
5
5
|
export class Interface extends EventEmitter {
|
|
6
|
+
input;
|
|
7
|
+
output;
|
|
8
|
+
terminal;
|
|
9
|
+
line = '';
|
|
10
|
+
_cursor = 0;
|
|
6
11
|
get cursor() {
|
|
7
12
|
return this._cursor;
|
|
8
13
|
}
|
|
14
|
+
_buffer = '';
|
|
15
|
+
_closed = false;
|
|
16
|
+
_paused = false;
|
|
17
|
+
_prompt = '';
|
|
18
|
+
_history = [];
|
|
19
|
+
_historyIndex = -1;
|
|
20
|
+
_currentLine = '';
|
|
9
21
|
constructor(input, output, completer, terminal = false) {
|
|
10
22
|
super();
|
|
11
23
|
this.input = input;
|
|
12
24
|
this.output = output;
|
|
13
25
|
this.terminal = terminal;
|
|
14
|
-
this.line = '';
|
|
15
|
-
this._cursor = 0;
|
|
16
|
-
this._buffer = '';
|
|
17
|
-
this._closed = false;
|
|
18
|
-
this._paused = false;
|
|
19
|
-
this._prompt = '';
|
|
20
|
-
this._history = [];
|
|
21
|
-
this._historyIndex = -1;
|
|
22
|
-
this._currentLine = '';
|
|
23
|
-
this._onData = (data) => {
|
|
24
|
-
if (this._paused || this._closed)
|
|
25
|
-
return;
|
|
26
|
-
this._buffer += typeof data === 'string' ? data : data.toString('utf8');
|
|
27
|
-
for (let lineEnd = this._buffer.indexOf('\n'); lineEnd >= 0; lineEnd = this._buffer.indexOf('\n')) {
|
|
28
|
-
let line = this._buffer.substring(0, lineEnd);
|
|
29
|
-
if (line.endsWith('\r')) {
|
|
30
|
-
line = line.substring(0, line.length - 1);
|
|
31
|
-
}
|
|
32
|
-
this._buffer = this._buffer.substring(lineEnd + 1);
|
|
33
|
-
this.line = line;
|
|
34
|
-
if (line.trim() && !line.trim().match(/^\s*$/) && this._history.at(-1) != line) {
|
|
35
|
-
this._history.push(line);
|
|
36
|
-
this._historyIndex = this._history.length;
|
|
37
|
-
this.emit('history', this._history);
|
|
38
|
-
}
|
|
39
|
-
this.emit('line', line);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
26
|
this.input.on('data', this._onData);
|
|
43
27
|
this.input.on('end', this.close.bind(this));
|
|
44
28
|
this.input.on('close', this.close.bind(this));
|
|
45
29
|
}
|
|
30
|
+
_onData = (data) => {
|
|
31
|
+
if (this._paused || this._closed)
|
|
32
|
+
return;
|
|
33
|
+
this._buffer += typeof data === 'string' ? data : data.toString('utf8');
|
|
34
|
+
for (let lineEnd = this._buffer.indexOf('\n'); lineEnd >= 0; lineEnd = this._buffer.indexOf('\n')) {
|
|
35
|
+
let line = this._buffer.substring(0, lineEnd);
|
|
36
|
+
if (line.endsWith('\r')) {
|
|
37
|
+
line = line.substring(0, line.length - 1);
|
|
38
|
+
}
|
|
39
|
+
this._buffer = this._buffer.substring(lineEnd + 1);
|
|
40
|
+
this.line = line;
|
|
41
|
+
if (line.trim() && !line.trim().match(/^\s*$/) && this._history.at(-1) != line) {
|
|
42
|
+
this._history.push(line);
|
|
43
|
+
this._historyIndex = this._history.length;
|
|
44
|
+
this.emit('history', this._history);
|
|
45
|
+
}
|
|
46
|
+
this.emit('line', line);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
46
49
|
/**
|
|
47
50
|
* Closes the interface and removes all event listeners
|
|
48
51
|
*/
|
|
49
52
|
close() {
|
|
50
|
-
var _a, _b;
|
|
51
53
|
if (this._closed)
|
|
52
54
|
return;
|
|
53
55
|
this._closed = true;
|
|
54
|
-
|
|
56
|
+
this.input?.removeAllListeners?.();
|
|
55
57
|
if (this._buffer.length) {
|
|
56
58
|
const line = this._buffer;
|
|
57
59
|
this._buffer = '';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Exception } from 'kerium';
|
|
2
2
|
import type * as fs from 'node:fs';
|
|
3
|
+
import type { Worker as NodeWorker } from 'node:worker_threads';
|
|
3
4
|
import { type OptionalTuple } from 'utilium';
|
|
4
5
|
declare global {
|
|
5
6
|
function atob(data: string): string;
|
|
@@ -57,3 +58,4 @@ export declare function normalizeOptions(options: fs.WriteFileOptions | (fs.Enco
|
|
|
57
58
|
* @internal
|
|
58
59
|
*/
|
|
59
60
|
export declare function globToRegex(pattern: string): RegExp;
|
|
61
|
+
export declare function waitOnline(worker: NodeWorker): Promise<void>;
|
package/dist/utils.js
CHANGED
|
@@ -31,7 +31,7 @@ export function normalizeMode(mode, def) {
|
|
|
31
31
|
}
|
|
32
32
|
if (typeof def == 'number')
|
|
33
33
|
return def;
|
|
34
|
-
throw withErrno('EINVAL', 'Invalid mode: ' +
|
|
34
|
+
throw withErrno('EINVAL', 'Invalid mode: ' + mode?.toString());
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Normalizes a time
|
|
@@ -85,15 +85,15 @@ export function normalizePath(p, noResolve = false) {
|
|
|
85
85
|
export function normalizeOptions(options, encoding = 'utf8', flag, mode = 0) {
|
|
86
86
|
if (typeof options != 'object' || options === null) {
|
|
87
87
|
return {
|
|
88
|
-
encoding: typeof options == 'string' ? options : (encoding
|
|
88
|
+
encoding: typeof options == 'string' ? options : (encoding ?? null),
|
|
89
89
|
flag,
|
|
90
90
|
mode,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
return {
|
|
94
|
-
encoding: typeof
|
|
95
|
-
flag: typeof
|
|
96
|
-
mode: normalizeMode('mode' in options ? options
|
|
94
|
+
encoding: typeof options?.encoding == 'string' ? options.encoding : (encoding ?? null),
|
|
95
|
+
flag: typeof options?.flag == 'string' ? options.flag : flag,
|
|
96
|
+
mode: normalizeMode('mode' in options ? options?.mode : null, mode),
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
@@ -108,3 +108,9 @@ export function globToRegex(pattern) {
|
|
|
108
108
|
.replace(/\?/g, '.');
|
|
109
109
|
return new RegExp(`^${pattern}$`);
|
|
110
110
|
}
|
|
111
|
+
export async function waitOnline(worker) {
|
|
112
|
+
const online = Promise.withResolvers();
|
|
113
|
+
setTimeout(() => online.reject(withErrno('ETIMEDOUT')), 500);
|
|
114
|
+
worker.on('online', online.resolve);
|
|
115
|
+
await online.promise;
|
|
116
|
+
}
|
package/dist/vfs/acl.js
CHANGED
|
@@ -32,21 +32,6 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
32
32
|
}
|
|
33
33
|
return useValue ? value : void 0;
|
|
34
34
|
};
|
|
35
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
36
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
37
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
38
|
-
};
|
|
39
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
40
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
41
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
42
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
43
|
-
};
|
|
44
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
45
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
46
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
47
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
48
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
49
|
-
};
|
|
50
35
|
/*
|
|
51
36
|
Access Control Lists.
|
|
52
37
|
At the moment, they are only intended for internal use.
|
|
@@ -81,9 +66,8 @@ export var Tag;
|
|
|
81
66
|
Tag[Tag["_None"] = 0] = "_None";
|
|
82
67
|
})(Tag || (Tag = {}));
|
|
83
68
|
let Entry = (() => {
|
|
84
|
-
var _Entry_tag_accessor_storage, _Entry_perm_accessor_storage, _Entry_id_accessor_storage;
|
|
85
69
|
var _a, _b, _c;
|
|
86
|
-
let _classDecorators = [struct(packed)];
|
|
70
|
+
let _classDecorators = [struct(packed, { name: 'Entry' })];
|
|
87
71
|
let _classDescriptor;
|
|
88
72
|
let _classExtraInitializers = [];
|
|
89
73
|
let _classThis;
|
|
@@ -97,46 +81,41 @@ let Entry = (() => {
|
|
|
97
81
|
let _id_decorators;
|
|
98
82
|
let _id_initializers = [];
|
|
99
83
|
let _id_extraInitializers = [];
|
|
100
|
-
var Entry =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
84
|
+
var Entry = class extends _classSuper {
|
|
85
|
+
static { _classThis = this; }
|
|
86
|
+
static {
|
|
87
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
88
|
+
_tag_decorators = [(_a = t).uint16.bind(_a)];
|
|
89
|
+
_perm_decorators = [(_b = t).uint16.bind(_b)];
|
|
90
|
+
_id_decorators = [(_c = t).uint32.bind(_c)];
|
|
91
|
+
__esDecorate(this, null, _tag_decorators, { kind: "accessor", name: "tag", static: false, private: false, access: { has: obj => "tag" in obj, get: obj => obj.tag, set: (obj, value) => { obj.tag = value; } }, metadata: _metadata }, _tag_initializers, _tag_extraInitializers);
|
|
92
|
+
__esDecorate(this, null, _perm_decorators, { kind: "accessor", name: "perm", static: false, private: false, access: { has: obj => "perm" in obj, get: obj => obj.perm, set: (obj, value) => { obj.perm = value; } }, metadata: _metadata }, _perm_initializers, _perm_extraInitializers);
|
|
93
|
+
__esDecorate(this, null, _id_decorators, { kind: "accessor", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
94
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
95
|
+
Entry = _classThis = _classDescriptor.value;
|
|
96
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
97
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
98
|
+
}
|
|
99
|
+
#tag_accessor_storage = __runInitializers(this, _tag_initializers, void 0);
|
|
100
|
+
get tag() { return this.#tag_accessor_storage; }
|
|
101
|
+
set tag(value) { this.#tag_accessor_storage = value; }
|
|
102
|
+
#perm_accessor_storage = (__runInitializers(this, _tag_extraInitializers), __runInitializers(this, _perm_initializers, void 0));
|
|
103
|
+
get perm() { return this.#perm_accessor_storage; }
|
|
104
|
+
set perm(value) { this.#perm_accessor_storage = value; }
|
|
105
|
+
#id_accessor_storage = (__runInitializers(this, _perm_extraInitializers), __runInitializers(this, _id_initializers, void 0));
|
|
106
|
+
get id() { return this.#id_accessor_storage; }
|
|
107
|
+
set id(value) { this.#id_accessor_storage = value; }
|
|
107
108
|
constructor() {
|
|
108
109
|
super(...arguments);
|
|
109
|
-
_Entry_tag_accessor_storage.set(this, __runInitializers(this, _tag_initializers, void 0));
|
|
110
|
-
_Entry_perm_accessor_storage.set(this, (__runInitializers(this, _tag_extraInitializers), __runInitializers(this, _perm_initializers, void 0)));
|
|
111
|
-
_Entry_id_accessor_storage.set(this, (__runInitializers(this, _perm_extraInitializers), __runInitializers(this, _id_initializers, void 0)));
|
|
112
110
|
__runInitializers(this, _id_extraInitializers);
|
|
113
111
|
}
|
|
114
112
|
};
|
|
115
|
-
_Entry_tag_accessor_storage = new WeakMap();
|
|
116
|
-
_Entry_perm_accessor_storage = new WeakMap();
|
|
117
|
-
_Entry_id_accessor_storage = new WeakMap();
|
|
118
|
-
__setFunctionName(_classThis, "Entry");
|
|
119
|
-
(() => {
|
|
120
|
-
var _a;
|
|
121
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
122
|
-
_tag_decorators = [(_a = t).uint16.bind(_a)];
|
|
123
|
-
_perm_decorators = [(_b = t).uint16.bind(_b)];
|
|
124
|
-
_id_decorators = [(_c = t).uint32.bind(_c)];
|
|
125
|
-
__esDecorate(_classThis, null, _tag_decorators, { kind: "accessor", name: "tag", static: false, private: false, access: { has: obj => "tag" in obj, get: obj => obj.tag, set: (obj, value) => { obj.tag = value; } }, metadata: _metadata }, _tag_initializers, _tag_extraInitializers);
|
|
126
|
-
__esDecorate(_classThis, null, _perm_decorators, { kind: "accessor", name: "perm", static: false, private: false, access: { has: obj => "perm" in obj, get: obj => obj.perm, set: (obj, value) => { obj.perm = value; } }, metadata: _metadata }, _perm_initializers, _perm_extraInitializers);
|
|
127
|
-
__esDecorate(_classThis, null, _id_decorators, { kind: "accessor", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
128
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
129
|
-
Entry = _classThis = _classDescriptor.value;
|
|
130
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
131
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
132
|
-
})();
|
|
133
113
|
return Entry = _classThis;
|
|
134
114
|
})();
|
|
135
115
|
export { Entry };
|
|
136
116
|
let ACL = (() => {
|
|
137
|
-
var _ACL_version_accessor_storage;
|
|
138
117
|
var _a;
|
|
139
|
-
let _classDecorators = [struct(packed)];
|
|
118
|
+
let _classDecorators = [struct(packed, { name: 'ACL' })];
|
|
140
119
|
let _classDescriptor;
|
|
141
120
|
let _classExtraInitializers = [];
|
|
142
121
|
let _classThis;
|
|
@@ -144,14 +123,24 @@ let ACL = (() => {
|
|
|
144
123
|
let _version_decorators;
|
|
145
124
|
let _version_initializers = [];
|
|
146
125
|
let _version_extraInitializers = [];
|
|
147
|
-
var ACL =
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
var ACL = class extends _classSuper {
|
|
127
|
+
static { _classThis = this; }
|
|
128
|
+
static {
|
|
129
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
130
|
+
_version_decorators = [(_a = t).uint32.bind(_a)];
|
|
131
|
+
__esDecorate(this, null, _version_decorators, { kind: "accessor", name: "version", static: false, private: false, access: { has: obj => "version" in obj, get: obj => obj.version, set: (obj, value) => { obj.version = value; } }, metadata: _metadata }, _version_initializers, _version_extraInitializers);
|
|
132
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
133
|
+
ACL = _classThis = _classDescriptor.value;
|
|
134
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
135
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
136
|
+
}
|
|
137
|
+
#version_accessor_storage = __runInitializers(this, _version_initializers, void 0);
|
|
138
|
+
get version() { return this.#version_accessor_storage; }
|
|
139
|
+
set version(value) { this.#version_accessor_storage = value; }
|
|
140
|
+
entries = (__runInitializers(this, _version_extraInitializers), []);
|
|
150
141
|
constructor(...args) {
|
|
151
142
|
super(...args);
|
|
152
|
-
|
|
153
|
-
this.entries = (__runInitializers(this, _version_extraInitializers), []);
|
|
154
|
-
this.version || (this.version = version);
|
|
143
|
+
this.version ||= version;
|
|
155
144
|
if (this.version != version)
|
|
156
145
|
throw err(withErrno('EINVAL', 'Invalid ACL version'));
|
|
157
146
|
for (let offset = sizeof(ACL); offset < this.byteLength; offset += sizeof(Entry)) {
|
|
@@ -161,18 +150,6 @@ let ACL = (() => {
|
|
|
161
150
|
}
|
|
162
151
|
}
|
|
163
152
|
};
|
|
164
|
-
_ACL_version_accessor_storage = new WeakMap();
|
|
165
|
-
__setFunctionName(_classThis, "ACL");
|
|
166
|
-
(() => {
|
|
167
|
-
var _a;
|
|
168
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
169
|
-
_version_decorators = [(_a = t).uint32.bind(_a)];
|
|
170
|
-
__esDecorate(_classThis, null, _version_decorators, { kind: "accessor", name: "version", static: false, private: false, access: { has: obj => "version" in obj, get: obj => obj.version, set: (obj, value) => { obj.version = value; } }, metadata: _metadata }, _version_initializers, _version_extraInitializers);
|
|
171
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
172
|
-
ACL = _classThis = _classDescriptor.value;
|
|
173
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
174
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
175
|
-
})();
|
|
176
153
|
return ACL = _classThis;
|
|
177
154
|
})();
|
|
178
155
|
export { ACL };
|
|
@@ -224,11 +201,10 @@ export function setChecks(enabled) {
|
|
|
224
201
|
* @param access The requested access, combination of `W_OK`, `R_OK`, and `X_OK`
|
|
225
202
|
*/
|
|
226
203
|
export function check($, inode, access) {
|
|
227
|
-
var _a, _b;
|
|
228
204
|
if (!shouldCheck)
|
|
229
205
|
return true;
|
|
230
|
-
|
|
231
|
-
const { euid, egid } =
|
|
206
|
+
inode.attributes ??= new Attributes();
|
|
207
|
+
const { euid, egid } = $?.credentials ?? defaultContext.credentials;
|
|
232
208
|
const data = inode.attributes.get('system.posix_acl_access');
|
|
233
209
|
if (!data)
|
|
234
210
|
return true;
|
package/dist/vfs/async.js
CHANGED
|
@@ -109,7 +109,7 @@ export function fstat(fd, options, cb = nop) {
|
|
|
109
109
|
cb = typeof options == 'function' ? options : cb;
|
|
110
110
|
new promises.FileHandle(this, fd)
|
|
111
111
|
.stat()
|
|
112
|
-
.then(stats => cb(undefined, typeof options == 'object' &&
|
|
112
|
+
.then(stats => cb(undefined, typeof options == 'object' && options?.bigint ? new BigIntStats(stats) : stats))
|
|
113
113
|
.catch(cb);
|
|
114
114
|
}
|
|
115
115
|
fstat;
|
|
@@ -420,7 +420,7 @@ watch;
|
|
|
420
420
|
*/
|
|
421
421
|
export function createReadStream(path, options) {
|
|
422
422
|
options = typeof options == 'object' ? options : { encoding: options };
|
|
423
|
-
const _handle = promises.open.call(this, path, 'r', options
|
|
423
|
+
const _handle = promises.open.call(this, path, 'r', options?.mode);
|
|
424
424
|
return new ReadStream({ ...options, autoClose: true }, _handle);
|
|
425
425
|
}
|
|
426
426
|
createReadStream;
|
|
@@ -433,7 +433,7 @@ createReadStream;
|
|
|
433
433
|
*/
|
|
434
434
|
export function createWriteStream(path, options) {
|
|
435
435
|
options = typeof options == 'object' ? options : { encoding: options };
|
|
436
|
-
const _handle = promises.open.call(this, path, 'w', options
|
|
436
|
+
const _handle = promises.open.call(this, path, 'w', options?.mode);
|
|
437
437
|
return new WriteStream(options, _handle);
|
|
438
438
|
}
|
|
439
439
|
createWriteStream;
|
|
@@ -512,7 +512,7 @@ export function glob(pattern, options, callback = nop) {
|
|
|
512
512
|
callback = typeof options == 'function' ? options : callback;
|
|
513
513
|
const it = promises.glob.call(this, pattern, typeof options === 'function' ? undefined : options);
|
|
514
514
|
collectAsyncIterator(it)
|
|
515
|
-
.then(results =>
|
|
515
|
+
.then(results => callback(null, results ?? []))
|
|
516
516
|
.catch((e) => callback(e));
|
|
517
517
|
}
|
|
518
518
|
glob;
|
package/dist/vfs/dir.js
CHANGED
|
@@ -4,6 +4,9 @@ import { basename } from '../path.js';
|
|
|
4
4
|
import { readdir } from './promises.js';
|
|
5
5
|
import { readdirSync } from './sync.js';
|
|
6
6
|
export class Dirent {
|
|
7
|
+
path;
|
|
8
|
+
stats;
|
|
9
|
+
encoding;
|
|
7
10
|
get name() {
|
|
8
11
|
const name = Buffer.from(basename(this.path));
|
|
9
12
|
return (this.encoding == 'buffer' ? name : name.toString(this.encoding));
|
|
@@ -42,14 +45,17 @@ export class Dirent {
|
|
|
42
45
|
* A class representing a directory stream.
|
|
43
46
|
*/
|
|
44
47
|
export class Dir {
|
|
48
|
+
path;
|
|
49
|
+
context;
|
|
50
|
+
closed = false;
|
|
45
51
|
checkClosed() {
|
|
46
52
|
if (this.closed)
|
|
47
53
|
throw withErrno('EBADF', 'Can not use closed Dir');
|
|
48
54
|
}
|
|
55
|
+
_entries;
|
|
49
56
|
constructor(path, context) {
|
|
50
57
|
this.path = path;
|
|
51
58
|
this.context = context;
|
|
52
|
-
this.closed = false;
|
|
53
59
|
}
|
|
54
60
|
close(cb) {
|
|
55
61
|
this.closed = true;
|
|
@@ -66,14 +72,13 @@ export class Dir {
|
|
|
66
72
|
this.closed = true;
|
|
67
73
|
}
|
|
68
74
|
async _read() {
|
|
69
|
-
var _a, _b;
|
|
70
75
|
this.checkClosed();
|
|
71
|
-
|
|
76
|
+
this._entries ??= await readdir.call(this.context, this.path, {
|
|
72
77
|
withFileTypes: true,
|
|
73
|
-
})
|
|
78
|
+
});
|
|
74
79
|
if (!this._entries.length)
|
|
75
80
|
return null;
|
|
76
|
-
return
|
|
81
|
+
return this._entries.shift() ?? null;
|
|
77
82
|
}
|
|
78
83
|
read(cb) {
|
|
79
84
|
if (!cb) {
|
|
@@ -87,12 +92,11 @@ export class Dir {
|
|
|
87
92
|
* Directory entries returned by this function are in no particular order as provided by the operating system's underlying directory mechanisms.
|
|
88
93
|
*/
|
|
89
94
|
readSync() {
|
|
90
|
-
var _a, _b;
|
|
91
95
|
this.checkClosed();
|
|
92
|
-
|
|
96
|
+
this._entries ??= readdirSync.call(this.context, this.path, { withFileTypes: true });
|
|
93
97
|
if (!this._entries.length)
|
|
94
98
|
return null;
|
|
95
|
-
return
|
|
99
|
+
return this._entries.shift() ?? null;
|
|
96
100
|
}
|
|
97
101
|
async next() {
|
|
98
102
|
const value = await this._read();
|
package/dist/vfs/file.js
CHANGED
|
@@ -8,6 +8,17 @@ import { _chown } from './stats.js';
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export class SyncHandle {
|
|
11
|
+
context;
|
|
12
|
+
path;
|
|
13
|
+
fs;
|
|
14
|
+
internalPath;
|
|
15
|
+
flag;
|
|
16
|
+
inode;
|
|
17
|
+
_buffer;
|
|
18
|
+
/**
|
|
19
|
+
* Current position
|
|
20
|
+
*/
|
|
21
|
+
_position = 0;
|
|
11
22
|
/**
|
|
12
23
|
* Get the current file position.
|
|
13
24
|
*
|
|
@@ -23,6 +34,14 @@ export class SyncHandle {
|
|
|
23
34
|
set position(value) {
|
|
24
35
|
this._position = value;
|
|
25
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the file has changes which have not been written to the FS
|
|
39
|
+
*/
|
|
40
|
+
dirty = false;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the file is open or closed
|
|
43
|
+
*/
|
|
44
|
+
closed = false;
|
|
26
45
|
/**
|
|
27
46
|
* Creates a file with `path` and, optionally, the given contents.
|
|
28
47
|
* Note that, if contents is specified, it will be mutated by the file.
|
|
@@ -34,18 +53,6 @@ export class SyncHandle {
|
|
|
34
53
|
this.internalPath = internalPath;
|
|
35
54
|
this.flag = flag;
|
|
36
55
|
this.inode = inode;
|
|
37
|
-
/**
|
|
38
|
-
* Current position
|
|
39
|
-
*/
|
|
40
|
-
this._position = 0;
|
|
41
|
-
/**
|
|
42
|
-
* Whether the file has changes which have not been written to the FS
|
|
43
|
-
*/
|
|
44
|
-
this.dirty = false;
|
|
45
|
-
/**
|
|
46
|
-
* Whether the file is open or closed
|
|
47
|
-
*/
|
|
48
|
-
this.closed = false;
|
|
49
56
|
}
|
|
50
57
|
[Symbol.dispose]() {
|
|
51
58
|
this.close();
|
|
@@ -221,8 +228,7 @@ export class SyncHandle {
|
|
|
221
228
|
* @internal @hidden
|
|
222
229
|
*/
|
|
223
230
|
export function toFD(file) {
|
|
224
|
-
|
|
225
|
-
const map = (_b = (_a = file.context) === null || _a === void 0 ? void 0 : _a.descriptors) !== null && _b !== void 0 ? _b : defaultContext.descriptors;
|
|
231
|
+
const map = file.context?.descriptors ?? defaultContext.descriptors;
|
|
226
232
|
const fd = Math.max(map.size ? Math.max(...map.keys()) + 1 : 0, 4);
|
|
227
233
|
map.set(fd, file);
|
|
228
234
|
return fd;
|
|
@@ -231,14 +237,12 @@ export function toFD(file) {
|
|
|
231
237
|
* @internal @hidden
|
|
232
238
|
*/
|
|
233
239
|
export function fromFD($, fd) {
|
|
234
|
-
|
|
235
|
-
const map = (_a = $ === null || $ === void 0 ? void 0 : $.descriptors) !== null && _a !== void 0 ? _a : defaultContext.descriptors;
|
|
240
|
+
const map = $?.descriptors ?? defaultContext.descriptors;
|
|
236
241
|
const value = map.get(fd);
|
|
237
242
|
if (!value)
|
|
238
243
|
throw withErrno('EBADF');
|
|
239
244
|
return value;
|
|
240
245
|
}
|
|
241
246
|
export function deleteFD($, fd) {
|
|
242
|
-
|
|
243
|
-
return ((_a = $ === null || $ === void 0 ? void 0 : $.descriptors) !== null && _a !== void 0 ? _a : defaultContext.descriptors).delete(fd);
|
|
247
|
+
return ($?.descriptors ?? defaultContext.descriptors).delete(fd);
|
|
244
248
|
}
|
package/dist/vfs/ioctl.js
CHANGED
|
@@ -38,21 +38,6 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
38
38
|
}
|
|
39
39
|
return useValue ? value : void 0;
|
|
40
40
|
};
|
|
41
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
42
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
43
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
44
|
-
};
|
|
45
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
46
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
47
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
48
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
49
|
-
};
|
|
50
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
51
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
52
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
53
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
54
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
55
|
-
};
|
|
56
41
|
import { Errno, Exception, setUVMessage, UV } from 'kerium';
|
|
57
42
|
import { sizeof, struct, types as t } from 'memium';
|
|
58
43
|
import { _throw } from 'utilium';
|
|
@@ -101,7 +86,6 @@ var XFlag;
|
|
|
101
86
|
XFlag[XFlag["HasAttr"] = 2147483648] = "HasAttr";
|
|
102
87
|
})(XFlag || (XFlag = {}));
|
|
103
88
|
let fsxattr = (() => {
|
|
104
|
-
var _fsxattr_xflags_accessor_storage, _fsxattr_extsize_accessor_storage, _fsxattr_nextents_accessor_storage, _fsxattr_projid_accessor_storage, _fsxattr_cowextsize_accessor_storage, _fsxattr_pad_accessor_storage;
|
|
105
89
|
var _a, _b, _c, _d, _e;
|
|
106
90
|
let _classDecorators = [struct()];
|
|
107
91
|
let _classDescriptor;
|
|
@@ -126,32 +110,52 @@ let fsxattr = (() => {
|
|
|
126
110
|
let _pad_decorators;
|
|
127
111
|
let _pad_initializers = [];
|
|
128
112
|
let _pad_extraInitializers = [];
|
|
129
|
-
var fsxattr =
|
|
113
|
+
var fsxattr = class extends _classSuper {
|
|
114
|
+
static { _classThis = this; }
|
|
115
|
+
static {
|
|
116
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
117
|
+
_xflags_decorators = [(_a = t).uint32.bind(_a)];
|
|
118
|
+
_extsize_decorators = [(_b = t).uint32.bind(_b)];
|
|
119
|
+
_nextents_decorators = [(_c = t).uint32.bind(_c)];
|
|
120
|
+
_projid_decorators = [(_d = t).uint32.bind(_d)];
|
|
121
|
+
_cowextsize_decorators = [(_e = t).uint32.bind(_e)];
|
|
122
|
+
_pad_decorators = [t.char(8)];
|
|
123
|
+
__esDecorate(this, null, _xflags_decorators, { kind: "accessor", name: "xflags", static: false, private: false, access: { has: obj => "xflags" in obj, get: obj => obj.xflags, set: (obj, value) => { obj.xflags = value; } }, metadata: _metadata }, _xflags_initializers, _xflags_extraInitializers);
|
|
124
|
+
__esDecorate(this, null, _extsize_decorators, { kind: "accessor", name: "extsize", static: false, private: false, access: { has: obj => "extsize" in obj, get: obj => obj.extsize, set: (obj, value) => { obj.extsize = value; } }, metadata: _metadata }, _extsize_initializers, _extsize_extraInitializers);
|
|
125
|
+
__esDecorate(this, null, _nextents_decorators, { kind: "accessor", name: "nextents", static: false, private: false, access: { has: obj => "nextents" in obj, get: obj => obj.nextents, set: (obj, value) => { obj.nextents = value; } }, metadata: _metadata }, _nextents_initializers, _nextents_extraInitializers);
|
|
126
|
+
__esDecorate(this, null, _projid_decorators, { kind: "accessor", name: "projid", static: false, private: false, access: { has: obj => "projid" in obj, get: obj => obj.projid, set: (obj, value) => { obj.projid = value; } }, metadata: _metadata }, _projid_initializers, _projid_extraInitializers);
|
|
127
|
+
__esDecorate(this, null, _cowextsize_decorators, { kind: "accessor", name: "cowextsize", static: false, private: false, access: { has: obj => "cowextsize" in obj, get: obj => obj.cowextsize, set: (obj, value) => { obj.cowextsize = value; } }, metadata: _metadata }, _cowextsize_initializers, _cowextsize_extraInitializers);
|
|
128
|
+
__esDecorate(this, null, _pad_decorators, { kind: "accessor", name: "pad", static: false, private: false, access: { has: obj => "pad" in obj, get: obj => obj.pad, set: (obj, value) => { obj.pad = value; } }, metadata: _metadata }, _pad_initializers, _pad_extraInitializers);
|
|
129
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
130
|
+
fsxattr = _classThis = _classDescriptor.value;
|
|
131
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
132
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
133
|
+
}
|
|
134
|
+
#xflags_accessor_storage = __runInitializers(this, _xflags_initializers, void 0);
|
|
130
135
|
/** xflags field value */
|
|
131
|
-
get xflags() { return
|
|
132
|
-
set xflags(value) {
|
|
136
|
+
get xflags() { return this.#xflags_accessor_storage; }
|
|
137
|
+
set xflags(value) { this.#xflags_accessor_storage = value; }
|
|
138
|
+
#extsize_accessor_storage = (__runInitializers(this, _xflags_extraInitializers), __runInitializers(this, _extsize_initializers, void 0));
|
|
133
139
|
/** extsize field value */
|
|
134
|
-
get extsize() { return
|
|
135
|
-
set extsize(value) {
|
|
140
|
+
get extsize() { return this.#extsize_accessor_storage; }
|
|
141
|
+
set extsize(value) { this.#extsize_accessor_storage = value; }
|
|
142
|
+
#nextents_accessor_storage = (__runInitializers(this, _extsize_extraInitializers), __runInitializers(this, _nextents_initializers, void 0));
|
|
136
143
|
/** nextents field value */
|
|
137
|
-
get nextents() { return
|
|
138
|
-
set nextents(value) {
|
|
144
|
+
get nextents() { return this.#nextents_accessor_storage; }
|
|
145
|
+
set nextents(value) { this.#nextents_accessor_storage = value; }
|
|
146
|
+
#projid_accessor_storage = (__runInitializers(this, _nextents_extraInitializers), __runInitializers(this, _projid_initializers, void 0));
|
|
139
147
|
/** project identifier */
|
|
140
|
-
get projid() { return
|
|
141
|
-
set projid(value) {
|
|
148
|
+
get projid() { return this.#projid_accessor_storage; }
|
|
149
|
+
set projid(value) { this.#projid_accessor_storage = value; }
|
|
150
|
+
#cowextsize_accessor_storage = (__runInitializers(this, _projid_extraInitializers), __runInitializers(this, _cowextsize_initializers, void 0));
|
|
142
151
|
/** CoW extsize field value */
|
|
143
|
-
get cowextsize() { return
|
|
144
|
-
set cowextsize(value) {
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
get cowextsize() { return this.#cowextsize_accessor_storage; }
|
|
153
|
+
set cowextsize(value) { this.#cowextsize_accessor_storage = value; }
|
|
154
|
+
#pad_accessor_storage = (__runInitializers(this, _cowextsize_extraInitializers), __runInitializers(this, _pad_initializers, []));
|
|
155
|
+
get pad() { return this.#pad_accessor_storage; }
|
|
156
|
+
set pad(value) { this.#pad_accessor_storage = value; }
|
|
147
157
|
constructor(inode = _throw(new Exception(Errno.EINVAL, 'fsxattr must be initialized with an inode'))) {
|
|
148
158
|
super(new ArrayBuffer(sizeof(fsxattr)));
|
|
149
|
-
_fsxattr_xflags_accessor_storage.set(this, __runInitializers(this, _xflags_initializers, void 0));
|
|
150
|
-
_fsxattr_extsize_accessor_storage.set(this, (__runInitializers(this, _xflags_extraInitializers), __runInitializers(this, _extsize_initializers, void 0)));
|
|
151
|
-
_fsxattr_nextents_accessor_storage.set(this, (__runInitializers(this, _extsize_extraInitializers), __runInitializers(this, _nextents_initializers, void 0)));
|
|
152
|
-
_fsxattr_projid_accessor_storage.set(this, (__runInitializers(this, _nextents_extraInitializers), __runInitializers(this, _projid_initializers, void 0)));
|
|
153
|
-
_fsxattr_cowextsize_accessor_storage.set(this, (__runInitializers(this, _projid_extraInitializers), __runInitializers(this, _cowextsize_initializers, void 0)));
|
|
154
|
-
_fsxattr_pad_accessor_storage.set(this, (__runInitializers(this, _cowextsize_extraInitializers), __runInitializers(this, _pad_initializers, [])));
|
|
155
159
|
__runInitializers(this, _pad_extraInitializers);
|
|
156
160
|
this.extsize = inode.size;
|
|
157
161
|
this.nextents = 1;
|
|
@@ -165,33 +169,6 @@ let fsxattr = (() => {
|
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
};
|
|
168
|
-
_fsxattr_xflags_accessor_storage = new WeakMap();
|
|
169
|
-
_fsxattr_extsize_accessor_storage = new WeakMap();
|
|
170
|
-
_fsxattr_nextents_accessor_storage = new WeakMap();
|
|
171
|
-
_fsxattr_projid_accessor_storage = new WeakMap();
|
|
172
|
-
_fsxattr_cowextsize_accessor_storage = new WeakMap();
|
|
173
|
-
_fsxattr_pad_accessor_storage = new WeakMap();
|
|
174
|
-
__setFunctionName(_classThis, "fsxattr");
|
|
175
|
-
(() => {
|
|
176
|
-
var _a;
|
|
177
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_a = _classSuper[Symbol.metadata]) !== null && _a !== void 0 ? _a : null) : void 0;
|
|
178
|
-
_xflags_decorators = [(_a = t).uint32.bind(_a)];
|
|
179
|
-
_extsize_decorators = [(_b = t).uint32.bind(_b)];
|
|
180
|
-
_nextents_decorators = [(_c = t).uint32.bind(_c)];
|
|
181
|
-
_projid_decorators = [(_d = t).uint32.bind(_d)];
|
|
182
|
-
_cowextsize_decorators = [(_e = t).uint32.bind(_e)];
|
|
183
|
-
_pad_decorators = [t.char(8)];
|
|
184
|
-
__esDecorate(_classThis, null, _xflags_decorators, { kind: "accessor", name: "xflags", static: false, private: false, access: { has: obj => "xflags" in obj, get: obj => obj.xflags, set: (obj, value) => { obj.xflags = value; } }, metadata: _metadata }, _xflags_initializers, _xflags_extraInitializers);
|
|
185
|
-
__esDecorate(_classThis, null, _extsize_decorators, { kind: "accessor", name: "extsize", static: false, private: false, access: { has: obj => "extsize" in obj, get: obj => obj.extsize, set: (obj, value) => { obj.extsize = value; } }, metadata: _metadata }, _extsize_initializers, _extsize_extraInitializers);
|
|
186
|
-
__esDecorate(_classThis, null, _nextents_decorators, { kind: "accessor", name: "nextents", static: false, private: false, access: { has: obj => "nextents" in obj, get: obj => obj.nextents, set: (obj, value) => { obj.nextents = value; } }, metadata: _metadata }, _nextents_initializers, _nextents_extraInitializers);
|
|
187
|
-
__esDecorate(_classThis, null, _projid_decorators, { kind: "accessor", name: "projid", static: false, private: false, access: { has: obj => "projid" in obj, get: obj => obj.projid, set: (obj, value) => { obj.projid = value; } }, metadata: _metadata }, _projid_initializers, _projid_extraInitializers);
|
|
188
|
-
__esDecorate(_classThis, null, _cowextsize_decorators, { kind: "accessor", name: "cowextsize", static: false, private: false, access: { has: obj => "cowextsize" in obj, get: obj => obj.cowextsize, set: (obj, value) => { obj.cowextsize = value; } }, metadata: _metadata }, _cowextsize_initializers, _cowextsize_extraInitializers);
|
|
189
|
-
__esDecorate(_classThis, null, _pad_decorators, { kind: "accessor", name: "pad", static: false, private: false, access: { has: obj => "pad" in obj, get: obj => obj.pad, set: (obj, value) => { obj.pad = value; } }, metadata: _metadata }, _pad_initializers, _pad_extraInitializers);
|
|
190
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
191
|
-
fsxattr = _classThis = _classDescriptor.value;
|
|
192
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
193
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
194
|
-
})();
|
|
195
172
|
return fsxattr = _classThis;
|
|
196
173
|
})();
|
|
197
174
|
/**
|