unetjs 3.1.0 → 3.1.3

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/dist/cjs/unet.cjs CHANGED
@@ -1,8 +1,8 @@
1
- /* unet.js v3.1.0 2024-01-26T11:16:07.040Z */
1
+ /* unet.js v3.1.3 2024-04-02T09:34:11.478Z */
2
2
 
3
3
  'use strict';
4
4
 
5
- /* fjage.js v1.12.0 */
5
+ /* fjage.js v1.12.1 */
6
6
 
7
7
  const isBrowser =
8
8
  typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -46,21 +46,20 @@ class TCPconnector {
46
46
  /**
47
47
  * Create an TCPConnector to connect to a fjage master over TCP
48
48
  * @param {Object} opts
49
- * @param {string} [opts.hostname='localhost'] - hostname/ip address of the master container to connect to
50
- * @param {number} opts.port - port number of the master container to connect to
51
- * @param {string} opts.pathname - path of the master container to connect to
49
+ * @param {string} opts.hostname - hostname/ip address of the master container to connect to
50
+ * @param {string} opts.port - port number of the master container to connect to
52
51
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
53
52
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
54
53
  */
55
54
  constructor(opts = {}) {
55
+ let host = opts.hostname;
56
+ let port = opts.port;
57
+ this._keepAlive = opts.keepAlive;
58
+ this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
56
59
  this.url = new URL('tcp://localhost');
57
- let host = opts.hostname || 'localhost';
58
- let port = opts.port || -1;
59
60
  this.url.hostname = host;
60
61
  this.url.port = port;
61
62
  this._buf = '';
62
- this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
63
- this._keepAlive = opts.keepAlive || true;
64
63
  this._firstConn = true; // if the Gateway has managed to connect to a server before
65
64
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
66
65
  this.pendingOnOpen = []; // list of callbacks make as soon as gateway is open
@@ -232,7 +231,7 @@ class WSConnector {
232
231
  * Create an WSConnector to connect to a fjage master over WebSockets
233
232
  * @param {Object} opts
234
233
  * @param {string} opts.hostname - hostname/ip address of the master container to connect to
235
- * @param {number} opts.port - port number of the master container to connect to
234
+ * @param {string} opts.port - port number of the master container to connect to
236
235
  * @param {string} opts.pathname - path of the master container to connect to
237
236
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
238
237
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
@@ -242,8 +241,8 @@ class WSConnector {
242
241
  this.url.hostname = opts.hostname;
243
242
  this.url.port = opts.port;
244
243
  this.url.pathname = opts.pathname;
244
+ this._keepAlive = opts.keepAlive;
245
245
  this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME;
246
- this._keepAlive = opts.keepAlive || true;
247
246
  this.debug = opts.debug || false; // debug info to be logged to console?
248
247
  this._firstConn = true; // if the Gateway has managed to connect to a server before
249
248
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
@@ -663,17 +662,17 @@ class Message {
663
662
  *
664
663
  * @class
665
664
  * @param {Object} opts
666
- * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
667
- * @param {number} [opts.port=1100] - port number of the master container to connect to
668
- * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
669
- * @param {string} [opts.keepAlive=true] - try to reconnect if the connection is lost
670
- * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
671
- * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
665
+ * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
666
+ * @param {string} [opts.port='1100'] - port number of the master container to connect to
667
+ * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
668
+ * @param {boolean} [opts.keepAlive=true] - try to reconnect if the connection is lost
669
+ * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
670
+ * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
672
671
  * @param {boolean} [opts.returnNullOnFailedResponse=true] - return null instead of throwing an error when a parameter is not found
673
- * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
674
- * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
675
- * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
676
- * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
672
+ * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
673
+ * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
674
+ * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
675
+ * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
677
676
  */
678
677
  class Gateway {
679
678
 
@@ -682,13 +681,17 @@ class Gateway {
682
681
  if (typeof opts === 'string' || opts instanceof String){
683
682
  opts = {
684
683
  'hostname': opts,
685
- 'port' : port || gObj.location.port,
684
+ 'port' : port,
686
685
  'pathname' : pathname,
687
686
  'timeout' : timeout
688
687
  };
689
688
  console.warn('Deprecated use of Gateway constructor');
690
689
  }
691
- opts = Object.assign({}, GATEWAY_DEFAULTS, opts);
690
+
691
+ // Set defaults
692
+ for (var key in GATEWAY_DEFAULTS){
693
+ if (opts[key] == undefined || opts[key] === '') opts[key] = GATEWAY_DEFAULTS[key];
694
+ }
692
695
  var url = DEFAULT_URL;
693
696
  url.hostname = opts.hostname;
694
697
  url.port = opts.port;
@@ -697,7 +700,7 @@ class Gateway {
697
700
  if (existing) return existing;
698
701
  this._timeout = opts.timeout; // timeout for fjage level messages (agentForService etc)
699
702
  this._keepAlive = opts.keepAlive; // reconnect if connection gets closed/errored
700
- this._queueSize = opts.queueSize; // size of queue
703
+ this._queueSize = opts.queueSize; // size of queue
701
704
  this._returnNullOnFailedResponse = opts.returnNullOnFailedResponse; // null or error
702
705
  this.pending = {}; // msgid to callback mapping for pending requests to server
703
706
  this.subscriptions = {}; // hashset for all topics that are subscribed
@@ -1775,7 +1778,7 @@ const RxFrameNtf = UnetMessages.RxFrameNtf;
1775
1778
  *
1776
1779
  * @class UnetSocket
1777
1780
  * @param {string} [hostname] - hostname/ip address of the master container to connect to
1778
- * @param {number} [port] - port number of the master container to connect to
1781
+ * @param {string} [port] - port number of the master container to connect to
1779
1782
  * @param {string} [path=''] - path of the master container to connect to (for WebSockets)
1780
1783
  * @returns {Promise<UnetSocket>} - Promise which resolves to the UnetSocket object being constructed
1781
1784
  *
package/dist/esm/unet.js CHANGED
@@ -1,6 +1,6 @@
1
- /* unet.js v3.1.0 2024-01-26T11:16:07.039Z */
1
+ /* unet.js v3.1.3 2024-04-02T09:34:11.477Z */
2
2
 
3
- /* fjage.js v1.12.0 */
3
+ /* fjage.js v1.12.1 */
4
4
 
5
5
  const isBrowser =
6
6
  typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -44,21 +44,20 @@ class TCPconnector {
44
44
  /**
45
45
  * Create an TCPConnector to connect to a fjage master over TCP
46
46
  * @param {Object} opts
47
- * @param {string} [opts.hostname='localhost'] - hostname/ip address of the master container to connect to
48
- * @param {number} opts.port - port number of the master container to connect to
49
- * @param {string} opts.pathname - path of the master container to connect to
47
+ * @param {string} opts.hostname - hostname/ip address of the master container to connect to
48
+ * @param {string} opts.port - port number of the master container to connect to
50
49
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
51
50
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
52
51
  */
53
52
  constructor(opts = {}) {
53
+ let host = opts.hostname;
54
+ let port = opts.port;
55
+ this._keepAlive = opts.keepAlive;
56
+ this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
54
57
  this.url = new URL('tcp://localhost');
55
- let host = opts.hostname || 'localhost';
56
- let port = opts.port || -1;
57
58
  this.url.hostname = host;
58
59
  this.url.port = port;
59
60
  this._buf = '';
60
- this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
61
- this._keepAlive = opts.keepAlive || true;
62
61
  this._firstConn = true; // if the Gateway has managed to connect to a server before
63
62
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
64
63
  this.pendingOnOpen = []; // list of callbacks make as soon as gateway is open
@@ -230,7 +229,7 @@ class WSConnector {
230
229
  * Create an WSConnector to connect to a fjage master over WebSockets
231
230
  * @param {Object} opts
232
231
  * @param {string} opts.hostname - hostname/ip address of the master container to connect to
233
- * @param {number} opts.port - port number of the master container to connect to
232
+ * @param {string} opts.port - port number of the master container to connect to
234
233
  * @param {string} opts.pathname - path of the master container to connect to
235
234
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
236
235
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
@@ -240,8 +239,8 @@ class WSConnector {
240
239
  this.url.hostname = opts.hostname;
241
240
  this.url.port = opts.port;
242
241
  this.url.pathname = opts.pathname;
242
+ this._keepAlive = opts.keepAlive;
243
243
  this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME;
244
- this._keepAlive = opts.keepAlive || true;
245
244
  this.debug = opts.debug || false; // debug info to be logged to console?
246
245
  this._firstConn = true; // if the Gateway has managed to connect to a server before
247
246
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
@@ -661,17 +660,17 @@ class Message {
661
660
  *
662
661
  * @class
663
662
  * @param {Object} opts
664
- * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
665
- * @param {number} [opts.port=1100] - port number of the master container to connect to
666
- * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
667
- * @param {string} [opts.keepAlive=true] - try to reconnect if the connection is lost
668
- * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
669
- * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
663
+ * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
664
+ * @param {string} [opts.port='1100'] - port number of the master container to connect to
665
+ * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
666
+ * @param {boolean} [opts.keepAlive=true] - try to reconnect if the connection is lost
667
+ * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
668
+ * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
670
669
  * @param {boolean} [opts.returnNullOnFailedResponse=true] - return null instead of throwing an error when a parameter is not found
671
- * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
672
- * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
673
- * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
674
- * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
670
+ * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
671
+ * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
672
+ * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
673
+ * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
675
674
  */
676
675
  class Gateway {
677
676
 
@@ -680,13 +679,17 @@ class Gateway {
680
679
  if (typeof opts === 'string' || opts instanceof String){
681
680
  opts = {
682
681
  'hostname': opts,
683
- 'port' : port || gObj.location.port,
682
+ 'port' : port,
684
683
  'pathname' : pathname,
685
684
  'timeout' : timeout
686
685
  };
687
686
  console.warn('Deprecated use of Gateway constructor');
688
687
  }
689
- opts = Object.assign({}, GATEWAY_DEFAULTS, opts);
688
+
689
+ // Set defaults
690
+ for (var key in GATEWAY_DEFAULTS){
691
+ if (opts[key] == undefined || opts[key] === '') opts[key] = GATEWAY_DEFAULTS[key];
692
+ }
690
693
  var url = DEFAULT_URL;
691
694
  url.hostname = opts.hostname;
692
695
  url.port = opts.port;
@@ -695,7 +698,7 @@ class Gateway {
695
698
  if (existing) return existing;
696
699
  this._timeout = opts.timeout; // timeout for fjage level messages (agentForService etc)
697
700
  this._keepAlive = opts.keepAlive; // reconnect if connection gets closed/errored
698
- this._queueSize = opts.queueSize; // size of queue
701
+ this._queueSize = opts.queueSize; // size of queue
699
702
  this._returnNullOnFailedResponse = opts.returnNullOnFailedResponse; // null or error
700
703
  this.pending = {}; // msgid to callback mapping for pending requests to server
701
704
  this.subscriptions = {}; // hashset for all topics that are subscribed
@@ -1773,7 +1776,7 @@ const RxFrameNtf = UnetMessages.RxFrameNtf;
1773
1776
  *
1774
1777
  * @class UnetSocket
1775
1778
  * @param {string} [hostname] - hostname/ip address of the master container to connect to
1776
- * @param {number} [port] - port number of the master container to connect to
1779
+ * @param {string} [port] - port number of the master container to connect to
1777
1780
  * @param {string} [path=''] - path of the master container to connect to (for WebSockets)
1778
1781
  * @returns {Promise<UnetSocket>} - Promise which resolves to the UnetSocket object being constructed
1779
1782
  *
package/dist/unetjs.js CHANGED
@@ -4,7 +4,7 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.unet = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
- /* fjage.js v1.12.0 */
7
+ /* fjage.js v1.12.1 */
8
8
 
9
9
  const isBrowser =
10
10
  typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -48,21 +48,20 @@
48
48
  /**
49
49
  * Create an TCPConnector to connect to a fjage master over TCP
50
50
  * @param {Object} opts
51
- * @param {string} [opts.hostname='localhost'] - hostname/ip address of the master container to connect to
52
- * @param {number} opts.port - port number of the master container to connect to
53
- * @param {string} opts.pathname - path of the master container to connect to
51
+ * @param {string} opts.hostname - hostname/ip address of the master container to connect to
52
+ * @param {string} opts.port - port number of the master container to connect to
54
53
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
55
54
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
56
55
  */
57
56
  constructor(opts = {}) {
57
+ let host = opts.hostname;
58
+ let port = opts.port;
59
+ this._keepAlive = opts.keepAlive;
60
+ this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
58
61
  this.url = new URL('tcp://localhost');
59
- let host = opts.hostname || 'localhost';
60
- let port = opts.port || -1;
61
62
  this.url.hostname = host;
62
63
  this.url.port = port;
63
64
  this._buf = '';
64
- this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME$1;
65
- this._keepAlive = opts.keepAlive || true;
66
65
  this._firstConn = true; // if the Gateway has managed to connect to a server before
67
66
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
68
67
  this.pendingOnOpen = []; // list of callbacks make as soon as gateway is open
@@ -234,7 +233,7 @@
234
233
  * Create an WSConnector to connect to a fjage master over WebSockets
235
234
  * @param {Object} opts
236
235
  * @param {string} opts.hostname - hostname/ip address of the master container to connect to
237
- * @param {number} opts.port - port number of the master container to connect to
236
+ * @param {string} opts.port - port number of the master container to connect to
238
237
  * @param {string} opts.pathname - path of the master container to connect to
239
238
  * @param {boolean} opts.keepAlive - try to reconnect if the connection is lost
240
239
  * @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error
@@ -244,8 +243,8 @@
244
243
  this.url.hostname = opts.hostname;
245
244
  this.url.port = opts.port;
246
245
  this.url.pathname = opts.pathname;
246
+ this._keepAlive = opts.keepAlive;
247
247
  this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME;
248
- this._keepAlive = opts.keepAlive || true;
249
248
  this.debug = opts.debug || false; // debug info to be logged to console?
250
249
  this._firstConn = true; // if the Gateway has managed to connect to a server before
251
250
  this._firstReConn = true; // if the Gateway has attempted to reconnect to a server before
@@ -665,17 +664,17 @@
665
664
  *
666
665
  * @class
667
666
  * @param {Object} opts
668
- * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
669
- * @param {number} [opts.port=1100] - port number of the master container to connect to
670
- * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
671
- * @param {string} [opts.keepAlive=true] - try to reconnect if the connection is lost
672
- * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
673
- * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
667
+ * @param {string} [opts.hostname="localhost"] - hostname/ip address of the master container to connect to
668
+ * @param {string} [opts.port='1100'] - port number of the master container to connect to
669
+ * @param {string} [opts.pathname=""] - path of the master container to connect to (for WebSockets)
670
+ * @param {boolean} [opts.keepAlive=true] - try to reconnect if the connection is lost
671
+ * @param {number} [opts.queueSize=128] - size of the queue of received messages that haven't been consumed yet
672
+ * @param {number} [opts.timeout=1000] - timeout for fjage level messages in ms
674
673
  * @param {boolean} [opts.returnNullOnFailedResponse=true] - return null instead of throwing an error when a parameter is not found
675
- * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
676
- * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
677
- * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
678
- * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
674
+ * @param {string} [hostname="localhost"] - <strike>Deprecated : hostname/ip address of the master container to connect to</strike>
675
+ * @param {number} [port=] - <strike>Deprecated : port number of the master container to connect to</strike>
676
+ * @param {string} [pathname=="/ws/"] - <strike>Deprecated : path of the master container to connect to (for WebSockets)</strike>
677
+ * @param {number} [timeout=1000] - <strike>Deprecated : timeout for fjage level messages in ms</strike>
679
678
  */
680
679
  class Gateway {
681
680
 
@@ -684,13 +683,17 @@
684
683
  if (typeof opts === 'string' || opts instanceof String){
685
684
  opts = {
686
685
  'hostname': opts,
687
- 'port' : port || gObj.location.port,
686
+ 'port' : port,
688
687
  'pathname' : pathname,
689
688
  'timeout' : timeout
690
689
  };
691
690
  console.warn('Deprecated use of Gateway constructor');
692
691
  }
693
- opts = Object.assign({}, GATEWAY_DEFAULTS, opts);
692
+
693
+ // Set defaults
694
+ for (var key in GATEWAY_DEFAULTS){
695
+ if (opts[key] == undefined || opts[key] === '') opts[key] = GATEWAY_DEFAULTS[key];
696
+ }
694
697
  var url = DEFAULT_URL;
695
698
  url.hostname = opts.hostname;
696
699
  url.port = opts.port;
@@ -699,7 +702,7 @@
699
702
  if (existing) return existing;
700
703
  this._timeout = opts.timeout; // timeout for fjage level messages (agentForService etc)
701
704
  this._keepAlive = opts.keepAlive; // reconnect if connection gets closed/errored
702
- this._queueSize = opts.queueSize; // size of queue
705
+ this._queueSize = opts.queueSize; // size of queue
703
706
  this._returnNullOnFailedResponse = opts.returnNullOnFailedResponse; // null or error
704
707
  this.pending = {}; // msgid to callback mapping for pending requests to server
705
708
  this.subscriptions = {}; // hashset for all topics that are subscribed
@@ -1777,7 +1780,7 @@
1777
1780
  *
1778
1781
  * @class UnetSocket
1779
1782
  * @param {string} [hostname] - hostname/ip address of the master container to connect to
1780
- * @param {number} [port] - port number of the master container to connect to
1783
+ * @param {string} [port] - port number of the master container to connect to
1781
1784
  * @param {string} [path=''] - path of the master container to connect to (for WebSockets)
1782
1785
  * @returns {Promise<UnetSocket>} - Promise which resolves to the UnetSocket object being constructed
1783
1786
  *