starpc 0.4.6 → 0.4.9
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/echo/index.d.ts +2 -2
- package/dist/echo/index.js +2 -2
- package/dist/rpcstream/index.d.ts +2 -1
- package/dist/rpcstream/index.js +2 -1
- package/dist/rpcstream/rpcstream.js +2 -2
- package/dist/srpc/broadcast-channel.d.ts +2 -2
- package/dist/srpc/broadcast-channel.js +6 -6
- package/dist/srpc/index.d.ts +2 -1
- package/dist/srpc/index.js +2 -1
- package/e2e/e2e_test.go +11 -6
- package/echo/index.ts +7 -2
- package/package.json +9 -9
- package/patches/{ts-poet+4.13.0.patch → ts-poet+4.14.0.patch} +1 -1
- package/srpc/broadcast-channel.ts +8 -8
- package/srpc/index.ts +3 -2
package/dist/echo/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { EchoMsg, Echoer, EchoerClientImpl, EchoerDefinition, } from './echo.pb.js';
|
|
2
|
+
export { EchoerServer } from './server.js';
|
|
3
3
|
export { runClientTest } from './client-test.js';
|
package/dist/echo/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { EchoMsg, EchoerClientImpl, EchoerDefinition, } from './echo.pb.js';
|
|
2
|
+
export { EchoerServer } from './server.js';
|
|
3
3
|
export { runClientTest } from './client-test.js';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { RpcStream, RpcStreamCaller, RpcStreamGetter, handleRpcStream, buildRpcStreamOpenStream, } from './rpcstream.js';
|
|
2
|
+
export { RpcStreamPacket, RpcStreamInit } from './rpcstream.pb.js';
|
package/dist/rpcstream/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { RpcStream, handleRpcStream, buildRpcStreamOpenStream, } from './rpcstream.js';
|
|
2
|
+
export { RpcStreamPacket, RpcStreamInit } from './rpcstream.pb.js';
|
|
@@ -11,7 +11,7 @@ export function buildRpcStreamOpenStream(componentId, caller) {
|
|
|
11
11
|
body: {
|
|
12
12
|
$case: 'init',
|
|
13
13
|
init: { componentId },
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
15
|
});
|
|
16
16
|
// build & return the stream
|
|
17
17
|
return new RpcStream(packetSink, packetSource);
|
|
@@ -67,7 +67,7 @@ export class RpcStream {
|
|
|
67
67
|
try {
|
|
68
68
|
for await (const msg of source) {
|
|
69
69
|
this._packetSink.push({
|
|
70
|
-
body: { $case: 'data', data: msg }
|
|
70
|
+
body: { $case: 'data', data: msg },
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
this._packetSink.end();
|
|
@@ -2,7 +2,7 @@ import type { Duplex, Sink } from 'it-stream-types';
|
|
|
2
2
|
import { ConnParams } from './conn.js';
|
|
3
3
|
import { Server } from './server.js';
|
|
4
4
|
import { DuplexConn } from './conn-duplex.js';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class BroadcastChannelDuplex<T> implements Duplex<T> {
|
|
6
6
|
readonly readChannel: BroadcastChannel;
|
|
7
7
|
readonly writeChannel: BroadcastChannel;
|
|
8
8
|
sink: Sink<T>;
|
|
@@ -12,7 +12,7 @@ export declare class BroadcastChannelIterable<T> implements Duplex<T> {
|
|
|
12
12
|
private _createSink;
|
|
13
13
|
private _createSource;
|
|
14
14
|
}
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function newBroadcastChannelDuplex<T>(readName: string, writeName: string): BroadcastChannelDuplex<T>;
|
|
16
16
|
export declare class BroadcastChannelConn extends DuplexConn {
|
|
17
17
|
private broadcastChannel;
|
|
18
18
|
constructor(readChannel: BroadcastChannel, writeChannel: BroadcastChannel, server?: Server, connParams?: ConnParams);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventIterator } from 'event-iterator';
|
|
2
2
|
import { DuplexConn } from './conn-duplex.js';
|
|
3
|
-
//
|
|
4
|
-
export class
|
|
3
|
+
// BroadcastChannelDuplex is a AsyncIterable wrapper for BroadcastChannel.
|
|
4
|
+
export class BroadcastChannelDuplex {
|
|
5
5
|
constructor(readChannel, writeChannel) {
|
|
6
6
|
this.readChannel = readChannel;
|
|
7
7
|
this.writeChannel = writeChannel;
|
|
@@ -36,16 +36,16 @@ export class BroadcastChannelIterable {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
//
|
|
40
|
-
export function
|
|
41
|
-
return new
|
|
39
|
+
// newBroadcastChannelDuplex constructs a BroadcastChannelDuplex with a channel name.
|
|
40
|
+
export function newBroadcastChannelDuplex(readName, writeName) {
|
|
41
|
+
return new BroadcastChannelDuplex(new BroadcastChannel(readName), new BroadcastChannel(writeName));
|
|
42
42
|
}
|
|
43
43
|
// BroadcastChannelConn implements a connection with a BroadcastChannel.
|
|
44
44
|
//
|
|
45
45
|
// expects Uint8Array objects over the BroadcastChannel.
|
|
46
46
|
export class BroadcastChannelConn extends DuplexConn {
|
|
47
47
|
constructor(readChannel, writeChannel, server, connParams) {
|
|
48
|
-
const broadcastChannel = new
|
|
48
|
+
const broadcastChannel = new BroadcastChannelDuplex(readChannel, writeChannel);
|
|
49
49
|
super(broadcastChannel, server, connParams);
|
|
50
50
|
this.broadcastChannel = broadcastChannel;
|
|
51
51
|
}
|
package/dist/srpc/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export { Client } from './client.js';
|
|
|
3
3
|
export { Server } from './server.js';
|
|
4
4
|
export { Conn, ConnParams } from './conn.js';
|
|
5
5
|
export { Handler, InvokeFn, createHandler, createInvokeFn } from './handler.js';
|
|
6
|
+
export { Packet, CallStart, CallData } from './rpcproto.pb.js';
|
|
6
7
|
export { Mux, createMux } from './mux.js';
|
|
7
|
-
export {
|
|
8
|
+
export { BroadcastChannelDuplex, newBroadcastChannelDuplex, BroadcastChannelConn, } from './broadcast-channel.js';
|
|
8
9
|
export { MessagePortIterable, newMessagePortIterable, MessagePortConn, } from './message-port.js';
|
|
9
10
|
export { ObservableSource } from './observable-source.js';
|
package/dist/srpc/index.js
CHANGED
|
@@ -2,7 +2,8 @@ export { Client } from './client.js';
|
|
|
2
2
|
export { Server } from './server.js';
|
|
3
3
|
export { Conn } from './conn.js';
|
|
4
4
|
export { createHandler, createInvokeFn } from './handler.js';
|
|
5
|
+
export { Packet, CallStart, CallData } from './rpcproto.pb.js';
|
|
5
6
|
export { createMux } from './mux.js';
|
|
6
|
-
export {
|
|
7
|
+
export { BroadcastChannelDuplex, newBroadcastChannelDuplex, BroadcastChannelConn, } from './broadcast-channel.js';
|
|
7
8
|
export { MessagePortIterable, newMessagePortIterable, MessagePortConn, } from './message-port.js';
|
|
8
9
|
export { ObservableSource } from './observable-source.js';
|
package/e2e/e2e_test.go
CHANGED
|
@@ -5,6 +5,7 @@ import (
|
|
|
5
5
|
"io"
|
|
6
6
|
"net"
|
|
7
7
|
"testing"
|
|
8
|
+
"time"
|
|
8
9
|
|
|
9
10
|
"github.com/aperturerobotics/starpc/echo"
|
|
10
11
|
"github.com/aperturerobotics/starpc/srpc"
|
|
@@ -30,17 +31,21 @@ func RunE2E(t *testing.T, cb func(client echo.SRPCEchoerClient) error) {
|
|
|
30
31
|
// construct the client
|
|
31
32
|
clientPipe, serverPipe := net.Pipe()
|
|
32
33
|
|
|
34
|
+
clientMp, err := mp.NewMultiplex(clientPipe, false, nil)
|
|
35
|
+
if err != nil {
|
|
36
|
+
t.Fatal(err.Error())
|
|
37
|
+
}
|
|
38
|
+
client := srpc.NewClientWithMuxedConn(mplex.NewMuxedConn(clientMp))
|
|
39
|
+
|
|
33
40
|
ctx := context.Background()
|
|
41
|
+
serverMp, _ := mp.NewMultiplex(serverPipe, true, nil)
|
|
34
42
|
go func() {
|
|
35
|
-
serverMp, _ := mp.NewMultiplex(serverPipe, false, nil)
|
|
36
43
|
_ = server.AcceptMuxedConn(ctx, mplex.NewMuxedConn(serverMp))
|
|
37
44
|
}()
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
client := srpc.NewClientWithMuxedConn(mplex.NewMuxedConn(clientMp))
|
|
46
|
+
// TODO: requires a moment for the listener to start: not sure why.
|
|
47
|
+
// the packets /should/ be buffered in the pipe.
|
|
48
|
+
<-time.After(time.Millisecond * 100)
|
|
44
49
|
|
|
45
50
|
// construct the client rpc interface
|
|
46
51
|
clientEcho := echo.NewSRPCEchoerClient(client)
|
package/echo/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -56,23 +56,23 @@
|
|
|
56
56
|
"singleQuote": true
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
60
|
-
"@typescript-eslint/parser": "^5.
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
60
|
+
"@typescript-eslint/parser": "^5.30.0",
|
|
61
61
|
"depcheck": "^1.4.3",
|
|
62
|
-
"esbuild": "^0.14.
|
|
62
|
+
"esbuild": "^0.14.47",
|
|
63
63
|
"eslint": "^8.18.0",
|
|
64
64
|
"eslint-config-prettier": "^8.5.0",
|
|
65
65
|
"prettier": "^2.7.1",
|
|
66
66
|
"rimraf": "^3.0.2",
|
|
67
|
-
"ts-proto": "^1.115.
|
|
67
|
+
"ts-proto": "^1.115.5",
|
|
68
68
|
"typescript": "^4.7.4"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@libp2p/interface-connection": "^2.
|
|
72
|
-
"@libp2p/interface-stream-muxer": "^
|
|
73
|
-
"@libp2p/mplex": "^
|
|
71
|
+
"@libp2p/interface-connection": "^2.1.1",
|
|
72
|
+
"@libp2p/interface-stream-muxer": "^2.0.1",
|
|
73
|
+
"@libp2p/mplex": "^4.0.0",
|
|
74
74
|
"event-iterator": "^2.0.0",
|
|
75
|
-
"isomorphic-ws": "^
|
|
75
|
+
"isomorphic-ws": "^5.0.0",
|
|
76
76
|
"it-length-prefixed": "^7.0.1",
|
|
77
77
|
"it-pipe": "^2.0.3",
|
|
78
78
|
"it-pushable": "^3.0.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
diff --git a/node_modules/ts-poet/build/Import.js b/node_modules/ts-poet/build/Import.js
|
|
2
|
-
index
|
|
2
|
+
index fe1f6d2..280df8f 100644
|
|
3
3
|
--- a/node_modules/ts-poet/build/Import.js
|
|
4
4
|
+++ b/node_modules/ts-poet/build/Import.js
|
|
5
5
|
@@ -293,6 +293,14 @@ function emitImports(imports, ourModulePath, importMappings) {
|
|
@@ -5,8 +5,8 @@ import { ConnParams } from './conn.js'
|
|
|
5
5
|
import { Server } from './server.js'
|
|
6
6
|
import { DuplexConn } from './conn-duplex.js'
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
export class
|
|
8
|
+
// BroadcastChannelDuplex is a AsyncIterable wrapper for BroadcastChannel.
|
|
9
|
+
export class BroadcastChannelDuplex<T> implements Duplex<T> {
|
|
10
10
|
// readChannel is the incoming broadcast channel
|
|
11
11
|
public readonly readChannel: BroadcastChannel
|
|
12
12
|
// writeChannel is the outgoing broadcast channel
|
|
@@ -55,12 +55,12 @@ export class BroadcastChannelIterable<T> implements Duplex<T> {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//
|
|
59
|
-
export function
|
|
58
|
+
// newBroadcastChannelDuplex constructs a BroadcastChannelDuplex with a channel name.
|
|
59
|
+
export function newBroadcastChannelDuplex<T>(
|
|
60
60
|
readName: string,
|
|
61
61
|
writeName: string
|
|
62
|
-
):
|
|
63
|
-
return new
|
|
62
|
+
): BroadcastChannelDuplex<T> {
|
|
63
|
+
return new BroadcastChannelDuplex<T>(
|
|
64
64
|
new BroadcastChannel(readName),
|
|
65
65
|
new BroadcastChannel(writeName)
|
|
66
66
|
)
|
|
@@ -71,7 +71,7 @@ export function newBroadcastChannelIterable<T>(
|
|
|
71
71
|
// expects Uint8Array objects over the BroadcastChannel.
|
|
72
72
|
export class BroadcastChannelConn extends DuplexConn {
|
|
73
73
|
// broadcastChannel is the broadcast channel iterable
|
|
74
|
-
private broadcastChannel:
|
|
74
|
+
private broadcastChannel: BroadcastChannelDuplex<Uint8Array>
|
|
75
75
|
|
|
76
76
|
constructor(
|
|
77
77
|
readChannel: BroadcastChannel,
|
|
@@ -79,7 +79,7 @@ export class BroadcastChannelConn extends DuplexConn {
|
|
|
79
79
|
server?: Server,
|
|
80
80
|
connParams?: ConnParams
|
|
81
81
|
) {
|
|
82
|
-
const broadcastChannel = new
|
|
82
|
+
const broadcastChannel = new BroadcastChannelDuplex<Uint8Array>(
|
|
83
83
|
readChannel,
|
|
84
84
|
writeChannel
|
|
85
85
|
)
|
package/srpc/index.ts
CHANGED
|
@@ -3,10 +3,11 @@ export { Client } from './client.js'
|
|
|
3
3
|
export { Server } from './server.js'
|
|
4
4
|
export { Conn, ConnParams } from './conn.js'
|
|
5
5
|
export { Handler, InvokeFn, createHandler, createInvokeFn } from './handler.js'
|
|
6
|
+
export { Packet, CallStart, CallData } from './rpcproto.pb.js'
|
|
6
7
|
export { Mux, createMux } from './mux.js'
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
BroadcastChannelDuplex,
|
|
10
|
+
newBroadcastChannelDuplex,
|
|
10
11
|
BroadcastChannelConn,
|
|
11
12
|
} from './broadcast-channel.js'
|
|
12
13
|
export {
|