@dxos/rpc 0.5.1-next.ed1615e → 0.5.2-main.2408cc7
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/dist/lib/browser/index.mjs +43 -43
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +43 -43
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/rpc.d.ts +6 -2
- package/dist/types/src/rpc.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/rpc.ts +9 -4
- package/src/service.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/rpc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2-main.2408cc7",
|
|
4
4
|
"description": "A lightweight, transport-agnostic RPC implementation",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dxos/async": "0.5.
|
|
20
|
-
"@dxos/codec-protobuf": "0.5.
|
|
21
|
-
"@dxos/
|
|
22
|
-
"@dxos/
|
|
23
|
-
"@dxos/
|
|
24
|
-
"@dxos/
|
|
25
|
-
"@dxos/
|
|
26
|
-
"@dxos/
|
|
19
|
+
"@dxos/async": "0.5.2-main.2408cc7",
|
|
20
|
+
"@dxos/codec-protobuf": "0.5.2-main.2408cc7",
|
|
21
|
+
"@dxos/debug": "0.5.2-main.2408cc7",
|
|
22
|
+
"@dxos/invariant": "0.5.2-main.2408cc7",
|
|
23
|
+
"@dxos/protocols": "0.5.2-main.2408cc7",
|
|
24
|
+
"@dxos/util": "0.5.2-main.2408cc7",
|
|
25
|
+
"@dxos/node-std": "0.5.2-main.2408cc7",
|
|
26
|
+
"@dxos/log": "0.5.2-main.2408cc7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"earljs": "~0.1.10",
|
package/src/rpc.ts
CHANGED
|
@@ -28,13 +28,18 @@ export interface RpcPeerOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
timeout?: number;
|
|
30
30
|
|
|
31
|
-
callHandler: (method: string, request: Any) => MaybePromise<Any>;
|
|
32
|
-
streamHandler?: (method: string, request: Any) => Stream<Any>;
|
|
31
|
+
callHandler: (method: string, request: Any, options?: RequestOptions) => MaybePromise<Any>;
|
|
32
|
+
streamHandler?: (method: string, request: Any, options?: RequestOptions) => Stream<Any>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Do not require or send handshake messages.
|
|
36
36
|
*/
|
|
37
37
|
noHandshake?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* What options get passed to the `callHandler` and `streamHandler`.
|
|
41
|
+
*/
|
|
42
|
+
handlerRpcOptions?: RequestOptions;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/**
|
|
@@ -481,7 +486,7 @@ export class RpcPeer {
|
|
|
481
486
|
invariant(req.payload);
|
|
482
487
|
invariant(req.method);
|
|
483
488
|
|
|
484
|
-
const response = await this._params.callHandler(req.method, req.payload);
|
|
489
|
+
const response = await this._params.callHandler(req.method, req.payload, this._params.handlerRpcOptions);
|
|
485
490
|
return {
|
|
486
491
|
id: req.id,
|
|
487
492
|
payload: response,
|
|
@@ -501,7 +506,7 @@ export class RpcPeer {
|
|
|
501
506
|
invariant(req.payload);
|
|
502
507
|
invariant(req.method);
|
|
503
508
|
|
|
504
|
-
const responseStream = this._params.streamHandler(req.method, req.payload);
|
|
509
|
+
const responseStream = this._params.streamHandler(req.method, req.payload, this._params.handlerRpcOptions);
|
|
505
510
|
responseStream.onReady(() => {
|
|
506
511
|
callback({
|
|
507
512
|
id: req.id,
|
package/src/service.ts
CHANGED
|
@@ -103,22 +103,22 @@ export const createProtoRpcPeer = <Client = {}, Server = {}>({
|
|
|
103
103
|
const peer = new RpcPeer({
|
|
104
104
|
...rest,
|
|
105
105
|
|
|
106
|
-
callHandler: (method, request) => {
|
|
106
|
+
callHandler: (method, request, options) => {
|
|
107
107
|
const [serviceName, methodName] = parseMethodName(method);
|
|
108
108
|
if (!exposedRpcs[serviceName]) {
|
|
109
109
|
throw new Error(`Service not supported: ${serviceName}`);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
return exposedRpcs[serviceName].call(methodName, request);
|
|
112
|
+
return exposedRpcs[serviceName].call(methodName, request, options);
|
|
113
113
|
},
|
|
114
114
|
|
|
115
|
-
streamHandler: (method, request) => {
|
|
115
|
+
streamHandler: (method, request, options) => {
|
|
116
116
|
const [serviceName, methodName] = parseMethodName(method);
|
|
117
117
|
if (!exposedRpcs[serviceName]) {
|
|
118
118
|
throw new Error(`Service not supported: ${serviceName}`);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
return exposedRpcs[serviceName].callStream(methodName, request);
|
|
121
|
+
return exposedRpcs[serviceName].callStream(methodName, request, options);
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
124
|
|