vrpc 3.5.0 → 3.5.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/browser/vrpc.js +6 -6
- package/browser/vrpc.js.LICENSE.txt +10 -1
- package/package.json +2 -2
- package/vrpc/VrpcAdapter.js +0 -13
- package/vrpc/VrpcClient.js +14 -1
|
@@ -1 +1,10 @@
|
|
|
1
|
-
/*!
|
|
1
|
+
/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
9
|
+
|
|
10
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vrpc",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "Variadic Remote Procedure Calls",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"buffer": "^6.0.3",
|
|
74
74
|
"caller": "^1.1.0",
|
|
75
75
|
"json-stringify-safe": "^5.0.1",
|
|
76
|
-
"mqtt": "^
|
|
76
|
+
"mqtt": "^4.3.7",
|
|
77
77
|
"nanoid": "^3.3.8",
|
|
78
78
|
"process": "^0.11.10"
|
|
79
79
|
},
|
package/vrpc/VrpcAdapter.js
CHANGED
|
@@ -547,11 +547,6 @@ class VrpcAdapter {
|
|
|
547
547
|
return
|
|
548
548
|
}
|
|
549
549
|
const unwrapped = VrpcAdapter._unwrapArguments(json)
|
|
550
|
-
if (!unwrapped) {
|
|
551
|
-
// this call must be skipped (event emitter stuff)
|
|
552
|
-
json.r = true
|
|
553
|
-
return
|
|
554
|
-
}
|
|
555
550
|
// Check whether context is a registered class
|
|
556
551
|
const entry = VrpcAdapter._functionRegistry.get(json.c)
|
|
557
552
|
if (entry !== undefined) {
|
|
@@ -680,9 +675,6 @@ class VrpcAdapter {
|
|
|
680
675
|
eventId: arg,
|
|
681
676
|
event: args[0]
|
|
682
677
|
})
|
|
683
|
-
if (!listener) {
|
|
684
|
-
return null // skip call as listener is already registered
|
|
685
|
-
}
|
|
686
678
|
unwrapped.push(listener)
|
|
687
679
|
// event un-registration
|
|
688
680
|
} else if (func === 'off' || func === 'removeListener') {
|
|
@@ -691,9 +683,6 @@ class VrpcAdapter {
|
|
|
691
683
|
instanceId: context,
|
|
692
684
|
eventId: arg
|
|
693
685
|
})
|
|
694
|
-
if (!listener) {
|
|
695
|
-
return null // skip call as others are still interested
|
|
696
|
-
}
|
|
697
686
|
unwrapped.push(listener)
|
|
698
687
|
} else {
|
|
699
688
|
this._mustTrackClient = true
|
|
@@ -759,8 +748,6 @@ class VrpcAdapter {
|
|
|
759
748
|
return VrpcAdapter._listeners[instanceId][eventId].listener
|
|
760
749
|
}
|
|
761
750
|
VrpcAdapter._listeners[instanceId][eventId].clients.push(clientId)
|
|
762
|
-
// if "event" is defined we are calling against a plain EventEmitter and
|
|
763
|
-
// have to skip this call as we have registered internally
|
|
764
751
|
return VrpcAdapter._listeners[instanceId][eventId].listener
|
|
765
752
|
}
|
|
766
753
|
|
package/vrpc/VrpcClient.js
CHANGED
|
@@ -135,6 +135,7 @@ class VrpcClient extends EventEmitter {
|
|
|
135
135
|
this._cachedSubscriptions = {}
|
|
136
136
|
this._proxies = {}
|
|
137
137
|
this._callbackIds = new WeakMap()
|
|
138
|
+
this._emitterListener = new WeakMap()
|
|
138
139
|
if (log === 'console') {
|
|
139
140
|
this._log = console
|
|
140
141
|
this._log.debug = () => {}
|
|
@@ -1222,12 +1223,24 @@ class VrpcClient extends EventEmitter {
|
|
|
1222
1223
|
// special case of an EventEmitter provided as argument
|
|
1223
1224
|
if (this._isEmitter(x)) {
|
|
1224
1225
|
const { emitter, event } = x
|
|
1226
|
+
let callback = (...args) => emitter.emit(event, ...args)
|
|
1227
|
+
if (this._emitterListener.has(emitter)) {
|
|
1228
|
+
const eventMap = this._emitterListener.get(emitter)
|
|
1229
|
+
if (eventMap.has(event)) {
|
|
1230
|
+
callback = eventMap.get(event)
|
|
1231
|
+
} else {
|
|
1232
|
+
eventMap.set(event, callback)
|
|
1233
|
+
}
|
|
1234
|
+
} else {
|
|
1235
|
+
this._emitterListener.set(emitter, new Map([[event, callback]]))
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1225
1238
|
const id = this._onRemoteEvent({
|
|
1226
1239
|
agent,
|
|
1227
1240
|
className,
|
|
1228
1241
|
instance,
|
|
1229
1242
|
event,
|
|
1230
|
-
callback
|
|
1243
|
+
callback
|
|
1231
1244
|
})
|
|
1232
1245
|
wrapped.push(id)
|
|
1233
1246
|
continue
|