starpc 0.27.2 → 0.27.3

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.
@@ -16,7 +16,7 @@ export declare const MockMsg: {
16
16
  body?: string | undefined;
17
17
  } & {
18
18
  body?: string | undefined;
19
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): MockMsg;
19
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
20
20
  fromPartial<I_1 extends {
21
21
  body?: string | undefined;
22
22
  } & {
@@ -57,7 +57,7 @@ export declare const MockDefinition: {
57
57
  body?: string | undefined;
58
58
  } & {
59
59
  body?: string | undefined;
60
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): MockMsg;
60
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
61
61
  fromPartial<I_1 extends {
62
62
  body?: string | undefined;
63
63
  } & {
@@ -76,7 +76,7 @@ export declare const MockDefinition: {
76
76
  body?: string | undefined;
77
77
  } & {
78
78
  body?: string | undefined;
79
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): MockMsg;
79
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
80
80
  fromPartial<I_1 extends {
81
81
  body?: string | undefined;
82
82
  } & {
@@ -17,7 +17,7 @@ export declare const EchoMsg: {
17
17
  body?: string | undefined;
18
18
  } & {
19
19
  body?: string | undefined;
20
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
20
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
21
21
  fromPartial<I_1 extends {
22
22
  body?: string | undefined;
23
23
  } & {
@@ -70,7 +70,7 @@ export declare const EchoerDefinition: {
70
70
  body?: string | undefined;
71
71
  } & {
72
72
  body?: string | undefined;
73
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
73
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
74
74
  fromPartial<I_1 extends {
75
75
  body?: string | undefined;
76
76
  } & {
@@ -89,7 +89,7 @@ export declare const EchoerDefinition: {
89
89
  body?: string | undefined;
90
90
  } & {
91
91
  body?: string | undefined;
92
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
92
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
93
93
  fromPartial<I_1 extends {
94
94
  body?: string | undefined;
95
95
  } & {
@@ -113,7 +113,7 @@ export declare const EchoerDefinition: {
113
113
  body?: string | undefined;
114
114
  } & {
115
115
  body?: string | undefined;
116
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
116
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
117
117
  fromPartial<I_1 extends {
118
118
  body?: string | undefined;
119
119
  } & {
@@ -132,7 +132,7 @@ export declare const EchoerDefinition: {
132
132
  body?: string | undefined;
133
133
  } & {
134
134
  body?: string | undefined;
135
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
135
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
136
136
  fromPartial<I_1 extends {
137
137
  body?: string | undefined;
138
138
  } & {
@@ -156,7 +156,7 @@ export declare const EchoerDefinition: {
156
156
  body?: string | undefined;
157
157
  } & {
158
158
  body?: string | undefined;
159
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
159
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
160
160
  fromPartial<I_1 extends {
161
161
  body?: string | undefined;
162
162
  } & {
@@ -175,7 +175,7 @@ export declare const EchoerDefinition: {
175
175
  body?: string | undefined;
176
176
  } & {
177
177
  body?: string | undefined;
178
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
178
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
179
179
  fromPartial<I_1 extends {
180
180
  body?: string | undefined;
181
181
  } & {
@@ -199,7 +199,7 @@ export declare const EchoerDefinition: {
199
199
  body?: string | undefined;
200
200
  } & {
201
201
  body?: string | undefined;
202
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
202
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
203
203
  fromPartial<I_1 extends {
204
204
  body?: string | undefined;
205
205
  } & {
@@ -218,7 +218,7 @@ export declare const EchoerDefinition: {
218
218
  body?: string | undefined;
219
219
  } & {
220
220
  body?: string | undefined;
221
- } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): EchoMsg;
221
+ } & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
222
222
  fromPartial<I_1 extends {
223
223
  body?: string | undefined;
224
224
  } & {
@@ -84,7 +84,7 @@ export declare const RpcStreamPacket: {
84
84
  data?: Uint8Array | undefined;
85
85
  $case: "data";
86
86
  } & { [K_4 in Exclude<keyof I["body"], "$case" | "data">]: never; }) | undefined;
87
- } & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): RpcStreamPacket;
87
+ } & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I): RpcStreamPacket;
88
88
  fromPartial<I_1 extends {
89
89
  body?: ({
90
90
  init?: {
@@ -151,7 +151,7 @@ export declare const RpcStreamInit: {
151
151
  componentId?: string | undefined;
152
152
  } & {
153
153
  componentId?: string | undefined;
154
- } & { [K in Exclude<keyof I, "componentId">]: never; }>(base?: I | undefined): RpcStreamInit;
154
+ } & { [K in Exclude<keyof I, "componentId">]: never; }>(base?: I): RpcStreamInit;
155
155
  fromPartial<I_1 extends {
156
156
  componentId?: string | undefined;
157
157
  } & {
@@ -169,7 +169,7 @@ export declare const RpcAck: {
169
169
  error?: string | undefined;
170
170
  } & {
171
171
  error?: string | undefined;
172
- } & { [K in Exclude<keyof I, "error">]: never; }>(base?: I | undefined): RpcAck;
172
+ } & { [K in Exclude<keyof I, "error">]: never; }>(base?: I): RpcAck;
173
173
  fromPartial<I_1 extends {
174
174
  error?: string | undefined;
175
175
  } & {
@@ -17,7 +17,6 @@ export class ChannelStream {
17
17
  get isOpen() {
18
18
  return this.remoteOpen ?? false;
19
19
  }
20
- // remoteOpen indicates that we know the remote has already opened the stream.
21
20
  constructor(localId, channel, opts) {
22
21
  // initial state
23
22
  this.localId = localId;
@@ -132,7 +132,7 @@ export declare const Packet: {
132
132
  callCancel?: boolean | undefined;
133
133
  $case: "callCancel";
134
134
  } & { [K_4 in Exclude<keyof I["body"], "callCancel" | "$case">]: never; }) | undefined;
135
- } & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I | undefined): Packet;
135
+ } & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I): Packet;
136
136
  fromPartial<I_1 extends {
137
137
  body?: ({
138
138
  callStart?: {
@@ -229,7 +229,7 @@ export declare const CallStart: {
229
229
  rpcMethod?: string | undefined;
230
230
  data?: Uint8Array | undefined;
231
231
  dataIsZero?: boolean | undefined;
232
- } & { [K in Exclude<keyof I, keyof CallStart>]: never; }>(base?: I | undefined): CallStart;
232
+ } & { [K in Exclude<keyof I, keyof CallStart>]: never; }>(base?: I): CallStart;
233
233
  fromPartial<I_1 extends {
234
234
  rpcService?: string | undefined;
235
235
  rpcMethod?: string | undefined;
@@ -259,7 +259,7 @@ export declare const CallData: {
259
259
  dataIsZero?: boolean | undefined;
260
260
  complete?: boolean | undefined;
261
261
  error?: string | undefined;
262
- } & { [K in Exclude<keyof I, keyof CallData>]: never; }>(base?: I | undefined): CallData;
262
+ } & { [K in Exclude<keyof I, keyof CallData>]: never; }>(base?: I): CallData;
263
263
  fromPartial<I_1 extends {
264
264
  data?: Uint8Array | undefined;
265
265
  dataIsZero?: boolean | undefined;
@@ -165,7 +165,7 @@ export const CallStart = {
165
165
  if (message.data.length !== 0) {
166
166
  writer.uint32(26).bytes(message.data);
167
167
  }
168
- if (message.dataIsZero === true) {
168
+ if (message.dataIsZero !== false) {
169
169
  writer.uint32(32).bool(message.dataIsZero);
170
170
  }
171
171
  return writer;
@@ -264,7 +264,7 @@ export const CallStart = {
264
264
  if (message.data.length !== 0) {
265
265
  obj.data = base64FromBytes(message.data);
266
266
  }
267
- if (message.dataIsZero === true) {
267
+ if (message.dataIsZero !== false) {
268
268
  obj.dataIsZero = message.dataIsZero;
269
269
  }
270
270
  return obj;
@@ -294,10 +294,10 @@ export const CallData = {
294
294
  if (message.data.length !== 0) {
295
295
  writer.uint32(10).bytes(message.data);
296
296
  }
297
- if (message.dataIsZero === true) {
297
+ if (message.dataIsZero !== false) {
298
298
  writer.uint32(16).bool(message.dataIsZero);
299
299
  }
300
- if (message.complete === true) {
300
+ if (message.complete !== false) {
301
301
  writer.uint32(24).bool(message.complete);
302
302
  }
303
303
  if (message.error !== '') {
@@ -391,10 +391,10 @@ export const CallData = {
391
391
  if (message.data.length !== 0) {
392
392
  obj.data = base64FromBytes(message.data);
393
393
  }
394
- if (message.dataIsZero === true) {
394
+ if (message.dataIsZero !== false) {
395
395
  obj.dataIsZero = message.dataIsZero;
396
396
  }
397
- if (message.complete === true) {
397
+ if (message.complete !== false) {
398
398
  obj.complete = message.complete;
399
399
  }
400
400
  if (message.error !== '') {
package/go.mod CHANGED
@@ -4,14 +4,14 @@ go 1.21
4
4
 
5
5
  require (
6
6
  github.com/pkg/errors v0.9.1 // latest
7
- google.golang.org/protobuf v1.32.0 // latest
7
+ google.golang.org/protobuf v1.33.0 // latest
8
8
  nhooyr.io/websocket v1.8.10 // latest
9
9
  )
10
10
 
11
11
  require (
12
- github.com/aperturerobotics/util v1.14.3 // latest
13
- github.com/libp2p/go-libp2p v0.33.0 // latest
14
- github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d // master
12
+ github.com/aperturerobotics/util v1.15.1 // latest
13
+ github.com/libp2p/go-libp2p v0.33.1 // latest
14
+ github.com/libp2p/go-yamux/v4 v4.0.2-0.20240314112558-188b1fda7dc9 // master
15
15
  github.com/sirupsen/logrus v1.9.3 // latest
16
16
  )
17
17
 
package/go.sum CHANGED
@@ -1,7 +1,5 @@
1
- github.com/aperturerobotics/util v1.14.2 h1:AghqzGgZoufsdQstY6cCssHHMB/uCv8+BjysAE55S98=
2
- github.com/aperturerobotics/util v1.14.2/go.mod h1:1+G2THhT7VCmR7xeRlqDnyEtRFvONWoPft19xTHvbyk=
3
- github.com/aperturerobotics/util v1.14.3 h1:tn8eET9vlFwnveFY+rt4VbbMertQW8dcd+V5fK7SyHo=
4
- github.com/aperturerobotics/util v1.14.3/go.mod h1:1+G2THhT7VCmR7xeRlqDnyEtRFvONWoPft19xTHvbyk=
1
+ github.com/aperturerobotics/util v1.15.1 h1:cCNuxDI+ATnv++e5NHVDXKGaqMiPiwag9xMNQsYOspA=
2
+ github.com/aperturerobotics/util v1.15.1/go.mod h1:NW+A6UUfEv+BsLrfnqwXR9g6CO97Hwe+1En9zGeW1so=
5
3
  github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6
4
  github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
7
5
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -17,12 +15,12 @@ github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuV
17
15
  github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
18
16
  github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
19
17
  github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
20
- github.com/libp2p/go-libp2p v0.33.0 h1:yTPSr8sJRbfeEYXyeN8VPVSlTlFjtMUwGDRniwaf/xQ=
21
- github.com/libp2p/go-libp2p v0.33.0/go.mod h1:RIJFRQVUBKy82dnW7J5f1homqqv6NcsDJAl3e7CRGfE=
18
+ github.com/libp2p/go-libp2p v0.33.1 h1:tvJl9b9M6nSLBtZSXSguq+/lRhRj2oLRkyhBmQNMFLA=
19
+ github.com/libp2p/go-libp2p v0.33.1/go.mod h1:zOUTMjG4I7TXwMndNyOBn/CNtVBLlvBlnxfi+8xzx+E=
22
20
  github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
23
21
  github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
24
- github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d h1:Lag2VlBLRAiYKMnbIJGSDFmfSIoaeQRZ3wJXt91ZWV8=
25
- github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d/go.mod h1:OsNeDpmxccy93bUsruLEdsqIuO1VbBOFsQ4c4GfwenE=
22
+ github.com/libp2p/go-yamux/v4 v4.0.2-0.20240314112558-188b1fda7dc9 h1:8tAUqfDLYiZnTHlSQvA3wgGdqMSj8F5HBfAOnyARdR4=
23
+ github.com/libp2p/go-yamux/v4 v4.0.2-0.20240314112558-188b1fda7dc9/go.mod h1:PGP+3py2ZWDKABvqstBZtMnixEHNC7U/odnGylzur5o=
26
24
  github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
27
25
  github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
28
26
  github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
@@ -65,8 +63,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
65
63
  golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
66
64
  golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
67
65
  golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
68
- google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
69
- google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
66
+ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
67
+ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
70
68
  gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
71
69
  gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
72
70
  gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.27.2",
3
+ "version": "0.27.3",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
package/srpc/channel.ts CHANGED
@@ -89,7 +89,6 @@ export class ChannelStream<T = Uint8Array>
89
89
  return this.remoteOpen ?? false
90
90
  }
91
91
 
92
- // remoteOpen indicates that we know the remote has already opened the stream.
93
92
  constructor(localId: string, channel: ChannelPort, opts?: ChannelStreamOpts) {
94
93
  // initial state
95
94
  this.localId = localId
@@ -0,0 +1,48 @@
1
+ //go:build js
2
+
3
+ package srpc
4
+
5
+ import (
6
+ "io"
7
+ "sync/atomic"
8
+ "syscall/js"
9
+ )
10
+
11
+ // PushablePacketWriter is a PacketWriter which writes packets to a Pushable<Uint8Array>.
12
+ type PushablePacketWriter struct {
13
+ closed atomic.Bool
14
+ pushable js.Value
15
+ }
16
+
17
+ // NewPushablePacketWriter creates a new PushablePacketWriter.
18
+ func NewPushablePacketWriter(pushable js.Value) *PushablePacketWriter {
19
+ return &PushablePacketWriter{pushable: pushable}
20
+ }
21
+
22
+ // WritePacket writes a packet to the remote.
23
+ func (w *PushablePacketWriter) WritePacket(pkt *Packet) error {
24
+ if w.closed.Load() {
25
+ return io.ErrClosedPipe
26
+ }
27
+
28
+ data, err := pkt.MarshalVT()
29
+ if err != nil {
30
+ return err
31
+ }
32
+
33
+ a := js.Global().Get("Uint8Array").New(len(data))
34
+ js.CopyBytesToJS(a, data)
35
+ w.pushable.Call("push", a)
36
+ return nil
37
+ }
38
+
39
+ // Close closes the writer.
40
+ func (w *PushablePacketWriter) Close() error {
41
+ if !w.closed.Swap(true) {
42
+ w.pushable.Call("end")
43
+ }
44
+ return nil
45
+ }
46
+
47
+ // _ is a type assertion
48
+ var _ PacketWriter = (*PushablePacketWriter)(nil)
@@ -250,7 +250,7 @@ export const CallStart = {
250
250
  if (message.data.length !== 0) {
251
251
  writer.uint32(26).bytes(message.data)
252
252
  }
253
- if (message.dataIsZero === true) {
253
+ if (message.dataIsZero !== false) {
254
254
  writer.uint32(32).bool(message.dataIsZero)
255
255
  }
256
256
  return writer
@@ -365,7 +365,7 @@ export const CallStart = {
365
365
  if (message.data.length !== 0) {
366
366
  obj.data = base64FromBytes(message.data)
367
367
  }
368
- if (message.dataIsZero === true) {
368
+ if (message.dataIsZero !== false) {
369
369
  obj.dataIsZero = message.dataIsZero
370
370
  }
371
371
  return obj
@@ -403,10 +403,10 @@ export const CallData = {
403
403
  if (message.data.length !== 0) {
404
404
  writer.uint32(10).bytes(message.data)
405
405
  }
406
- if (message.dataIsZero === true) {
406
+ if (message.dataIsZero !== false) {
407
407
  writer.uint32(16).bool(message.dataIsZero)
408
408
  }
409
- if (message.complete === true) {
409
+ if (message.complete !== false) {
410
410
  writer.uint32(24).bool(message.complete)
411
411
  }
412
412
  if (message.error !== '') {
@@ -516,10 +516,10 @@ export const CallData = {
516
516
  if (message.data.length !== 0) {
517
517
  obj.data = base64FromBytes(message.data)
518
518
  }
519
- if (message.dataIsZero === true) {
519
+ if (message.dataIsZero !== false) {
520
520
  obj.dataIsZero = message.dataIsZero
521
521
  }
522
- if (message.complete === true) {
522
+ if (message.complete !== false) {
523
523
  obj.complete = message.complete
524
524
  }
525
525
  if (message.error !== '') {