starpc 0.26.1 → 0.26.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/dist/srpc/message-port.d.ts +2 -2
- package/e2e/mock/mock.pb.go +1 -1
- package/echo/echo.go +20 -0
- package/echo/echo.pb.go +1 -1
- package/echo/echo_srpc.pb.go +3 -0
- package/go.mod +7 -7
- package/go.sum +14 -22
- package/package.json +2 -2
- package/srpc/message-port.ts +2 -2
- package/srpc/rpcproto.pb.go +1 -1
- package/srpc/rpcproto.pb.ts +2 -2
- package/srpc/stream.go +25 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Duplex, Source } from 'it-stream-types';
|
|
2
2
|
import { StreamConn, StreamConnParams } from './conn.js';
|
|
3
3
|
import { Server } from './server';
|
|
4
|
-
export declare class MessagePortDuplex<T extends
|
|
4
|
+
export declare class MessagePortDuplex<T extends NonNullable<unknown>> implements Duplex<AsyncGenerator<T>, Source<T>, Promise<void>> {
|
|
5
5
|
readonly port: MessagePort;
|
|
6
6
|
sink: (source: Source<T>) => Promise<void>;
|
|
7
7
|
source: AsyncGenerator<T>;
|
|
@@ -10,7 +10,7 @@ export declare class MessagePortDuplex<T extends {}> implements Duplex<AsyncGene
|
|
|
10
10
|
private _createSink;
|
|
11
11
|
private _createSource;
|
|
12
12
|
}
|
|
13
|
-
export declare function newMessagePortDuplex<T extends
|
|
13
|
+
export declare function newMessagePortDuplex<T extends NonNullable<unknown>>(port: MessagePort): MessagePortDuplex<T>;
|
|
14
14
|
export declare class MessagePortConn extends StreamConn {
|
|
15
15
|
private _messagePort;
|
|
16
16
|
constructor(port: MessagePort, server?: Server, connParams?: StreamConnParams);
|
package/e2e/mock/mock.pb.go
CHANGED
package/echo/echo.go
CHANGED
|
@@ -1 +1,21 @@
|
|
|
1
1
|
package echo
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/aperturerobotics/starpc/rpcstream"
|
|
5
|
+
srpc "github.com/aperturerobotics/starpc/srpc"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// _ is a type assertion
|
|
9
|
+
var (
|
|
10
|
+
_ srpc.StreamRecv[EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
11
|
+
_ srpc.StreamRecv[EchoMsg] = (SRPCEchoer_EchoServerStreamClient)(nil)
|
|
12
|
+
|
|
13
|
+
_ srpc.StreamSend[EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
14
|
+
_ srpc.StreamSend[EchoMsg] = (SRPCEchoer_EchoClientStreamClient)(nil)
|
|
15
|
+
|
|
16
|
+
_ srpc.StreamSendAndClose[EchoMsg] = (SRPCEchoer_EchoBidiStreamStream)(nil)
|
|
17
|
+
_ srpc.StreamSendAndClose[EchoMsg] = (SRPCEchoer_EchoServerStreamStream)(nil)
|
|
18
|
+
|
|
19
|
+
_ srpc.StreamRecv[rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
20
|
+
_ srpc.StreamSendAndClose[rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
21
|
+
)
|
package/echo/echo.pb.go
CHANGED
package/echo/echo_srpc.pb.go
CHANGED
|
@@ -366,6 +366,7 @@ func (x *srpcEchoer_EchoServerStreamStream) SendAndClose(m *EchoMsg) error {
|
|
|
366
366
|
type SRPCEchoer_EchoClientStreamStream interface {
|
|
367
367
|
srpc.Stream
|
|
368
368
|
Recv() (*EchoMsg, error)
|
|
369
|
+
RecvTo(*EchoMsg) error
|
|
369
370
|
}
|
|
370
371
|
|
|
371
372
|
type srpcEchoer_EchoClientStreamStream struct {
|
|
@@ -389,6 +390,7 @@ type SRPCEchoer_EchoBidiStreamStream interface {
|
|
|
389
390
|
Send(*EchoMsg) error
|
|
390
391
|
SendAndClose(*EchoMsg) error
|
|
391
392
|
Recv() (*EchoMsg, error)
|
|
393
|
+
RecvTo(*EchoMsg) error
|
|
392
394
|
}
|
|
393
395
|
|
|
394
396
|
type srpcEchoer_EchoBidiStreamStream struct {
|
|
@@ -425,6 +427,7 @@ type SRPCEchoer_RpcStreamStream interface {
|
|
|
425
427
|
Send(*rpcstream.RpcStreamPacket) error
|
|
426
428
|
SendAndClose(*rpcstream.RpcStreamPacket) error
|
|
427
429
|
Recv() (*rpcstream.RpcStreamPacket, error)
|
|
430
|
+
RecvTo(*rpcstream.RpcStreamPacket) error
|
|
428
431
|
}
|
|
429
432
|
|
|
430
433
|
type srpcEchoer_RpcStreamStream struct {
|
package/go.mod
CHANGED
|
@@ -9,8 +9,8 @@ require (
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
|
-
github.com/aperturerobotics/util v1.13.
|
|
13
|
-
github.com/libp2p/go-libp2p v0.
|
|
12
|
+
github.com/aperturerobotics/util v1.13.8 // latest
|
|
13
|
+
github.com/libp2p/go-libp2p v0.33.0 // latest
|
|
14
14
|
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d // master
|
|
15
15
|
github.com/sirupsen/logrus v1.9.3 // latest
|
|
16
16
|
)
|
|
@@ -20,21 +20,21 @@ require github.com/planetscale/vtprotobuf v0.6.0
|
|
|
20
20
|
require (
|
|
21
21
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
|
22
22
|
github.com/ipfs/go-cid v0.4.1 // indirect
|
|
23
|
-
github.com/klauspost/cpuid/v2 v2.2.
|
|
23
|
+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
|
24
24
|
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
|
25
25
|
github.com/minio/sha256-simd v1.0.1 // indirect
|
|
26
26
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
|
27
27
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
|
28
28
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
|
29
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
29
|
+
github.com/multiformats/go-multiaddr v0.12.2 // indirect
|
|
30
30
|
github.com/multiformats/go-multibase v0.2.0 // indirect
|
|
31
31
|
github.com/multiformats/go-multicodec v0.9.0 // indirect
|
|
32
32
|
github.com/multiformats/go-multihash v0.2.3 // indirect
|
|
33
33
|
github.com/multiformats/go-multistream v0.5.0 // indirect
|
|
34
34
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
|
35
35
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
36
|
-
golang.org/x/crypto v0.
|
|
37
|
-
golang.org/x/exp v0.0.0-
|
|
38
|
-
golang.org/x/sys v0.
|
|
36
|
+
golang.org/x/crypto v0.19.0 // indirect
|
|
37
|
+
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
|
|
38
|
+
golang.org/x/sys v0.17.0 // indirect
|
|
39
39
|
lukechampine.com/blake3 v1.2.1 // indirect
|
|
40
40
|
)
|
package/go.sum
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
github.com/aperturerobotics/util v1.13.
|
|
2
|
-
github.com/aperturerobotics/util v1.13.
|
|
3
|
-
github.com/aperturerobotics/util v1.13.3 h1:N4JXKYql0R/A2hMuV79SZ2vaftf8tiN8DUJ8sGc7Rso=
|
|
4
|
-
github.com/aperturerobotics/util v1.13.3/go.mod h1:JdziNd9tR6lWqc9bSMIe1At8Gagrg986rmtZuPCv6+w=
|
|
5
|
-
github.com/aperturerobotics/util v1.13.5 h1:g8Q9VKBUYR5Nu5Ee/ZygVbe0JkGXeNq1fBkT0ipLBMY=
|
|
6
|
-
github.com/aperturerobotics/util v1.13.5/go.mod h1:8AfpGb9RJqUItLBb5ec3sprpl9swYyHlgOw0HzkE+S8=
|
|
7
|
-
github.com/aperturerobotics/util v1.13.6 h1:8FKBjj+vs23QZBiwkGod5WUY19Cisda48Rbg1zaqzZU=
|
|
8
|
-
github.com/aperturerobotics/util v1.13.6/go.mod h1:8AfpGb9RJqUItLBb5ec3sprpl9swYyHlgOw0HzkE+S8=
|
|
1
|
+
github.com/aperturerobotics/util v1.13.8 h1:hpBfvD+afJg4Ox4iXpCRA+0LsOyftmV6/mAVU0uiG2w=
|
|
2
|
+
github.com/aperturerobotics/util v1.13.8/go.mod h1:8AfpGb9RJqUItLBb5ec3sprpl9swYyHlgOw0HzkE+S8=
|
|
9
3
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
10
4
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
11
5
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
@@ -17,12 +11,12 @@ github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
|
|
17
11
|
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
|
18
12
|
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
|
|
19
13
|
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
|
|
20
|
-
github.com/klauspost/cpuid/v2 v2.2.
|
|
21
|
-
github.com/klauspost/cpuid/v2 v2.2.
|
|
14
|
+
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
|
15
|
+
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
|
22
16
|
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
|
|
23
17
|
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
|
24
|
-
github.com/libp2p/go-libp2p v0.
|
|
25
|
-
github.com/libp2p/go-libp2p v0.
|
|
18
|
+
github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ=
|
|
19
|
+
github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE=
|
|
26
20
|
github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
|
|
27
21
|
github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
|
|
28
22
|
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d h1:Lag2VlBLRAiYKMnbIJGSDFmfSIoaeQRZ3wJXt91ZWV8=
|
|
@@ -35,8 +29,8 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG
|
|
|
35
29
|
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
|
36
30
|
github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
|
|
37
31
|
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
|
|
38
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
39
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
32
|
+
github.com/multiformats/go-multiaddr v0.12.2 h1:9G9sTY/wCYajKa9lyfWPmpZAwe6oV+Wb1zcmMS1HG24=
|
|
33
|
+
github.com/multiformats/go-multiaddr v0.12.2/go.mod h1:GKyaTYjZRdcUhyOetrxTk9z0cW+jA/YrnqTOvKgi44M=
|
|
40
34
|
github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g=
|
|
41
35
|
github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
|
|
42
36
|
github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg=
|
|
@@ -61,16 +55,14 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|
|
61
55
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
62
56
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
|
63
57
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
64
|
-
golang.org/x/crypto v0.
|
|
65
|
-
golang.org/x/crypto v0.
|
|
66
|
-
golang.org/x/exp v0.0.0-
|
|
67
|
-
golang.org/x/exp v0.0.0-
|
|
58
|
+
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
|
59
|
+
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
|
60
|
+
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE=
|
|
61
|
+
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
|
68
62
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
69
63
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
70
|
-
golang.org/x/sys v0.
|
|
71
|
-
golang.org/x/sys v0.
|
|
72
|
-
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
|
73
|
-
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
64
|
+
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
|
65
|
+
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
74
66
|
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
|
75
67
|
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
|
76
68
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"singleQuote": true
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@aperturerobotics/ts-common": "^0.8.
|
|
64
|
+
"@aperturerobotics/ts-common": "^0.8.6",
|
|
65
65
|
"bufferutil": "^4.0.7",
|
|
66
66
|
"depcheck": "^1.4.6",
|
|
67
67
|
"esbuild": "^0.20.0",
|
package/srpc/message-port.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { combineUint8ArrayListTransform } from './array-list.js'
|
|
|
12
12
|
// null will be written through the channel to indicate closure when the sink is closed.
|
|
13
13
|
// Note: there is no way to know for sure when a MessagePort is closed!
|
|
14
14
|
// You will need an additional keep-alive on top of MessagePortDuplex.
|
|
15
|
-
export class MessagePortDuplex<T extends
|
|
15
|
+
export class MessagePortDuplex<T extends NonNullable<unknown>>
|
|
16
16
|
implements Duplex<AsyncGenerator<T>, Source<T>, Promise<void>>
|
|
17
17
|
{
|
|
18
18
|
// port is the message port
|
|
@@ -84,7 +84,7 @@ export class MessagePortDuplex<T extends {}>
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// newMessagePortDuplex constructs a MessagePortDuplex with a channel name.
|
|
87
|
-
export function newMessagePortDuplex<T extends
|
|
87
|
+
export function newMessagePortDuplex<T extends NonNullable<unknown>>(
|
|
88
88
|
port: MessagePort,
|
|
89
89
|
): MessagePortDuplex<T> {
|
|
90
90
|
return new MessagePortDuplex<T>(port)
|
package/srpc/rpcproto.pb.go
CHANGED
package/srpc/rpcproto.pb.ts
CHANGED
|
@@ -542,7 +542,7 @@ export const CallData = {
|
|
|
542
542
|
}
|
|
543
543
|
|
|
544
544
|
function bytesFromBase64(b64: string): Uint8Array {
|
|
545
|
-
if (globalThis.Buffer) {
|
|
545
|
+
if ((globalThis as any).Buffer) {
|
|
546
546
|
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'))
|
|
547
547
|
} else {
|
|
548
548
|
const bin = globalThis.atob(b64)
|
|
@@ -555,7 +555,7 @@ function bytesFromBase64(b64: string): Uint8Array {
|
|
|
555
555
|
}
|
|
556
556
|
|
|
557
557
|
function base64FromBytes(arr: Uint8Array): string {
|
|
558
|
-
if (globalThis.Buffer) {
|
|
558
|
+
if ((globalThis as any).Buffer) {
|
|
559
559
|
return globalThis.Buffer.from(arr).toString('base64')
|
|
560
560
|
} else {
|
|
561
561
|
const bin: string[] = []
|
package/srpc/stream.go
CHANGED
|
@@ -22,3 +22,28 @@ type Stream interface {
|
|
|
22
22
|
// Close closes the stream for reading and writing.
|
|
23
23
|
Close() error
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
// StreamRecv is a stream that can receive typed messages.
|
|
27
|
+
//
|
|
28
|
+
// T is the response type.
|
|
29
|
+
type StreamRecv[T any] interface {
|
|
30
|
+
Stream
|
|
31
|
+
Recv() (*T, error)
|
|
32
|
+
RecvTo(*T) error
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// StreamSend is a stream that can send typed messages.
|
|
36
|
+
//
|
|
37
|
+
// T is the outgoing type.
|
|
38
|
+
type StreamSend[T any] interface {
|
|
39
|
+
Stream
|
|
40
|
+
Send(*T) error
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// StreamSendAndClose is a stream that can send typed messages, closing after.
|
|
44
|
+
//
|
|
45
|
+
// T is the outgoing type.
|
|
46
|
+
type StreamSendAndClose[T any] interface {
|
|
47
|
+
StreamSend[T]
|
|
48
|
+
SendAndClose(*T) error
|
|
49
|
+
}
|