core-3nweb-client-lib 0.25.3 → 0.26.0
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/README.md +2 -2
- package/build/api-defs/files.d.ts +23 -20
- package/build/core/asmail/config/common.js +2 -2
- package/build/core/asmail/delivery/index.js +4 -3
- package/build/core/asmail/delivery/msg.js +5 -4
- package/build/core/asmail/delivery/per-recipient-wip.js +2 -2
- package/build/core/asmail/inbox/attachments/fs.js +6 -0
- package/build/core/asmail/inbox/cached-msgs.js +2 -2
- package/build/core/asmail/inbox/inbox-events.js +2 -1
- package/build/core/asmail/inbox/index.js +2 -2
- package/build/core/asmail/inbox/msg-downloader.js +2 -2
- package/build/core/asmail/inbox/msg-indexing.js +3 -3
- package/build/core/asmail/inbox/msg-on-disk.js +2 -2
- package/build/core/asmail/keyring/keyring-storage.js +2 -2
- package/build/core/asmail/sending-params/own-params.js +2 -2
- package/build/core/asmail/sending-params/params-from-others.js +2 -2
- package/build/core/id-manager.js +2 -2
- package/build/core/sign-in.d.ts +5 -4
- package/build/core/sign-in.js +9 -11
- package/build/core/sign-up.d.ts +1 -0
- package/build/core/sign-up.js +7 -3
- package/build/core/storage/common/json-saving.d.ts +21 -0
- package/build/core/storage/common/json-saving.js +82 -0
- package/build/core/storage/common/obj-info-file.d.ts +43 -0
- package/build/core/storage/common/obj-info-file.js +119 -3
- package/build/core/storage/index.js +1 -1
- package/build/core/storage/local/obj-files-gc.js +8 -6
- package/build/core/storage/local/obj-files.d.ts +3 -3
- package/build/core/storage/local/obj-files.js +9 -9
- package/build/core/storage/local/obj-status.d.ts +9 -25
- package/build/core/storage/local/obj-status.js +28 -110
- package/build/core/storage/local/storage.d.ts +8 -1
- package/build/core/storage/local/storage.js +10 -2
- package/build/core/storage/synced/downloader.js +6 -5
- package/build/core/storage/synced/obj-files-gc.d.ts +1 -0
- package/build/core/storage/synced/obj-files-gc.js +44 -5
- package/build/core/storage/synced/obj-files.d.ts +13 -20
- package/build/core/storage/synced/obj-files.js +70 -48
- package/build/core/storage/synced/obj-status.d.ts +74 -15
- package/build/core/storage/synced/obj-status.js +291 -107
- package/build/core/storage/synced/remote-events.js +32 -26
- package/build/core/storage/synced/storage.d.ts +11 -1
- package/build/core/storage/synced/storage.js +28 -3
- package/build/core/storage/synced/upsyncer.d.ts +8 -7
- package/build/core/storage/synced/upsyncer.js +211 -163
- package/build/ipc-via-protobuf/asmail-cap.js +17 -34
- package/build/ipc-via-protobuf/connector-clients-side.js +2 -2
- package/build/ipc-via-protobuf/file.js +26 -18
- package/build/ipc-via-protobuf/fs.js +33 -35
- package/build/ipc-via-protobuf/mailerid.js +3 -2
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +2 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +11 -1
- package/build/ipc-via-protobuf/startup-cap.js +5 -5
- package/build/lib-client/3nstorage/exceptions.d.ts +9 -8
- package/build/lib-client/3nstorage/exceptions.js +18 -9
- package/build/lib-client/3nstorage/service.js +10 -6
- package/build/lib-client/3nstorage/xsp-fs/common.d.ts +18 -4
- package/build/lib-client/3nstorage/xsp-fs/common.js +6 -1
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +3 -3
- package/build/lib-client/3nstorage/xsp-fs/file.js +4 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +27 -13
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +11 -6
- package/build/lib-client/3nstorage/xsp-fs/fs.js +189 -58
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +4 -0
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +51 -24
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +2 -2
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +2 -2
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +3 -3
- package/build/lib-client/cryptor/cryptor-in-worker.js +4 -4
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-wasm.js +2 -2
- package/build/lib-client/files.js +2 -0
- package/build/lib-client/fs-collection.js +3 -2
- package/build/lib-client/logging/log-to-file.js +6 -14
- package/build/lib-client/objs-on-disk/file-writing-proc.js +2 -2
- package/build/lib-client/objs-on-disk/obj-folders.d.ts +12 -1
- package/build/lib-client/objs-on-disk/obj-folders.js +26 -19
- package/build/lib-client/request-utils.js +2 -2
- package/build/lib-client/server-events.js +4 -3
- package/build/lib-client/ws-utils.js +2 -2
- package/build/lib-common/async-fs-node.d.ts +6 -0
- package/build/lib-common/async-fs-node.js +28 -4
- package/build/lib-common/byte-streaming/wrapping.js +17 -17
- package/build/lib-common/exceptions/file.js +6 -1
- package/build/lib-common/ipc/generic-ipc.js +2 -2
- package/build/lib-common/json-utils.js +2 -1
- package/build/lib-common/objs-on-disk/obj-file.js +4 -3
- package/build/lib-common/objs-on-disk/utils.js +2 -2
- package/build/lib-common/processes/deferred.d.ts +6 -0
- package/build/lib-common/processes/deferred.js +30 -0
- package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
- package/build/lib-common/processes/labelled-exec-pools.js +141 -0
- package/build/lib-common/processes/pressure.d.ts +7 -0
- package/build/lib-common/processes/pressure.js +56 -0
- package/build/lib-common/processes/sleep.d.ts +1 -0
- package/build/lib-common/processes/sleep.js +26 -0
- package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
- package/build/lib-common/{processes.js → processes/synced.js} +187 -204
- package/build/lib-common/processes/timeout.d.ts +1 -0
- package/build/lib-common/processes/timeout.js +51 -0
- package/build/lib-common/service-api/3nstorage/owner.d.ts +5 -4
- package/build/lib-common/service-api/3nstorage/owner.js +3 -2
- package/build/lib-common/utils-for-observables.d.ts +15 -1
- package/build/lib-common/utils-for-observables.js +68 -17
- package/build/protos/asmail.proto.js +404 -78
- package/build/protos/file.proto.js +370 -44
- package/build/protos/fs.proto.js +404 -78
- package/package.json +4 -4
- package/protos/file.proto +10 -2
- package/protos/fs.proto +2 -2
- package/build/core/storage/synced/upsync-status.d.ts +0 -41
- package/build/core/storage/synced/upsync-status.js +0 -158
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.LabelledExecPools = void 0;
|
|
20
|
+
const assert_1 = require("../assert");
|
|
21
|
+
class ProcessingPool {
|
|
22
|
+
constructor(label, maxProcs, logError) {
|
|
23
|
+
this.label = label;
|
|
24
|
+
this.maxProcs = maxProcs;
|
|
25
|
+
this.logError = logError;
|
|
26
|
+
this.inProcess = new Set();
|
|
27
|
+
this.queue = [];
|
|
28
|
+
this.isRunning = false;
|
|
29
|
+
this.doOnError = async (err) => {
|
|
30
|
+
if (this.logError) {
|
|
31
|
+
await this.logError(err, `Error in pool ${this.label}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
Object.seal(this);
|
|
35
|
+
}
|
|
36
|
+
add(task) {
|
|
37
|
+
this.queue.push(task);
|
|
38
|
+
if (this.isRunning) {
|
|
39
|
+
this.processNextQueued();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async processNextQueued() {
|
|
43
|
+
if (!this.isRunning || (this.inProcess.size >= this.maxProcs)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const task = this.queue.shift();
|
|
47
|
+
if (!task) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (task.neededExecutor() !== this.label) {
|
|
51
|
+
return this.processNextQueued();
|
|
52
|
+
}
|
|
53
|
+
let proc = undefined;
|
|
54
|
+
try {
|
|
55
|
+
proc = task.process().catch(this.doOnError);
|
|
56
|
+
this.inProcess.add(proc);
|
|
57
|
+
await proc;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
await this.doOnError(err);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (proc) {
|
|
64
|
+
this.inProcess.delete(proc);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return this.processNextQueued();
|
|
68
|
+
}
|
|
69
|
+
pause() {
|
|
70
|
+
this.isRunning = false;
|
|
71
|
+
}
|
|
72
|
+
start() {
|
|
73
|
+
this.isRunning = true;
|
|
74
|
+
const triggerCount = Math.min(this.maxProcs, this.queue.length);
|
|
75
|
+
for (let i = 0; i < triggerCount; i += 1) {
|
|
76
|
+
this.processNextQueued();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async stop() {
|
|
80
|
+
if (!this.isRunning) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
this.isRunning = false;
|
|
84
|
+
const cancellations = this.queue.splice(0, this.queue.length)
|
|
85
|
+
.map(t => t.cancel().catch(this.doOnError));
|
|
86
|
+
await Promise.all(cancellations.concat(Array.from(this.inProcess)));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
Object.freeze(ProcessingPool.prototype);
|
|
90
|
+
Object.freeze(ProcessingPool);
|
|
91
|
+
class LabelledExecPools {
|
|
92
|
+
constructor(setup, logError) {
|
|
93
|
+
this.pools = new Map();
|
|
94
|
+
this.isRunning = false;
|
|
95
|
+
assert_1.assert(setup.length > 0);
|
|
96
|
+
for (const { label, maxProcs } of setup) {
|
|
97
|
+
const pool = new ProcessingPool(label, maxProcs, logError);
|
|
98
|
+
this.pools.set(pool.label, pool);
|
|
99
|
+
}
|
|
100
|
+
Object.seal(this);
|
|
101
|
+
}
|
|
102
|
+
add(task, queueIfNotRunning = false) {
|
|
103
|
+
if (!this.isRunning && !queueIfNotRunning) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const label = task.neededExecutor();
|
|
107
|
+
if (!label) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const pool = this.pools.get(label);
|
|
111
|
+
if (!pool) {
|
|
112
|
+
throw new Error(`Task needs unknown pool ${label}`);
|
|
113
|
+
}
|
|
114
|
+
pool.add(task);
|
|
115
|
+
}
|
|
116
|
+
start() {
|
|
117
|
+
if (this.isRunning) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.isRunning = true;
|
|
121
|
+
for (const pool of this.pools.values()) {
|
|
122
|
+
pool.start();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
pause() {
|
|
126
|
+
this.isRunning = false;
|
|
127
|
+
}
|
|
128
|
+
async stop() {
|
|
129
|
+
if (!this.isRunning) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.isRunning = false;
|
|
133
|
+
const cancelations = Array.from(this.pools.values())
|
|
134
|
+
.map(pool => pool.stop());
|
|
135
|
+
await Promise.all(cancelations);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.LabelledExecPools = LabelledExecPools;
|
|
139
|
+
Object.freeze(ProcessingPool.prototype);
|
|
140
|
+
Object.freeze(ProcessingPool);
|
|
141
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2015, 2017, 2019 - 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.PressureValve = void 0;
|
|
20
|
+
const error_1 = require("../exceptions/error");
|
|
21
|
+
const deferred_1 = require("./deferred");
|
|
22
|
+
class PressureValve {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.stopper = undefined;
|
|
25
|
+
this.pressure = async () => {
|
|
26
|
+
if (!this.stopper) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
await this.stopper.promise;
|
|
30
|
+
};
|
|
31
|
+
Object.seal(this);
|
|
32
|
+
}
|
|
33
|
+
toggle(flag) {
|
|
34
|
+
if (flag) {
|
|
35
|
+
if (this.stopper) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.stopper = deferred_1.defer();
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (!this.stopper) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.stopper.resolve();
|
|
45
|
+
this.stopper = undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
pressWithError(err) {
|
|
49
|
+
this.toggle(true);
|
|
50
|
+
this.stopper.reject(error_1.errWithCause(err, `Backpressure error`));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.PressureValve = PressureValve;
|
|
54
|
+
Object.freeze(PressureValve.prototype);
|
|
55
|
+
Object.freeze(PressureValve);
|
|
56
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(millis: number): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2015 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.sleep = void 0;
|
|
20
|
+
function sleep(millis) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
setTimeout(resolve, millis).unref();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.sleep = sleep;
|
|
26
|
+
Object.freeze(exports);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function sleep(millis: number): Promise<void>;
|
|
2
1
|
/**
|
|
3
2
|
* This represents a function that will create a promise, potentially starting
|
|
4
3
|
* some background process, only when it is called. Such wrap of code is needed
|
|
@@ -68,46 +67,7 @@ export declare class SingleProc {
|
|
|
68
67
|
private runIfIdle;
|
|
69
68
|
startOrChain<T>(action: Action<T>): Promise<T>;
|
|
70
69
|
}
|
|
71
|
-
export declare class DeduppedRunner<T> {
|
|
72
|
-
private readonly action;
|
|
73
|
-
private proc;
|
|
74
|
-
private waiting;
|
|
75
|
-
constructor(action: Action<T>);
|
|
76
|
-
trigger(): Promise<T>;
|
|
77
|
-
private startAction;
|
|
78
|
-
}
|
|
79
70
|
/**
|
|
80
71
|
* This wraps given function/method into syncing wrap.
|
|
81
72
|
*/
|
|
82
73
|
export declare function makeSyncedFunc<T extends Function>(syncProc: SingleProc, thisArg: any, func: T): T;
|
|
83
|
-
export interface Deferred<T> {
|
|
84
|
-
promise: Promise<T>;
|
|
85
|
-
resolve: (result?: T | PromiseLike<T>) => void;
|
|
86
|
-
reject: (err: any) => void;
|
|
87
|
-
}
|
|
88
|
-
export declare function defer<T>(): Deferred<T>;
|
|
89
|
-
export declare class PressureValve {
|
|
90
|
-
private stopper;
|
|
91
|
-
constructor();
|
|
92
|
-
toggle(flag: boolean): void;
|
|
93
|
-
pressWithError(err: any): void;
|
|
94
|
-
readonly pressure: () => Promise<void>;
|
|
95
|
-
}
|
|
96
|
-
export declare function callWithTimeout<T>(f: () => Promise<T>, timeout: number, timeoutErr: () => any): Promise<T>;
|
|
97
|
-
export declare class Worker<T> {
|
|
98
|
-
private readonly process;
|
|
99
|
-
private readonly stopPendingIn;
|
|
100
|
-
private readonly queue;
|
|
101
|
-
private readonly set;
|
|
102
|
-
private isRunning;
|
|
103
|
-
private readonly procs;
|
|
104
|
-
private maxProcs;
|
|
105
|
-
constructor(process: (w: T) => Promise<void>, stopPendingIn: (queue: T[]) => Promise<void>);
|
|
106
|
-
add(w: T, queueIfNotRunning?: boolean): void;
|
|
107
|
-
private addToQueueOnce;
|
|
108
|
-
private getFromQueueHead;
|
|
109
|
-
private runQueued;
|
|
110
|
-
start(maxNumOfProcs: number): void;
|
|
111
|
-
pause(): void;
|
|
112
|
-
stop(): Promise<void>;
|
|
113
|
-
}
|