xcraft-core-busclient 5.7.0 → 5.7.2
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/eslint.config.js +62 -0
- package/index.js +22 -5
- package/package.json +2 -2
- package/.eslintrc.js +0 -39
package/eslint.config.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const js = require('@eslint/js');
|
|
2
|
+
const globals = require('globals');
|
|
3
|
+
const react = require('eslint-plugin-react');
|
|
4
|
+
const jsdoc = require('eslint-plugin-jsdoc');
|
|
5
|
+
const babel = require('@babel/eslint-plugin');
|
|
6
|
+
const prettier = require('eslint-config-prettier');
|
|
7
|
+
const babelParser = require('@babel/eslint-parser');
|
|
8
|
+
|
|
9
|
+
module.exports = [
|
|
10
|
+
js.configs.recommended,
|
|
11
|
+
react.configs.flat.recommended,
|
|
12
|
+
jsdoc.configs['flat/recommended'],
|
|
13
|
+
prettier,
|
|
14
|
+
{
|
|
15
|
+
languageOptions: {
|
|
16
|
+
parser: babelParser,
|
|
17
|
+
parserOptions: {
|
|
18
|
+
requireConfigFile: false,
|
|
19
|
+
ecmaFeatures: {
|
|
20
|
+
jsx: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
globals: {
|
|
24
|
+
...globals.browser,
|
|
25
|
+
...globals.node,
|
|
26
|
+
...globals.es2022,
|
|
27
|
+
...globals.mocha,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
plugins: {
|
|
31
|
+
'react': react,
|
|
32
|
+
'jsdoc': jsdoc,
|
|
33
|
+
'@babel': babel,
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
'eqeqeq': 'error',
|
|
37
|
+
'no-console': 'off',
|
|
38
|
+
'react/display-name': 'off',
|
|
39
|
+
'@babel/no-unused-expressions': 'error',
|
|
40
|
+
'no-unused-vars': [
|
|
41
|
+
'error',
|
|
42
|
+
{
|
|
43
|
+
vars: 'all',
|
|
44
|
+
args: 'none',
|
|
45
|
+
ignoreRestSiblings: true,
|
|
46
|
+
destructuredArrayIgnorePattern: '^_',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
'jsdoc/require-jsdoc': 'off',
|
|
50
|
+
'jsdoc/require-param-description': 'off',
|
|
51
|
+
'jsdoc/require-returns-description': 'off',
|
|
52
|
+
},
|
|
53
|
+
settings: {
|
|
54
|
+
react: {
|
|
55
|
+
version: 'detect',
|
|
56
|
+
},
|
|
57
|
+
jsdoc: {
|
|
58
|
+
mode: 'typescript',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
];
|
package/index.js
CHANGED
|
@@ -19,6 +19,12 @@ const Resp = require('./lib/resp.js');
|
|
|
19
19
|
|
|
20
20
|
let globalBusClient = null;
|
|
21
21
|
|
|
22
|
+
const autoconnect = {
|
|
23
|
+
no: 0,
|
|
24
|
+
yes: 1,
|
|
25
|
+
wait: 2,
|
|
26
|
+
};
|
|
27
|
+
|
|
22
28
|
class BusClient extends EventEmitter {
|
|
23
29
|
#lastErrorReason = null;
|
|
24
30
|
|
|
@@ -39,7 +45,7 @@ class BusClient extends EventEmitter {
|
|
|
39
45
|
|
|
40
46
|
this._token = 'invalid';
|
|
41
47
|
this._orcName = null;
|
|
42
|
-
this._autoconnect =
|
|
48
|
+
this._autoconnect = autoconnect.no;
|
|
43
49
|
this._connected = false;
|
|
44
50
|
this._subClosed = true;
|
|
45
51
|
this._pushClosed = true;
|
|
@@ -133,7 +139,7 @@ class BusClient extends EventEmitter {
|
|
|
133
139
|
this.emit('reconnect');
|
|
134
140
|
});
|
|
135
141
|
|
|
136
|
-
this._autoconnect =
|
|
142
|
+
this._autoconnect = autoconnect.yes;
|
|
137
143
|
};
|
|
138
144
|
|
|
139
145
|
this._subSocket
|
|
@@ -186,8 +192,18 @@ class BusClient extends EventEmitter {
|
|
|
186
192
|
|
|
187
193
|
if (topic.startsWith('greathall::')) {
|
|
188
194
|
if (topic === 'greathall::heartbeat') {
|
|
189
|
-
if (
|
|
190
|
-
this._autoconnect
|
|
195
|
+
if (
|
|
196
|
+
this._autoconnect === autoconnect.wait &&
|
|
197
|
+
Date.now() - this._autoconnectDelay > 5000
|
|
198
|
+
) {
|
|
199
|
+
/* Try a new autoconnect after 5 seconds */
|
|
200
|
+
this._autoconnect = autoconnect.yes;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (this._autoconnect === autoconnect.yes) {
|
|
204
|
+
this._autoconnect = autoconnect.wait;
|
|
205
|
+
this._autoconnectDelay = Date.now();
|
|
206
|
+
|
|
191
207
|
autoConnectToken = xUtils.crypto.genToken();
|
|
192
208
|
this._subSocket.subscribe(
|
|
193
209
|
autoConnectToken + '::autoconnect.finished'
|
|
@@ -261,6 +277,7 @@ class BusClient extends EventEmitter {
|
|
|
261
277
|
);
|
|
262
278
|
this._eventsRegistry[escapeTopic].handler(msg); // FIXME: replace by a getter
|
|
263
279
|
this.unregisterEvents('autoconnect.finished');
|
|
280
|
+
this._autoconnect = autoconnect.no;
|
|
264
281
|
return;
|
|
265
282
|
}
|
|
266
283
|
|
|
@@ -432,7 +449,7 @@ class BusClient extends EventEmitter {
|
|
|
432
449
|
if (!busToken) {
|
|
433
450
|
/* Autoconnect is sent when the server is ready (heartbeat). */
|
|
434
451
|
this._registerAutoconnect(callback, err);
|
|
435
|
-
this._autoconnect =
|
|
452
|
+
this._autoconnect = autoconnect.yes;
|
|
436
453
|
return;
|
|
437
454
|
}
|
|
438
455
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xcraft-core-busclient",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.2",
|
|
4
4
|
"description": "Xcraft bus client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"prettier": "2.0.4",
|
|
40
40
|
"xcraft-dev-prettier": "^2.0.0",
|
|
41
|
-
"xcraft-dev-rules": "^4.
|
|
41
|
+
"xcraft-dev-rules": "^4.4.0"
|
|
42
42
|
},
|
|
43
43
|
"prettier": "xcraft-dev-prettier"
|
|
44
44
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
root: true,
|
|
5
|
-
parserOptions: {
|
|
6
|
-
sourceType: 'module',
|
|
7
|
-
ecmaFeatures: {
|
|
8
|
-
jsx: true,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
env: {
|
|
12
|
-
browser: true,
|
|
13
|
-
es2022: true,
|
|
14
|
-
mocha: true,
|
|
15
|
-
node: true,
|
|
16
|
-
},
|
|
17
|
-
plugins: ['react', 'babel', 'jsdoc'],
|
|
18
|
-
extends: [
|
|
19
|
-
'prettier',
|
|
20
|
-
'eslint:recommended',
|
|
21
|
-
'plugin:react/recommended',
|
|
22
|
-
'plugin:jsdoc/recommended',
|
|
23
|
-
],
|
|
24
|
-
rules: {
|
|
25
|
-
// Other rules
|
|
26
|
-
'no-console': 'off',
|
|
27
|
-
'eqeqeq': 'error',
|
|
28
|
-
'react/display-name': 'off',
|
|
29
|
-
'no-unused-vars': [
|
|
30
|
-
'error',
|
|
31
|
-
{
|
|
32
|
-
vars: 'all',
|
|
33
|
-
args: 'none',
|
|
34
|
-
ignoreRestSiblings: true,
|
|
35
|
-
destructuredArrayIgnorePattern: '^_',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
};
|