@nxtedition/deepstream.io-client-js 31.2.15 → 31.2.17
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,7 +1,7 @@
|
|
|
1
1
|
import * as C from '../constants/constants.js'
|
|
2
2
|
import * as messageBuilder from '../message/message-builder.js'
|
|
3
3
|
import * as messageParser from '../message/message-parser.js'
|
|
4
|
-
import
|
|
4
|
+
import LegacyListener from '../utils/legacy-listener.js'
|
|
5
5
|
import UnicastListener from '../utils/unicast-listener.js'
|
|
6
6
|
import EventEmitter from 'component-emitter2'
|
|
7
7
|
import * as rxjs from 'rxjs'
|
|
@@ -126,7 +126,7 @@ EventHandler.prototype.provide = function (pattern, callback, options) {
|
|
|
126
126
|
const listener =
|
|
127
127
|
options.mode?.toLowerCase() === 'unicast'
|
|
128
128
|
? new UnicastListener(C.TOPIC.EVENT, pattern, callback, this, options)
|
|
129
|
-
: new
|
|
129
|
+
: new LegacyListener(C.TOPIC.EVENT, pattern, callback, this, options)
|
|
130
130
|
|
|
131
131
|
this._listeners.set(pattern, listener)
|
|
132
132
|
return () => {
|
|
@@ -10,6 +10,11 @@ import type {
|
|
|
10
10
|
|
|
11
11
|
type Lookup<Table, Name> = Name extends keyof Table ? Table[Name] : unknown
|
|
12
12
|
|
|
13
|
+
type Disposer = {
|
|
14
|
+
(): void
|
|
15
|
+
[Symbol.dispose](): void
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
export default class RecordHandler<Records = Record<string, unknown>> {
|
|
14
19
|
VOID: 0
|
|
15
20
|
CLIENT: 1
|
|
@@ -41,7 +46,7 @@ export default class RecordHandler<Records = Record<string, unknown>> {
|
|
|
41
46
|
pattern: string,
|
|
42
47
|
callback: (key: string) => unknown,
|
|
43
48
|
optionsOrRecursive?: ProvideOptions | boolean,
|
|
44
|
-
) =>
|
|
49
|
+
) => Disposer
|
|
45
50
|
|
|
46
51
|
sync: (options?: SyncOptions) => Promise<void>
|
|
47
52
|
|
|
@@ -223,6 +228,7 @@ export interface RecordStats {
|
|
|
223
228
|
export interface ProvideOptions {
|
|
224
229
|
recursive?: boolean
|
|
225
230
|
stringify?: ((input: unknown) => string) | null
|
|
231
|
+
mode: undefined | null | 'unicast'
|
|
226
232
|
}
|
|
227
233
|
|
|
228
234
|
export interface SyncOptions {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Record from './record.js'
|
|
2
|
-
import
|
|
2
|
+
import LegacyListener from '../utils/legacy-listener.js'
|
|
3
3
|
import UnicastListener from '../utils/unicast-listener.js'
|
|
4
4
|
import * as C from '../constants/constants.js'
|
|
5
5
|
import * as rxjs from 'rxjs'
|
|
@@ -84,9 +84,18 @@ function onTimeout(subscription) {
|
|
|
84
84
|
|
|
85
85
|
subscription.subscriber.error(
|
|
86
86
|
Object.assign(
|
|
87
|
-
new Error(
|
|
87
|
+
new Error(
|
|
88
|
+
!subscription.synced
|
|
89
|
+
? `timeout sync: ${subscription.record.name}`
|
|
90
|
+
: `timeout state: ${subscription.record.name} [${current}<${expected}]`,
|
|
91
|
+
),
|
|
88
92
|
{
|
|
89
93
|
code: 'ETIMEDOUT',
|
|
94
|
+
timeout: subscription.timeoutValue,
|
|
95
|
+
expected,
|
|
96
|
+
current,
|
|
97
|
+
synced: subscription.synced,
|
|
98
|
+
name: subscription.record.name,
|
|
90
99
|
},
|
|
91
100
|
),
|
|
92
101
|
)
|
|
@@ -261,7 +270,7 @@ class RecordHandler {
|
|
|
261
270
|
const listener =
|
|
262
271
|
options.mode?.toLowerCase() === 'unicast'
|
|
263
272
|
? new UnicastListener(C.TOPIC.RECORD, pattern, callback, this, options)
|
|
264
|
-
: new
|
|
273
|
+
: new LegacyListener(C.TOPIC.RECORD, pattern, callback, this, options)
|
|
265
274
|
|
|
266
275
|
this._stats.listeners += 1
|
|
267
276
|
this._listeners.set(pattern, listener)
|
|
@@ -678,7 +687,6 @@ class RecordHandler {
|
|
|
678
687
|
subscription.record = this.getRecord(name).subscribe(onUpdate, subscription)
|
|
679
688
|
|
|
680
689
|
if (sync) {
|
|
681
|
-
// TODO (fix): What about sync timeout?
|
|
682
690
|
this._sync(onSync, sync === true ? 'WEAK' : sync, subscription)
|
|
683
691
|
} else {
|
|
684
692
|
onSync(subscription)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as rxjs from 'rxjs'
|
|
2
2
|
import * as C from '../constants/constants.js'
|
|
3
|
-
import { h64ToString, findBigIntPaths } from '
|
|
3
|
+
import { h64ToString, findBigIntPaths } from './utils.js'
|
|
4
4
|
|
|
5
5
|
export default class Listener {
|
|
6
6
|
constructor(topic, pattern, callback, handler, { recursive = false, stringify = null } = {}) {
|