@zenfs/core 0.12.0 → 0.12.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/backend.d.ts +15 -5
- package/dist/backends/index/fs.d.ts +1 -0
- package/dist/backends/index/index.d.ts +5 -0
- package/dist/backends/index/index.js +1 -0
- package/dist/backends/overlay.js +1 -1
- package/dist/backends/port/fs.d.ts +3 -1
- package/dist/browser.min.js +4 -4
- package/dist/browser.min.js.map +4 -4
- package/dist/config.d.ts +33 -11
- package/dist/config.js +16 -7
- package/dist/emulation/async.d.ts +5 -4
- package/dist/emulation/async.js +3 -2
- package/dist/emulation/index.d.ts +1 -1
- package/dist/emulation/index.js +1 -1
- package/dist/emulation/path.d.ts +4 -1
- package/dist/emulation/promises.d.ts +4 -4
- package/dist/emulation/promises.js +27 -27
- package/dist/emulation/shared.d.ts +6 -0
- package/dist/emulation/shared.js +19 -1
- package/dist/emulation/sync.d.ts +4 -4
- package/dist/emulation/sync.js +76 -38
- package/dist/file.d.ts +5 -10
- package/dist/file.js +38 -55
- package/dist/filesystem.d.ts +45 -3
- package/dist/filesystem.js +37 -8
- package/dist/stats.d.ts +16 -16
- package/dist/stats.js +42 -49
- package/package.json +2 -2
- package/src/backends/backend.ts +15 -6
- package/src/backends/index/index.ts +5 -0
- package/src/backends/overlay.ts +1 -1
- package/src/config.ts +62 -21
- package/src/emulation/async.ts +19 -18
- package/src/emulation/index.ts +1 -1
- package/src/emulation/path.ts +4 -1
- package/src/emulation/promises.ts +33 -31
- package/src/emulation/shared.ts +22 -1
- package/src/emulation/sync.ts +83 -54
- package/src/error.ts +1 -1
- package/src/file.ts +39 -57
- package/src/filesystem.ts +133 -51
- package/src/stats.ts +48 -60
|
@@ -4,7 +4,7 @@ type OptionType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undef
|
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the type of Backend.options from the options interface
|
|
6
6
|
*/
|
|
7
|
-
type OptionsConfig<T> = {
|
|
7
|
+
export type OptionsConfig<T> = {
|
|
8
8
|
[K in keyof T]: {
|
|
9
9
|
/**
|
|
10
10
|
* The basic JavaScript type(s) for this option.
|
|
@@ -54,7 +54,16 @@ export interface Backend<FS extends FileSystem = FileSystem, TOptions extends ob
|
|
|
54
54
|
*/
|
|
55
55
|
isAvailable(): boolean | Promise<boolean>;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Gets the options type of a backend
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export type OptionsOf<T extends Backend> = T extends Backend<FileSystem, infer TOptions> ? TOptions : never;
|
|
62
|
+
/**
|
|
63
|
+
* Gets the FileSystem type for a backend
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
export type FilesystemOf<T extends Backend> = T extends Backend<infer FS> ? FS : never;
|
|
58
67
|
/**
|
|
59
68
|
* @internal
|
|
60
69
|
*/
|
|
@@ -63,7 +72,7 @@ export declare function isBackend(arg: unknown): arg is Backend;
|
|
|
63
72
|
* Checks that the given options object is valid for the file system options.
|
|
64
73
|
* @internal
|
|
65
74
|
*/
|
|
66
|
-
export declare function checkOptions<T extends Backend>(backend: T, opts:
|
|
75
|
+
export declare function checkOptions<T extends Backend>(backend: T, opts: Record<string, unknown>): Promise<void>;
|
|
67
76
|
/**
|
|
68
77
|
* Specifies a file system backend type and its options.
|
|
69
78
|
*
|
|
@@ -72,11 +81,12 @@ export declare function checkOptions<T extends Backend>(backend: T, opts: Partia
|
|
|
72
81
|
*
|
|
73
82
|
* The option object for each file system corresponds to that file system's option object passed to its `Create()` method.
|
|
74
83
|
*/
|
|
75
|
-
export type BackendConfiguration<T extends Backend
|
|
84
|
+
export type BackendConfiguration<T extends Backend> = OptionsOf<T> & {
|
|
76
85
|
backend: T;
|
|
86
|
+
disableAsyncCache?: boolean;
|
|
77
87
|
};
|
|
78
88
|
/**
|
|
79
89
|
* @internal
|
|
80
90
|
*/
|
|
81
|
-
export declare function isBackendConfig(arg: unknown): arg is BackendConfiguration
|
|
91
|
+
export declare function isBackendConfig<T extends Backend>(arg: unknown): arg is BackendConfiguration<T>;
|
|
82
92
|
export {};
|
|
@@ -19,6 +19,7 @@ declare const IndexFS_base: (abstract new (...args: any[]) => {
|
|
|
19
19
|
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
20
20
|
sync(path: string, data: Uint8Array, stats: Readonly<Stats>): Promise<void>;
|
|
21
21
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
22
|
+
_type?: number | undefined;
|
|
22
23
|
ready(): Promise<void>;
|
|
23
24
|
stat(path: string, cred: Cred): Promise<Stats>;
|
|
24
25
|
statSync(path: string, cred: Cred): Stats;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Stats, StatsLike } from '../../stats.js';
|
|
2
|
+
/**
|
|
3
|
+
* An Index in JSON form
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
2
6
|
export interface IndexData {
|
|
3
7
|
version: 1;
|
|
4
8
|
entries: Record<string, StatsLike<number>>;
|
|
@@ -6,6 +10,7 @@ export interface IndexData {
|
|
|
6
10
|
export declare const version = 1;
|
|
7
11
|
/**
|
|
8
12
|
* An index of files
|
|
13
|
+
* @internal
|
|
9
14
|
*/
|
|
10
15
|
export declare class Index extends Map<string, Stats> {
|
|
11
16
|
constructor();
|
package/dist/backends/overlay.js
CHANGED
|
@@ -166,7 +166,7 @@ export class UnlockedOverlayFS extends FileSystem {
|
|
|
166
166
|
}
|
|
167
167
|
// Create an OverlayFile.
|
|
168
168
|
const file = this._readable.openFileSync(path, parseFlag('r'), cred);
|
|
169
|
-
const stats = Stats
|
|
169
|
+
const stats = new Stats(file.statSync());
|
|
170
170
|
const data = new Uint8Array(stats.size);
|
|
171
171
|
file.readSync(data);
|
|
172
172
|
return new PreloadFile(this, path, flag, stats, data);
|
|
@@ -40,7 +40,8 @@ export declare class PortFile extends File {
|
|
|
40
40
|
type FSMethods = ExtractProperties<FileSystem, (...args: any[]) => Promise<any> | FileSystemMetadata>;
|
|
41
41
|
type FSMethod = keyof FSMethods;
|
|
42
42
|
declare const PortFS_base: (abstract new (...args: any[]) => {
|
|
43
|
-
|
|
43
|
+
_disableSync: boolean;
|
|
44
|
+
_sync?: FileSystem | undefined;
|
|
44
45
|
queueDone(): Promise<void>;
|
|
45
46
|
metadata(): FileSystemMetadata;
|
|
46
47
|
ready(): Promise<void>;
|
|
@@ -54,6 +55,7 @@ declare const PortFS_base: (abstract new (...args: any[]) => {
|
|
|
54
55
|
readdirSync(path: string, cred: Cred): string[];
|
|
55
56
|
linkSync(srcpath: string, dstpath: string, cred: Cred): void;
|
|
56
57
|
syncSync(path: string, data: Uint8Array, stats: Readonly<Stats>): void;
|
|
58
|
+
_type?: number | undefined;
|
|
57
59
|
rename(oldPath: string, newPath: string, cred: Cred): Promise<void>;
|
|
58
60
|
stat(path: string, cred: Cred): Promise<Stats>;
|
|
59
61
|
openFile(path: string, flag: string, cred: Cred): Promise<File>;
|