libshv-js 11.0.0 → 11.0.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.
Files changed (2) hide show
  1. package/dist/ws-client.js +19 -24
  2. package/package.json +3 -3
package/dist/ws-client.js CHANGED
@@ -390,8 +390,8 @@ class WsClient {
390
390
  await Promise.all(pendingHandlers);
391
391
  });
392
392
  this.websocket.addEventListener('error', evt => {
393
- console.log('WebSocket ERROR', evt);
394
- this.logDebug('WebSocket ERROR');
393
+ console.log('Websocket ERROR', evt);
394
+ this.logDebug('Websocket ERROR');
395
395
  });
396
396
  if ('onWorkflows' in this.options) {
397
397
  this.workflowsProcedure(this.options);
@@ -429,7 +429,7 @@ class WsClient {
429
429
  workflowsProcedure(options) {
430
430
  let workflowsObtained = false;
431
431
  this.websocket.addEventListener('open', () => {
432
- this.options.logDebug('CONNECTED');
432
+ this.options.logDebug('Websocket CONNECTED');
433
433
  const handleConnectionError = (error) => {
434
434
  this.logDebug('FAILURE: couldn\'t retrieve workflows', error.message);
435
435
  options.onWorkflowsFailed();
@@ -447,7 +447,7 @@ class WsClient {
447
447
  });
448
448
  });
449
449
  this.websocket.addEventListener('close', () => {
450
- this.logDebug('DISCONNECTED');
450
+ this.logDebug('Websocket DISCONNECTED');
451
451
  if (!workflowsObtained) {
452
452
  options.onWorkflowsFailed();
453
453
  }
@@ -455,22 +455,7 @@ class WsClient {
455
455
  }
456
456
  loginProcedure(options) {
457
457
  this.websocket.addEventListener('open', () => {
458
- this.options.logDebug('CONNECTED');
459
- const handleConnectionError = (error) => {
460
- this.logDebug('FAILURE: couldn\'t perform initial handshake', error.message);
461
- options.onConnectionFailure(error);
462
- };
463
- const handleLoginResponse = (response) => {
464
- if (response instanceof Error) {
465
- handleConnectionError(response);
466
- return;
467
- }
468
- this.logDebug('SUCCESS: connected to shv broker');
469
- options.onConnected();
470
- this.pingTimerId = setInterval(() => {
471
- this.sendPing();
472
- }, options.pingInterval ?? DEFAULT_PING_INTERVAL);
473
- };
458
+ this.options.logDebug('Websocket CONNECTED');
474
459
  const makeLoginParams = (loginMap) => makeMap({
475
460
  login: loginMap,
476
461
  options: makeMap({
@@ -479,8 +464,7 @@ class WsClient {
479
464
  });
480
465
  this.callRpcMethod(undefined, 'hello').then(response => {
481
466
  if (response instanceof Error) {
482
- handleConnectionError(response);
483
- return;
467
+ return response;
484
468
  }
485
469
  const makeLoginMap = () => {
486
470
  switch (options.login.type) {
@@ -498,12 +482,23 @@ class WsClient {
498
482
  }
499
483
  };
500
484
  return this.callRpcMethod(undefined, 'login', makeLoginParams(makeLoginMap()));
501
- }).then(handleLoginResponse).catch(() => {
485
+ }).then(response => {
486
+ if (response instanceof Error) {
487
+ this.logDebug('FAILURE: couldn\'t perform initial handshake:', response.message);
488
+ options.onConnectionFailure(response);
489
+ return;
490
+ }
491
+ this.logDebug('SUCCESS: connected to shv broker');
492
+ options.onConnected();
493
+ this.pingTimerId = setInterval(() => {
494
+ this.sendPing();
495
+ }, options.pingInterval ?? DEFAULT_PING_INTERVAL);
496
+ }).catch(() => {
502
497
  this.logDebug('FAILURE: couldn\' connected to shv broker');
503
498
  });
504
499
  });
505
500
  this.websocket.addEventListener('close', () => {
506
- this.logDebug('DISCONNECTED');
501
+ this.logDebug('Websocket DISCONNECTED');
507
502
  this.subscriptions.length = 0;
508
503
  options.onDisconnected();
509
504
  clearInterval(this.pingTimerId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "11.0.0",
3
+ "version": "11.0.2",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,9 +41,9 @@
41
41
  "@typescript-eslint/parser": "^8.56.1",
42
42
  "@eslint/js": "^10.0.1",
43
43
  "eslint": "^10.0.0",
44
- "eslint-config-xo": "^5.0.0",
44
+ "eslint-config-xo": "^6.0.0",
45
45
  "eslint-formatter-unix": "^9.0.1",
46
- "eslint-plugin-unicorn": "^77.0.0",
46
+ "eslint-plugin-unicorn": "^78.0.0",
47
47
  "typescript": "^6.0.2",
48
48
  "typescript-eslint": "^8.46.1"
49
49
  },