@nxtedition/deepstream.io-client-js 24.4.2 → 24.4.4

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": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.4.2",
3
+ "version": "24.4.4",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -26,6 +26,7 @@ export default function Connection(client, url, options) {
26
26
  action: null,
27
27
  data: null,
28
28
  }
29
+ this._decoder = new globalThis.TextDecoder()
29
30
  this._recvQueue = new FixedQueue()
30
31
  this._reconnectTimeout = null
31
32
  this._reconnectionAttempt = 0
@@ -88,19 +89,23 @@ Connection.prototype.close = function () {
88
89
  }
89
90
 
90
91
  Connection.prototype._createEndpoint = function () {
91
- this._endpoint = NodeWebSocket
92
- ? new NodeWebSocket(this._url, {
93
- generateMask() {},
94
- })
95
- : new BrowserWebSocket(this._url)
92
+ if (utils.isNode) {
93
+ this._endpoint = new NodeWebSocket(this._url, {
94
+ generateMask() {},
95
+ })
96
+ this._endpoint.binaryType = 'nodebuffer'
97
+ } else {
98
+ this._endpoint = new BrowserWebSocket(this._url)
99
+ this._endpoint.binaryType = 'arraybuffer'
100
+ }
101
+
96
102
  this._corked = false
97
103
 
98
104
  this._endpoint.onopen = this._onOpen.bind(this)
99
105
  this._endpoint.onerror = this._onError.bind(this)
100
106
  this._endpoint.onclose = this._onClose.bind(this)
101
- this._endpoint.onmessage = BrowserWebSocket
102
- ? ({ data }) => this._onMessage(typeof data === 'string' ? data : Buffer.from(data).toString())
103
- : ({ data }) => this._onMessage(typeof data === 'string' ? data : data.toString())
107
+ this._endpoint.onmessage = ({ data }) =>
108
+ this._onMessage(typeof data === 'string' ? data : this._decoder.decode(data))
104
109
  }
105
110
 
106
111
  Connection.prototype.send = function (message) {
@@ -161,7 +166,7 @@ Connection.prototype._sendAuthParams = function () {
161
166
  this._setState(C.CONNECTION_STATE.AUTHENTICATING)
162
167
  const authMessage = messageBuilder.getMsg(C.TOPIC.AUTH, C.ACTIONS.REQUEST, [
163
168
  this._authParams,
164
- '24.4.0',
169
+ '24.4.4',
165
170
  utils.isNode
166
171
  ? `Node/${process.version}`
167
172
  : globalThis.navigator && globalThis.navigator.userAgent,