starpc 0.1.2 → 0.1.5
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/README.md +9 -8
- package/dist/srpc/conn.d.ts +1 -1
- package/dist/srpc/conn.js +1 -1
- package/go.mod +7 -8
- package/go.sum +13 -13
- package/package.json +8 -5
- package/patches/{@libp2p+mplex+1.2.1.patch → @libp2p+mplex+2.0.0.patch} +6 -5
- package/patches/ts-poet+4.12.0.patch +72 -0
- package/srpc/conn.ts +2 -2
package/README.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
# Stream RPC
|
|
2
2
|
|
|
3
|
-
**starpc**
|
|
4
|
-
TypeScript and Go.
|
|
3
|
+
**starpc** implements [Proto3 services] in both TypeScript and Go.
|
|
5
4
|
|
|
6
5
|
[Proto3 services]: https://developers.google.com/protocol-buffers/docs/proto3#services
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
Supports **client-to-server streaming** RPCs in the web browser, currently not
|
|
8
|
+
supported by any of the major RPC libraries.
|
|
9
9
|
|
|
10
|
-
The [rpcproto](./srpc/rpcproto.proto) file
|
|
10
|
+
The [rpcproto](./srpc/rpcproto.proto) file describes the protocol.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
HTTP/2 or [libp2p-mplex] over a WebSocket.
|
|
12
|
+
Uses any Stream multiplexer: defaults to [libp2p-mplex] over a WebSocket.
|
|
14
13
|
|
|
15
14
|
[libp2p-mplex]: https://github.com/libp2p/js-libp2p-mplex
|
|
16
15
|
|
|
@@ -27,7 +26,9 @@ TypeScript and Go code for them.
|
|
|
27
26
|
|
|
28
27
|
See the [protobuf-project] template on the "starpc" branch.
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
The demo/boilerplate project implements the Echo example below.
|
|
30
|
+
|
|
31
|
+
[protobuf-project]: https://github.com/aperturerobotics/protobuf-project/tree/starpc
|
|
31
32
|
|
|
32
33
|
## Protobuf
|
|
33
34
|
|
|
@@ -150,7 +151,7 @@ Community contributions and discussion are welcomed!
|
|
|
150
151
|
|
|
151
152
|
Please open a [GitHub issue] with any questions / issues.
|
|
152
153
|
|
|
153
|
-
[GitHub issue]: https://github.com/aperturerobotics/
|
|
154
|
+
[GitHub issue]: https://github.com/aperturerobotics/starpc/issues/new
|
|
154
155
|
|
|
155
156
|
... or feel free to reach out on [Matrix Chat] or [Discord].
|
|
156
157
|
|
package/dist/srpc/conn.d.ts
CHANGED
package/dist/srpc/conn.js
CHANGED
package/go.mod
CHANGED
|
@@ -4,14 +4,14 @@ go 1.18
|
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
6
|
github.com/pkg/errors v0.9.1
|
|
7
|
-
google.golang.org/protobuf v1.
|
|
8
|
-
nhooyr.io/websocket v1.8.
|
|
7
|
+
google.golang.org/protobuf v1.27.1
|
|
8
|
+
nhooyr.io/websocket v1.8.8-0.20210410000328-8dee580a7f74
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
12
|
github.com/libp2p/go-libp2p v0.20.1
|
|
13
|
-
github.com/
|
|
14
|
-
|
|
13
|
+
github.com/libp2p/go-libp2p-core v0.16.1
|
|
14
|
+
github.com/sirupsen/logrus v1.8.2-0.20220112234510-85981c045988
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
require (
|
|
@@ -23,9 +23,8 @@ require (
|
|
|
23
23
|
github.com/ipfs/go-cid v0.1.0 // indirect
|
|
24
24
|
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
|
25
25
|
github.com/klauspost/compress v1.15.1 // indirect
|
|
26
|
-
github.com/klauspost/cpuid/v2 v2.0.
|
|
26
|
+
github.com/klauspost/cpuid/v2 v2.0.12 // indirect
|
|
27
27
|
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
|
|
28
|
-
github.com/libp2p/go-libp2p-core v0.16.1 // indirect
|
|
29
28
|
github.com/libp2p/go-mplex v0.7.0 // indirect
|
|
30
29
|
github.com/libp2p/go-openssl v0.0.7 // indirect
|
|
31
30
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
|
@@ -44,7 +43,7 @@ require (
|
|
|
44
43
|
go.uber.org/atomic v1.7.0 // indirect
|
|
45
44
|
go.uber.org/multierr v1.6.0 // indirect
|
|
46
45
|
go.uber.org/zap v1.19.1 // indirect
|
|
47
|
-
golang.org/x/crypto v0.0.0-
|
|
48
|
-
golang.org/x/sys v0.0.0-
|
|
46
|
+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
|
47
|
+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
|
|
49
48
|
lukechampine.com/blake3 v1.1.6 // indirect
|
|
50
49
|
)
|
package/go.sum
CHANGED
|
@@ -55,8 +55,9 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs
|
|
|
55
55
|
github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A=
|
|
56
56
|
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
|
57
57
|
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
|
58
|
-
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
|
59
58
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
|
59
|
+
github.com/klauspost/cpuid/v2 v2.0.12 h1:p9dKCg8i4gmOxtv35DvrYoWqYzQrvEVdjQ762Y0OqZE=
|
|
60
|
+
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
|
|
60
61
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
|
61
62
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|
62
63
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|
@@ -112,14 +113,13 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
|
|
112
113
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
113
114
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
114
115
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
115
|
-
github.com/sirupsen/logrus v1.8.
|
|
116
|
-
github.com/sirupsen/logrus v1.8.
|
|
116
|
+
github.com/sirupsen/logrus v1.8.2-0.20220112234510-85981c045988 h1:MF2lii450TvZhyAadvfiBGAr37d/U/ug5+N8eMvK89o=
|
|
117
|
+
github.com/sirupsen/logrus v1.8.2-0.20220112234510-85981c045988/go.mod h1:x/wqQ2RFrvQZEw5sMa05JQ/UbAAIfbzwTyMeXz9S0YI=
|
|
117
118
|
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 h1:RC6RW7j+1+HkWaX/Yh71Ee5ZHaHYt7ZP4sQgUrm6cDU=
|
|
118
119
|
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572/go.mod h1:w0SWMsp6j9O/dk4/ZpIhL+3CkG8ofA2vuv7k+ltqUMc=
|
|
119
120
|
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
|
120
121
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
|
121
122
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
122
|
-
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
123
123
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
|
124
124
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
|
125
125
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
|
@@ -145,8 +145,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|
|
145
145
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
146
146
|
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
|
147
147
|
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
|
148
|
-
golang.org/x/crypto v0.0.0-
|
|
149
|
-
golang.org/x/crypto v0.0.0-
|
|
148
|
+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
|
|
149
|
+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
150
150
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
|
151
151
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
152
152
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
|
@@ -173,14 +173,14 @@ golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7w
|
|
|
173
173
|
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
174
174
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
175
175
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
176
|
-
golang.org/x/sys v0.0.0-
|
|
177
|
-
golang.org/x/sys v0.0.0-
|
|
176
|
+
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
177
|
+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
|
178
|
+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
178
179
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
|
179
180
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
|
180
181
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
181
182
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|
182
183
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
183
|
-
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
|
184
184
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
|
185
185
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
186
186
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
|
@@ -194,8 +194,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
|
|
|
194
194
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
|
195
195
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
|
196
196
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
|
197
|
-
google.golang.org/protobuf v1.
|
|
198
|
-
google.golang.org/protobuf v1.
|
|
197
|
+
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
|
198
|
+
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
|
199
199
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
200
200
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
201
201
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
@@ -206,5 +206,5 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v
|
|
|
206
206
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
207
207
|
lukechampine.com/blake3 v1.1.6 h1:H3cROdztr7RCfoaTpGZFQsrqvweFLrqS73j7L7cmR5c=
|
|
208
208
|
lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
|
|
209
|
-
nhooyr.io/websocket v1.8.
|
|
210
|
-
nhooyr.io/websocket v1.8.
|
|
209
|
+
nhooyr.io/websocket v1.8.8-0.20210410000328-8dee580a7f74 h1:V2XOYY4rGPHLTGQD4TiOMOfVwNd0zAuEPofzzEqiFWk=
|
|
210
|
+
nhooyr.io/websocket v1.8.8-0.20210410000328-8dee580a7f74/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"lint": "npm run lint:go && npm run lint:js",
|
|
46
46
|
"lint:go": "make lint",
|
|
47
47
|
"lint:js": "eslint -c .eslintrc.js --ext .ts ./{srpc,echo}/**/*.ts",
|
|
48
|
-
"
|
|
48
|
+
"prepare": "patch-package",
|
|
49
49
|
"precommit": "npm run format"
|
|
50
50
|
},
|
|
51
51
|
"prettier": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@types/varint": "^6.0.0",
|
|
57
57
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
58
58
|
"@typescript-eslint/parser": "^5.27.1",
|
|
59
|
-
"esbuild": "^0.14.
|
|
59
|
+
"esbuild": "^0.14.44",
|
|
60
60
|
"eslint": "^8.17.0",
|
|
61
61
|
"eslint-config-prettier": "^8.5.0",
|
|
62
62
|
"eslint-config-standard-with-typescript": "^21.0.1",
|
|
@@ -67,7 +67,9 @@
|
|
|
67
67
|
"typescript": "^4.7.3"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@libp2p/
|
|
70
|
+
"@libp2p/components": "^1.0.0",
|
|
71
|
+
"@libp2p/interface-connection": "^1.0.1",
|
|
72
|
+
"@libp2p/mplex": "^2.0.0",
|
|
71
73
|
"event-iterator": "^2.0.0",
|
|
72
74
|
"isomorphic-ws": "^4.0.1",
|
|
73
75
|
"it-length-prefixed": "^7.0.1",
|
|
@@ -75,9 +77,10 @@
|
|
|
75
77
|
"it-pushable": "^3.0.0",
|
|
76
78
|
"it-stream-types": "^1.0.4",
|
|
77
79
|
"it-ws": "^5.0.2",
|
|
78
|
-
"protobufjs": "^6.11.3",
|
|
79
80
|
"patch-package": "^6.4.7",
|
|
81
|
+
"protobufjs": "^6.11.3",
|
|
80
82
|
"rxjs": "^7.5.5",
|
|
83
|
+
"ts-poet": "^4.12.0",
|
|
81
84
|
"ws": "^8.8.0"
|
|
82
85
|
}
|
|
83
86
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
diff --git a/node_modules/@libp2p/mplex/dist/src/index.d.ts b/node_modules/@libp2p/mplex/dist/src/index.d.ts
|
|
2
|
-
index
|
|
2
|
+
index 14c5f6e..32d0ee0 100644
|
|
3
3
|
--- a/node_modules/@libp2p/mplex/dist/src/index.d.ts
|
|
4
4
|
+++ b/node_modules/@libp2p/mplex/dist/src/index.d.ts
|
|
5
5
|
@@ -1,6 +1,7 @@
|
|
6
|
-
import
|
|
7
|
-
import type { StreamMuxerFactory, StreamMuxerInit } from '@libp2p/
|
|
6
|
+
import { Components, Initializable } from '@libp2p/components';
|
|
7
|
+
import type { StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer';
|
|
8
8
|
import { MplexStreamMuxer } from './mplex.js';
|
|
9
9
|
+export { MplexStreamMuxer } from './mplex.js';
|
|
10
10
|
export interface MplexInit {
|
|
11
11
|
/**
|
|
12
12
|
* The maximum size of message that can be sent in one go in bytes.
|
|
13
13
|
diff --git a/node_modules/@libp2p/mplex/dist/src/index.js b/node_modules/@libp2p/mplex/dist/src/index.js
|
|
14
|
-
index
|
|
14
|
+
index 4d692df..7bf592c 100644
|
|
15
15
|
--- a/node_modules/@libp2p/mplex/dist/src/index.js
|
|
16
16
|
+++ b/node_modules/@libp2p/mplex/dist/src/index.js
|
|
17
|
-
@@ -1,
|
|
17
|
+
@@ -1,5 +1,6 @@
|
|
18
|
+
import { Components } from '@libp2p/components';
|
|
18
19
|
import { MplexStreamMuxer } from './mplex.js';
|
|
19
20
|
+export { MplexStreamMuxer } from './mplex.js';
|
|
20
21
|
export class Mplex {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
diff --git a/node_modules/ts-poet/build/Import.js b/node_modules/ts-poet/build/Import.js
|
|
2
|
+
index 955a7eb..0ad3a67 100644
|
|
3
|
+
--- a/node_modules/ts-poet/build/Import.js
|
|
4
|
+
+++ b/node_modules/ts-poet/build/Import.js
|
|
5
|
+
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sameModule = exports.maybeRelativePath = exports.emitImports = exports.SideEffect = exports.Augmented = exports.ImportsAll = exports.ImportsDefault = exports.ImportsName = exports.Imported = exports.Implicit = exports.Import = exports.importType = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
+const path = require("path");
|
|
10
|
+
const Node_1 = require("./Node");
|
|
11
|
+
const typeImportMarker = '(?:t:)?';
|
|
12
|
+
const fileNamePattern = '(?:[a-zA-Z0-9._-]+)';
|
|
13
|
+
@@ -274,6 +275,15 @@ function emitImports(imports, ourModulePath, importMappings) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
let result = '';
|
|
17
|
+
+ const thisProject = process.env.PROJECT;
|
|
18
|
+
+ let ourModuleImportPath = path.normalize(ourModulePath);
|
|
19
|
+
+ // HACK: if this is an import from our project, set the path accordingly
|
|
20
|
+
+ // github.com/aperturerobotics/protobuf-project/example/example -> ./example/example
|
|
21
|
+
+ if (thisProject && ourModuleImportPath.startsWith(thisProject)) {
|
|
22
|
+
+ ourModuleImportPath = './' + ourModuleImportPath.substr(thisProject.length + 1);
|
|
23
|
+
+ }
|
|
24
|
+
+ // result += `// ourModulePath: ${ourModulePath}\n`;
|
|
25
|
+
+ // result += `// ourModuleImportPath: ${ourModuleImportPath}\n`;
|
|
26
|
+
const augmentImports = lodash_1.default.groupBy(filterInstances(imports, Augmented), (a) => a.augmented);
|
|
27
|
+
// Group the imports by source module they're imported from
|
|
28
|
+
const importsByModule = lodash_1.default.groupBy(imports.filter((it) => it.source !== undefined &&
|
|
29
|
+
@@ -288,7 +298,16 @@ function emitImports(imports, ourModulePath, importMappings) {
|
|
30
|
+
if (modulePath in importMappings) {
|
|
31
|
+
modulePath = importMappings[modulePath];
|
|
32
|
+
}
|
|
33
|
+
- const importPath = maybeRelativePath(ourModulePath, modulePath);
|
|
34
|
+
+ // HACK: if this is an import from a different project, use vendor/ tree.
|
|
35
|
+
+ if (thisProject && modulePath.startsWith('./')) {
|
|
36
|
+
+ if (!modulePath.substr(2).startsWith(thisProject)) {
|
|
37
|
+
+ modulePath = './vendor/' + path.normalize(modulePath);
|
|
38
|
+
+ } else {
|
|
39
|
+
+ modulePath = './' + modulePath.substr(3 + thisProject.length);
|
|
40
|
+
+ }
|
|
41
|
+
+ }
|
|
42
|
+
+ // result += `// modulePath: ${modulePath}\n`;
|
|
43
|
+
+ const importPath = maybeRelativePath(ourModuleImportPath, modulePath);
|
|
44
|
+
// Output star imports individually
|
|
45
|
+
unique(filterInstances(imports, ImportsAll).map((i) => i.symbol)).forEach((symbol) => {
|
|
46
|
+
result += `import * as ${symbol} from '${importPath}';\n`;
|
|
47
|
+
@@ -337,17 +356,15 @@ function maybeRelativePath(outputPath, importPath) {
|
|
48
|
+
if (!importPath.startsWith('./')) {
|
|
49
|
+
return importPath;
|
|
50
|
+
}
|
|
51
|
+
- // Drop the `./` prefix from the outputPath if it exists.
|
|
52
|
+
- const basePath = outputPath.replace(/^.\//, '');
|
|
53
|
+
- // Ideally we'd use a path library to do all this.
|
|
54
|
+
- const numberOfDirs = basePath.split('').filter((l) => l === '/').length;
|
|
55
|
+
- if (numberOfDirs === 0) {
|
|
56
|
+
- return importPath;
|
|
57
|
+
+ importPath = path.normalize(importPath);
|
|
58
|
+
+ outputPath = path.normalize(outputPath);
|
|
59
|
+
+ const outputPathDir = path.dirname(outputPath);
|
|
60
|
+
+ let relativePath = path.relative(outputPathDir, importPath);
|
|
61
|
+
+ if (!relativePath.startsWith('.')) {
|
|
62
|
+
+ // ensure the js compiler recognizes this is a relative path.
|
|
63
|
+
+ relativePath = './' + relativePath;
|
|
64
|
+
}
|
|
65
|
+
- // Make an array of `..` to get our importPath to the root directory.
|
|
66
|
+
- const a = new Array(numberOfDirs);
|
|
67
|
+
- const prefix = a.fill('..', 0, numberOfDirs).join('/');
|
|
68
|
+
- return prefix + importPath.substring(1);
|
|
69
|
+
+ return relativePath;
|
|
70
|
+
}
|
|
71
|
+
exports.maybeRelativePath = maybeRelativePath;
|
|
72
|
+
/** Checks if `path1 === path2` despite minor path differences like `./foo` and `foo`. */
|
package/srpc/conn.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Stream } from '@libp2p/
|
|
1
|
+
import type { Stream } from '@libp2p/interface-connection'
|
|
2
2
|
import type { Duplex } from 'it-stream-types'
|
|
3
|
-
import { Components } from '@libp2p/
|
|
3
|
+
import { Components } from '@libp2p/components'
|
|
4
4
|
import { MplexStreamMuxer } from '@libp2p/mplex'
|
|
5
5
|
import type { Stream as SRPCStream } from './stream'
|
|
6
6
|
import { Client } from './client'
|