@nxtedition/deepstream.io-client-js 24.4.1 → 24.4.3

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.1",
3
+ "version": "24.4.3",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ import * as messageParser from '../message/message-parser.js'
4
4
  import MulticastListener from '../utils/multicast-listener.js'
5
5
  import UnicastListener from '../utils/unicast-listener.js'
6
6
  import EventEmitter from 'component-emitter2'
7
- import rxjs from 'rxjs'
7
+ import * as rxjs from 'rxjs'
8
8
 
9
9
  const EventHandler = function (options, connection, client) {
10
10
  this._options = options
@@ -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,22 @@ 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 }) => this._onMessage(this._decoder.decode(data))
104
108
  }
105
109
 
106
110
  Connection.prototype.send = function (message) {
@@ -161,7 +165,7 @@ Connection.prototype._sendAuthParams = function () {
161
165
  this._setState(C.CONNECTION_STATE.AUTHENTICATING)
162
166
  const authMessage = messageBuilder.getMsg(C.TOPIC.AUTH, C.ACTIONS.REQUEST, [
163
167
  this._authParams,
164
- '24.4.0',
168
+ '24.4.3',
165
169
  utils.isNode
166
170
  ? `Node/${process.version}`
167
171
  : globalThis.navigator && globalThis.navigator.userAgent,
@@ -2,12 +2,11 @@ import Record from './record.js'
2
2
  import MulticastListener from '../utils/multicast-listener.js'
3
3
  import UnicastListener from '../utils/unicast-listener.js'
4
4
  import * as C from '../constants/constants.js'
5
- import rxjs from 'rxjs'
5
+ import * as rxjs from 'rxjs'
6
6
  import invariant from 'invariant'
7
7
  import EventEmitter from 'component-emitter2'
8
8
  import jsonPath from '@nxtedition/json-path'
9
9
  import * as utils from '../utils/utils.js'
10
- import rx from 'rxjs/operators'
11
10
  import xuid from 'xuid'
12
11
  import * as timers from '../utils/timers.js'
13
12
 
@@ -472,7 +471,7 @@ class RecordHandler {
472
471
  // TODO (fix): Missing sync..
473
472
  return new Promise((resolve, reject) => {
474
473
  this.observe(...args)
475
- .pipe(rx.first())
474
+ .pipe(rxjs.first())
476
475
  .subscribe({
477
476
  next: resolve,
478
477
  error: reject,
@@ -488,7 +487,7 @@ class RecordHandler {
488
487
  get2(...args) {
489
488
  return new Promise((resolve, reject) => {
490
489
  this.observe2(...args)
491
- .pipe(rx.first())
490
+ .pipe(rxjs.first())
492
491
  .subscribe({
493
492
  next: resolve,
494
493
  error: reject,