@kabacorp/kaba-electron-rpc 8.1.0 → 8.1.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/lib/export-api.js +11 -7
- package/package.json +1 -1
package/lib/export-api.js
CHANGED
|
@@ -106,10 +106,17 @@ module.exports = function (
|
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
// Reverting to your original logic: .reply if it exists, otherwise .sender.send
|
|
110
|
+
const performSend = (val) => {
|
|
111
|
+
if (event.reply) {
|
|
112
|
+
event.reply(channelName, msgType, requestId, err, val);
|
|
113
|
+
} else if (event.sender && event.sender.send) {
|
|
114
|
+
event.sender.send(channelName, msgType, requestId, err, val);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
110
117
|
|
|
111
118
|
try {
|
|
112
|
-
|
|
119
|
+
performSend(value);
|
|
113
120
|
} catch (serializationError) {
|
|
114
121
|
debug("serialization failed, attempting sanitization", {
|
|
115
122
|
requestId,
|
|
@@ -133,12 +140,11 @@ module.exports = function (
|
|
|
133
140
|
error:
|
|
134
141
|
"Object too complex to serialize: " +
|
|
135
142
|
serializationError.message,
|
|
136
|
-
stack: serializationError.stack,
|
|
137
143
|
};
|
|
138
144
|
}
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
|
-
|
|
147
|
+
performSend(sanitizedValue);
|
|
142
148
|
}
|
|
143
149
|
};
|
|
144
150
|
|
|
@@ -164,7 +170,6 @@ module.exports = function (
|
|
|
164
170
|
const err = new Error(`Method not found: "${methodName}"`);
|
|
165
171
|
debug("error: method not found", methodName);
|
|
166
172
|
api.emit("error", err, { methodName, requestId, args });
|
|
167
|
-
// If async/promise, we should probably let the caller know
|
|
168
173
|
if (type === "async" || type === "promise")
|
|
169
174
|
send("async-reply", errorObject(err));
|
|
170
175
|
return;
|
|
@@ -342,7 +347,6 @@ module.exports = function (
|
|
|
342
347
|
}
|
|
343
348
|
|
|
344
349
|
function createDuplexEvents(event, stream, requestId, send) {
|
|
345
|
-
// Note: unregisterEvents will be shared, which is correct
|
|
346
350
|
return Object.assign(
|
|
347
351
|
createWritableEvents(event, stream, requestId, send),
|
|
348
352
|
createReadableEvents(event, stream, requestId, send)
|
|
@@ -408,6 +412,6 @@ function errorObject(error) {
|
|
|
408
412
|
const copy = Object.assign({}, error);
|
|
409
413
|
copy.message = error.message || error.toString();
|
|
410
414
|
if (error.name) copy.name = error.name;
|
|
411
|
-
if (error.stack) copy.stack = error.stack;
|
|
415
|
+
if (error.stack) copy.stack = error.stack;
|
|
412
416
|
return copy;
|
|
413
417
|
}
|
package/package.json
CHANGED