@zenfs/core 1.0.0 → 1.0.2
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/store/simple.d.ts +0 -1
- package/dist/backends/store/simple.js +2 -2
- package/dist/browser.min.js +3 -3
- package/dist/browser.min.js.map +4 -4
- package/dist/emulation/async.d.ts +2 -0
- package/dist/emulation/promises.d.ts +1 -0
- package/dist/emulation/streams.d.ts +1 -0
- package/dist/emulation/sync.d.ts +1 -0
- package/dist/emulation/watchers.d.ts +1 -0
- package/eslint.shared.js +56 -46
- package/package.json +7 -10
- package/src/backends/fetch.ts +1 -1
- package/src/backends/file_index.ts +1 -1
- package/src/backends/overlay.ts +1 -1
- package/src/backends/port/fs.ts +9 -1
- package/src/backends/store/fs.ts +1 -1
- package/src/backends/store/simple.ts +0 -4
- package/src/backends/store/store.ts +5 -1
- package/src/emulation/dir.ts +1 -1
- package/src/error.ts +1 -1
- package/src/file.ts +3 -3
- package/src/inode.ts +1 -1
- package/src/stats.ts +4 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
5
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
6
|
import { Buffer } from 'buffer';
|
|
5
7
|
import type * as fs from 'node:fs';
|
|
6
8
|
import type { FileContents } from '../filesystem.js';
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/// <reference types="node" resolution-mode="require"/>
|
|
6
6
|
/// <reference types="node" resolution-mode="require"/>
|
|
7
7
|
/// <reference types="node" resolution-mode="require"/>
|
|
8
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
8
9
|
import { Buffer } from 'buffer';
|
|
9
10
|
import type * as fs from 'node:fs';
|
|
10
11
|
import type * as promises from 'node:fs/promises';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
4
|
import type * as Node from 'fs';
|
|
4
5
|
import { Readable, Writable } from 'readable-stream';
|
|
5
6
|
import type { Callback } from '../utils.js';
|
package/dist/emulation/sync.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
5
|
import { Buffer } from 'buffer';
|
|
5
6
|
import type * as fs from 'node:fs';
|
|
6
7
|
import type { FileContents } from '../filesystem.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
/// <reference types="node" resolution-mode="require"/>
|
|
4
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
4
5
|
import { EventEmitter } from 'eventemitter3';
|
|
5
6
|
import type { EventEmitter as NodeEventEmitter } from 'node:events';
|
|
6
7
|
import type * as fs from 'node:fs';
|
package/eslint.shared.js
CHANGED
|
@@ -1,53 +1,63 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Shared eslint rules
|
|
3
|
-
*/
|
|
4
|
-
|
|
1
|
+
/* Shared eslint rules */
|
|
5
2
|
import eslint from '@eslint/js';
|
|
6
3
|
import stylistic from '@stylistic/eslint-plugin';
|
|
7
4
|
import globals from 'globals';
|
|
8
5
|
import tseslint from 'typescript-eslint';
|
|
9
6
|
|
|
10
|
-
export default
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
export default [
|
|
8
|
+
{
|
|
9
|
+
name: 'ZenFS',
|
|
10
|
+
extends: [eslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
|
|
11
|
+
files: ['src/**/*.ts', 'tests/**/*.ts'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
globals: { ...globals.browser, ...globals.node },
|
|
14
|
+
ecmaVersion: 'latest',
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
},
|
|
17
|
+
plugins: { stylistic },
|
|
18
|
+
rules: {
|
|
19
|
+
'no-useless-escape': 'warn',
|
|
20
|
+
'stylistic/no-mixed-spaces-and-tabs': 'warn',
|
|
21
|
+
'no-unreachable': 'warn',
|
|
22
|
+
'stylistic/no-extra-semi': 'warn',
|
|
23
|
+
'no-fallthrough': 'warn',
|
|
24
|
+
'no-empty': 'warn',
|
|
25
|
+
'no-case-declarations': 'warn',
|
|
26
|
+
'prefer-const': 'warn',
|
|
27
|
+
'prefer-rest-params': 'warn',
|
|
28
|
+
'prefer-spread': 'warn',
|
|
29
|
+
'no-unused-vars': 'off',
|
|
30
|
+
'@typescript-eslint/no-unused-vars': 'warn',
|
|
31
|
+
'@typescript-eslint/no-inferrable-types': 'off',
|
|
32
|
+
'@typescript-eslint/no-this-alias': 'off',
|
|
33
|
+
'@typescript-eslint/no-unsafe-function-type': 'warn',
|
|
34
|
+
'@typescript-eslint/no-wrapper-object-types': 'warn',
|
|
35
|
+
'@typescript-eslint/triple-slash-reference': 'warn',
|
|
36
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
37
|
+
'@typescript-eslint/no-namespace': 'warn',
|
|
38
|
+
'@typescript-eslint/prefer-as-const': 'warn',
|
|
39
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
40
|
+
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
41
|
+
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
42
|
+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
|
43
|
+
'@typescript-eslint/require-await': 'warn',
|
|
44
|
+
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
45
|
+
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
46
|
+
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
47
|
+
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
48
|
+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
49
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
50
|
+
},
|
|
18
51
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
'prefer-rest-params': 'warn',
|
|
30
|
-
'prefer-spread': 'warn',
|
|
31
|
-
'no-unused-vars': 'off',
|
|
32
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
33
|
-
'@typescript-eslint/no-inferrable-types': 'off',
|
|
34
|
-
'@typescript-eslint/no-this-alias': 'off',
|
|
35
|
-
'@typescript-eslint/no-unsafe-function-type': 'warn',
|
|
36
|
-
'@typescript-eslint/no-wrapper-object-types': 'warn',
|
|
37
|
-
'@typescript-eslint/triple-slash-reference': 'warn',
|
|
38
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
39
|
-
'@typescript-eslint/no-namespace': 'warn',
|
|
40
|
-
'@typescript-eslint/prefer-as-const': 'warn',
|
|
41
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
42
|
-
'@typescript-eslint/consistent-type-assertions': 'warn',
|
|
43
|
-
'@typescript-eslint/consistent-type-imports': 'warn',
|
|
44
|
-
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
|
|
45
|
-
'@typescript-eslint/require-await': 'warn',
|
|
46
|
-
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
47
|
-
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
48
|
-
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
49
|
-
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
50
|
-
'@typescript-eslint/no-redundant-type-constituents': 'warn',
|
|
51
|
-
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
52
|
+
{
|
|
53
|
+
name: 'Tests overrides',
|
|
54
|
+
files: ['tests/**/*.ts'],
|
|
55
|
+
rules: {
|
|
56
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
57
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
58
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
59
|
+
'@typescript-eslint/no-floating-promises': 'off',
|
|
60
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
61
|
+
},
|
|
52
62
|
},
|
|
53
|
-
|
|
63
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenfs/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A filesystem, anywhere",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
".": "./dist/index.js",
|
|
42
42
|
"./*": "./dist/*",
|
|
43
43
|
"./promises": "./dist/emulation/promises.js",
|
|
44
|
-
"./mixins": "./dist/mixins/index.js"
|
|
44
|
+
"./mixins": "./dist/mixins/index.js",
|
|
45
|
+
"./eslint": "./eslint.shared.js"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"format": "prettier --write .",
|
|
48
49
|
"format:check": "prettier --check .",
|
|
49
50
|
"lint": "tsc -p tsconfig.json --noEmit && eslint src tests",
|
|
50
|
-
"test": "
|
|
51
|
+
"test": "tsx --test --experimental-test-coverage",
|
|
51
52
|
"build": "node scripts/build.js --globalName=ZenFS --entry src/index.ts",
|
|
52
53
|
"build:docs": "typedoc",
|
|
53
54
|
"dev": "npm run build -- --watch",
|
|
@@ -59,29 +60,25 @@
|
|
|
59
60
|
]
|
|
60
61
|
},
|
|
61
62
|
"dependencies": {
|
|
62
|
-
"@types/node": "^20.
|
|
63
|
+
"@types/node": "^20.16.10",
|
|
63
64
|
"@types/readable-stream": "^4.0.10",
|
|
64
65
|
"buffer": "^6.0.3",
|
|
65
66
|
"eventemitter3": "^5.0.1",
|
|
66
67
|
"minimatch": "^9.0.3",
|
|
67
68
|
"readable-stream": "^4.5.2",
|
|
68
|
-
"utilium": "
|
|
69
|
+
"utilium": "^0.7.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@eslint/js": "^9.8.0",
|
|
72
73
|
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
|
|
73
|
-
"@jest/globals": "^29.5.0",
|
|
74
74
|
"@stylistic/eslint-plugin": "^2.6.1",
|
|
75
75
|
"@types/eslint__js": "^8.42.3",
|
|
76
|
-
"@types/jest": "^29.5.1",
|
|
77
|
-
"cross-env": "^7.0.3",
|
|
78
76
|
"esbuild": "^0.21.0",
|
|
79
77
|
"eslint": "^9.8.0",
|
|
80
78
|
"globals": "^15.9.0",
|
|
81
|
-
"jest": "^29.7.0",
|
|
82
79
|
"lint-staged": "^15.2.7",
|
|
83
80
|
"prettier": "^3.2.5",
|
|
84
|
-
"
|
|
81
|
+
"tsx": "^4.19.1",
|
|
85
82
|
"typedoc": "^0.25.13",
|
|
86
83
|
"typedoc-plugin-remove-references": "^0.0.6",
|
|
87
84
|
"typescript": "^5.4.0",
|
package/src/backends/fetch.ts
CHANGED
|
@@ -94,7 +94,7 @@ export class FetchFS extends IndexFS {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
constructor({ index = 'index.json', baseUrl = '' }: FetchOptions) {
|
|
97
|
+
public constructor({ index = 'index.json', baseUrl = '' }: FetchOptions) {
|
|
98
98
|
super(typeof index != 'string' ? index : fetchFile<IndexData>(index, 'json'));
|
|
99
99
|
|
|
100
100
|
// prefix url must end in a directory separator.
|
|
@@ -118,7 +118,7 @@ export abstract class IndexFS extends Readonly(FileSystem) {
|
|
|
118
118
|
this._isInitialized = true;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
constructor(private indexData: IndexData | Promise<IndexData>) {
|
|
121
|
+
public constructor(private indexData: IndexData | Promise<IndexData>) {
|
|
122
122
|
super();
|
|
123
123
|
}
|
|
124
124
|
|
package/src/backends/overlay.ts
CHANGED
|
@@ -57,7 +57,7 @@ export class UnmutexedOverlayFS extends FileSystem {
|
|
|
57
57
|
|
|
58
58
|
private _ready: Promise<void>;
|
|
59
59
|
|
|
60
|
-
constructor({ writable, readable }: OverlayOptions) {
|
|
60
|
+
public constructor({ writable, readable }: OverlayOptions) {
|
|
61
61
|
super();
|
|
62
62
|
this.writable = writable;
|
|
63
63
|
this.readable = readable;
|
package/src/backends/port/fs.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface FileRequest<TMethod extends FileMethod = FileMethod> extends RPC.Reque
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export class PortFile extends File {
|
|
24
|
-
constructor(
|
|
24
|
+
public constructor(
|
|
25
25
|
public fs: PortFS,
|
|
26
26
|
public readonly fd: number,
|
|
27
27
|
path: string,
|
|
@@ -194,27 +194,35 @@ export class PortFS extends Async(FileSystem) {
|
|
|
194
194
|
public sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void> {
|
|
195
195
|
return this.rpc('sync', path, data, stats);
|
|
196
196
|
}
|
|
197
|
+
|
|
197
198
|
public openFile(path: string, flag: string): Promise<File> {
|
|
198
199
|
return this.rpc('openFile', path, flag);
|
|
199
200
|
}
|
|
201
|
+
|
|
200
202
|
public createFile(path: string, flag: string, mode: number): Promise<File> {
|
|
201
203
|
return this.rpc('createFile', path, flag, mode);
|
|
202
204
|
}
|
|
205
|
+
|
|
203
206
|
public unlink(path: string): Promise<void> {
|
|
204
207
|
return this.rpc('unlink', path);
|
|
205
208
|
}
|
|
209
|
+
|
|
206
210
|
public rmdir(path: string): Promise<void> {
|
|
207
211
|
return this.rpc('rmdir', path);
|
|
208
212
|
}
|
|
213
|
+
|
|
209
214
|
public mkdir(path: string, mode: number): Promise<void> {
|
|
210
215
|
return this.rpc('mkdir', path, mode);
|
|
211
216
|
}
|
|
217
|
+
|
|
212
218
|
public readdir(path: string): Promise<string[]> {
|
|
213
219
|
return this.rpc('readdir', path);
|
|
214
220
|
}
|
|
221
|
+
|
|
215
222
|
public exists(path: string): Promise<boolean> {
|
|
216
223
|
return this.rpc('exists', path);
|
|
217
224
|
}
|
|
225
|
+
|
|
218
226
|
public link(srcpath: string, dstpath: string): Promise<void> {
|
|
219
227
|
return this.rpc('link', srcpath, dstpath);
|
|
220
228
|
}
|
package/src/backends/store/fs.ts
CHANGED
|
@@ -82,10 +82,6 @@ export class SimpleTransaction extends SyncTransaction<SimpleSyncStore> {
|
|
|
82
82
|
|
|
83
83
|
protected declare store: SimpleSyncStore;
|
|
84
84
|
|
|
85
|
-
constructor(store: SimpleSyncStore) {
|
|
86
|
-
super(store);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
85
|
public getSync(ino: Ino): Uint8Array {
|
|
90
86
|
const val = this.store.get(ino);
|
|
91
87
|
this.stashOldValue(ino, val);
|
|
@@ -36,7 +36,7 @@ export interface Store {
|
|
|
36
36
|
* A transaction for a store.
|
|
37
37
|
*/
|
|
38
38
|
export abstract class Transaction<T extends Store = Store> {
|
|
39
|
-
constructor(protected store: T) {}
|
|
39
|
+
public constructor(protected store: T) {}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Whether the transaction was commited or aborted
|
|
@@ -134,15 +134,19 @@ export abstract class SyncTransaction<T extends Store = Store> extends Transacti
|
|
|
134
134
|
public async get(ino: Ino): Promise<Uint8Array> {
|
|
135
135
|
return this.getSync(ino);
|
|
136
136
|
}
|
|
137
|
+
|
|
137
138
|
public async set(ino: bigint, data: Uint8Array): Promise<void> {
|
|
138
139
|
return this.setSync(ino, data);
|
|
139
140
|
}
|
|
141
|
+
|
|
140
142
|
public async remove(ino: Ino): Promise<void> {
|
|
141
143
|
return this.removeSync(ino);
|
|
142
144
|
}
|
|
145
|
+
|
|
143
146
|
public async commit(): Promise<void> {
|
|
144
147
|
return this.commitSync();
|
|
145
148
|
}
|
|
149
|
+
|
|
146
150
|
public async abort(): Promise<void> {
|
|
147
151
|
return this.abortSync();
|
|
148
152
|
}
|
package/src/emulation/dir.ts
CHANGED
package/src/error.ts
CHANGED
|
@@ -272,7 +272,7 @@ export class ErrnoError extends Error implements NodeJS.ErrnoException {
|
|
|
272
272
|
* @param type The type of the error.
|
|
273
273
|
* @param message A descriptive error message.
|
|
274
274
|
*/
|
|
275
|
-
constructor(
|
|
275
|
+
public constructor(
|
|
276
276
|
public errno: Errno,
|
|
277
277
|
message: string = errorMessages[errno],
|
|
278
278
|
public path?: string,
|
package/src/file.ts
CHANGED
|
@@ -146,7 +146,7 @@ export function isExclusive(flag: string): boolean {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
export abstract class File {
|
|
149
|
-
constructor(
|
|
149
|
+
public constructor(
|
|
150
150
|
/**
|
|
151
151
|
* @internal
|
|
152
152
|
* The file system that created the file
|
|
@@ -359,7 +359,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
|
|
|
359
359
|
* contents of the file. PreloadFile will mutate this buffer. If not
|
|
360
360
|
* specified, we assume it is a new file.
|
|
361
361
|
*/
|
|
362
|
-
constructor(
|
|
362
|
+
public constructor(
|
|
363
363
|
/**
|
|
364
364
|
* The file system that created the file.
|
|
365
365
|
* @internal
|
|
@@ -765,7 +765,7 @@ export class PreloadFile<FS extends FileSystem> extends File {
|
|
|
765
765
|
* For the filesystems which do not sync to anything..
|
|
766
766
|
*/
|
|
767
767
|
export class NoSyncFile<T extends FileSystem> extends PreloadFile<T> {
|
|
768
|
-
constructor(fs: T, path: string, flag: string, stats: Stats, contents?: Uint8Array) {
|
|
768
|
+
public constructor(fs: T, path: string, flag: string, stats: Stats, contents?: Uint8Array) {
|
|
769
769
|
super(fs, path, flag, stats, contents);
|
|
770
770
|
}
|
|
771
771
|
/**
|
package/src/inode.ts
CHANGED
|
@@ -81,7 +81,7 @@ export class Inode implements StatsLike {
|
|
|
81
81
|
|
|
82
82
|
protected view: DataView;
|
|
83
83
|
|
|
84
|
-
constructor(buffer?: ArrayBufferLike) {
|
|
84
|
+
public constructor(buffer?: ArrayBufferLike) {
|
|
85
85
|
const setDefaults = !buffer;
|
|
86
86
|
buffer ??= new ArrayBuffer(offsets.end);
|
|
87
87
|
if (buffer?.byteLength < offsets.end) {
|
package/src/stats.ts
CHANGED
|
@@ -174,7 +174,7 @@ export abstract class StatsCommon<T extends number | bigint> implements Node.Sta
|
|
|
174
174
|
/**
|
|
175
175
|
* Creates a new stats instance from a stats-like object. Can be used to copy stats (note)
|
|
176
176
|
*/
|
|
177
|
-
constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino }: Partial<StatsLike> = {}) {
|
|
177
|
+
public constructor({ atimeMs, mtimeMs, ctimeMs, birthtimeMs, uid, gid, size, mode, ino }: Partial<StatsLike> = {}) {
|
|
178
178
|
const now = Date.now();
|
|
179
179
|
this.atimeMs = this._convert(atimeMs ?? now);
|
|
180
180
|
this.mtimeMs = this._convert(mtimeMs ?? now);
|
|
@@ -290,12 +290,15 @@ export abstract class StatsCommon<T extends number | bigint> implements Node.Sta
|
|
|
290
290
|
public get atimeNs(): bigint {
|
|
291
291
|
return BigInt(this.atimeMs) * 1000n;
|
|
292
292
|
}
|
|
293
|
+
|
|
293
294
|
public get mtimeNs(): bigint {
|
|
294
295
|
return BigInt(this.mtimeMs) * 1000n;
|
|
295
296
|
}
|
|
297
|
+
|
|
296
298
|
public get ctimeNs(): bigint {
|
|
297
299
|
return BigInt(this.ctimeMs) * 1000n;
|
|
298
300
|
}
|
|
301
|
+
|
|
299
302
|
public get birthtimeNs(): bigint {
|
|
300
303
|
return BigInt(this.birthtimeMs) * 1000n;
|
|
301
304
|
}
|