starpc 0.9.2 → 0.10.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.
@@ -1,5 +1,5 @@
1
1
  // Code generated by protoc-gen-go-vtproto. DO NOT EDIT.
2
- // protoc-gen-go-vtproto version: v0.3.1-0.20220531071333-dfd3d322ffb6
2
+ // protoc-gen-go-vtproto version: v0.3.1-0.20220817155510-0ae748fd2007
3
3
  // source: github.com/aperturerobotics/starpc/srpc/rpcproto.proto
4
4
 
5
5
  package srpc
@@ -21,9 +21,9 @@ const (
21
21
 
22
22
  func (this *Packet) EqualVT(that *Packet) bool {
23
23
  if this == nil {
24
- return that == nil || that.String() == ""
24
+ return that == nil
25
25
  } else if that == nil {
26
- return this.String() == ""
26
+ return false
27
27
  }
28
28
  if this.Body == nil && that.Body != nil {
29
29
  return false
@@ -31,21 +31,68 @@ func (this *Packet) EqualVT(that *Packet) bool {
31
31
  if that.Body == nil {
32
32
  return false
33
33
  }
34
- if !this.GetCallStart().EqualVT(that.GetCallStart()) {
34
+ if !this.Body.(interface{ EqualVT(isPacket_Body) bool }).EqualVT(that.Body) {
35
35
  return false
36
36
  }
37
- if !this.GetCallData().EqualVT(that.GetCallData()) {
37
+ }
38
+ return string(this.unknownFields) == string(that.unknownFields)
39
+ }
40
+
41
+ func (this *Packet_CallStart) EqualVT(thatIface isPacket_Body) bool {
42
+ that, ok := thatIface.(*Packet_CallStart)
43
+ if !ok {
44
+ return false
45
+ }
46
+ if this == that {
47
+ return true
48
+ }
49
+ if this == nil && that != nil || this != nil && that == nil {
50
+ return false
51
+ }
52
+ if p, q := this.CallStart, that.CallStart; p != q {
53
+ if p == nil {
54
+ p = &CallStart{}
55
+ }
56
+ if q == nil {
57
+ q = &CallStart{}
58
+ }
59
+ if !p.EqualVT(q) {
38
60
  return false
39
61
  }
40
62
  }
41
- return string(this.unknownFields) == string(that.unknownFields)
63
+ return true
64
+ }
65
+
66
+ func (this *Packet_CallData) EqualVT(thatIface isPacket_Body) bool {
67
+ that, ok := thatIface.(*Packet_CallData)
68
+ if !ok {
69
+ return false
70
+ }
71
+ if this == that {
72
+ return true
73
+ }
74
+ if this == nil && that != nil || this != nil && that == nil {
75
+ return false
76
+ }
77
+ if p, q := this.CallData, that.CallData; p != q {
78
+ if p == nil {
79
+ p = &CallData{}
80
+ }
81
+ if q == nil {
82
+ q = &CallData{}
83
+ }
84
+ if !p.EqualVT(q) {
85
+ return false
86
+ }
87
+ }
88
+ return true
42
89
  }
43
90
 
44
91
  func (this *CallStart) EqualVT(that *CallStart) bool {
45
92
  if this == nil {
46
- return that == nil || that.String() == ""
93
+ return that == nil
47
94
  } else if that == nil {
48
- return this.String() == ""
95
+ return false
49
96
  }
50
97
  if this.RpcService != that.RpcService {
51
98
  return false
@@ -64,9 +111,9 @@ func (this *CallStart) EqualVT(that *CallStart) bool {
64
111
 
65
112
  func (this *CallData) EqualVT(that *CallData) bool {
66
113
  if this == nil {
67
- return that == nil || that.String() == ""
114
+ return that == nil
68
115
  } else if that == nil {
69
- return this.String() == ""
116
+ return false
70
117
  }
71
118
  if string(this.Data) != string(that.Data) {
72
119
  return false
@@ -464,7 +511,7 @@ func (m *Packet) UnmarshalVT(dAtA []byte) error {
464
511
  if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil {
465
512
  return err
466
513
  }
467
- m.Body = &Packet_CallStart{v}
514
+ m.Body = &Packet_CallStart{CallStart: v}
468
515
  }
469
516
  iNdEx = postIndex
470
517
  case 2:
@@ -505,7 +552,7 @@ func (m *Packet) UnmarshalVT(dAtA []byte) error {
505
552
  if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil {
506
553
  return err
507
554
  }
508
- m.Body = &Packet_CallData{v}
555
+ m.Body = &Packet_CallData{CallData: v}
509
556
  }
510
557
  iNdEx = postIndex
511
558
  default:
package/srpc/server.go CHANGED
@@ -4,7 +4,7 @@ import (
4
4
  "context"
5
5
  "io"
6
6
 
7
- "github.com/libp2p/go-libp2p-core/network"
7
+ "github.com/libp2p/go-libp2p/core/network"
8
8
  )
9
9
 
10
10
  // Server handles incoming RPC streams with a mux.
package/srpc/server.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Stream } from '@libp2p/interface-connection'
2
2
  import { Duplex } from 'it-stream-types'
3
3
  import { pipe } from 'it-pipe'
4
+ import { Uint8ArrayList } from 'uint8arraylist'
4
5
 
5
6
  import { LookupMethod } from './mux.js'
6
7
  import { ServerRPC } from './server-rpc.js'
@@ -41,7 +42,9 @@ export class Server implements StreamHandler {
41
42
  }
42
43
 
43
44
  // handleDuplex handles an incoming message duplex.
44
- public handleDuplex(stream: Duplex<Uint8Array>): ServerRPC {
45
+ public handleDuplex(
46
+ stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>
47
+ ): ServerRPC {
45
48
  const rpc = this.startRpc()
46
49
  pipe(
47
50
  stream,
@@ -51,7 +54,6 @@ export class Server implements StreamHandler {
51
54
  rpc,
52
55
  encodePacketSource,
53
56
  prependLengthPrefixTransform(),
54
- combineUint8ArrayListTransform(),
55
57
  stream
56
58
  )
57
59
  return rpc
package/srpc/stream.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import type { Packet } from './rpcproto.pb.js'
2
2
  import type { Duplex } from 'it-stream-types'
3
+ import { Uint8ArrayList } from 'uint8arraylist'
3
4
 
4
5
  // PacketHandler handles incoming packets.
5
6
  export type PacketHandler = (packet: Packet) => Promise<void>
6
7
 
7
8
  // Stream is an open connection.
8
- export type Stream = Duplex<Uint8Array>
9
+ export type Stream = Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>
9
10
 
10
11
  // OpenStreamFunc is a function to start a new RPC by opening a Stream.
11
12
  export type OpenStreamFunc = () => Promise<Stream>
package/srpc/websocket.go CHANGED
@@ -4,7 +4,7 @@ import (
4
4
  "context"
5
5
  "io"
6
6
 
7
- "github.com/libp2p/go-libp2p-core/network"
7
+ "github.com/libp2p/go-libp2p/core/network"
8
8
  "github.com/libp2p/go-libp2p/p2p/muxer/mplex"
9
9
  "nhooyr.io/websocket"
10
10
  )
@@ -1,45 +0,0 @@
1
- diff --git a/node_modules/ts-poet/build/Import.js b/node_modules/ts-poet/build/Import.js
2
- index b92bea3..d35c845 100644
3
- --- a/node_modules/ts-poet/build/Import.js
4
- +++ b/node_modules/ts-poet/build/Import.js
5
- @@ -26,6 +26,7 @@ exports.sameModule = exports.maybeRelativePath = exports.emitImports = exports.S
6
- const lodash_1 = __importDefault(require("lodash"));
7
- const path = __importStar(require("path"));
8
- const Node_1 = require("./Node");
9
- +const fs = require('fs');
10
- const typeImportMarker = '(?:t:)?';
11
- const fileNamePattern = '(?:[a-zA-Z0-9._-]+)';
12
- const modulePattern = `@?(?:(?:${fileNamePattern}(?:/${fileNamePattern})*))`;
13
- @@ -293,6 +294,16 @@ function emitImports(imports, ourModulePath, importMappings) {
14
- return '';
15
- }
16
- let result = '';
17
- + // HACK: take the project root import path from $PROJECT
18
- + const thisProject = process.env.PROJECT;
19
- + let ourModuleImportPath = path.normalize(ourModulePath);
20
- + // HACK: if this is an import from our project, set the path accordingly
21
- + // github.com/aperturerobotics/protobuf-project/example/example -> ./example/example
22
- + if (thisProject && ourModuleImportPath.startsWith(thisProject)) {
23
- + ourModuleImportPath = './' + ourModuleImportPath.substr(thisProject.length + 1);
24
- + } else {
25
- + ourModuleImportPath = './vendor/' + ourModuleImportPath;
26
- + }
27
- const augmentImports = lodash_1.default.groupBy(filterInstances(imports, Augmented), (a) => a.augmented);
28
- // Group the imports by source module they're imported from
29
- const importsByModule = lodash_1.default.groupBy(imports.filter((it) => it.source !== undefined &&
30
- @@ -307,7 +318,14 @@ function emitImports(imports, ourModulePath, importMappings) {
31
- if (modulePath in importMappings) {
32
- modulePath = importMappings[modulePath];
33
- }
34
- - const importPath = maybeRelativePath(ourModulePath, modulePath);
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
- + const importPath = maybeRelativePath(ourModuleImportPath, modulePath);
43
- // Output star imports individually
44
- unique(filterInstances(imports, ImportsAll).map((i) => i.symbol)).forEach((symbol) => {
45
- result += `import * as ${symbol} from '${importPath}';\n`;