core-3nweb-client-lib 0.47.1 → 0.47.3
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Abortable } from 'events';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BufferEncodingOption, promises as fsFns, Mode, ObjectEncodingOptions, OpenMode, RmDirOptions, StatOptions, Stats } from 'fs';
|
|
3
3
|
import { FlagAndOpenMode } from 'fs/promises';
|
|
4
4
|
import type Stream = require('stream');
|
|
5
5
|
export type { Stats } from 'fs';
|
|
@@ -32,74 +32,39 @@ export interface PlatformDeviceFS {
|
|
|
32
32
|
*/
|
|
33
33
|
copyFile(src: string, dst: string, overwrite?: boolean, dstMode?: string): Promise<void>;
|
|
34
34
|
}
|
|
35
|
-
declare function readFile(path:
|
|
35
|
+
declare function readFile(path: string, options?: ({
|
|
36
36
|
encoding?: null | undefined;
|
|
37
37
|
flag?: OpenMode | undefined;
|
|
38
38
|
} & Abortable) | null): Promise<Buffer>;
|
|
39
|
-
declare function readFile(path:
|
|
39
|
+
declare function readFile(path: string, options: ({
|
|
40
40
|
encoding: BufferEncoding;
|
|
41
41
|
flag?: OpenMode | undefined;
|
|
42
42
|
} & Abortable) | BufferEncoding): Promise<string>;
|
|
43
|
-
declare function readFile(path:
|
|
43
|
+
declare function readFile(path: string, options?: (ObjectEncodingOptions & Abortable & {
|
|
44
44
|
flag?: OpenMode | undefined;
|
|
45
45
|
}) | BufferEncoding | null): Promise<string | Buffer>;
|
|
46
|
-
declare function writeFile(file:
|
|
46
|
+
declare function writeFile(file: string, data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream, options?: (ObjectEncodingOptions & {
|
|
47
47
|
mode?: Mode | undefined;
|
|
48
48
|
flag?: OpenMode | undefined;
|
|
49
49
|
flush?: boolean | undefined;
|
|
50
50
|
} & Abortable) | BufferEncoding | null): Promise<void>;
|
|
51
|
-
declare function appendFile(path:
|
|
51
|
+
declare function appendFile(path: string, data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode & {
|
|
52
52
|
flush?: boolean | undefined;
|
|
53
53
|
}) | BufferEncoding | null): Promise<void>;
|
|
54
|
-
declare function mkdir(path:
|
|
55
|
-
recursive
|
|
54
|
+
declare function mkdir(path: string, options?: {
|
|
55
|
+
recursive?: boolean;
|
|
56
56
|
}): Promise<string | undefined>;
|
|
57
|
-
declare function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
declare function
|
|
61
|
-
declare function
|
|
62
|
-
declare function
|
|
63
|
-
declare function
|
|
64
|
-
declare function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
declare function
|
|
70
|
-
|
|
71
|
-
}): Promise<BigIntStats>;
|
|
72
|
-
declare function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
73
|
-
declare function stat(path: PathLike, opts?: StatOptions & {
|
|
74
|
-
bigint?: false | undefined;
|
|
75
|
-
}): Promise<Stats>;
|
|
76
|
-
declare function stat(path: PathLike, opts: StatOptions & {
|
|
77
|
-
bigint: true;
|
|
78
|
-
}): Promise<BigIntStats>;
|
|
79
|
-
declare function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
|
80
|
-
declare function readdir(path: PathLike, options?: (ObjectEncodingOptions & {
|
|
81
|
-
withFileTypes?: false | undefined;
|
|
82
|
-
recursive?: boolean | undefined;
|
|
83
|
-
}) | BufferEncoding | null): Promise<string[]>;
|
|
84
|
-
declare function readdir(path: PathLike, options: {
|
|
85
|
-
encoding: "buffer";
|
|
86
|
-
withFileTypes?: false | undefined;
|
|
87
|
-
recursive?: boolean | undefined;
|
|
88
|
-
} | "buffer"): Promise<Buffer[]>;
|
|
89
|
-
declare function readdir(path: PathLike, options?: (ObjectEncodingOptions & {
|
|
90
|
-
withFileTypes?: false | undefined;
|
|
91
|
-
recursive?: boolean | undefined;
|
|
92
|
-
}) | BufferEncoding | null): Promise<string[] | Buffer[]>;
|
|
93
|
-
declare function readdir(path: PathLike, options: ObjectEncodingOptions & {
|
|
94
|
-
withFileTypes: true;
|
|
95
|
-
recursive?: boolean | undefined;
|
|
96
|
-
}): Promise<Dirent[]>;
|
|
97
|
-
declare function readdir(path: PathLike, options: {
|
|
98
|
-
encoding: "buffer";
|
|
99
|
-
withFileTypes: true;
|
|
100
|
-
recursive?: boolean | undefined;
|
|
101
|
-
}): Promise<Dirent<Buffer>[]>;
|
|
102
|
-
declare function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
|
|
103
|
-
declare function unlink(path: PathLike): Promise<void>;
|
|
104
|
-
declare function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
|
105
|
-
declare function truncate(path: PathLike, len?: number): Promise<void>;
|
|
57
|
+
declare function open(path: string, flags?: string | number, mode?: Mode): Promise<FileHandle>;
|
|
58
|
+
declare function symlink(target: string, path: string, type?: string | null): Promise<void>;
|
|
59
|
+
declare function readlink(path: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
60
|
+
declare function readlink(path: string, options: BufferEncodingOption): Promise<Buffer>;
|
|
61
|
+
declare function readlink(path: string, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
62
|
+
declare function lstat(path: string, opts?: StatOptions): Promise<Stats>;
|
|
63
|
+
declare function stat(path: string, opts?: StatOptions): Promise<Stats>;
|
|
64
|
+
declare function readdir(path: string, options?: {
|
|
65
|
+
recursive?: boolean;
|
|
66
|
+
}): Promise<string[]>;
|
|
67
|
+
declare function rmdir(path: string, options?: RmDirOptions): Promise<void>;
|
|
68
|
+
declare function unlink(path: string): Promise<void>;
|
|
69
|
+
declare function rename(oldPath: string, newPath: string): Promise<void>;
|
|
70
|
+
declare function truncate(path: string, len?: number): Promise<void>;
|
|
@@ -43,31 +43,26 @@ async function makeFolder(root, path, exclusive = false) {
|
|
|
43
43
|
if (path.length === 0) {
|
|
44
44
|
throw new Error('Invalid file path');
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
pathStr += '/' + path[i];
|
|
50
|
-
const stats = await fs.lstat(pathStr).catch((exc) => {
|
|
46
|
+
const pathStr = pathMod.join(root, ...path);
|
|
47
|
+
if (exclusive) {
|
|
48
|
+
const stats = await fs.lstat(pathStr).catch(async (exc) => {
|
|
51
49
|
if (exc.code !== file_1.Code.notFound) {
|
|
52
50
|
throw (0, file_1.maskPathInExc)(root.length, exc);
|
|
53
51
|
}
|
|
54
|
-
return fs.mkdir(pathStr)
|
|
55
|
-
.catch((exc) => {
|
|
56
|
-
if (!exc.alreadyExists) {
|
|
57
|
-
throw exc;
|
|
58
|
-
}
|
|
59
|
-
}); // resolves to undefined, leading to !stats
|
|
60
52
|
});
|
|
61
53
|
if (!stats) {
|
|
62
|
-
|
|
54
|
+
await fs.mkdir(pathStr, { recursive: true });
|
|
63
55
|
}
|
|
64
|
-
if (!stats.isDirectory()) {
|
|
65
|
-
throw (0, file_1.makeFileException)('notDirectory', path.
|
|
56
|
+
else if (!stats.isDirectory()) {
|
|
57
|
+
throw (0, file_1.makeFileException)('notDirectory', path.join('/'));
|
|
66
58
|
}
|
|
67
|
-
else
|
|
59
|
+
else {
|
|
68
60
|
throw (0, file_1.makeFileException)('alreadyExists', path.join('/'));
|
|
69
61
|
}
|
|
70
62
|
}
|
|
63
|
+
else {
|
|
64
|
+
await fs.mkdir(pathStr, { recursive: true });
|
|
65
|
+
}
|
|
71
66
|
}
|
|
72
67
|
async function checkPresence(type, root, path, throwIfMissing) {
|
|
73
68
|
try {
|
|
@@ -5,72 +5,29 @@ export type { FileHandle, FileException, Stats } from '../injected-globals/platf
|
|
|
5
5
|
* fs functions follow node's type, and are injected via global object to allow injection in
|
|
6
6
|
* non-node environments, like Android or browser.
|
|
7
7
|
*/
|
|
8
|
-
export declare const appendFile: (path:
|
|
8
|
+
export declare const appendFile: (path: string, data: string | Uint8Array, options?: (import("fs").ObjectEncodingOptions & import("fs/promises").FlagAndOpenMode & {
|
|
9
9
|
flush?: boolean | undefined;
|
|
10
|
-
}) | BufferEncoding | null) => Promise<void>, lstat: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(path: import("fs").PathLike, opts: import("fs").StatOptions & {
|
|
15
|
-
bigint: true;
|
|
16
|
-
}): Promise<import("fs").BigIntStats>;
|
|
17
|
-
(path: import("fs").PathLike, opts?: import("fs").StatOptions): Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
18
|
-
}, mkdir: {
|
|
19
|
-
(path: import("fs").PathLike, options: import("fs").MakeDirectoryOptions & {
|
|
20
|
-
recursive: true;
|
|
21
|
-
}): Promise<string | undefined>;
|
|
22
|
-
(path: import("fs").PathLike, options?: import("fs").Mode | (import("fs").MakeDirectoryOptions & {
|
|
23
|
-
recursive?: false | undefined;
|
|
24
|
-
}) | null): Promise<void>;
|
|
25
|
-
(path: import("fs").PathLike, options?: import("fs").Mode | import("fs").MakeDirectoryOptions | null): Promise<string | undefined>;
|
|
26
|
-
}, open: (path: import("fs").PathLike, flags?: string | number, mode?: import("fs").Mode) => Promise<FileHandle>, readFile: {
|
|
27
|
-
(path: import("fs").PathLike | FileHandle, options?: ({
|
|
10
|
+
}) | BufferEncoding | null) => Promise<void>, lstat: (path: string, opts?: import("fs").StatOptions) => Promise<import("fs").Stats>, mkdir: (path: string, options?: {
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}) => Promise<string | undefined>, open: (path: string, flags?: string | number, mode?: import("fs").Mode) => Promise<FileHandle>, readFile: {
|
|
13
|
+
(path: string, options?: ({
|
|
28
14
|
encoding?: null | undefined;
|
|
29
15
|
flag?: import("fs").OpenMode | undefined;
|
|
30
16
|
} & import("events").Abortable) | null): Promise<Buffer>;
|
|
31
|
-
(path:
|
|
17
|
+
(path: string, options: ({
|
|
32
18
|
encoding: BufferEncoding;
|
|
33
19
|
flag?: import("fs").OpenMode | undefined;
|
|
34
20
|
} & import("events").Abortable) | BufferEncoding): Promise<string>;
|
|
35
|
-
(path:
|
|
21
|
+
(path: string, options?: (import("fs").ObjectEncodingOptions & import("events").Abortable & {
|
|
36
22
|
flag?: import("fs").OpenMode | undefined;
|
|
37
23
|
}) | BufferEncoding | null): Promise<string | Buffer>;
|
|
38
|
-
}, readdir: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
(path: import("fs").
|
|
44
|
-
|
|
45
|
-
withFileTypes?: false | undefined;
|
|
46
|
-
recursive?: boolean | undefined;
|
|
47
|
-
} | "buffer"): Promise<Buffer[]>;
|
|
48
|
-
(path: import("fs").PathLike, options?: (import("fs").ObjectEncodingOptions & {
|
|
49
|
-
withFileTypes?: false | undefined;
|
|
50
|
-
recursive?: boolean | undefined;
|
|
51
|
-
}) | BufferEncoding | null): Promise<string[] | Buffer[]>;
|
|
52
|
-
(path: import("fs").PathLike, options: import("fs").ObjectEncodingOptions & {
|
|
53
|
-
withFileTypes: true;
|
|
54
|
-
recursive?: boolean | undefined;
|
|
55
|
-
}): Promise<import("fs").Dirent[]>;
|
|
56
|
-
(path: import("fs").PathLike, options: {
|
|
57
|
-
encoding: "buffer";
|
|
58
|
-
withFileTypes: true;
|
|
59
|
-
recursive?: boolean | undefined;
|
|
60
|
-
}): Promise<import("fs").Dirent<Buffer>[]>;
|
|
61
|
-
}, readlink: {
|
|
62
|
-
(path: import("fs").PathLike, options?: import("fs").ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
63
|
-
(path: import("fs").PathLike, options: import("fs").BufferEncodingOption): Promise<Buffer>;
|
|
64
|
-
(path: import("fs").PathLike, options?: import("fs").ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
65
|
-
}, rename: (oldPath: import("fs").PathLike, newPath: import("fs").PathLike) => Promise<void>, rmdir: (path: import("fs").PathLike, options?: import("fs").RmDirOptions) => Promise<void>, stat: {
|
|
66
|
-
(path: import("fs").PathLike, opts?: import("fs").StatOptions & {
|
|
67
|
-
bigint?: false | undefined;
|
|
68
|
-
}): Promise<import("fs").Stats>;
|
|
69
|
-
(path: import("fs").PathLike, opts: import("fs").StatOptions & {
|
|
70
|
-
bigint: true;
|
|
71
|
-
}): Promise<import("fs").BigIntStats>;
|
|
72
|
-
(path: import("fs").PathLike, opts?: import("fs").StatOptions): Promise<import("fs").Stats | import("fs").BigIntStats>;
|
|
73
|
-
}, symlink: (target: import("fs").PathLike, path: import("fs").PathLike, type?: string | null) => Promise<void>, truncate: (path: import("fs").PathLike, len?: number) => Promise<void>, unlink: (path: import("fs").PathLike) => Promise<void>, writeFile: (file: import("fs").PathLike | FileHandle, data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | import("stream"), options?: (import("fs").ObjectEncodingOptions & {
|
|
24
|
+
}, readdir: (path: string, options?: {
|
|
25
|
+
recursive?: boolean;
|
|
26
|
+
}) => Promise<string[]>, readlink: {
|
|
27
|
+
(path: string, options?: import("fs").ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
28
|
+
(path: string, options: import("fs").BufferEncodingOption): Promise<Buffer>;
|
|
29
|
+
(path: string, options?: import("fs").ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
30
|
+
}, rename: (oldPath: string, newPath: string) => Promise<void>, rmdir: (path: string, options?: import("fs").RmDirOptions) => Promise<void>, stat: (path: string, opts?: import("fs").StatOptions) => Promise<import("fs").Stats>, symlink: (target: string, path: string, type?: string | null) => Promise<void>, truncate: (path: string, len?: number) => Promise<void>, unlink: (path: string) => Promise<void>, writeFile: (file: string, data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | import("stream"), options?: (import("fs").ObjectEncodingOptions & {
|
|
74
31
|
mode?: import("fs").Mode | undefined;
|
|
75
32
|
flag?: import("fs").OpenMode | undefined;
|
|
76
33
|
flush?: boolean | undefined;
|