@nxtedition/deepstream.io-client-js 24.3.0 → 24.3.2

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,9 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.3.0",
3
+ "version": "24.3.2",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
+ "type": "module",
6
7
  "bugs": {
7
8
  "url": "https://github.com/deepstreamIO/deepstream.io-client-js/issues"
8
9
  },
package/src/client.js CHANGED
@@ -1,12 +1,12 @@
1
- const C = require('./constants/constants')
2
- const Emitter = require('component-emitter2')
3
- const Connection = require('./message/connection')
4
- const EventHandler = require('./event/event-handler')
5
- const RpcHandler = require('./rpc/rpc-handler')
6
- const RecordHandler = require('./record/record-handler')
7
- const defaultOptions = require('./default-options')
8
- const xuid = require('xuid')
9
- const utils = require('./utils/utils')
1
+ import * as C from './constants/constants.js'
2
+ import Emitter from 'component-emitter2'
3
+ import Connection from './message/connection.js'
4
+ import EventHandler from './event/event-handler.js'
5
+ import RpcHandler from './rpc/rpc-handler.js'
6
+ import RecordHandler from './record/record-handler.js'
7
+ import defaultOptions from './default-options.js'
8
+ import xuid from 'xuid'
9
+ import * as utils from './utils/utils.js'
10
10
 
