vrpc 3.3.1 → 3.4.0
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 +1 -1
- package/vrpc/VrpcClient.js +4 -11
- package/vrpc/VrpcPersistor.js +12 -11
package/package.json
CHANGED
package/vrpc/VrpcClient.js
CHANGED
|
@@ -1081,8 +1081,6 @@ class VrpcClient extends EventEmitter {
|
|
|
1081
1081
|
event,
|
|
1082
1082
|
callback
|
|
1083
1083
|
})
|
|
1084
|
-
// indicate that no network call is required
|
|
1085
|
-
if (id === null) return null
|
|
1086
1084
|
wrapped.push(id)
|
|
1087
1085
|
continue
|
|
1088
1086
|
} else if (
|
|
@@ -1098,8 +1096,6 @@ class VrpcClient extends EventEmitter {
|
|
|
1098
1096
|
event,
|
|
1099
1097
|
callback
|
|
1100
1098
|
})
|
|
1101
|
-
// indicate that no network call is required
|
|
1102
|
-
if (id === null) return null
|
|
1103
1099
|
wrapped.push(id)
|
|
1104
1100
|
continue
|
|
1105
1101
|
} else {
|
|
@@ -1123,8 +1119,6 @@ class VrpcClient extends EventEmitter {
|
|
|
1123
1119
|
event,
|
|
1124
1120
|
callback: (...args) => emitter.emit(event, ...args)
|
|
1125
1121
|
})
|
|
1126
|
-
// indicate that no network call is required
|
|
1127
|
-
if (id === null) return null
|
|
1128
1122
|
wrapped.push(id)
|
|
1129
1123
|
continue
|
|
1130
1124
|
}
|
|
@@ -1153,8 +1147,7 @@ class VrpcClient extends EventEmitter {
|
|
|
1153
1147
|
}
|
|
1154
1148
|
// otherwise just add the new callback-handler pair
|
|
1155
1149
|
this._cachedSubscriptions[topic].push({ callback, handler })
|
|
1156
|
-
|
|
1157
|
-
return null
|
|
1150
|
+
return id
|
|
1158
1151
|
}
|
|
1159
1152
|
|
|
1160
1153
|
_offRemoteEvent ({ agent, className, instance, event, callback }) {
|
|
@@ -1177,8 +1170,7 @@ class VrpcClient extends EventEmitter {
|
|
|
1177
1170
|
delete this._cachedSubscriptions[topic]
|
|
1178
1171
|
return id
|
|
1179
1172
|
}
|
|
1180
|
-
|
|
1181
|
-
return null
|
|
1173
|
+
return id
|
|
1182
1174
|
} else {
|
|
1183
1175
|
this._log.warn(`Can not unsubscribe from non-existing event: ${event}`)
|
|
1184
1176
|
}
|
|
@@ -1225,7 +1217,8 @@ class VrpcClient extends EventEmitter {
|
|
|
1225
1217
|
|
|
1226
1218
|
_isEmitter (variable) {
|
|
1227
1219
|
return (
|
|
1228
|
-
variable &&
|
|
1220
|
+
variable &&
|
|
1221
|
+
typeof variable === 'object' &&
|
|
1229
1222
|
variable.hasOwnProperty('emitter') &&
|
|
1230
1223
|
variable.hasOwnProperty('event') &&
|
|
1231
1224
|
typeof variable.emitter === 'object' &&
|
package/vrpc/VrpcPersistor.js
CHANGED
|
@@ -38,7 +38,6 @@ SOFTWARE.
|
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
const VrpcAdapter = require('./VrpcAdapter')
|
|
41
|
-
const Storage = require('@heisenware/storage')
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
43
|
* Provides a persistence layer for VRPC instances.
|
|
@@ -55,19 +54,21 @@ class VrpcPersistor {
|
|
|
55
54
|
*
|
|
56
55
|
* @param {object} options Configuration options for the persistor.
|
|
57
56
|
* @param {VrpcAgent} options.agentInstance The VRPC agent whose instances should be persisted.
|
|
58
|
-
* @param {object} [options.log] Optional logger object (e.g., console) with info, warn, and error methods.
|
|
59
57
|
* @param {string} [options.dir] Optional directory for storage. Defaults to a path derived from the agent's name.
|
|
58
|
+
* @param {object} [options.log] Optional logger object (e.g. console) with info, warn, and error methods.
|
|
60
59
|
*/
|
|
61
|
-
constructor ({ agentInstance,
|
|
62
|
-
|
|
60
|
+
constructor ({ agentInstance, dir, log = console }) {
|
|
61
|
+
let Storage
|
|
62
|
+
try {
|
|
63
|
+
Storage = require('@heisenware/storage')
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
"The '@heisenware/storage' package is required to use VrpcPersistor. Please install it (`npm i @heisenware/storage`) and add it to your project's dependencies."
|
|
67
|
+
)
|
|
68
|
+
}
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Create a default logger that does nothing.
|
|
67
|
-
const defaultLogger = { info: noop, warn: noop, error: noop }
|
|
68
|
-
// Merge the user-provided logger with the default.
|
|
69
|
-
// This makes the log property optional and prevents crashes if methods are missing.
|
|
70
|
-
this._log = Object.assign({}, defaultLogger, log)
|
|
70
|
+
this._agentInstance = agentInstance
|
|
71
|
+
this._log = log
|
|
71
72
|
|
|
72
73
|
this._dir =
|
|
73
74
|
dir ||
|