@nxtedition/deepstream.io-client-js 28.0.0 → 28.0.1
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": "28.0.
|
|
3
|
+
"version": "28.0.1",
|
|
4
4
|
"description": "the javascript client for deepstream.io",
|
|
5
5
|
"homepage": "http://deepstream.io",
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"invariant": "^2.2.4",
|
|
41
41
|
"lodash.clonedeep": "^4.5.0",
|
|
42
42
|
"utf-8-validate": "^6.0.4",
|
|
43
|
-
"varint": "^6.0.0",
|
|
44
43
|
"ws": "^8.18.0",
|
|
45
44
|
"xuid": "^4.1.3",
|
|
46
45
|
"xxhash-wasm": "^1.0.2"
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as C from '../constants/constants.js'
|
|
2
2
|
import * as utils from '../utils/utils.js'
|
|
3
|
-
import varint from 'varint'
|
|
4
3
|
|
|
5
4
|
const poolEncoder = new globalThis.TextEncoder()
|
|
6
5
|
|
|
@@ -9,14 +8,12 @@ const maxMessageSize = 1024 * 1024
|
|
|
9
8
|
const poolSize = maxMessageSize * 8
|
|
10
9
|
|
|
11
10
|
let poolBuffer
|
|
12
|
-
let poolView
|
|
13
11
|
let poolOffset
|
|
14
12
|
|
|
15
13
|
function reallocPool() {
|
|
16
14
|
poolBuffer = utils.isNode
|
|
17
15
|
? globalThis.Buffer.allocUnsafe(poolSize)
|
|
18
16
|
: new Uint8Array(new ArrayBuffer(poolSize))
|
|
19
|
-
poolView = new DataView(poolBuffer.buffer)
|
|
20
17
|
poolOffset = 0
|
|
21
18
|
}
|
|
22
19
|
|
|
@@ -50,14 +47,6 @@ export function getMsg(topic, action, data) {
|
|
|
50
47
|
|
|
51
48
|
const start = poolOffset
|
|
52
49
|
|
|
53
|
-
const headerSize = 8
|
|
54
|
-
for (let n = 0; n < headerSize; n++) {
|
|
55
|
-
poolBuffer[poolOffset++] = 0
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let headerPos = start
|
|
59
|
-
poolBuffer[headerPos++] = 128 + headerSize
|
|
60
|
-
|
|
61
50
|
poolBuffer[poolOffset++] = topic.charCodeAt(0)
|
|
62
51
|
poolBuffer[poolOffset++] = 31
|
|
63
52
|
for (let n = 0; n < action.length; n++) {
|
|
@@ -67,30 +56,18 @@ export function getMsg(topic, action, data) {
|
|
|
67
56
|
if (data) {
|
|
68
57
|
for (let i = 0; i < data.length; i++) {
|
|
69
58
|
const type = typeof data[i]
|
|
70
|
-
let len
|
|
71
59
|
if (data[i] == null) {
|
|
72
60
|
poolBuffer[poolOffset++] = 31
|
|
73
|
-
|
|
61
|
+
poolOffset += 0
|
|
74
62
|
} else if (type === 'object') {
|
|
75
63
|
poolBuffer[poolOffset++] = 31
|
|
76
|
-
|
|
77
|
-
} else if (type === 'bigint') {
|
|
78
|
-
poolBuffer[poolOffset++] = 31
|
|
79
|
-
poolView.setBigUint64(poolOffset, data[i], false)
|
|
80
|
-
len = 8
|
|
64
|
+
poolOffset += writeString(poolBuffer, JSON.stringify(data[i]), poolOffset)
|
|
81
65
|
} else if (type === 'string') {
|
|
82
66
|
poolBuffer[poolOffset++] = 31
|
|
83
|
-
|
|
67
|
+
poolOffset += writeString(poolBuffer, data[i], poolOffset)
|
|
84
68
|
} else {
|
|
85
69
|
throw new Error('invalid data')
|
|
86
70
|
}
|
|
87
|
-
poolOffset += len
|
|
88
|
-
|
|
89
|
-
varint.encode(len + 1, poolBuffer, headerPos)
|
|
90
|
-
headerPos += varint.encode.bytes
|
|
91
|
-
if (headerPos - start >= headerSize) {
|
|
92
|
-
throw new Error('header too large')
|
|
93
|
-
}
|
|
94
71
|
|
|
95
72
|
if (poolOffset >= poolSize) {
|
|
96
73
|
throw new Error('message too large')
|