libshv-js 3.9.1 → 3.10.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ws-client.ts +3 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "3.9.1",
3
+ "version": "3.10.0",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/src/ws-client.ts CHANGED
@@ -58,7 +58,7 @@ type WsClientOptionsLogin = WsClientOptionsCommon & {
58
58
  onConnected: () => void;
59
59
  onConnectionFailure: (error: Error) => void;
60
60
  onDisconnected: () => void;
61
- onRequest: (shvPath: string, method: string, param: RpcValue, delay: (progress: number) => void) => Promise<RpcValue>;
61
+ onRequest: (shvPath: string, method: string, param: RpcValue, delay: (progress: number) => void) => RpcValue | Promise<RpcValue>;
62
62
  };
63
63
 
64
64
  type WsClientOptionsWorkflows = WsClientOptionsCommon & {
@@ -193,8 +193,9 @@ class WsClient {
193
193
  }));
194
194
  };
195
195
 
196
+ const result = this.options.onRequest(rpcMsg.meta[RPC_MESSAGE_SHV_PATH], rpcMsg.meta[RPC_MESSAGE_METHOD], rpcMsg.value[RPC_MESSAGE_PARAMS], sendDelay);
196
197
  respond(makeIMap({
197
- [RPC_MESSAGE_RESULT]: await this.options.onRequest(rpcMsg.meta[RPC_MESSAGE_SHV_PATH], rpcMsg.meta[RPC_MESSAGE_METHOD], rpcMsg.value[RPC_MESSAGE_PARAMS], sendDelay),
198
+ [RPC_MESSAGE_RESULT]: result instanceof Promise ? await result : result,
198
199
  }));
199
200
  } catch (error: unknown) {
200
201
  const sendError = (error: RpcError) => {