@nxtedition/deepstream.io-client-js 24.2.2 → 24.2.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,8 +1,8 @@
|
|
|
1
1
|
const BrowserWebSocket = globalThis.WebSocket || globalThis.MozWebSocket
|
|
2
|
-
const
|
|
2
|
+
const utils = require('../utils/utils')
|
|
3
|
+
const NodeWebSocket = utils.isNode ? require('ws') : null
|
|
3
4
|
const messageParser = require('./message-parser')
|
|
4
5
|
const messageBuilder = require('./message-builder')
|
|
5
|
-
const utils = require('../utils/utils')
|
|
6
6
|
const C = require('../constants/constants')
|
|
7
7
|
const pkg = require('../../package.json')
|
|
8
8
|
const xxhash = require('xxhash-wasm')
|
|
@@ -101,11 +101,11 @@ Connection.prototype.close = function () {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
Connection.prototype._createEndpoint = function () {
|
|
104
|
-
this._endpoint =
|
|
105
|
-
? new
|
|
106
|
-
: new NodeWebSocket(this._url, {
|
|
104
|
+
this._endpoint = NodeWebSocket
|
|
105
|
+
? new NodeWebSocket(this._url, {
|
|
107
106
|
generateMask() {},
|
|
108
107
|
})
|
|
108
|
+
: new BrowserWebSocket(this._url)
|
|
109
109
|
this._corked = false
|
|
110
110
|
|
|
111
111
|
this._endpoint.onopen = this._onOpen.bind(this)
|
|
@@ -330,7 +330,7 @@ class RecordHandler {
|
|
|
330
330
|
|
|
331
331
|
let serverTimeout
|
|
332
332
|
const token = xuid()
|
|
333
|
-
await Promise.race([
|
|
333
|
+
return await Promise.race([
|
|
334
334
|
await new Promise((resolve) => {
|
|
335
335
|
this._syncEmitter.once(token, resolve)
|
|
336
336
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
@@ -613,7 +613,7 @@ class RecordHandler {
|
|
|
613
613
|
}
|
|
614
614
|
|
|
615
615
|
if (message.action === C.ACTIONS.SYNC) {
|
|
616
|
-
this._syncEmitter.emit(message.data[0])
|
|
616
|
+
this._syncEmitter.emit(message.data[0], message.data[1]?.toString())
|
|
617
617
|
return true
|
|
618
618
|
}
|
|
619
619
|
|
package/src/record/record.js
CHANGED
|
@@ -205,17 +205,17 @@ class Record {
|
|
|
205
205
|
|
|
206
206
|
return new Promise((resolve, reject) => {
|
|
207
207
|
if (this._state >= state) {
|
|
208
|
-
resolve(
|
|
208
|
+
resolve(this)
|
|
209
209
|
return
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
let timeoutHandle
|
|
213
213
|
|
|
214
|
-
const onDone = (err
|
|
214
|
+
const onDone = (err) => {
|
|
215
215
|
if (err) {
|
|
216
216
|
reject(err)
|
|
217
217
|
} else {
|
|
218
|
-
resolve(
|
|
218
|
+
resolve(this)
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
this.unref()
|
|
@@ -231,7 +231,7 @@ class Record {
|
|
|
231
231
|
|
|
232
232
|
const onUpdate = () => {
|
|
233
233
|
if (this._state >= state) {
|
|
234
|
-
onDone(null
|
|
234
|
+
onDone(null)
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|