@leapdev/app-platform 0.1.0-beta.25 → 0.1.0-beta.26
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leapdev/app-platform",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.26",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.3.0",
|
|
6
6
|
"vkbeautify": "^0.99.3",
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
"type": "commonjs",
|
|
15
15
|
"main": "./src/index.js",
|
|
16
16
|
"typings": "./src/index.d.ts"
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -5,6 +5,7 @@ exports.SignalRService = void 0;
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const signalR = tslib_1.__importStar(require("@microsoft/signalr"));
|
|
7
7
|
const uuid_1 = require("uuid");
|
|
8
|
+
const INIT_DATA_TIMEOUT_MS = 5000;
|
|
8
9
|
class SignalRService {
|
|
9
10
|
constructor() {
|
|
10
11
|
_SignalRService_instances.add(this);
|
|
@@ -39,45 +40,48 @@ class SignalRService {
|
|
|
39
40
|
return new Promise((resolve) => resolve(tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f")));
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
|
-
// check if ld is open
|
|
43
43
|
getInitData(params) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
const connection = tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f");
|
|
45
|
+
if (!connection) {
|
|
46
|
+
return Promise.resolve(null);
|
|
47
|
+
}
|
|
48
|
+
const { clientId } = params;
|
|
49
|
+
const requestId = (0, uuid_1.v4)();
|
|
50
|
+
const payload = {
|
|
51
|
+
source: 'automationCore',
|
|
52
|
+
sessionId: tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f"),
|
|
53
|
+
requestId,
|
|
54
|
+
action: 'init_data',
|
|
55
|
+
payload: {
|
|
56
|
+
clientId,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
const cleanup = () => {
|
|
61
|
+
clearTimeout(timeoutId);
|
|
62
|
+
connection.off('ProcessMessage', handler);
|
|
55
63
|
};
|
|
56
|
-
|
|
57
|
-
if (tslib_1.__classPrivateFieldGet(this,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|
|
62
|
-
tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f").on('ProcessMessage', (message) => {
|
|
63
|
-
if (message.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
|
|
64
|
-
message.requestId === requestId) {
|
|
65
|
-
// do another action open matter
|
|
66
|
-
resolve(message.payload);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
.catch((e) => {
|
|
72
|
-
console.log('SignalR sendMessage error', e);
|
|
73
|
-
return resolve(null);
|
|
74
|
-
});
|
|
64
|
+
const handler = (message) => {
|
|
65
|
+
if (message.sessionId === tslib_1.__classPrivateFieldGet(this, _SignalRService_sessionId, "f") &&
|
|
66
|
+
message.requestId === requestId) {
|
|
67
|
+
cleanup();
|
|
68
|
+
resolve(message.payload);
|
|
75
69
|
}
|
|
70
|
+
};
|
|
71
|
+
const timeoutId = setTimeout(() => {
|
|
72
|
+
cleanup();
|
|
73
|
+
console.warn('[SignalR] init_data timed out waiting for ProcessMessage response');
|
|
74
|
+
resolve(null);
|
|
75
|
+
}, INIT_DATA_TIMEOUT_MS);
|
|
76
|
+
// Register before invoke so a fast response cannot be missed.
|
|
77
|
+
connection.on('ProcessMessage', handler);
|
|
78
|
+
connection.invoke('ProcessMessage', payload, true)
|
|
79
|
+
.catch((e) => {
|
|
80
|
+
console.log('SignalR sendMessage error', e);
|
|
81
|
+
cleanup();
|
|
82
|
+
resolve(null);
|
|
76
83
|
});
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return new Promise((resolve) => resolve(null));
|
|
80
|
-
}
|
|
84
|
+
});
|
|
81
85
|
}
|
|
82
86
|
openDocument(params) {
|
|
83
87
|
if (tslib_1.__classPrivateFieldGet(this, _SignalRService_connection, "f")) {
|