@kronos-integration/endpoint 9.4.31 → 9.4.34

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/@kronos-integration/endpoint.svg)](https://www.npmjs.com/package/@kronos-integration/endpoint)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
- [![minified size](https://badgen.net/bundlephobia/min/@kronos-integration/endpoint)](https://bundlephobia.com/result?p=@kronos-integration/endpoint)
3
+ [![Open Bundle](https://bundlejs.com/badge-light.svg)](https://bundlejs.com/?q=@kronos-integration/endpoint)
4
4
  [![downloads](http://img.shields.io/npm/dm/@kronos-integration/endpoint.svg?style=flat-square)](https://npmjs.org/package/@kronos-integration/endpoint)
5
5
  [![GitHub Issues](https://img.shields.io/github/issues/Kronos-Integration/endpoint.svg?style=flat-square)](https://github.com/Kronos-Integration/endpoint/issues)
6
6
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FKronos-Integration%2Fendpoint%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/Kronos-Integration/endpoint/goto)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/endpoint",
3
- "version": "9.4.31",
3
+ "version": "9.4.34",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,16 +32,16 @@
32
32
  "lint:docs": "documentation lint ./src/**/*.mjs"
33
33
  },
34
34
  "dependencies": {
35
- "@kronos-integration/interceptor": "^10.2.23"
35
+ "@kronos-integration/interceptor": "^10.2.26"
36
36
  },
37
37
  "devDependencies": {
38
- "ava": "^4.3.0",
39
- "c8": "^7.11.3",
38
+ "ava": "^4.3.1",
39
+ "c8": "^7.12.0",
40
40
  "documentation": "^13.2.5",
41
41
  "semantic-release": "^19.0.3"
42
42
  },
43
43
  "engines": {
44
- "node": ">=16.15.1"
44
+ "node": ">=16.16.0"
45
45
  },
46
46
  "repository": {
47
47
  "type": "git",
@@ -6,12 +6,12 @@ import { ReceivableEndpoint } from "./receivable-endpoint.mjs";
6
6
  * Can hold several connections.
7
7
  */
8
8
  export class MultiConnectionEndpoint extends ReceivableEndpoint {
9
-
9
+
10
+ #connections = new Map();
11
+
10
12
  constructor(name, owner, options = {}) {
11
13
  super(name, owner, options);
12
14
 
13
- this._connections = new Map();
14
-
15
15
  if (isEndpoint(options.connected)) {
16
16
  this.addConnection(options.connected);
17
17
  }
@@ -23,7 +23,7 @@ export class MultiConnectionEndpoint extends ReceivableEndpoint {
23
23
  * @return {any} our state for the connection to other
24
24
  */
25
25
  getConnectionState(other) {
26
- return this._connections.get(other);
26
+ return this.#connections.get(other);
27
27
  }
28
28
 
29
29
  /**
@@ -32,7 +32,7 @@ export class MultiConnectionEndpoint extends ReceivableEndpoint {
32
32
  * @param {any} state for the connection to other
33
33
  */
34
34
  setConnectionState(other, state) {
35
- this._connections.set(other, state);
35
+ this.#connections.set(other, state);
36
36
  }
37
37
 
38
38
  addConnection(other, backpointer) {
@@ -42,18 +42,18 @@ export class MultiConnectionEndpoint extends ReceivableEndpoint {
42
42
  );
43
43
  }
44
44
 
45
- if (!this._connections.get(other)) {
45
+ if (!this.#connections.get(other)) {
46
46
  if (!backpointer) {
47
47
  other.addConnection(this, true);
48
48
  }
49
49
 
50
- this._connections.set(other, undefined); // dummy
50
+ this.#connections.set(other, undefined); // dummy
51
51
  }
52
52
  }
53
53
 
54
54
  removeConnection(other, backpointer) {
55
55
  this.closeConnection(other);
56
- this._connections.delete(other);
56
+ this.#connections.delete(other);
57
57
 
58
58
  if (!backpointer) {
59
59
  other.removeConnection(this, true);
@@ -66,13 +66,13 @@ export class MultiConnectionEndpoint extends ReceivableEndpoint {
66
66
  * @return {boolean} true if we are connected with other
67
67
  */
68
68
  isConnected(other) {
69
- return this._connections.has(other);
69
+ return this.#connections.has(other);
70
70
  }
71
71
 
72
72
  /**
73
73
  * All connections
74
74
  */
75
75
  *connections() {
76
- yield* this._connections.keys();
76
+ yield* this.#connections.keys();
77
77
  }
78
78
  }
@@ -12,6 +12,10 @@ import { ReceivableEndpoint } from "./receivable-endpoint.mjs";
12
12
  * @param {Function} [options.didConnect] called after receiver is present
13
13
  */
14
14
  export class SendEndpoint extends ReceivableEndpoint {
15
+
16
+ #connection;
17
+ #state;
18
+
15
19
  constructor(name, owner, options = {}) {
16
20
  super(name, owner, options);
17
21
  if (isEndpoint(options.connected)) {
@@ -28,21 +32,21 @@ export class SendEndpoint extends ReceivableEndpoint {
28
32
  }
29
33
 
30
34
  get isOpen() {
31
- return this._connection !== undefined;
35
+ return this.#connection !== undefined;
32
36
  }
33
37
 
34
38
  getConnectionState(other) {
35
- return other === this._connection ? this._state : undefined;
39
+ return other === this.#connection ? this.#state : undefined;
36
40
  }
37
41
 
38
42
  setConnectionState(other, state) {
39
- if (other === this._connection) {
40
- this._state = state;
43
+ if (other === this.#connection) {
44
+ this.#state = state;
41
45
  }
42
46
  }
43
47
 
44
48
  addConnection(other, backpointer) {
45
- if (this._connection === other) {
49
+ if (this.#connection === other) {
46
50
  return;
47
51
  }
48
52
 
@@ -52,18 +56,18 @@ export class SendEndpoint extends ReceivableEndpoint {
52
56
  );
53
57
  }
54
58
 
55
- if (this._connection !== undefined) {
59
+ if (this.#connection !== undefined) {
56
60
  // do not break standing connection if only setting backpinter
57
61
  if (backpointer) {
58
62
  return;
59
63
  }
60
64
 
61
- throw new Error(`Already connected to: ${this._connection.identifier}`);
65
+ throw new Error(`Already connected to: ${this.#connection.identifier}`);
62
66
  }
63
67
 
64
- this.removeConnection(this._connection, backpointer);
68
+ this.removeConnection(this.#connection, backpointer);
65
69
 
66
- this._connection = other;
70
+ this.#connection = other;
67
71
 
68
72
  if (!backpointer) {
69
73
  other.addConnection(this, true);
@@ -76,22 +80,22 @@ export class SendEndpoint extends ReceivableEndpoint {
76
80
  if (!backpointer && other !== undefined) {
77
81
  other.removeConnection(this, true);
78
82
  }
79
- this._connection = undefined;
83
+ this.#connection = undefined;
80
84
  }
81
85
 
82
86
  *connections() {
83
- if (this._connection) {
84
- yield this._connection;
87
+ if (this.#connection) {
88
+ yield this.#connection;
85
89
  }
86
90
  }
87
91
 
88
92
  async send(...args) {
89
- if (this._connection === undefined) {
93
+ if (this.#connection === undefined) {
90
94
  throw new Error(`${this.identifier} is not connected`);
91
95
  }
92
- if (!this._connection.isOpen) {
96
+ if (!this.#connection.isOpen) {
93
97
  throw new Error(
94
- `${this.identifier}: ${this._connection.identifier} is not open`
98
+ `${this.identifier}: ${this.#connection.identifier} is not open`
95
99
  );
96
100
  }
97
101
 
@@ -100,7 +104,7 @@ export class SendEndpoint extends ReceivableEndpoint {
100
104
 
101
105
  const next = async (...args) =>
102
106
  c >= interceptors.length
103
- ? this._connection.receive(...args)
107
+ ? this.#connection.receive(...args)
104
108
  : interceptors[c++].receive(this, next, ...args);
105
109
 
106
110
  return next(...args);