11
11
  const Client = function (url, options) {
12
12
  this._url = url
@@ -135,4 +135,4 @@ Client.prototype.isSameOrNewer = utils.isSameOrNewer
135
135
  Client.prototype.CONSTANTS = C
136
136
  createDeepstream.CONSTANTS = C
137
137
 
138
- module.exports = createDeepstream
138
+ export default createDeepstream
@@ -1,98 +1,98 @@
1
- module.exports.CONNECTION_STATE = {}
1
+ export const CONNECTION_STATE = {}
2
2
 
3
- module.exports.CONNECTION_STATE.CLOSED = 'CLOSED'
4
- module.exports.CONNECTION_STATE.AWAITING_CONNECTION = 'AWAITING_CONNECTION'
5
- module.exports.CONNECTION_STATE.CHALLENGING = 'CHALLENGING'
6
- module.exports.CONNECTION_STATE.AWAITING_AUTHENTICATION = 'AWAITING_AUTHENTICATION'
7
- module.exports.CONNECTION_STATE.AUTHENTICATING = 'AUTHENTICATING'
8
- module.exports.CONNECTION_STATE.OPEN = 'OPEN'
9
- module.exports.CONNECTION_STATE.ERROR = 'ERROR'
10
- module.exports.CONNECTION_STATE.RECONNECTING = 'RECONNECTING'
3
+ CONNECTION_STATE.CLOSED = 'CLOSED'
4
+ CONNECTION_STATE.AWAITING_CONNECTION = 'AWAITING_CONNECTION'
5
+ CONNECTION_STATE.CHALLENGING = 'CHALLENGING'
6
+ CONNECTION_STATE.AWAITING_AUTHENTICATION = 'AWAITING_AUTHENTICATION'
7
+ CONNECTION_STATE.AUTHENTICATING = 'AUTHENTICATING'
8
+ CONNECTION_STATE.OPEN = 'OPEN'
9
+ CONNECTION_STATE.ERROR = 'ERROR'
10
+ CONNECTION_STATE.RECONNECTING = 'RECONNECTING'
11
11
 
12
- module.exports.RECORD_STATE = {}
13
- module.exports.RECORD_STATE.VOID = 0
14
- module.exports.RECORD_STATE.CLIENT = 1
15
- module.exports.RECORD_STATE.SERVER = 2
16
- module.exports.RECORD_STATE.STALE = 3
17
- module.exports.RECORD_STATE.PROVIDER = 4
12
+ export const RECORD_STATE = {}
13
+ RECORD_STATE.VOID = 0
14
+ RECORD_STATE.CLIENT = 1
15
+ RECORD_STATE.SERVER = 2
16
+ RECORD_STATE.STALE = 3
17
+ RECORD_STATE.PROVIDER = 4
18
18
 
19
- module.exports.RECORD_STATE_NAME = []
20
- for (const [key, val] of Object.entries(module.exports.RECORD_STATE)) {
21
- module.exports.RECORD_STATE_NAME[val] = key
19
+ export const RECORD_STATE_NAME = []
20
+ for (const [key, val] of Object.entries(RECORD_STATE)) {
21
+ RECORD_STATE_NAME[val] = key
22
22
  }
23
23
 
24
- module.exports.MESSAGE_SEPERATOR = String.fromCharCode(30) // ASCII Record Seperator 1E
25
- module.exports.MESSAGE_PART_SEPERATOR = String.fromCharCode(31) // ASCII Unit Separator 1F
24
+ export const MESSAGE_SEPERATOR = String.fromCharCode(30) // ASCII Record Seperator 1E
25
+ export const MESSAGE_PART_SEPERATOR = String.fromCharCode(31) // ASCII Unit Separator 1F
26
26
 
27
- module.exports.TYPES = {}
28
- module.exports.TYPES.STRING = 'S'
29
- module.exports.TYPES.OBJECT = 'O'
30
- module.exports.TYPES.NUMBER = 'N'
31
- module.exports.TYPES.NULL = 'L'
32
- module.exports.TYPES.TRUE = 'T'
33
- module.exports.TYPES.FALSE = 'F'
34
- module.exports.TYPES.UNDEFINED = 'U'
27
+ export const TYPES = {}
28
+ TYPES.STRING = 'S'
29
+ TYPES.OBJECT = 'O'
30
+ TYPES.NUMBER = 'N'
31
+ TYPES.NULL = 'L'
32
+ TYPES.TRUE = 'T'
33
+ TYPES.FALSE = 'F'
34
+ TYPES.UNDEFINED = 'U'
35
35
 
36
- module.exports.TOPIC = {}
37
- module.exports.TOPIC.CONNECTION = 'C'
38
- module.exports.TOPIC.AUTH = 'A'
39
- module.exports.TOPIC.ERROR = 'X'
40
- module.exports.TOPIC.EVENT = 'E'
41
- module.exports.TOPIC.RECORD = 'R'
42
- module.exports.TOPIC.RPC = 'P'
43
- module.exports.TOPIC.PRIVATE = 'PRIVATE/'
36
+ export const TOPIC = {}
37
+ TOPIC.CONNECTION = 'C'
38
+ TOPIC.AUTH = 'A'
39
+ TOPIC.ERROR = 'X'
40
+ TOPIC.EVENT = 'E'
41
+ TOPIC.RECORD = 'R'
42
+ TOPIC.RPC = 'P'
43
+ TOPIC.PRIVATE = 'PRIVATE/'
44
44
 
45
- module.exports.EVENT = {}
46
- module.exports.EVENT.CONNECTION_ERROR = 'connectionError'
47
- module.exports.EVENT.CONNECTION_STATE_CHANGED = 'connectionStateChanged'
48
- module.exports.EVENT.CONNECTED = 'connected'
49
- module.exports.EVENT.MAX_RECONNECTION_ATTEMPTS_REACHED = 'MAX_RECONNECTION_ATTEMPTS_REACHED'
50
- module.exports.EVENT.CONNECTION_AUTHENTICATION_TIMEOUT = 'CONNECTION_AUTHENTICATION_TIMEOUT'
51
- module.exports.EVENT.NO_RPC_PROVIDER = 'NO_RPC_PROVIDER'
52
- module.exports.EVENT.RPC_ERROR = 'RPC_ERROR'
53
- module.exports.EVENT.TIMEOUT = 'TIMEOUT'
54
- module.exports.EVENT.UNSOLICITED_MESSAGE = 'UNSOLICITED_MESSAGE'
55
- module.exports.EVENT.MESSAGE_DENIED = 'MESSAGE_DENIED'
56
- module.exports.EVENT.NOT_CONNECTED = 'NOT_CONNECTED'
57
- module.exports.EVENT.MESSAGE_PARSE_ERROR = 'MESSAGE_PARSE_ERROR'
58
- module.exports.EVENT.NOT_AUTHENTICATED = 'NOT_AUTHENTICATED'
59
- module.exports.EVENT.MESSAGE_PERMISSION_ERROR = 'MESSAGE_PERMISSION_ERROR'
60
- module.exports.EVENT.LISTENER_EXISTS = 'LISTENER_EXISTS'
61
- module.exports.EVENT.PROVIDER_ERROR = 'PROVIDER_ERROR'
62
- module.exports.EVENT.CACHE_ERROR = 'CACHE_ERROR'
63
- module.exports.EVENT.UPDATE_ERROR = 'UPDATE_ERROR'
64
- module.exports.EVENT.USER_ERROR = 'USER_ERROR'
65
- module.exports.EVENT.REF_ERROR = 'REF_ERROR'
66
- module.exports.EVENT.PROVIDER_EXISTS = 'PROVIDER_EXISTS'
67
- module.exports.EVENT.NOT_LISTENING = 'NOT_LISTENING'
68
- module.exports.EVENT.NOT_PROVIDING = 'NOT_PROVIDING'
69
- module.exports.EVENT.LISTENER_ERROR = 'LISTENER_ERROR'
70
- module.exports.EVENT.TOO_MANY_AUTH_ATTEMPTS = 'TOO_MANY_AUTH_ATTEMPTS'
71
- module.exports.EVENT.IS_CLOSED = 'IS_CLOSED'
72
- module.exports.EVENT.RECORD_NOT_FOUND = 'RECORD_NOT_FOUND'
73
- module.exports.EVENT.NOT_SUBSCRIBED = 'NOT_SUBSCRIBED'
45
+ export const EVENT = {}
46
+ EVENT.CONNECTION_ERROR = 'connectionError'
47
+ EVENT.CONNECTION_STATE_CHANGED = 'connectionStateChanged'
48
+ EVENT.CONNECTED = 'connected'
49
+ EVENT.MAX_RECONNECTION_ATTEMPTS_REACHED = 'MAX_RECONNECTION_ATTEMPTS_REACHED'
50
+ EVENT.CONNECTION_AUTHENTICATION_TIMEOUT = 'CONNECTION_AUTHENTICATION_TIMEOUT'
51
+ EVENT.NO_RPC_PROVIDER = 'NO_RPC_PROVIDER'
52
+ EVENT.RPC_ERROR = 'RPC_ERROR'
53
+ EVENT.TIMEOUT = 'TIMEOUT'
54
+ EVENT.UNSOLICITED_MESSAGE = 'UNSOLICITED_MESSAGE'
55
+ EVENT.MESSAGE_DENIED = 'MESSAGE_DENIED'
56
+ EVENT.NOT_CONNECTED = 'NOT_CONNECTED'
57
+ EVENT.MESSAGE_PARSE_ERROR = 'MESSAGE_PARSE_ERROR'
58
+ EVENT.NOT_AUTHENTICATED = 'NOT_AUTHENTICATED'
59
+ EVENT.MESSAGE_PERMISSION_ERROR = 'MESSAGE_PERMISSION_ERROR'
60
+ EVENT.LISTENER_EXISTS = 'LISTENER_EXISTS'
61
+ EVENT.PROVIDER_ERROR = 'PROVIDER_ERROR'
62
+ EVENT.CACHE_ERROR = 'CACHE_ERROR'
63
+ EVENT.UPDATE_ERROR = 'UPDATE_ERROR'
64
+ EVENT.USER_ERROR = 'USER_ERROR'
65
+ EVENT.REF_ERROR = 'REF_ERROR'
66
+ EVENT.PROVIDER_EXISTS = 'PROVIDER_EXISTS'
67
+ EVENT.NOT_LISTENING = 'NOT_LISTENING'
68
+ EVENT.NOT_PROVIDING = 'NOT_PROVIDING'
69
+ EVENT.LISTENER_ERROR = 'LISTENER_ERROR'
70
+ EVENT.TOO_MANY_AUTH_ATTEMPTS = 'TOO_MANY_AUTH_ATTEMPTS'
71
+ EVENT.IS_CLOSED = 'IS_CLOSED'
72
+ EVENT.RECORD_NOT_FOUND = 'RECORD_NOT_FOUND'
73
+ EVENT.NOT_SUBSCRIBED = 'NOT_SUBSCRIBED'
74
74
 
75
- module.exports.ACTIONS = {}
76
- module.exports.ACTIONS.PING = 'PI'
77
- module.exports.ACTIONS.PONG = 'PO'
78
- module.exports.ACTIONS.ACK = 'A'
79
- module.exports.ACTIONS.REDIRECT = 'RED'
80
- module.exports.ACTIONS.CHALLENGE = 'CH'
81
- module.exports.ACTIONS.CHALLENGE_RESPONSE = 'CHR'
82
- module.exports.ACTIONS.READ = 'R'
83
- module.exports.ACTIONS.UPDATE = 'U'
84
- module.exports.ACTIONS.SUBSCRIBE = 'S'
85
- module.exports.ACTIONS.SYNC = 'SY'
86
- module.exports.ACTIONS.UNSUBSCRIBE = 'US'
87
- module.exports.ACTIONS.SUBSCRIPTION_FOR_PATTERN_FOUND = 'SP'
88
- module.exports.ACTIONS.SUBSCRIPTION_FOR_PATTERN_REMOVED = 'SR'
89
- module.exports.ACTIONS.SUBSCRIPTION_HAS_PROVIDER = 'SH'
90
- module.exports.ACTIONS.LISTEN = 'L'
91
- module.exports.ACTIONS.UNLISTEN = 'UL'
92
- module.exports.ACTIONS.LISTEN_ACCEPT = 'LA'
93
- module.exports.ACTIONS.LISTEN_REJECT = 'LR'
94
- module.exports.ACTIONS.EVENT = 'EVT'
95
- module.exports.ACTIONS.ERROR = 'E'
96
- module.exports.ACTIONS.REQUEST = 'REQ'
97
- module.exports.ACTIONS.RESPONSE = 'RES'
98
- module.exports.ACTIONS.REJECTION = 'REJ'
75
+ export const ACTIONS = {}
76
+ ACTIONS.PING = 'PI'
77
+ ACTIONS.PONG = 'PO'
78
+ ACTIONS.ACK = 'A'
79
+ ACTIONS.REDIRECT = 'RED'
80
+ ACTIONS.CHALLENGE = 'CH'
81
+ ACTIONS.CHALLENGE_RESPONSE = 'CHR'
82
+ ACTIONS.READ = 'R'
83
+ ACTIONS.UPDATE = 'U'
84
+ ACTIONS.SUBSCRIBE = 'S'
85
+ ACTIONS.SYNC = 'SY'
86
+ ACTIONS.UNSUBSCRIBE = 'US'
87
+ ACTIONS.SUBSCRIPTION_FOR_PATTERN_FOUND = 'SP'
88
+ ACTIONS.SUBSCRIPTION_FOR_PATTERN_REMOVED = 'SR'
89
+ ACTIONS.SUBSCRIPTION_HAS_PROVIDER = 'SH'
90
+ ACTIONS.LISTEN = 'L'
91
+ ACTIONS.UNLISTEN = 'UL'
92
+ ACTIONS.LISTEN_ACCEPT = 'LA'
93
+ ACTIONS.LISTEN_REJECT = 'LR'
94
+ ACTIONS.EVENT = 'EVT'
95
+ ACTIONS.ERROR = 'E'
96
+ ACTIONS.REQUEST = 'REQ'
97
+ ACTIONS.RESPONSE = 'RES'
98
+ ACTIONS.REJECTION = 'REJ'
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  reconnectIntervalIncrement: 1e3,
3
3
  maxReconnectInterval: 6e3,
4
4
  maxReconnectAttempts: Infinity,
@@ -1,10 +1,10 @@
1
- const messageBuilder = require('../message/message-builder')
2
- const messageParser = require('../message/message-parser')
3
- const C = require('../constants/constants')
4
- const MulticastListener = require('../utils/multicast-listener')
5
- const UnicastListener = require('../utils/unicast-listener')
6
- const EventEmitter = require('component-emitter2')
7
- const rxjs = require('rxjs')
1
+ import * as C from '../constants/constants.js'
2
+ import * as messageBuilder from '../message/message-builder.js'
3
+ import messageParser from '../message/message-parser.js'
4
+ import MulticastListener from '../utils/multicast-listener.js'
5
+ import UnicastListener from '../utils/unicast-listener.js'
6
+ import EventEmitter from 'component-emitter2'
7
+ import rxjs from 'rxjs'
8
8
 
9
9
  const EventHandler = function (options, connection, client) {
10
10
  this._options = options
@@ -164,4 +164,4 @@ EventHandler.prototype._onConnectionStateChange = function (connected) {
164
164
  }
165
165
  }
166
166
 
167
- module.exports = EventHandler
167
+ export default EventHandler
@@ -1,13 +1,15 @@
1
+ import * as utils from '../utils/utils.js'
2
+ import messageParser from './message-parser.js'
3
+ import * as messageBuilder from './message-builder.js'
4
+ import * as C from '../constants/constants.js'
5
+ import xxhash from 'xxhash-wasm'
6
+ import FixedQueue from '../utils/fixed-queue.js'
7
+ import Emitter from 'component-emitter2'
8
+
1
9
  const BrowserWebSocket = globalThis.WebSocket || globalThis.MozWebSocket
2
- const utils = require('../utils/utils')
3
- const NodeWebSocket = utils.isNode ? require('ws') : null
4
- const messageParser = require('./message-parser')
5
- const messageBuilder = require('./message-builder')
6
- const C = require('../constants/constants')
7
- const pkg = require('../../package.json')
8
- const xxhash = require('xxhash-wasm')
9
- const FixedQueue = require('../utils/fixed-queue')
10
- const Emitter = require('component-emitter2')
10
+ const NodeWebSocket = utils.isNode ? await import('ws').then((x) => x.default) : null
11
+
12
+ const HASHER = await xxhash()
11
13
 
12
14
  const Connection = function (client, url, options) {
13
15
  this._client = client
@@ -30,7 +32,6 @@ const Connection = function (client, url, options) {
30
32
  this._recvQueue = new FixedQueue()
31
33
  this._reconnectTimeout = null
32
34
  this._reconnectionAttempt = 0
33
- this._endpoint = null
34
35
 
35
36
  this._processingRecv = false
36
37
  this._recvMessages = this._recvMessages.bind(this)
@@ -39,11 +40,9 @@ const Connection = function (client, url, options) {
39
40
 
40
41
  this._state = C.CONNECTION_STATE.CLOSED
41
42
 
42
- this.hasher = null
43
- xxhash().then((hasher) => {
44
- this.hasher = hasher
45
- this._createEndpoint()
46
- })
43
+ this.hasher = HASHER
44
+
45
+ this._createEndpoint()
47
46
  }
48
47
 
49
48
  Emitter(Connection.prototype)
@@ -171,7 +170,7 @@ Connection.prototype._sendAuthParams = function () {
171
170
  this._setState(C.CONNECTION_STATE.AUTHENTICATING)
172
171
  const authMessage = messageBuilder.getMsg(C.TOPIC.AUTH, C.ACTIONS.REQUEST, [
173
172
  this._authParams,
174
- pkg.version,
173
+ '24.3.1', // TODO (fix): How to read from package.json?
175
174
  utils.isNode
176
175
  ? `Node/${process.version}`
177
176
  : globalThis.navigator && globalThis.navigator.userAgent,
@@ -365,4 +364,4 @@ Connection.prototype._clearReconnect = function () {
365
364
  this._reconnectionAttempt = 0
366
365
  }
367
366
 
368
- module.exports = Connection
367
+ export default Connection
@@ -1,4 +1,4 @@
1
- const C = require('../constants/constants')
1
+ import * as C from '../constants/constants.js'
2
2
 
3
3
  const poolEncoder = new TextEncoder()
4
4
 
@@ -24,7 +24,7 @@ function alignPool() {
24
24
 
25
25
  reallocPool()
26
26
 
27
- module.exports.getMsg = function (topic, action, data) {
27
+ export function getMsg(topic, action, data) {
28
28
  if (data && !(data instanceof Array)) {
29
29
  throw new Error('data must be an array')
30
30
  }
@@ -69,14 +69,14 @@ module.exports.getMsg = function (topic, action, data) {
69
69
 
70
70
  if (poolOffset >= poolBuffer.length) {
71
71
  reallocPool(start === 0 ? poolSize * 2 : poolSize)
72
- return this.getMsg(topic, action, data)
72
+ return getMsg(topic, action, data)
73
73
  }
74
74
  }
75
75
  }
76
76
  return new Uint8Array(poolBuffer.buffer, start, poolOffset - start)
77
77
  }
78
78
 
79
- module.exports.typed = function (value) {
79
+ export function typed(value) {
80
80
  const type = typeof value
81
81
 
82
82
  if (type === 'string') {
@@ -1,4 +1,4 @@
1
- const C = require('../constants/constants')
1
+ import * as C from '../constants/constants.js'
2
2
 
3
3
  const MessageParser = function () {
4
4
  this._actions = this._getActions()
@@ -88,4 +88,4 @@ MessageParser.prototype.parseMessage = function (message, client, result) {
88
88
  result.data = parts.splice(2)
89
89
  }
90
90
 
91
- module.exports = new MessageParser()
91
+ export default new MessageParser()
@@ -1,15 +1,15 @@
1
- const Record = require('./record')
2
- const MulticastListener = require('../utils/multicast-listener')
3
- const UnicastListener = require('../utils/unicast-listener')
4
- const C = require('../constants/constants')
5
- const rxjs = require('rxjs')
6
- const invariant = require('invariant')
7
- const EventEmitter = require('component-emitter2')
8
- const jsonPath = require('@nxtedition/json-path')
9
- const utils = require('../utils/utils')
10
- const rx = require('rxjs/operators')
11
- const xuid = require('xuid')
12
- const timers = require('../utils/timers')
1
+ import Record from './record.js'
2
+ import MulticastListener from '../utils/multicast-listener.js'
3
+ import UnicastListener from '../utils/unicast-listener.js'
4
+ import * as C from '../constants/constants.js'
5
+ import rxjs from 'rxjs'
6
+ import invariant from 'invariant'
7
+ import EventEmitter from 'component-emitter2'
8
+ import jsonPath from '@nxtedition/json-path'
9
+ import * as utils from '../utils/utils.js'
10
+ import rx from 'rxjs/operators'
11
+ import xuid from 'xuid'
12
+ import * as timers from '../utils/timers.js'
13
13
 
14
14
  const kEmpty = Symbol('kEmpty')
15
15
 
@@ -650,4 +650,4 @@ class RecordHandler {
650
650
  }
651
651
  }
652
652
 
653
- module.exports = RecordHandler
653
+ export default RecordHandler
@@ -1,11 +1,13 @@
1
- const jsonPath = require('@nxtedition/json-path')
2
- const utils = require('../utils/utils')
3
- const C = require('../constants/constants')
4
- const messageParser = require('../message/message-parser')
5
- const xuid = require('xuid')
6
- const invariant = require('invariant')
7
- const cloneDeep = require('lodash.clonedeep')
8
- const timers = require('../utils/timers')
1
+ import jsonPath from '@nxtedition/json-path'
2
+ import * as utils from '../utils/utils.js'
3
+ import * as C from '../constants/constants.js'
4
+ import messageParser from '../message/message-parser.js'
5
+ import xuid from 'xuid'
6
+ import invariant from 'invariant'
7
+ import cloneDeep from 'lodash.clonedeep'
8
+ import * as timers from '../utils/timers.js'
9
+
10
+ // const encoder = new TextEncoder()
9
11
 
10
12
  class Record {
11
13
  static STATE = C.RECORD_STATE
@@ -15,14 +17,20 @@ class Record {
15
17
 
16
18
  this._handler = handler
17
19
 
20
+ // TODO (fix): Implement this once we have binary header.
21
+ // this._key = name.length <= 8 && encoder.encode(name).byteLength === 8
22
+ // ? name
23
+ // : connection.hasher?.h64(name)
24
+
18
25
  this._name = name
19
- this._key = connection.hasher?.h64(name) ?? name
26
+ this._key = name
20
27
  this._version = ''
21
28
  this._data = jsonPath.EMPTY
22
29
  this._state = C.RECORD_STATE.VOID
23
30
  this._refs = 0
24
31
  this._subscriptions = []
25
32
  this._emitting = false
33
+
26
34
  /** @type Map? */ this._updating = null
27
35
  /** @type Array? */ this._patching = null
28
36
  this._subscribed = connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, [
@@ -328,7 +336,6 @@ class Record {
328
336
  const connection = this._handler._connection
329
337
 
330
338
  if (connected) {
331
- this._key = typeof this._key === 'bigint' ? this._key : connection.hasher?.h64(this._name)
332
339
  this._subscribed =
333
340
  this._refs > 0 &&
334
341
  connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, [this._name, this._key])
@@ -579,4 +586,4 @@ Object.defineProperty(Record.prototype, 'hasProvider', {
579
586
  },
580
587
  })
581
588
 
582
- module.exports = Record
589
+ export default Record
@@ -1,8 +1,8 @@
1
- const C = require('../constants/constants')
2
- const RpcResponse = require('./rpc-response')
3
- const messageParser = require('../message/message-parser')
4
- const messageBuilder = require('../message/message-builder')
5
- const xuid = require('xuid')
1
+ import * as C from '../constants/constants.js'
2
+ import RpcResponse from './rpc-response.js'
3
+ import messageParser from '../message/message-parser.js'
4
+ import * as messageBuilder from '../message/message-builder.js'
5
+ import xuid from 'xuid'
6
6
 
7
7
  const RpcHandler = function (options, connection, client) {
8
8
  this._options = options
@@ -175,4 +175,4 @@ RpcHandler.prototype._onConnectionStateChange = function (connected) {
175
175
  }
176
176
  }
177
177
 
178
- module.exports = RpcHandler
178
+ export default RpcHandler
@@ -1,5 +1,5 @@
1
- const C = require('../constants/constants')
2
- const messageBuilder = require('../message/message-builder')
1
+ import * as C from '../constants/constants.js'
2
+ import * as messageBuilder from '../message/message-builder.js'
3
3
 
4
4
  const RpcResponse = function (connection, name, id) {
5
5
  this._connection = connection
@@ -44,4 +44,4 @@ RpcResponse.prototype.send = function (data) {
44
44
  ])
45
45
  }
46
46
 
47
- module.exports = RpcResponse
47
+ export default RpcResponse
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  // Currently optimal queue size, tested on V8 6.0 - 6.6. Must be power of two.
4
2
  const kSize = 2048
5
3
  const kMask = kSize - 1
@@ -82,7 +80,7 @@ class FixedCircularBuffer {
82
80
  }
83
81
  }
84
82
 
85
- module.exports = class FixedQueue {
83
+ export default class FixedQueue {
86
84
  constructor() {
87
85
  this.head = this.tail = new FixedCircularBuffer()
88
86
  }
@@ -1,5 +1,5 @@
1
- const C = require('../constants/constants')
2
- const rxjs = require('rxjs')
1
+ import * as C from '../constants/constants.js'
2
+ import rxjs from 'rxjs'
3
3
 
4
4
  class Listener {
5
5
  constructor(topic, pattern, callback, handler, { recursive = false, stringify = null } = {}) {
@@ -229,4 +229,4 @@ class Listener {
229
229
  }
230
230
  }
231
231
 
232
- module.exports = Listener
232
+ export default Listener
@@ -1,7 +1,3 @@
1
- // undici timers
2
-
3
- 'use strict'
4
-
5
1
  let fastNow = Date.now()
6
2
  let fastNowTimeout
7
3
 
@@ -44,8 +40,8 @@ function refreshTimeout() {
44
40
  if (fastNowTimeout && fastNowTimeout.refresh) {
45
41
  fastNowTimeout.refresh()
46
42
  } else {
47
- clearTimeout(fastNowTimeout)
48
- fastNowTimeout = setTimeout(onTimeout, 1e3)
43
+ globalThis.clearTimeout(fastNowTimeout)
44
+ fastNowTimeout = globalThis.setTimeout(onTimeout, 1e3)
49
45
  if (fastNowTimeout.unref) {
50
46
  fastNowTimeout.unref()
51
47
  }
@@ -83,15 +79,16 @@ class Timeout {
83
79
  }
84
80
  }
85
81
 
86
- module.exports = {
87
- setTimeout(callback, delay, opaque) {
88
- return delay < 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque)
89
- },
90
- clearTimeout(timeout) {
91
- if (timeout instanceof Timeout) {
92
- timeout.clear()
93
- } else {
94
- clearTimeout(timeout)
95
- }
96
- },
82
+ export function setTimeout(callback, delay, opaque) {
83
+ return delay < 1e3
84
+ ? globalThis.setTimeout(callback, delay, opaque)
85
+ : new Timeout(callback, delay, opaque)
86
+ }
87
+
88
+ export function clearTimeout(timeout) {
89
+ if (timeout instanceof Timeout) {
90
+ timeout.clear()
91
+ } else {
92
+ globalThis.clearTimeout(timeout)
93
+ }
97
94
  }
@@ -1,6 +1,6 @@
1
- const C = require('../constants/constants')
2
- const rx = require('rxjs/operators')
3
- const rxjs = require('rxjs')
1
+ import * as C from '../constants/constants.js'
2
+ import rx from 'rxjs/operators'
3
+ import rxjs from 'rxjs'
4
4
 
5
5
  const PIPE = rxjs.pipe(
6
6
  rx.map((value) => {
@@ -127,4 +127,4 @@ class Listener {
127
127
  }
128
128
  }
129
129
 
130
- module.exports = Listener
130
+ export default Listener
@@ -1,11 +1,8 @@
1
1
  const NODE_ENV = typeof process !== 'undefined' && process.env && process.env.NODE_ENV
2
- const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
3
- const isProduction = NODE_ENV === 'production'
2
+ export const isNode = typeof process !== 'undefined' && process.toString() === '[object process]'
3
+ export const isProduction = NODE_ENV === 'production'
4
4
 
5
- module.exports.isNode = isNode
6
- module.exports.isProduction = isProduction
7
-
8
- module.exports.deepFreeze = function (o) {
5
+ export function deepFreeze(o) {
9
6
  if (isProduction) {
10
7
  return o
11
8
  }
@@ -16,12 +13,12 @@ module.exports.deepFreeze = function (o) {
16
13
 
17
14
  Object.freeze(o)
18
15
 
19
- Object.getOwnPropertyNames(o).forEach((prop) => module.exports.deepFreeze(o[prop]))
16
+ Object.getOwnPropertyNames(o).forEach((prop) => deepFreeze(o[prop]))
20
17
 
21
18
  return o
22
19
  }
23
20
 
24
- module.exports.splitRev = function (s) {
21
+ export function splitRev(s) {
25
22
  if (!s) {
26
23
  return [-1, '00000000000000']
27
24
  }
@@ -32,7 +29,7 @@ module.exports.splitRev = function (s) {
32
29
  return [ver.charAt(0) === 'I' ? Infinity : parseInt(ver, 10), s.slice(i + 1)]
33
30
  }
34
31
 
35
- module.exports.isPlainObject = function (value, isPlainJSON) {
32
+ export function isPlainObject(value, isPlainJSON) {
36
33
  if (isPlainJSON) {
37
34
  return value && typeof value === 'object' && !Array.isArray(value)
38
35
  }
@@ -53,13 +50,13 @@ module.exports.isPlainObject = function (value, isPlainJSON) {
53
50
  return Object.getPrototypeOf(value) === proto
54
51
  }
55
52
 
56
- module.exports.isSameOrNewer = function (a, b) {
57
- const [av, ar] = module.exports.splitRev(a)
58
- const [bv, br] = module.exports.splitRev(b)
53
+ export function isSameOrNewer(a, b) {
54
+ const [av, ar] = splitRev(a)
55
+ const [bv, br] = splitRev(b)
59
56
  return av > bv || (av === bv && ar >= br)
60
57
  }
61
58
 
62
- module.exports.shallowCopy = function (obj) {
59
+ export function shallowCopy(obj) {
63
60
  if (Array.isArray(obj)) {
64
61
  return obj.slice(0)
65
62
  }
@@ -72,15 +69,15 @@ module.exports.shallowCopy = function (obj) {
72
69
  return copy
73
70
  }
74
71
 
75
- module.exports.setTimeout = function (callback, timeoutDuration) {
72
+ export function setTimeout(callback, timeoutDuration) {
76
73
  if (timeoutDuration !== null) {
77
- return setTimeout(callback, timeoutDuration)
74
+ return globalThis.setTimeout(callback, timeoutDuration)
78
75
  } else {
79
76
  return -1
80
77
  }
81
78
  }
82
79
 
83
- module.exports.setInterval = function (callback, intervalDuration) {
80
+ export function setInterval(callback, intervalDuration) {
84
81
  if (intervalDuration !== null) {
85
82
  return setInterval(callback, intervalDuration)
86
83
  } else {
@@ -88,7 +85,7 @@ module.exports.setInterval = function (callback, intervalDuration) {
88
85
  }
89
86
  }
90
87
 
91
- module.exports.compareRev = function compareRev(a, b) {
88
+ export function compareRev(a, b) {
92
89
  if (!a) {
93
90
  return b ? -1 : 0
94
91
  }
@@ -118,7 +115,7 @@ module.exports.compareRev = function compareRev(a, b) {
118
115
  return 0
119
116
  }
120
117
 
121
- module.exports.AbortError = class AbortError extends Error {
118
+ export class AbortError extends Error {
122
119
  constructor() {
123
120
  super('The operation was aborted')
124
121
  this.code = 'ABORT_ERR'
@@ -130,7 +127,7 @@ function defaultSchedule(fn) {
130
127
  setTimeout(fn, 0)
131
128
  }
132
129
 
133
- module.exports.schedule = isNode ? defaultSchedule : window.requestIdleCallback
130
+ export const schedule = isNode ? defaultSchedule : window.requestIdleCallback
134
131
 
135
132
  const abortSignals = new WeakMap()
136
133
  const onAbort = function () {
@@ -142,7 +139,7 @@ const onAbort = function () {
142
139
  }
143
140
  }
144
141
 
145
- module.exports.addAbortListener = function addAbortListener(signal, handler) {
142
+ export function addAbortListener(signal, handler) {
146
143
  if (!signal) {
147
144
  return
148
145
  }
@@ -160,7 +157,7 @@ module.exports.addAbortListener = function addAbortListener(signal, handler) {
160
157
  }
161
158
  }
162
159
 
163
- module.exports.removeAbortListener = function removeAbortListener(signal, handler) {
160
+ export function removeAbortListener(signal, handler) {
164
161
  if (!signal) {
165
162
  return
166
163
  }