core-3nweb-client-lib 0.43.4 → 0.43.6
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/api-defs/files.d.ts +9 -5
- package/build/core/asmail/inbox/inbox-events.d.ts +2 -7
- package/build/core/asmail/inbox/inbox-events.js +28 -75
- package/build/core/storage/synced/obj-status.d.ts +1 -1
- package/build/core/storage/synced/obj-status.js +2 -2
- package/build/core/storage/synced/remote-events.d.ts +3 -2
- package/build/core/storage/synced/remote-events.js +19 -24
- package/build/core/storage/synced/storage.js +3 -7
- package/build/core-ipc/file.js +2 -2
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/xsp-fs/folder-node.js +5 -10
- package/build/lib-client/xsp-fs/node-in-fs.d.ts +2 -0
- package/build/lib-client/xsp-fs/node-in-fs.js +11 -5
- package/build/lib-common/ipc/ws-ipc.d.ts +12 -0
- package/build/lib-common/ipc/ws-ipc.js +66 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -383,10 +383,10 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
383
383
|
const attrs = this.attrs.copy();
|
|
384
384
|
// do action within transition state
|
|
385
385
|
const changeEvents = await change(state, version);
|
|
386
|
-
// save
|
|
386
|
+
// save new state
|
|
387
387
|
const encSub = await this.crypto.write(state, version, attrs, this.xattrs);
|
|
388
388
|
await this.storage.saveObj(this.objId, version, encSub);
|
|
389
|
-
//
|
|
389
|
+
// apply new state to in-memory object
|
|
390
390
|
this.currentState = state;
|
|
391
391
|
this.setCurrentVersion(version);
|
|
392
392
|
this.attrs = attrs;
|
|
@@ -681,7 +681,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
681
681
|
}
|
|
682
682
|
async removeFolderObj(src, passIdsForRmUpload = false) {
|
|
683
683
|
const childrenNodes = await this.doChange(true, async () => {
|
|
684
|
-
if (this.
|
|
684
|
+
if (this.isMarkedRemoved) {
|
|
685
685
|
return;
|
|
686
686
|
}
|
|
687
687
|
const childrenNodes = await this.getAllNodes();
|
|
@@ -692,12 +692,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
694
694
|
if (this.isInSyncedStorage) {
|
|
695
|
-
|
|
696
|
-
return this.removeChildrenObjsInSyncedStorage(childrenNodes, src, true);
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
this.removeChildrenObjsInSyncedStorage(childrenNodes, src, false);
|
|
700
|
-
}
|
|
695
|
+
return await this.removeChildrenObjsInSyncedStorage(childrenNodes, src, passIdsForRmUpload);
|
|
701
696
|
}
|
|
702
697
|
else {
|
|
703
698
|
this.callRemoveObjOnAll(src, childrenNodes);
|
|
@@ -709,7 +704,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
709
704
|
}
|
|
710
705
|
}
|
|
711
706
|
async removeChildrenObjsInSyncedStorage(childrenNodes, src, passIdsForRmUpload) {
|
|
712
|
-
if (this.
|
|
707
|
+
if (this.isMarkedRemoved) {
|
|
713
708
|
return;
|
|
714
709
|
}
|
|
715
710
|
let uploadRmsHere;
|
|
@@ -23,6 +23,8 @@ export declare abstract class NodeInFS<P extends NodePersistance> implements Nod
|
|
|
23
23
|
private writeProc;
|
|
24
24
|
get version(): number;
|
|
25
25
|
protected setCurrentVersion(newVersion: number): void;
|
|
26
|
+
private markRemoved;
|
|
27
|
+
protected get isMarkedRemoved(): boolean;
|
|
26
28
|
readonly isInSyncedStorage: boolean;
|
|
27
29
|
protected constructor(storage: Storage, type: NodeType, name: string, objId: string, currentVersion: number, parentId: string | undefined);
|
|
28
30
|
protected getObjSrcOfVersion(flags: VersionedReadFlags | undefined): Promise<ObjSource>;
|
|
@@ -37,11 +37,17 @@ class NodeInFS {
|
|
|
37
37
|
return this.currentVersion;
|
|
38
38
|
}
|
|
39
39
|
setCurrentVersion(newVersion) {
|
|
40
|
-
if (!Number.isInteger(newVersion)) {
|
|
41
|
-
throw new TypeError(`Version parameter must be
|
|
40
|
+
if (!Number.isInteger(newVersion) || (newVersion < 0)) {
|
|
41
|
+
throw new TypeError(`Version parameter must be a non-negative integer, but ${newVersion} is given`);
|
|
42
42
|
}
|
|
43
43
|
this.currentVersion = newVersion;
|
|
44
44
|
}
|
|
45
|
+
markRemoved() {
|
|
46
|
+
this.currentVersion = -1;
|
|
47
|
+
}
|
|
48
|
+
get isMarkedRemoved() {
|
|
49
|
+
return (this.currentVersion < 0);
|
|
50
|
+
}
|
|
45
51
|
constructor(storage, type, name, objId, currentVersion, parentId) {
|
|
46
52
|
this.storage = storage;
|
|
47
53
|
this.type = type;
|
|
@@ -184,12 +190,12 @@ class NodeInFS {
|
|
|
184
190
|
return this.doChange(true, () => this.removeThisFromStorageNodes(src));
|
|
185
191
|
}
|
|
186
192
|
async removeThisFromStorageNodes(src) {
|
|
187
|
-
if (this.
|
|
193
|
+
if (this.isMarkedRemoved) {
|
|
188
194
|
return;
|
|
189
195
|
}
|
|
190
196
|
await this.storage.removeObj(this.objId);
|
|
191
197
|
this.storage.nodes.delete(this);
|
|
192
|
-
this.
|
|
198
|
+
this.markRemoved();
|
|
193
199
|
const event = {
|
|
194
200
|
type: 'removed',
|
|
195
201
|
path: this.name,
|
|
@@ -217,7 +223,7 @@ class NodeInFS {
|
|
|
217
223
|
throw (0, runtime_1.makeRuntimeException)('file', { path: this.name, fsEtityType: this.type }, { concurrentUpdate: true });
|
|
218
224
|
}
|
|
219
225
|
const res = await this.writeProc.startOrChain(async () => {
|
|
220
|
-
if (this.
|
|
226
|
+
if (this.isMarkedRemoved) {
|
|
221
227
|
throw (0, runtime_1.makeRuntimeException)('file', {
|
|
222
228
|
path: this.name, fsEtityType: this.type,
|
|
223
229
|
message: `NodeInFS is marked removed`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Observable } from 'rxjs';
|
|
2
2
|
import { SubscribingClient } from './generic-ipc';
|
|
3
3
|
import * as WebSocket from 'ws';
|
|
4
|
+
import type { ConnectException, HTTPException } from '../exceptions/http';
|
|
4
5
|
export { RequestEnvelope, RequestHandler, EventfulServer, makeEventfulServer, SubscribingClient } from './generic-ipc';
|
|
5
6
|
export interface WSException extends web3n.RuntimeException {
|
|
6
7
|
type: 'websocket';
|
|
@@ -26,3 +27,14 @@ export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undef
|
|
|
26
27
|
heartbeat: Observable<ConnectionStatus>;
|
|
27
28
|
};
|
|
28
29
|
export declare function addToStatus<T extends ConnectionStatus>(status: ConnectionStatus, params: Partial<T>): T;
|
|
30
|
+
export declare function shouldRestartWSAfterErr(exc: WSException | ConnectException | HTTPException): boolean;
|
|
31
|
+
export declare class WebSocketListening {
|
|
32
|
+
readonly restartWaitSecs: number;
|
|
33
|
+
private readonly startWSProc;
|
|
34
|
+
private listeningProc;
|
|
35
|
+
constructor(restartWaitSecs: number, startWSProc: () => Observable<unknown>);
|
|
36
|
+
startListening(): void;
|
|
37
|
+
private sleepAndRestart;
|
|
38
|
+
close(): void;
|
|
39
|
+
get isListening(): boolean;
|
|
40
|
+
}
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.makeEventfulServer = void 0;
|
|
18
|
+
exports.WebSocketListening = exports.makeEventfulServer = void 0;
|
|
19
19
|
exports.makeWSException = makeWSException;
|
|
20
20
|
exports.makeSubscriber = makeSubscriber;
|
|
21
21
|
exports.addToStatus = addToStatus;
|
|
22
|
+
exports.shouldRestartWSAfterErr = shouldRestartWSAfterErr;
|
|
22
23
|
const rxjs_1 = require("rxjs");
|
|
23
24
|
const runtime_1 = require("../exceptions/runtime");
|
|
24
25
|
const generic_ipc_1 = require("./generic-ipc");
|
|
26
|
+
const sleep_1 = require("../processes/sleep");
|
|
25
27
|
var generic_ipc_2 = require("./generic-ipc");
|
|
26
28
|
Object.defineProperty(exports, "makeEventfulServer", { enumerable: true, get: function () { return generic_ipc_2.makeEventfulServer; } });
|
|
27
29
|
function makeWSException(params, flags) {
|
|
@@ -127,4 +129,67 @@ function addToStatus(status, params) {
|
|
|
127
129
|
}
|
|
128
130
|
return status;
|
|
129
131
|
}
|
|
132
|
+
function shouldRestartWSAfterErr(exc) {
|
|
133
|
+
if (!exc.runtimeException) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
if (exc.type === 'connect') {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
else if (exc.type === 'http-request') {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
else if (exc.type === 'websocket') {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
class WebSocketListening {
|
|
150
|
+
constructor(restartWaitSecs, startWSProc) {
|
|
151
|
+
this.restartWaitSecs = restartWaitSecs;
|
|
152
|
+
this.startWSProc = startWSProc;
|
|
153
|
+
this.listeningProc = undefined;
|
|
154
|
+
Object.seal(this);
|
|
155
|
+
}
|
|
156
|
+
startListening() {
|
|
157
|
+
if (this.listeningProc) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const clearListeningProc = () => {
|
|
161
|
+
if (this.listeningProc === sub) {
|
|
162
|
+
this.listeningProc = undefined;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const sub = this.startWSProc()
|
|
166
|
+
.subscribe({
|
|
167
|
+
complete: () => {
|
|
168
|
+
clearListeningProc();
|
|
169
|
+
},
|
|
170
|
+
error: async (exc) => {
|
|
171
|
+
clearListeningProc();
|
|
172
|
+
if (shouldRestartWSAfterErr(exc)) {
|
|
173
|
+
this.sleepAndRestart();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
this.listeningProc = sub;
|
|
178
|
+
}
|
|
179
|
+
async sleepAndRestart() {
|
|
180
|
+
await (0, sleep_1.sleep)(this.restartWaitSecs * 1000);
|
|
181
|
+
this.startListening();
|
|
182
|
+
}
|
|
183
|
+
close() {
|
|
184
|
+
var _a;
|
|
185
|
+
(_a = this.listeningProc) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
186
|
+
this.listeningProc = undefined;
|
|
187
|
+
}
|
|
188
|
+
get isListening() {
|
|
189
|
+
return !!this.listeningProc;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.WebSocketListening = WebSocketListening;
|
|
193
|
+
Object.freeze(WebSocketListening.prototype);
|
|
194
|
+
Object.freeze(WebSocketListening);
|
|
130
195
|
Object.freeze(exports);
|