@nxtedition/deepstream.io-client-js 26.0.7 → 26.0.8
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
|
@@ -170,7 +170,7 @@ Connection.prototype._sendAuthParams = function () {
|
|
|
170
170
|
this._setState(C.CONNECTION_STATE.AUTHENTICATING)
|
|
171
171
|
const authMessage = messageBuilder.getMsg(C.TOPIC.AUTH, C.ACTIONS.REQUEST, [
|
|
172
172
|
this._authParams,
|
|
173
|
-
'26.0.
|
|
173
|
+
'26.0.8', // TODO (fix): How to read from package.json?
|
|
174
174
|
utils.isNode
|
|
175
175
|
? `Node/${process.version}`
|
|
176
176
|
: globalThis.navigator && globalThis.navigator.userAgent,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as C from '../constants/constants.js'
|
|
2
2
|
import varint from 'varint'
|
|
3
|
-
import * as utils from '../utils/utils.js'
|
|
4
3
|
|
|
5
4
|
const poolEncoder = new TextEncoder()
|
|
6
5
|
|
|
@@ -9,11 +8,9 @@ let poolBuffer
|
|
|
9
8
|
let poolView
|
|
10
9
|
let poolOffset
|
|
11
10
|
|
|
12
|
-
function
|
|
11
|
+
function reallocPool(size) {
|
|
13
12
|
poolSize = size || poolSize || 1024 * 1024
|
|
14
|
-
poolBuffer =
|
|
15
|
-
? globalThis.Buffer.allocUnsafe(poolSize)
|
|
16
|
-
: new Uint8Array(new ArrayBuffer(poolSize))
|
|
13
|
+
poolBuffer = new Uint8Array(new ArrayBuffer(poolSize))
|
|
17
14
|
poolView = new DataView(poolBuffer.buffer)
|
|
18
15
|
poolOffset = 0
|
|
19
16
|
}
|
|
@@ -26,22 +23,13 @@ function alignPool() {
|
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
function writeString(dst, str, offset) {
|
|
30
|
-
if (utils.isNode) {
|
|
31
|
-
return dst.write(str, offset)
|
|
32
|
-
} else {
|
|
33
|
-
const res = poolEncoder.encodeInto(str, new Uint8Array(dst.buffer, offset))
|
|
34
|
-
return res.written
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
26
|
export function getMsg(topic, action, data) {
|
|
39
27
|
if (data && !(data instanceof Array)) {
|
|
40
28
|
throw new Error('data must be an array')
|
|
41
29
|
}
|
|
42
30
|
|
|
43
31
|
if (!poolSize || poolOffset + poolSize / 16 >= poolSize) {
|
|
44
|
-
|
|
32
|
+
reallocPool()
|
|
45
33
|
} else {
|
|
46
34
|
alignPool()
|
|
47
35
|
}
|
|
@@ -68,14 +56,19 @@ export function getMsg(topic, action, data) {
|
|
|
68
56
|
len = 0
|
|
69
57
|
} else if (type === 'object') {
|
|
70
58
|
poolBuffer[poolOffset++] = 31
|
|
71
|
-
|
|
59
|
+
const res = poolEncoder.encodeInto(
|
|
60
|
+
JSON.stringify(data[i]),
|
|
61
|
+
new Uint8Array(poolBuffer.buffer, poolOffset),
|
|
62
|
+
)
|
|
63
|
+
len = res.written
|
|
72
64
|
} else if (type === 'bigint') {
|
|
73
65
|
poolBuffer[poolOffset++] = 31
|
|
74
66
|
poolView.setBigUint64(poolOffset, data[i], false)
|
|
75
67
|
len = 8
|
|
76
68
|
} else if (type === 'string') {
|
|
77
69
|
poolBuffer[poolOffset++] = 31
|
|
78
|
-
|
|
70
|
+
const res = poolEncoder.encodeInto(data[i], new Uint8Array(poolBuffer.buffer, poolOffset))
|
|
71
|
+
len = res.written
|
|
79
72
|
} else {
|
|
80
73
|
throw new Error('invalid data')
|
|
81
74
|
}
|
|
@@ -89,7 +82,7 @@ export function getMsg(topic, action, data) {
|
|
|
89
82
|
}
|
|
90
83
|
|
|
91
84
|
if (poolOffset >= poolBuffer.length) {
|
|
92
|
-
|
|
85
|
+
reallocPool(start === 0 ? poolSize * 2 : poolSize)
|
|
93
86
|
return getMsg(topic, action, data)
|
|
94
87
|
}
|
|
95
88
|
}
|
|
@@ -208,11 +208,9 @@ class RecordHandler {
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
getKey(name) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const buf = this._encoder.encode(name)
|
|
215
|
-
return buf.byteLength === 8 ? utils.readBigUInt64BE(buf) : this._connection.hasher.h64Raw(buf)
|
|
211
|
+
return name.length <= 8 && this._encoder.encode(name).byteLength === 8
|
|
212
|
+
? name
|
|
213
|
+
: this._connection.hasher.h64(name)
|
|
216
214
|
}
|
|
217
215
|
|
|
218
216
|
/**
|
package/src/record/record.js
CHANGED
|
@@ -392,7 +392,7 @@ class Record {
|
|
|
392
392
|
this._version = nextVersion
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
-
_onUpdate([, version, data
|
|
395
|
+
_onUpdate([, version, data]) {
|
|
396
396
|
const prevData = this._data
|
|
397
397
|
const prevVersion = this._version
|
|
398
398
|
const prevState = this._state
|
|
@@ -425,9 +425,7 @@ class Record {
|
|
|
425
425
|
this._onPatching(false)
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
if (this._state < C.RECORD_STATE.
|
|
429
|
-
this._state = C.RECORD_STATE.PROVIDER
|
|
430
|
-
} else if (this._state < C.RECORD_STATE.SERVER) {
|
|
428
|
+
if (this._state < C.RECORD_STATE.SERVER) {
|
|
431
429
|
this._state = this._version.charAt(0) === 'I' ? C.RECORD_STATE.STALE : C.RECORD_STATE.SERVER
|
|
432
430
|
}
|
|
433
431
|
|
|
@@ -186,7 +186,6 @@ class Listener {
|
|
|
186
186
|
} else if (message.action === C.ACTIONS.LISTEN_ACCEPT) {
|
|
187
187
|
const provider = this._subscriptions.get(name)
|
|
188
188
|
if (!provider?.value$) {
|
|
189
|
-
this._error(name, 'invalid accept: listener missing')
|
|
190
189
|
return
|
|
191
190
|
}
|
|
192
191
|
|
|
@@ -220,7 +219,11 @@ class Listener {
|
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
_error(name, err) {
|
|
223
|
-
this._client._$onError(this._topic, C.EVENT.LISTENER_ERROR, err, [
|
|
222
|
+
this._client._$onError(this._topic, C.EVENT.LISTENER_ERROR, err, [
|
|
223
|
+
this._pattern,
|
|
224
|
+
name,
|
|
225
|
+
this._handler.getKey(name),
|
|
226
|
+
])
|
|
224
227
|
}
|
|
225
228
|
|
|
226
229
|
_reset() {
|
package/src/utils/utils.js
CHANGED
|
@@ -174,14 +174,3 @@ export function removeAbortListener(signal, handler) {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
|
|
178
|
-
export function readBigUInt64BE(buf, offset = 0) {
|
|
179
|
-
const first = buf[offset]
|
|
180
|
-
const last = buf[offset + 7]
|
|
181
|
-
|
|
182
|
-
const hi = first * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + buf[++offset]
|
|
183
|
-
|
|
184
|
-
const lo = buf[++offset] * 2 ** 24 + buf[++offset] * 2 ** 16 + buf[++offset] * 2 ** 8 + last
|
|
185
|
-
|
|
186
|
-
return (BigInt(hi) << 32n) + BigInt(lo)
|
|
187
|
-
}
|