@nxtedition/deepstream.io-client-js 25.6.3 → 25.6.5
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 +1 -1
- package/src/message/connection.js +7 -2
- package/src/utils/utils.js +4 -1
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@ import * as C from '../constants/constants.js'
|
|
|
5
5
|
import FixedQueue from '../utils/fixed-queue.js'
|
|
6
6
|
import Emitter from 'component-emitter2'
|
|
7
7
|
import pkg from '../../package.json' with { type: 'json' }
|
|
8
|
+
import NodeWebSocket from 'ws'
|
|
8
9
|
|
|
9
|
-
const NodeWebSocket = utils.isNode ? await import('ws').then((x) => x.default) : null
|
|
10
10
|
const BrowserWebSocket = globalThis.WebSocket || globalThis.MozWebSocket
|
|
11
11
|
|
|
12
12
|
export default function Connection(client, url, options) {
|
|
@@ -123,6 +123,10 @@ Connection.prototype.send = function (message) {
|
|
|
123
123
|
return false
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
if (!this._endpoint) {
|
|
127
|
+
return false
|
|
128
|
+
}
|
|
129
|
+
|
|
126
130
|
if (
|
|
127
131
|
this._state !== C.CONNECTION_STATE.OPEN ||
|
|
128
132
|
this._endpoint.readyState !== this._endpoint.OPEN
|
|
@@ -140,6 +144,7 @@ Connection.prototype.send = function (message) {
|
|
|
140
144
|
}
|
|
141
145
|
|
|
142
146
|
this.emit('send', message)
|
|
147
|
+
|
|
143
148
|
this._endpoint.send(message)
|
|
144
149
|
|
|
145
150
|
return true
|
|
@@ -152,7 +157,7 @@ Connection.prototype._submit = function (message) {
|
|
|
152
157
|
const err = new Error(`Packet to big: ${message.length} > ${maxPacketSize}`)
|
|
153
158
|
this._client._$onError(C.TOPIC.CONNECTION, C.EVENT.CONNECTION_ERROR, err)
|
|
154
159
|
return false
|
|
155
|
-
} else if (this._endpoint.readyState === this._endpoint.OPEN) {
|
|
160
|
+
} else if (this._endpoint != null && this._endpoint.readyState === this._endpoint.OPEN) {
|
|
156
161
|
this.emit('send', message)
|
|
157
162
|
this._endpoint.send(message)
|
|
158
163
|
return true
|
package/src/utils/utils.js
CHANGED
|
@@ -177,7 +177,10 @@ export function removeAbortListener(signal, handler) {
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
// This is a hack to avoid top-level await
|
|
181
|
+
// const HASHER = await xxhash()
|
|
182
|
+
let HASHER
|
|
183
|
+
xxhash().then((hasher) => (HASHER = hasher))
|
|
181
184
|
|
|
182
185
|
export function h64ToString(str) {
|
|
183
186
|
return HASHER.h64ToString(str)
|