@zenfs/core 2.5.0 → 2.5.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 +1 -1
- package/dist/internal/rpc.js +1 -0
- package/dist/mixins/async.js +0 -1
- package/dist/mixins/shared.js +0 -4
- package/dist/node/promises.d.ts +15 -15
- package/dist/node/readline.js +0 -1
- package/dist/node/sync.d.ts +6 -6
- package/dist/polyfills.js +1 -3
- package/dist/vfs/watchers.js +0 -2
- package/eslint.shared.js +2 -2
- package/package.json +5 -7
- package/scripts/test.js +13 -6
- package/tests/backend/single-buffer.test.ts +3 -3
package/dist/backends/backend.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
3
3
|
import { withErrno } from 'kerium';
|
|
4
4
|
import { debug, err } from 'kerium/log';
|
|
5
5
|
/**
|
package/dist/internal/rpc.js
CHANGED
package/dist/mixins/async.js
CHANGED
package/dist/mixins/shared.js
CHANGED
package/dist/node/promises.d.ts
CHANGED
|
@@ -72,11 +72,11 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
72
72
|
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: promises.FileReadOptions<T>): Promise<promises.FileReadResult<T>>;
|
|
73
73
|
readFile(options?: ({
|
|
74
74
|
encoding?: null;
|
|
75
|
-
} & Abortable) | null): Promise<
|
|
75
|
+
} & Abortable) | null): Promise<NonSharedBuffer>;
|
|
76
76
|
readFile(options: ({
|
|
77
77
|
encoding: BufferEncoding;
|
|
78
78
|
} & Abortable) | BufferEncoding): Promise<string>;
|
|
79
|
-
readFile(_options?: (fs.ObjectEncodingOptions & Abortable) | BufferEncoding | null): Promise<string |
|
|
79
|
+
readFile(_options?: (fs.ObjectEncodingOptions & Abortable) | BufferEncoding | null): Promise<string | NonSharedBuffer>;
|
|
80
80
|
/**
|
|
81
81
|
* Read file data using a `ReadableStream`.
|
|
82
82
|
* The handle will not be closed automatically.
|
|
@@ -139,14 +139,14 @@ export declare class FileHandle implements promises.FileHandle {
|
|
|
139
139
|
* @param position The position in the file where to begin writing.
|
|
140
140
|
* @returns The number of bytes written.
|
|
141
141
|
*/
|
|
142
|
-
writev(buffers:
|
|
142
|
+
writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(buffers: TBuffers, position?: number): Promise<fs.WriteVResult<TBuffers>>;
|
|
143
143
|
/**
|
|
144
144
|
* Asynchronous `readv`. Reads into multiple buffers.
|
|
145
145
|
* @param buffers An array of Uint8Array buffers.
|
|
146
146
|
* @param position The position in the file where to begin reading.
|
|
147
147
|
* @returns The number of bytes read.
|
|
148
148
|
*/
|
|
149
|
-
readv
|
|
149
|
+
readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(buffers: TBuffers, position?: number): Promise<fs.ReadVResult<TBuffers>>;
|
|
150
150
|
/**
|
|
151
151
|
* Creates a stream for reading from the file.
|
|
152
152
|
* @param options Options for the readable stream
|
|
@@ -197,14 +197,14 @@ export declare function open(this: V_Context, path: fs.PathLike, flag?: fs.OpenM
|
|
|
197
197
|
export declare function readFile(this: V_Context, path: fs.PathLike | promises.FileHandle, options?: ({
|
|
198
198
|
encoding?: null;
|
|
199
199
|
flag?: fs.OpenMode;
|
|
200
|
-
} & Abortable) | null): Promise<
|
|
200
|
+
} & Abortable) | null): Promise<NonSharedBuffer>;
|
|
201
201
|
export declare function readFile(this: V_Context, path: fs.PathLike | promises.FileHandle, options: ({
|
|
202
202
|
encoding: BufferEncoding;
|
|
203
203
|
flag?: fs.OpenMode;
|
|
204
204
|
} & Abortable) | BufferEncoding): Promise<string>;
|
|
205
205
|
export declare function readFile(this: V_Context, path: fs.PathLike | promises.FileHandle, _options?: (fs.ObjectEncodingOptions & Abortable & {
|
|
206
206
|
flag?: fs.OpenMode;
|
|
207
|
-
}) | BufferEncoding | null): Promise<string |
|
|
207
|
+
}) | BufferEncoding | null): Promise<string | NonSharedBuffer>;
|
|
208
208
|
/**
|
|
209
209
|
* Asynchronously writes data to a file, replacing the file if it already exists.
|
|
210
210
|
*
|
|
@@ -257,11 +257,11 @@ export declare function readdir(this: V_Context, path: fs.PathLike, options: {
|
|
|
257
257
|
encoding: 'buffer';
|
|
258
258
|
withFileTypes?: false;
|
|
259
259
|
recursive?: boolean;
|
|
260
|
-
} | 'buffer'): Promise<
|
|
260
|
+
} | 'buffer'): Promise<NonSharedBuffer[]>;
|
|
261
261
|
export declare function readdir(this: V_Context, path: fs.PathLike, options?: (fs.ObjectEncodingOptions & {
|
|
262
262
|
withFileTypes?: false;
|
|
263
263
|
recursive?: boolean;
|
|
264
|
-
}) | BufferEncoding | null): Promise<string[] |
|
|
264
|
+
}) | BufferEncoding | null): Promise<string[] | NonSharedBuffer[]>;
|
|
265
265
|
export declare function readdir(this: V_Context, path: fs.PathLike, options: fs.ObjectEncodingOptions & {
|
|
266
266
|
withFileTypes: true;
|
|
267
267
|
recursive?: boolean;
|
|
@@ -270,7 +270,7 @@ export declare function readdir(this: V_Context, path: fs.PathLike, options: {
|
|
|
270
270
|
encoding: 'buffer';
|
|
271
271
|
withFileTypes: true;
|
|
272
272
|
recursive?: boolean;
|
|
273
|
-
}): Promise<Dirent<
|
|
273
|
+
}): Promise<Dirent<NonSharedBuffer>[]>;
|
|
274
274
|
export declare function readdir(this: V_Context, path: fs.PathLike, options?: NodeReaddirOptions): Promise<string[] | Dirent<any>[] | Buffer[]>;
|
|
275
275
|
export declare function link(this: V_Context, path: fs.PathLike, dest: fs.PathLike): Promise<void>;
|
|
276
276
|
/**
|
|
@@ -280,9 +280,9 @@ export declare function link(this: V_Context, path: fs.PathLike, dest: fs.PathLi
|
|
|
280
280
|
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
281
281
|
*/
|
|
282
282
|
export declare function symlink(this: V_Context, dest: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | string | null): Promise<void>;
|
|
283
|
-
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Promise<
|
|
283
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
284
284
|
export declare function readlink(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | null): Promise<string>;
|
|
285
|
-
export declare function readlink(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption | fs.EncodingOption | string | null): Promise<string |
|
|
285
|
+
export declare function readlink(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption | fs.EncodingOption | string | null): Promise<string | NonSharedBuffer>;
|
|
286
286
|
export declare function chown(this: V_Context, path: fs.PathLike, uid: number, gid: number): Promise<void>;
|
|
287
287
|
export declare function lchown(this: V_Context, path: fs.PathLike, uid: number, gid: number): Promise<void>;
|
|
288
288
|
export declare function chmod(this: V_Context, path: fs.PathLike, mode: fs.Mode): Promise<void>;
|
|
@@ -301,11 +301,11 @@ export declare function lutimes(this: V_Context, path: fs.PathLike, atime: fs.Ti
|
|
|
301
301
|
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. Defaults to `'utf8'`.
|
|
302
302
|
* @todo handle options
|
|
303
303
|
*/
|
|
304
|
-
export declare function realpath(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Promise<
|
|
304
|
+
export declare function realpath(this: V_Context, path: fs.PathLike, options: fs.BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
305
305
|
export declare function realpath(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding): Promise<string>;
|
|
306
306
|
export declare function watch(this: V_Context, filename: fs.PathLike, options?: fs.WatchOptions | BufferEncoding): AsyncIteratorObject<promises.FileChangeInfo<string>, undefined>;
|
|
307
|
-
export declare function watch(this: V_Context, filename: fs.PathLike, options: fs.WatchOptions | fs.BufferEncodingOption): AsyncIteratorObject<promises.FileChangeInfo<
|
|
308
|
-
export declare function watch(this: V_Context, filename: fs.PathLike, options?: fs.WatchOptions | string): AsyncIteratorObject<promises.FileChangeInfo<string>, undefined> | AsyncIteratorObject<promises.FileChangeInfo<
|
|
307
|
+
export declare function watch(this: V_Context, filename: fs.PathLike, options: fs.WatchOptions | fs.BufferEncodingOption): AsyncIteratorObject<promises.FileChangeInfo<NonSharedBuffer>, undefined>;
|
|
308
|
+
export declare function watch(this: V_Context, filename: fs.PathLike, options?: fs.WatchOptions | string): AsyncIteratorObject<promises.FileChangeInfo<string>, undefined> | AsyncIteratorObject<promises.FileChangeInfo<NonSharedBuffer>, undefined>;
|
|
309
309
|
export declare function access(this: V_Context, path: fs.PathLike, mode?: number): Promise<void>;
|
|
310
310
|
/**
|
|
311
311
|
* Asynchronous `rm`. Removes files or directories (recursively).
|
|
@@ -319,7 +319,7 @@ export declare function rm(this: V_Context, path: fs.PathLike, options?: fs.RmOp
|
|
|
319
319
|
* @returns The path to the created temporary directory, encoded as a string or buffer.
|
|
320
320
|
*/
|
|
321
321
|
export declare function mkdtemp(this: V_Context, prefix: string, options?: fs.EncodingOption): Promise<string>;
|
|
322
|
-
export declare function mkdtemp(this: V_Context, prefix: string, options?: fs.BufferEncodingOption): Promise<
|
|
322
|
+
export declare function mkdtemp(this: V_Context, prefix: string, options?: fs.BufferEncodingOption): Promise<NonSharedBuffer>;
|
|
323
323
|
/**
|
|
324
324
|
* The resulting Promise holds an async-disposable object whose `path` property holds the created directory path.
|
|
325
325
|
* When the object is disposed, the directory and its contents will be removed asynchronously if it still exists.
|
package/dist/node/readline.js
CHANGED
package/dist/node/sync.d.ts
CHANGED
|
@@ -122,11 +122,11 @@ export declare function readdirSync(this: V_Context, path: fs.PathLike, options:
|
|
|
122
122
|
encoding: 'buffer';
|
|
123
123
|
withFileTypes?: false;
|
|
124
124
|
recursive?: boolean;
|
|
125
|
-
} | 'buffer'):
|
|
125
|
+
} | 'buffer'): NonSharedBuffer[];
|
|
126
126
|
export declare function readdirSync(this: V_Context, path: fs.PathLike, options?: (fs.ObjectEncodingOptions & {
|
|
127
127
|
withFileTypes?: false;
|
|
128
128
|
recursive?: boolean;
|
|
129
|
-
}) | BufferEncoding | null): string[] |
|
|
129
|
+
}) | BufferEncoding | null): string[] | NonSharedBuffer[];
|
|
130
130
|
export declare function readdirSync(this: V_Context, path: fs.PathLike, options: fs.ObjectEncodingOptions & {
|
|
131
131
|
withFileTypes: true;
|
|
132
132
|
recursive?: boolean;
|
|
@@ -135,7 +135,7 @@ export declare function readdirSync(this: V_Context, path: fs.PathLike, options:
|
|
|
135
135
|
encoding: 'buffer';
|
|
136
136
|
withFileTypes: true;
|
|
137
137
|
recursive?: boolean;
|
|
138
|
-
}): Dirent<
|
|
138
|
+
}): Dirent<NonSharedBuffer>[];
|
|
139
139
|
export declare function readdirSync(this: V_Context, path: fs.PathLike, options?: NodeReaddirOptions): string[] | Dirent<any>[] | Buffer[];
|
|
140
140
|
export declare function linkSync(this: V_Context, targetPath: fs.PathLike, linkPath: fs.PathLike): void;
|
|
141
141
|
/**
|
|
@@ -145,9 +145,9 @@ export declare function linkSync(this: V_Context, targetPath: fs.PathLike, linkP
|
|
|
145
145
|
* @param type can be either `'dir'` or `'file'` (default is `'file'`)
|
|
146
146
|
*/
|
|
147
147
|
export declare function symlinkSync(this: V_Context, target: fs.PathLike, path: fs.PathLike, type?: fs.symlink.Type | null): void;
|
|
148
|
-
export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption):
|
|
148
|
+
export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.BufferEncodingOption): NonSharedBuffer;
|
|
149
149
|
export declare function readlinkSync(this: V_Context, path: fs.PathLike, options: fs.EncodingOption | BufferEncoding): string;
|
|
150
|
-
export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding | fs.BufferEncodingOption):
|
|
150
|
+
export declare function readlinkSync(this: V_Context, path: fs.PathLike, options?: fs.EncodingOption | BufferEncoding | fs.BufferEncodingOption): NonSharedBuffer | string;
|
|
151
151
|
export declare function chownSync(this: V_Context, path: fs.PathLike, uid: number, gid: number): void;
|
|
152
152
|
export declare function lchownSync(this: V_Context, path: fs.PathLike, uid: number, gid: number): void;
|
|
153
153
|
export declare function chmodSync(this: V_Context, path: fs.PathLike, mode: fs.Mode): void;
|
|
@@ -174,7 +174,7 @@ export declare function rmSync(this: V_Context, path: fs.PathLike, options?: fs.
|
|
|
174
174
|
* @param options The encoding (or an object including `encoding`).
|
|
175
175
|
* @returns The path to the created temporary directory, encoded as a string or buffer.
|
|
176
176
|
*/
|
|
177
|
-
export declare function mkdtempSync(this: V_Context, prefix: fs.PathLike, options: fs.BufferEncodingOption):
|
|
177
|
+
export declare function mkdtempSync(this: V_Context, prefix: fs.PathLike, options: fs.BufferEncodingOption): NonSharedBuffer;
|
|
178
178
|
export declare function mkdtempSync(this: V_Context, prefix: fs.PathLike, options?: fs.EncodingOption): string;
|
|
179
179
|
/**
|
|
180
180
|
* Returns a disposable object whose `path` property holds the created directory path.
|
package/dist/polyfills.js
CHANGED
|
@@ -5,9 +5,7 @@ import { warn } from 'kerium/log';
|
|
|
5
5
|
Promise.withResolvers ??=
|
|
6
6
|
(warn('Using a polyfill of Promise.withResolvers'),
|
|
7
7
|
function () {
|
|
8
|
-
let _resolve,
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
_reject;
|
|
8
|
+
let _resolve, _reject;
|
|
11
9
|
const promise = new Promise((resolve, reject) => {
|
|
12
10
|
_resolve = resolve;
|
|
13
11
|
_reject = reject;
|
package/dist/vfs/watchers.js
CHANGED
|
@@ -14,14 +14,12 @@ import { normalizePath } from '../utils.js';
|
|
|
14
14
|
class Watcher extends EventEmitter {
|
|
15
15
|
_context;
|
|
16
16
|
path;
|
|
17
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
18
17
|
off(event, fn, context, once) {
|
|
19
18
|
return super.off(event, fn, context, once);
|
|
20
19
|
}
|
|
21
20
|
removeListener(event, fn, context, once) {
|
|
22
21
|
return super.removeListener(event, fn, context, once);
|
|
23
22
|
}
|
|
24
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
25
23
|
constructor(
|
|
26
24
|
/**
|
|
27
25
|
* @internal
|
package/eslint.shared.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* Shared eslint rules */
|
|
2
2
|
import eslint from '@eslint/js';
|
|
3
3
|
import globals from 'globals';
|
|
4
|
-
import
|
|
4
|
+
import { configs } from 'typescript-eslint';
|
|
5
5
|
|
|
6
6
|
export default [
|
|
7
7
|
{
|
|
8
8
|
name: 'ZenFS',
|
|
9
|
-
extends: [eslint.configs.recommended, ...
|
|
9
|
+
extends: [eslint.configs.recommended, ...configs.recommendedTypeChecked],
|
|
10
10
|
files: ['src/**/*.ts', 'tests/**/*.ts'],
|
|
11
11
|
languageOptions: {
|
|
12
12
|
globals: { ...globals.browser, ...globals.node },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"prepublishOnly": "npm run build"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@types/node": "^
|
|
74
|
+
"@types/node": "^25.2.0",
|
|
75
75
|
"buffer": "^6.0.3",
|
|
76
76
|
"eventemitter3": "^5.0.1",
|
|
77
77
|
"kerium": "^1.3.4",
|
|
@@ -80,12 +80,10 @@
|
|
|
80
80
|
"utilium": "^2.5.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@
|
|
84
|
-
"
|
|
85
|
-
"@types/eslint__js": "^8.42.3",
|
|
86
|
-
"c8": "^10.1.2",
|
|
83
|
+
"@octokit/action": "^8.0.4",
|
|
84
|
+
"c8": "^10.1.3",
|
|
87
85
|
"eslint": "^9.15.0",
|
|
88
|
-
"globals": "^
|
|
86
|
+
"globals": "^17.3.0",
|
|
89
87
|
"prettier": "^3.2.5",
|
|
90
88
|
"tsx": "^4.19.1",
|
|
91
89
|
"typedoc": "^0.28.0",
|
package/scripts/test.js
CHANGED
|
@@ -87,9 +87,19 @@ if (options.clean) {
|
|
|
87
87
|
process.exit();
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
function report() {
|
|
91
|
+
try {
|
|
92
|
+
execSync('npx c8 report --reporter=text', { stdio: 'inherit' });
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error('Failed to generate coverage report!');
|
|
95
|
+
console.error(e);
|
|
96
|
+
} finally {
|
|
97
|
+
rmSync(options.coverage, { recursive: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
if (options.report) {
|
|
91
|
-
|
|
92
|
-
rmSync(options.coverage, { recursive: true, force: true });
|
|
102
|
+
report();
|
|
93
103
|
process.exit();
|
|
94
104
|
}
|
|
95
105
|
|
|
@@ -237,7 +247,4 @@ for (const setupFile of positionals) {
|
|
|
237
247
|
}
|
|
238
248
|
}
|
|
239
249
|
|
|
240
|
-
if (!options.preserve)
|
|
241
|
-
execSync('npx c8 report --reporter=text', { stdio: 'inherit' });
|
|
242
|
-
rmSync(options.coverage, { recursive: true });
|
|
243
|
-
}
|
|
250
|
+
if (!options.preserve) report();
|
|
@@ -64,7 +64,7 @@ await suite('SingleBuffer', () => {
|
|
|
64
64
|
const growthSizes = [0, 1, 17, 512, 8192, 65535, 262144, 524288];
|
|
65
65
|
const shrinkSizes = [262144, 4096, 128, 0];
|
|
66
66
|
|
|
67
|
-
const verifySnapshot =
|
|
67
|
+
const verifySnapshot = (expected: Buffer, size: number) => {
|
|
68
68
|
mount(verifyMountPoint, writable);
|
|
69
69
|
try {
|
|
70
70
|
const reopened = fs.readFileSync(`${verifyMountPoint}/payload.bin`);
|
|
@@ -82,7 +82,7 @@ await suite('SingleBuffer', () => {
|
|
|
82
82
|
const direct = fs.readFileSync(filePath);
|
|
83
83
|
assert.strictEqual(direct.byteLength, size, `direct size mismatch for ${size} bytes`);
|
|
84
84
|
assert.deepStrictEqual(direct, payload, `direct content mismatch for ${size} bytes`);
|
|
85
|
-
|
|
85
|
+
verifySnapshot(direct, size);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
for (const size of shrinkSizes) {
|
|
@@ -91,7 +91,7 @@ await suite('SingleBuffer', () => {
|
|
|
91
91
|
const direct = fs.readFileSync(filePath);
|
|
92
92
|
assert.strictEqual(direct.byteLength, size, `direct size mismatch after shrink to ${size} bytes`);
|
|
93
93
|
assert.deepStrictEqual(direct, payload, `direct content mismatch after shrink to ${size} bytes`);
|
|
94
|
-
|
|
94
|
+
verifySnapshot(direct, size);
|
|
95
95
|
}
|
|
96
96
|
} finally {
|
|
97
97
|
if (fs.existsSync(filePath)) fs.unlinkSync(filePath);
|