@nxtedition/deepstream.io-client-js 32.0.20 → 32.0.21
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": "32.0.
|
|
3
|
+
"version": "32.0.21",
|
|
4
4
|
"description": "the javascript client for deepstream.io",
|
|
5
5
|
"homepage": "http://deepstream.io",
|
|
6
6
|
"type": "module",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"singleQuote": true
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nxtedition/json-path": "1.0.
|
|
40
|
-
"bufferutil": "4.0.8",
|
|
41
|
-
"component-emitter2": "1.3.5",
|
|
42
|
-
"invariant": "2.2.4",
|
|
43
|
-
"lodash.clonedeep": "4.5.0",
|
|
44
|
-
"utf-8-validate": "6.0.
|
|
45
|
-
"varint": "6.0.0",
|
|
46
|
-
"ws": "8.
|
|
47
|
-
"xuid": "4.1.
|
|
48
|
-
"xxhash-wasm": "^1.
|
|
39
|
+
"@nxtedition/json-path": "^1.0.8",
|
|
40
|
+
"bufferutil": "^4.0.8",
|
|
41
|
+
"component-emitter2": "^1.3.5",
|
|
42
|
+
"invariant": "^2.2.4",
|
|
43
|
+
"lodash.clonedeep": "^4.5.0",
|
|
44
|
+
"utf-8-validate": "^6.0.5",
|
|
45
|
+
"varint": "^6.0.0",
|
|
46
|
+
"ws": "^8.18.0",
|
|
47
|
+
"xuid": "^4.1.3",
|
|
48
|
+
"xxhash-wasm": "^1.0.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.10.3",
|
package/src/client.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Paths, Get } from './record/record.js'
|
|
|
3
3
|
import type RecordHandler from './record/record-handler.js'
|
|
4
4
|
import type { RecordStats, ProvideOptions, SyncOptions } from './record/record-handler.js'
|
|
5
5
|
import type EventHandler from './event/event-handler.js'
|
|
6
|
-
import type { EventStats } from './event/event-handler.js'
|
|
6
|
+
import type { EventStats, EventProvideOptions } from './event/event-handler.js'
|
|
7
7
|
import type RpcHandler from './rpc/rpc-handler.js'
|
|
8
8
|
import type { RpcStats, RpcMethodDef } from './rpc/rpc-handler.js'
|
|
9
9
|
|
|
@@ -30,6 +30,7 @@ export type {
|
|
|
30
30
|
RpcHandler,
|
|
31
31
|
RpcMethodDef,
|
|
32
32
|
ProvideOptions,
|
|
33
|
+
EventProvideOptions,
|
|
33
34
|
SyncOptions,
|
|
34
35
|
Paths,
|
|
35
36
|
Get,
|
|
@@ -4,7 +4,7 @@ export default class EventHandler {
|
|
|
4
4
|
connected: boolean
|
|
5
5
|
stats: EventStats
|
|
6
6
|
subscribe: (name: string, callback: (data: unknown) => void) => void
|
|
7
|
-
unsubscribe: (name: string, callback
|
|
7
|
+
unsubscribe: (name: string, callback?: (data: unknown) => void) => void
|
|
8
8
|
on: (name: string, callback: (data: unknown) => void) => this
|
|
9
9
|
once: (name: string, callback: (data: unknown) => void) => this
|
|
10
10
|
off: (name: string, callback: (data: unknown) => void) => this
|
|
@@ -13,10 +13,15 @@ export default class EventHandler {
|
|
|
13
13
|
provide: (
|
|
14
14
|
pattern: string,
|
|
15
15
|
callback: (name: string) => void,
|
|
16
|
-
options:
|
|
16
|
+
options: EventProvideOptions,
|
|
17
17
|
) => (() => void) | void
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export interface EventProvideOptions {
|
|
21
|
+
mode?: 'unicast' | (string & {})
|
|
22
|
+
stringify?: ((input: unknown) => string) | null
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
export interface EventStats {
|
|
21
26
|
emitted: number
|
|
22
27
|
listeners: number
|
|
@@ -71,21 +71,21 @@ EventHandler.prototype.unsubscribe = function (name, callback) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
EventHandler.on = function (name, callback) {
|
|
74
|
+
EventHandler.prototype.on = function (name, callback) {
|
|
75
75
|
this.subscribe(name, callback)
|
|
76
76
|
return this
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
EventHandler.once = function (name, callback) {
|
|
79
|
+
EventHandler.prototype.once = function (name, callback) {
|
|
80
80
|
const fn = (...args) => {
|
|
81
|
-
this.unsubscribe(fn)
|
|
81
|
+
this.unsubscribe(name, fn)
|
|
82
82
|
callback(...args)
|
|
83
83
|
}
|
|
84
84
|
this.subscribe(name, fn)
|
|
85
85
|
return this
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
EventHandler.off = function (name, callback) {
|
|
88
|
+
EventHandler.prototype.off = function (name, callback) {
|
|
89
89
|
this.unsubscribe(name, callback)
|
|
90
90
|
return this
|
|
91
91
|
}
|
|
@@ -42,6 +42,37 @@ export default class RecordHandler<Records = Record<string, unknown>> {
|
|
|
42
42
|
optionsOrRecursive?: ProvideOptions | boolean,
|
|
43
43
|
) => Disposer | void
|
|
44
44
|
|
|
45
|
+
put: (
|
|
46
|
+
name: string,
|
|
47
|
+
version: string,
|
|
48
|
+
data: Record<string, unknown> | null,
|
|
49
|
+
parent?: string,
|
|
50
|
+
) => void
|
|
51
|
+
|
|
52
|
+
getAsync: {
|
|
53
|
+
<Name extends string>(
|
|
54
|
+
name: Name,
|
|
55
|
+
options: ObserveOptions,
|
|
56
|
+
):
|
|
57
|
+
| { value: Lookup<Records, Name>; async: false }
|
|
58
|
+
| { value: Promise<Lookup<Records, Name>>; async: true }
|
|
59
|
+
|
|
60
|
+
<Name extends string, Path extends string | string[]>(
|
|
61
|
+
name: Name,
|
|
62
|
+
path: Path,
|
|
63
|
+
options?: ObserveOptions,
|
|
64
|
+
):
|
|
65
|
+
| { value: Get<Lookup<Records, Name>, Path>; async: false }
|
|
66
|
+
| { value: Promise<Get<Lookup<Records, Name>, Path>>; async: true }
|
|
67
|
+
|
|
68
|
+
<Name extends string>(
|
|
69
|
+
name: Name,
|
|
70
|
+
state?: number,
|
|
71
|
+
):
|
|
72
|
+
| { value: Lookup<Records, Name>; async: false }
|
|
73
|
+
| { value: Promise<Lookup<Records, Name>>; async: true }
|
|
74
|
+
}
|
|
75
|
+
|
|
45
76
|
sync: (options?: SyncOptions) => Promise<void>
|
|
46
77
|
|
|
47
78
|
set: {
|
|
@@ -287,12 +318,13 @@ export interface RecordStats {
|
|
|
287
318
|
pruning: number
|
|
288
319
|
patching: number
|
|
289
320
|
subscriptions: number
|
|
321
|
+
listeners: number
|
|
290
322
|
}
|
|
291
323
|
|
|
292
324
|
export interface ProvideOptions {
|
|
293
325
|
recursive?: boolean
|
|
294
326
|
stringify?: ((input: unknown) => string) | null
|
|
295
|
-
mode
|
|
327
|
+
mode?: null | 'unicast' | (string & {})
|
|
296
328
|
}
|
|
297
329
|
|
|
298
330
|
export interface SyncOptions {
|
package/src/record/record.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export default class Record<Data = unknown> {
|
|
|
60
60
|
get: {
|
|
61
61
|
// with path
|
|
62
62
|
<P extends string | string[]>(path: P): Get<Data, P>
|
|
63
|
+
// with function mapper
|
|
64
|
+
<R>(fn: (data: Data) => R): R
|
|
63
65
|
// without path
|
|
64
66
|
(): Data
|
|
65
67
|
(path: undefined | string | string[]): unknown
|
package/src/rpc/rpc-handler.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default class RpcHandler<
|
|
|
13
13
|
callback: (
|
|
14
14
|
args: Methods[Name][0],
|
|
15
15
|
response: RpcResponse<Methods[Name][1]>,
|
|
16
|
-
) => Methods[Name][1] | Promise<Methods[Name][1]> | void,
|
|
16
|
+
) => Methods[Name][1] | Promise<Methods[Name][1]> | Promise<void> | void,
|
|
17
17
|
) => UnprovideFn | void
|
|
18
18
|
|
|
19
19
|
unprovide: <Name extends keyof Methods>(name: Name) => void
|
package/src/utils/utils.js
CHANGED
|
@@ -83,14 +83,6 @@ export function setTimeout(callback, timeoutDuration) {
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export function setInterval(callback, intervalDuration) {
|
|
87
|
-
if (intervalDuration !== null) {
|
|
88
|
-
return setInterval(callback, intervalDuration)
|
|
89
|
-
} else {
|
|
90
|
-
return -1
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
86
|
export function compareRev(a, b) {
|
|
95
87
|
if (!a) {
|
|
96
88
|
return b ? -1 : 0
|