core-3nweb-client-lib 0.48.0 → 0.48.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/build/core/asmail/inbox/msg-on-disk.js +1 -1
- package/build/core/keyring/published-intro-key.js +3 -1
- package/build/injected-globals/platform-devfs.d.ts +13 -20
- package/build/lib-client/objs-on-disk/obj-folders.js +3 -2
- package/build/lib-common/async-fs-node.d.ts +13 -17
- package/build/lib-common/processes/sleep.js +2 -1
- package/build/lib-common/timed-non-weak-cache.js +3 -2
- package/build/lib-common/weak-cache.js +2 -1
- package/package.json +1 -1
|
@@ -122,7 +122,7 @@ Object.freeze(MsgOnDisk);
|
|
|
122
122
|
async function readJSON(msgFolderPath, fname, msgId) {
|
|
123
123
|
const path = (0, path_1.join)(msgFolderPath, fname);
|
|
124
124
|
try {
|
|
125
|
-
return JSON.parse(await fs.readFile(path, {
|
|
125
|
+
return JSON.parse(await fs.readFile(path, { encoding: 'utf8' }));
|
|
126
126
|
}
|
|
127
127
|
catch (err) {
|
|
128
128
|
throw (0, error_1.errWithCause)(err, `Can't read file ${fname} of message ${msgId}`);
|
|
@@ -49,6 +49,7 @@ class PublishedIntroKey {
|
|
|
49
49
|
return pk;
|
|
50
50
|
}
|
|
51
51
|
startExpiryCheckProcess(calledInInit = false) {
|
|
52
|
+
var _a, _b;
|
|
52
53
|
if (!calledInInit && !this.periodicExpiryCheck) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
@@ -61,7 +62,8 @@ class PublishedIntroKey {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
if (calledInInit) {
|
|
64
|
-
this.periodicExpiryCheck = setTimeout(() => this.startExpiryCheckProcess(), UPDATE_BEFORE_EXPIRY * 1000 / 20)
|
|
65
|
+
this.periodicExpiryCheck = setTimeout(() => this.startExpiryCheckProcess(), UPDATE_BEFORE_EXPIRY * 1000 / 20);
|
|
66
|
+
(_b = (_a = this.periodicExpiryCheck).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
async close() {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type { Abortable } from 'events';
|
|
2
1
|
import type { BufferEncodingOption, promises as fsFns, Mode, ObjectEncodingOptions, OpenMode, RmDirOptions, StatOptions, Stats } from 'fs';
|
|
3
|
-
import { FlagAndOpenMode } from 'fs/promises';
|
|
4
|
-
import type Stream = require('stream');
|
|
5
2
|
export type { Stats } from 'fs';
|
|
6
3
|
export type { FileException } from '../lib-common/exceptions/file';
|
|
7
4
|
export type FileHandle = fsFns.FileHandle;
|
|
@@ -32,28 +29,24 @@ export interface PlatformDeviceFS {
|
|
|
32
29
|
*/
|
|
33
30
|
copyFile(src: string, dst: string, overwrite?: boolean, dstMode?: string): Promise<void>;
|
|
34
31
|
}
|
|
35
|
-
declare function readFile(path: string, options?:
|
|
36
|
-
encoding?: null
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
declare function readFile(path: string, options: ({
|
|
32
|
+
declare function readFile(path: string, options?: {
|
|
33
|
+
encoding?: null;
|
|
34
|
+
} | null): Promise<Buffer>;
|
|
35
|
+
declare function readFile(path: string, options: {
|
|
40
36
|
encoding: BufferEncoding;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
declare function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
flush?: boolean | undefined;
|
|
50
|
-
} & Abortable) | BufferEncoding | null): Promise<void>;
|
|
51
|
-
declare function appendFile(path: string, data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode & {
|
|
37
|
+
} | BufferEncoding): Promise<string>;
|
|
38
|
+
declare function readFile(path: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
39
|
+
declare function writeFile(file: string, data: string | Uint8Array, options?: (ObjectEncodingOptions & {
|
|
40
|
+
mode?: Mode;
|
|
41
|
+
flag?: OpenMode;
|
|
42
|
+
flush?: boolean;
|
|
43
|
+
}) | BufferEncoding | null): Promise<void>;
|
|
44
|
+
declare function appendFile(path: string, data: string | Uint8Array, options?: (ObjectEncodingOptions & {
|
|
52
45
|
flush?: boolean | undefined;
|
|
53
46
|
}) | BufferEncoding | null): Promise<void>;
|
|
54
47
|
declare function mkdir(path: string, options?: {
|
|
55
48
|
recursive?: boolean;
|
|
56
|
-
}): Promise<
|
|
49
|
+
}): Promise<unknown>;
|
|
57
50
|
declare function open(path: string, flags?: string | number, mode?: Mode): Promise<FileHandle>;
|
|
58
51
|
declare function symlink(target: string, path: string, type?: string | null): Promise<void>;
|
|
59
52
|
declare function readlink(path: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
@@ -229,10 +229,11 @@ class RotationsProc {
|
|
|
229
229
|
return (0, path_1.join)(this.generationsFolder, `${backetIndex}`);
|
|
230
230
|
}
|
|
231
231
|
setNextCacheRotation(secs) {
|
|
232
|
-
|
|
232
|
+
var _a, _b;
|
|
233
|
+
(_b = (_a = setTimeout(async () => {
|
|
233
234
|
await this.rotate();
|
|
234
235
|
this.setNextCacheRotation(this.generations[0].period);
|
|
235
|
-
}, secs * 1000).unref();
|
|
236
|
+
}, secs * 1000)).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
236
237
|
}
|
|
237
238
|
async rotate() {
|
|
238
239
|
const now = Math.floor(Date.now() / 1000);
|
|
@@ -5,31 +5,27 @@ 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: string, data: string | Uint8Array, options?: (import("fs").ObjectEncodingOptions &
|
|
8
|
+
export declare const appendFile: (path: string, data: string | Uint8Array, options?: (import("fs").ObjectEncodingOptions & {
|
|
9
9
|
flush?: boolean | undefined;
|
|
10
10
|
}) | BufferEncoding | null) => Promise<void>, lstat: (path: string, opts?: import("fs").StatOptions) => Promise<import("fs").Stats>, mkdir: (path: string, options?: {
|
|
11
11
|
recursive?: boolean;
|
|
12
|
-
}) => Promise<
|
|
13
|
-
(path: string, options?:
|
|
14
|
-
encoding?: null
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
(path: string, options: ({
|
|
12
|
+
}) => Promise<unknown>, open: (path: string, flags?: string | number, mode?: import("fs").Mode) => Promise<FileHandle>, readFile: {
|
|
13
|
+
(path: string, options?: {
|
|
14
|
+
encoding?: null;
|
|
15
|
+
} | null): Promise<Buffer>;
|
|
16
|
+
(path: string, options: {
|
|
18
17
|
encoding: BufferEncoding;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(path: string, options?: (import("fs").ObjectEncodingOptions & import("events").Abortable & {
|
|
22
|
-
flag?: import("fs").OpenMode | undefined;
|
|
23
|
-
}) | BufferEncoding | null): Promise<string | Buffer>;
|
|
18
|
+
} | BufferEncoding): Promise<string>;
|
|
19
|
+
(path: string, options?: import("fs").ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
|
24
20
|
}, readdir: (path: string) => Promise<string[]>, readlink: {
|
|
25
21
|
(path: string, options?: import("fs").ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
|
26
22
|
(path: string, options: import("fs").BufferEncodingOption): Promise<Buffer>;
|
|
27
23
|
(path: string, options?: import("fs").ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
|
28
|
-
}, 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 |
|
|
29
|
-
mode?: import("fs").Mode
|
|
30
|
-
flag?: import("fs").OpenMode
|
|
31
|
-
flush?: boolean
|
|
32
|
-
}
|
|
24
|
+
}, 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 | Uint8Array, options?: (import("fs").ObjectEncodingOptions & {
|
|
25
|
+
mode?: import("fs").Mode;
|
|
26
|
+
flag?: import("fs").OpenMode;
|
|
27
|
+
flush?: boolean;
|
|
28
|
+
}) | BufferEncoding | null) => Promise<void>, copyFile: (src: string, dst: string, overwrite?: boolean, dstMode?: string) => Promise<void>;
|
|
33
29
|
/**
|
|
34
30
|
* @param fh is an open file handle
|
|
35
31
|
* @param pos is a position in the file, from which reading should start
|
|
@@ -19,7 +19,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.sleep = sleep;
|
|
20
20
|
function sleep(millis) {
|
|
21
21
|
return new Promise((resolve) => {
|
|
22
|
-
|
|
22
|
+
var _a, _b;
|
|
23
|
+
(_b = (_a = setTimeout(resolve, millis)).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
Object.freeze(exports);
|
|
@@ -19,10 +19,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.TimeWindowCache = void 0;
|
|
20
20
|
class TimeWindowCache {
|
|
21
21
|
constructor(periodMillis) {
|
|
22
|
+
var _a, _b;
|
|
22
23
|
this.filling = new Map();
|
|
23
24
|
this.waiting = new Map();
|
|
24
|
-
this.interval = setInterval(() => this.dropAndRotate(), periodMillis)
|
|
25
|
-
|
|
25
|
+
this.interval = setInterval(() => this.dropAndRotate(), periodMillis);
|
|
26
|
+
(_b = (_a = this.interval).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
26
27
|
Object.seal(this);
|
|
27
28
|
}
|
|
28
29
|
dropAndRotate() {
|
|
@@ -64,11 +64,12 @@ Object.freeze(WeakCache.prototype);
|
|
|
64
64
|
Object.freeze(WeakCache);
|
|
65
65
|
class WeakCacheWithMinLifeTime {
|
|
66
66
|
constructor(millis) {
|
|
67
|
+
var _a, _b;
|
|
67
68
|
this.wCache = new WeakCache();
|
|
68
69
|
this.filling = new Map();
|
|
69
70
|
this.waiting = new Map();
|
|
70
71
|
this.interval = setInterval(() => { this.dropAndRotate(); }, millis);
|
|
71
|
-
this.interval.unref();
|
|
72
|
+
(_b = (_a = this.interval).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
72
73
|
Object.seal(this);
|
|
73
74
|
}
|
|
74
75
|
dropAndRotate() {
|