starpc 0.11.0 → 0.11.2

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/echo/server.ts CHANGED
@@ -52,7 +52,7 @@ export class EchoerServer implements Echoer {
52
52
  ): AsyncIterable<RpcStreamPacket> {
53
53
  return handleRpcStream(
54
54
  request[Symbol.asyncIterator](),
55
- async (_componentId: string): Promise<RpcStreamHandler> => {
55
+ async (): Promise<RpcStreamHandler> => {
56
56
  if (!this.proxyServer) {
57
57
  throw new Error('rpc stream proxy server not set')
58
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -59,24 +59,25 @@
59
59
  "singleQuote": true
60
60
  },
61
61
  "devDependencies": {
62
- "@typescript-eslint/eslint-plugin": "^5.36.2",
63
- "@typescript-eslint/parser": "^5.36.2",
62
+ "@typescript-eslint/eslint-plugin": "^5.40.0",
63
+ "@typescript-eslint/parser": "^5.40.0",
64
64
  "bufferutil": "^4.0.6",
65
65
  "depcheck": "^1.4.3",
66
- "esbuild": "^0.15.7",
67
- "eslint": "^8.23.0",
66
+ "esbuild": "^0.15.10",
67
+ "eslint": "^8.25.0",
68
68
  "eslint-config-prettier": "^8.5.0",
69
69
  "prettier": "^2.7.1",
70
70
  "rimraf": "^3.0.2",
71
- "ts-proto": "^1.125.0",
72
- "typescript": "^4.8.2",
71
+ "ts-proto": "^1.126.1",
72
+ "typescript": "^4.8.4",
73
73
  "utf-8-validate": "^5.0.9"
74
74
  },
75
75
  "dependencies": {
76
- "@libp2p/interface-connection": "^3.0.1",
77
- "@libp2p/interface-stream-muxer": "^2.0.2",
78
- "@libp2p/mplex": "^5.1.1",
76
+ "@libp2p/interface-connection": "^3.0.2",
77
+ "@libp2p/interface-stream-muxer": "^3.0.0",
78
+ "@libp2p/mplex": "^6.0.2",
79
79
  "event-iterator": "^2.0.0",
80
+ "is-promise": "^4.0.0",
80
81
  "isomorphic-ws": "^5.0.0",
81
82
  "it-first": "^1.0.7",
82
83
  "it-length-prefixed": "^8.0.2",
@@ -86,8 +87,8 @@
86
87
  "it-ws": "^5.0.2",
87
88
  "long": "^5.2.0",
88
89
  "patch-package": "^6.4.7",
89
- "protobufjs": "^7.1.0",
90
+ "protobufjs": "^7.1.2",
90
91
  "uint8arraylist": "^2.3.2",
91
- "ws": "^8.8.1"
92
+ "ws": "^8.9.0"
92
93
  }
93
94
  }
@@ -0,0 +1,25 @@
1
+ diff --git a/node_modules/ts-proto/build/generate-services.js b/node_modules/ts-proto/build/generate-services.js
2
+ index 8ae7981..5ab6bf6 100644
3
+ --- a/node_modules/ts-proto/build/generate-services.js
4
+ +++ b/node_modules/ts-proto/build/generate-services.js
5
+ @@ -129,7 +129,7 @@ function generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
6
+ const data = ${encode};
7
+ const ${returnVariable} = this.rpc.${rpcMethod}(
8
+ ${maybeCtx}
9
+ - "${(0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name)}",
10
+ + this.service,
11
+ "${methodDesc.name}",
12
+ data
13
+ );
14
+ @@ -148,7 +148,10 @@ function generateServiceClientImpl(ctx, fileDesc, serviceDesc) {
15
+ // Create the constructor(rpc: Rpc)
16
+ const rpcType = options.context ? "Rpc<Context>" : "Rpc";
17
+ chunks.push((0, ts_poet_1.code) `private readonly rpc: ${rpcType};`);
18
+ - chunks.push((0, ts_poet_1.code) `constructor(rpc: ${rpcType}) {`);
19
+ + chunks.push((0, ts_poet_1.code) `private readonly service: string;`);
20
+ + chunks.push((0, ts_poet_1.code) `constructor(rpc: ${rpcType}, service?: string) {`);
21
+ + const serviceID = (0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name);
22
+ + chunks.push((0, ts_poet_1.code) `this.service = service || "${serviceID}";`);
23
+ chunks.push((0, ts_poet_1.code) `this.rpc = rpc;`);
24
+ // Bind each FooService method to the FooServiceImpl class
25
+ for (const methodDesc of serviceDesc.method) {
package/srpc/conn.ts CHANGED
@@ -7,6 +7,7 @@ import { pipe } from 'it-pipe'
7
7
  import type { Duplex } from 'it-stream-types'
8
8
  import { Mplex } from '@libp2p/mplex'
9
9
  import { Uint8ArrayList } from 'uint8arraylist'
10
+ import isPromise from 'is-promise'
10
11
 
11
12
  import type { OpenStreamFunc, Stream as SRPCStream } from './stream.js'
12
13
  import { Client } from './client.js'
@@ -85,6 +86,9 @@ export class Conn implements Duplex<Uint8Array> {
85
86
  // openStream implements the client open stream function.
86
87
  public async openStream(): Promise<SRPCStream> {
87
88
  const stream = this.muxer.newStream()
89
+ if (isPromise(stream)) {
90
+ return streamToSRPCStream(await stream)
91
+ }
88
92
  return streamToSRPCStream(stream)
89
93
  }
90
94