starpc 0.10.9 → 0.11.0
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/echo.pb.d.ts +5 -5
- package/dist/echo/echo.pb.js +20 -20
- package/dist/rpcstream/rpcstream.pb.d.ts +7 -7
- package/dist/rpcstream/rpcstream.pb.js +64 -39
- package/dist/srpc/handler.d.ts +1 -1
- package/dist/srpc/handler.js +6 -2
- package/dist/srpc/rpcproto.pb.d.ts +6 -6
- package/dist/srpc/rpcproto.pb.js +75 -38
- package/echo/echo.pb.ts +144 -88
- package/echo/echo_srpc.pb.go +17 -10
- package/package.json +1 -1
- package/srpc/conn.ts +3 -1
- package/srpc/definition.ts +1 -0
- package/srpc/handler.ts +11 -2
- package/srpc/rpcproto.pb.ts +273 -183
- package/srpc/server.ts +1 -3
package/srpc/rpcproto.pb.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import Long from
|
|
3
|
-
import _m0 from
|
|
2
|
+
import Long from 'long'
|
|
3
|
+
import _m0 from 'protobufjs/minimal.js'
|
|
4
4
|
|
|
5
|
-
export const protobufPackage =
|
|
5
|
+
export const protobufPackage = 'srpc'
|
|
6
6
|
|
|
7
7
|
/** Packet is a message sent over a srpc packet connection. */
|
|
8
8
|
export interface Packet {
|
|
9
|
-
body?:
|
|
9
|
+
body?:
|
|
10
|
+
| { $case: 'callStart'; callStart: CallStart }
|
|
11
|
+
| { $case: 'callData'; callData: CallData }
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/** CallStart requests starting a new RPC call. */
|
|
@@ -15,84 +17,96 @@ export interface CallStart {
|
|
|
15
17
|
* RpcService is the service to contact.
|
|
16
18
|
* Must be set.
|
|
17
19
|
*/
|
|
18
|
-
rpcService: string
|
|
20
|
+
rpcService: string
|
|
19
21
|
/**
|
|
20
22
|
* RpcMethod is the RPC method to call.
|
|
21
23
|
* Must be set.
|
|
22
24
|
*/
|
|
23
|
-
rpcMethod: string
|
|
25
|
+
rpcMethod: string
|
|
24
26
|
/**
|
|
25
27
|
* Data contains the request or the first message in the stream.
|
|
26
28
|
* Optional if streaming.
|
|
27
29
|
*/
|
|
28
|
-
data: Uint8Array
|
|
30
|
+
data: Uint8Array
|
|
29
31
|
/** DataIsZero indicates Data is set with an empty message. */
|
|
30
|
-
dataIsZero: boolean
|
|
32
|
+
dataIsZero: boolean
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** CallData contains a message in a streaming RPC sequence. */
|
|
34
36
|
export interface CallData {
|
|
35
37
|
/** Data contains the packet in the sequence. */
|
|
36
|
-
data: Uint8Array
|
|
38
|
+
data: Uint8Array
|
|
37
39
|
/** DataIsZero indicates Data is set with an empty message. */
|
|
38
|
-
dataIsZero: boolean
|
|
40
|
+
dataIsZero: boolean
|
|
39
41
|
/** Complete indicates the RPC call is completed. */
|
|
40
|
-
complete: boolean
|
|
42
|
+
complete: boolean
|
|
41
43
|
/**
|
|
42
44
|
* Error contains any error that caused the RPC to fail.
|
|
43
45
|
* If set, implies complete=true.
|
|
44
46
|
*/
|
|
45
|
-
error: string
|
|
47
|
+
error: string
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
function createBasePacket(): Packet {
|
|
49
|
-
return { body: undefined }
|
|
51
|
+
return { body: undefined }
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
export const Packet = {
|
|
53
|
-
encode(
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
encode(
|
|
56
|
+
message: Packet,
|
|
57
|
+
writer: _m0.Writer = _m0.Writer.create()
|
|
58
|
+
): _m0.Writer {
|
|
59
|
+
if (message.body?.$case === 'callStart') {
|
|
60
|
+
CallStart.encode(
|
|
61
|
+
message.body.callStart,
|
|
62
|
+
writer.uint32(10).fork()
|
|
63
|
+
).ldelim()
|
|
56
64
|
}
|
|
57
|
-
if (message.body?.$case ===
|
|
58
|
-
CallData.encode(message.body.callData, writer.uint32(18).fork()).ldelim()
|
|
65
|
+
if (message.body?.$case === 'callData') {
|
|
66
|
+
CallData.encode(message.body.callData, writer.uint32(18).fork()).ldelim()
|
|
59
67
|
}
|
|
60
|
-
return writer
|
|
68
|
+
return writer
|
|
61
69
|
},
|
|
62
70
|
|
|
63
71
|
decode(input: _m0.Reader | Uint8Array, length?: number): Packet {
|
|
64
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
65
|
-
let end = length === undefined ? reader.len : reader.pos + length
|
|
66
|
-
const message = createBasePacket()
|
|
72
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
73
|
+
let end = length === undefined ? reader.len : reader.pos + length
|
|
74
|
+
const message = createBasePacket()
|
|
67
75
|
while (reader.pos < end) {
|
|
68
|
-
const tag = reader.uint32()
|
|
76
|
+
const tag = reader.uint32()
|
|
69
77
|
switch (tag >>> 3) {
|
|
70
78
|
case 1:
|
|
71
|
-
message.body = {
|
|
72
|
-
|
|
79
|
+
message.body = {
|
|
80
|
+
$case: 'callStart',
|
|
81
|
+
callStart: CallStart.decode(reader, reader.uint32()),
|
|
82
|
+
}
|
|
83
|
+
break
|
|
73
84
|
case 2:
|
|
74
|
-
message.body = {
|
|
75
|
-
|
|
85
|
+
message.body = {
|
|
86
|
+
$case: 'callData',
|
|
87
|
+
callData: CallData.decode(reader, reader.uint32()),
|
|
88
|
+
}
|
|
89
|
+
break
|
|
76
90
|
default:
|
|
77
|
-
reader.skipType(tag & 7)
|
|
78
|
-
break
|
|
91
|
+
reader.skipType(tag & 7)
|
|
92
|
+
break
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
|
-
return message
|
|
95
|
+
return message
|
|
82
96
|
},
|
|
83
97
|
|
|
84
98
|
// encodeTransform encodes a source of message objects.
|
|
85
99
|
// Transform<Packet, Uint8Array>
|
|
86
100
|
async *encodeTransform(
|
|
87
|
-
source: AsyncIterable<Packet | Packet[]> | Iterable<Packet | Packet[]
|
|
101
|
+
source: AsyncIterable<Packet | Packet[]> | Iterable<Packet | Packet[]>
|
|
88
102
|
): AsyncIterable<Uint8Array> {
|
|
89
103
|
for await (const pkt of source) {
|
|
90
104
|
if (Array.isArray(pkt)) {
|
|
91
105
|
for (const p of pkt) {
|
|
92
|
-
yield* [Packet.encode(p).finish()]
|
|
106
|
+
yield* [Packet.encode(p).finish()]
|
|
93
107
|
}
|
|
94
108
|
} else {
|
|
95
|
-
yield* [Packet.encode(pkt).finish()]
|
|
109
|
+
yield* [Packet.encode(pkt).finish()]
|
|
96
110
|
}
|
|
97
111
|
}
|
|
98
112
|
},
|
|
@@ -100,15 +114,17 @@ export const Packet = {
|
|
|
100
114
|
// decodeTransform decodes a source of encoded messages.
|
|
101
115
|
// Transform<Uint8Array, Packet>
|
|
102
116
|
async *decodeTransform(
|
|
103
|
-
source:
|
|
117
|
+
source:
|
|
118
|
+
| AsyncIterable<Uint8Array | Uint8Array[]>
|
|
119
|
+
| Iterable<Uint8Array | Uint8Array[]>
|
|
104
120
|
): AsyncIterable<Packet> {
|
|
105
121
|
for await (const pkt of source) {
|
|
106
122
|
if (Array.isArray(pkt)) {
|
|
107
123
|
for (const p of pkt) {
|
|
108
|
-
yield* [Packet.decode(p)]
|
|
124
|
+
yield* [Packet.decode(p)]
|
|
109
125
|
}
|
|
110
126
|
} else {
|
|
111
|
-
yield* [Packet.decode(pkt)]
|
|
127
|
+
yield* [Packet.decode(pkt)]
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
},
|
|
@@ -116,94 +132,125 @@ export const Packet = {
|
|
|
116
132
|
fromJSON(object: any): Packet {
|
|
117
133
|
return {
|
|
118
134
|
body: isSet(object.callStart)
|
|
119
|
-
? {
|
|
135
|
+
? {
|
|
136
|
+
$case: 'callStart',
|
|
137
|
+
callStart: CallStart.fromJSON(object.callStart),
|
|
138
|
+
}
|
|
120
139
|
: isSet(object.callData)
|
|
121
|
-
? { $case:
|
|
140
|
+
? { $case: 'callData', callData: CallData.fromJSON(object.callData) }
|
|
122
141
|
: undefined,
|
|
123
|
-
}
|
|
142
|
+
}
|
|
124
143
|
},
|
|
125
144
|
|
|
126
145
|
toJSON(message: Packet): unknown {
|
|
127
|
-
const obj: any = {}
|
|
128
|
-
message.body?.$case ===
|
|
129
|
-
(obj.callStart = message.body?.callStart
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
146
|
+
const obj: any = {}
|
|
147
|
+
message.body?.$case === 'callStart' &&
|
|
148
|
+
(obj.callStart = message.body?.callStart
|
|
149
|
+
? CallStart.toJSON(message.body?.callStart)
|
|
150
|
+
: undefined)
|
|
151
|
+
message.body?.$case === 'callData' &&
|
|
152
|
+
(obj.callData = message.body?.callData
|
|
153
|
+
? CallData.toJSON(message.body?.callData)
|
|
154
|
+
: undefined)
|
|
155
|
+
return obj
|
|
133
156
|
},
|
|
134
157
|
|
|
135
158
|
fromPartial<I extends Exact<DeepPartial<Packet>, I>>(object: I): Packet {
|
|
136
|
-
const message = createBasePacket()
|
|
137
|
-
if (
|
|
138
|
-
|
|
159
|
+
const message = createBasePacket()
|
|
160
|
+
if (
|
|
161
|
+
object.body?.$case === 'callStart' &&
|
|
162
|
+
object.body?.callStart !== undefined &&
|
|
163
|
+
object.body?.callStart !== null
|
|
164
|
+
) {
|
|
165
|
+
message.body = {
|
|
166
|
+
$case: 'callStart',
|
|
167
|
+
callStart: CallStart.fromPartial(object.body.callStart),
|
|
168
|
+
}
|
|
139
169
|
}
|
|
140
|
-
if (
|
|
141
|
-
|
|
170
|
+
if (
|
|
171
|
+
object.body?.$case === 'callData' &&
|
|
172
|
+
object.body?.callData !== undefined &&
|
|
173
|
+
object.body?.callData !== null
|
|
174
|
+
) {
|
|
175
|
+
message.body = {
|
|
176
|
+
$case: 'callData',
|
|
177
|
+
callData: CallData.fromPartial(object.body.callData),
|
|
178
|
+
}
|
|
142
179
|
}
|
|
143
|
-
return message
|
|
180
|
+
return message
|
|
144
181
|
},
|
|
145
|
-
}
|
|
182
|
+
}
|
|
146
183
|
|
|
147
184
|
function createBaseCallStart(): CallStart {
|
|
148
|
-
return {
|
|
185
|
+
return {
|
|
186
|
+
rpcService: '',
|
|
187
|
+
rpcMethod: '',
|
|
188
|
+
data: new Uint8Array(),
|
|
189
|
+
dataIsZero: false,
|
|
190
|
+
}
|
|
149
191
|
}
|
|
150
192
|
|
|
151
193
|
export const CallStart = {
|
|
152
|
-
encode(
|
|
153
|
-
|
|
154
|
-
|
|
194
|
+
encode(
|
|
195
|
+
message: CallStart,
|
|
196
|
+
writer: _m0.Writer = _m0.Writer.create()
|
|
197
|
+
): _m0.Writer {
|
|
198
|
+
if (message.rpcService !== '') {
|
|
199
|
+
writer.uint32(10).string(message.rpcService)
|
|
155
200
|
}
|
|
156
|
-
if (message.rpcMethod !==
|
|
157
|
-
writer.uint32(18).string(message.rpcMethod)
|
|
201
|
+
if (message.rpcMethod !== '') {
|
|
202
|
+
writer.uint32(18).string(message.rpcMethod)
|
|
158
203
|
}
|
|
159
204
|
if (message.data.length !== 0) {
|
|
160
|
-
writer.uint32(26).bytes(message.data)
|
|
205
|
+
writer.uint32(26).bytes(message.data)
|
|
161
206
|
}
|
|
162
207
|
if (message.dataIsZero === true) {
|
|
163
|
-
writer.uint32(32).bool(message.dataIsZero)
|
|
208
|
+
writer.uint32(32).bool(message.dataIsZero)
|
|
164
209
|
}
|
|
165
|
-
return writer
|
|
210
|
+
return writer
|
|
166
211
|
},
|
|
167
212
|
|
|
168
213
|
decode(input: _m0.Reader | Uint8Array, length?: number): CallStart {
|
|
169
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
170
|
-
let end = length === undefined ? reader.len : reader.pos + length
|
|
171
|
-
const message = createBaseCallStart()
|
|
214
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
215
|
+
let end = length === undefined ? reader.len : reader.pos + length
|
|
216
|
+
const message = createBaseCallStart()
|
|
172
217
|
while (reader.pos < end) {
|
|
173
|
-
const tag = reader.uint32()
|
|
218
|
+
const tag = reader.uint32()
|
|
174
219
|
switch (tag >>> 3) {
|
|
175
220
|
case 1:
|
|
176
|
-
message.rpcService = reader.string()
|
|
177
|
-
break
|
|
221
|
+
message.rpcService = reader.string()
|
|
222
|
+
break
|
|
178
223
|
case 2:
|
|
179
|
-
message.rpcMethod = reader.string()
|
|
180
|
-
break
|
|
224
|
+
message.rpcMethod = reader.string()
|
|
225
|
+
break
|
|
181
226
|
case 3:
|
|
182
|
-
message.data = reader.bytes()
|
|
183
|
-
break
|
|
227
|
+
message.data = reader.bytes()
|
|
228
|
+
break
|
|
184
229
|
case 4:
|
|
185
|
-
message.dataIsZero = reader.bool()
|
|
186
|
-
break
|
|
230
|
+
message.dataIsZero = reader.bool()
|
|
231
|
+
break
|
|
187
232
|
default:
|
|
188
|
-
reader.skipType(tag & 7)
|
|
189
|
-
break
|
|
233
|
+
reader.skipType(tag & 7)
|
|
234
|
+
break
|
|
190
235
|
}
|
|
191
236
|
}
|
|
192
|
-
return message
|
|
237
|
+
return message
|
|
193
238
|
},
|
|
194
239
|
|
|
195
240
|
// encodeTransform encodes a source of message objects.
|
|
196
241
|
// Transform<CallStart, Uint8Array>
|
|
197
242
|
async *encodeTransform(
|
|
198
|
-
source:
|
|
243
|
+
source:
|
|
244
|
+
| AsyncIterable<CallStart | CallStart[]>
|
|
245
|
+
| Iterable<CallStart | CallStart[]>
|
|
199
246
|
): AsyncIterable<Uint8Array> {
|
|
200
247
|
for await (const pkt of source) {
|
|
201
248
|
if (Array.isArray(pkt)) {
|
|
202
249
|
for (const p of pkt) {
|
|
203
|
-
yield* [CallStart.encode(p).finish()]
|
|
250
|
+
yield* [CallStart.encode(p).finish()]
|
|
204
251
|
}
|
|
205
252
|
} else {
|
|
206
|
-
yield* [CallStart.encode(pkt).finish()]
|
|
253
|
+
yield* [CallStart.encode(pkt).finish()]
|
|
207
254
|
}
|
|
208
255
|
}
|
|
209
256
|
},
|
|
@@ -211,108 +258,126 @@ export const CallStart = {
|
|
|
211
258
|
// decodeTransform decodes a source of encoded messages.
|
|
212
259
|
// Transform<Uint8Array, CallStart>
|
|
213
260
|
async *decodeTransform(
|
|
214
|
-
source:
|
|
261
|
+
source:
|
|
262
|
+
| AsyncIterable<Uint8Array | Uint8Array[]>
|
|
263
|
+
| Iterable<Uint8Array | Uint8Array[]>
|
|
215
264
|
): AsyncIterable<CallStart> {
|
|
216
265
|
for await (const pkt of source) {
|
|
217
266
|
if (Array.isArray(pkt)) {
|
|
218
267
|
for (const p of pkt) {
|
|
219
|
-
yield* [CallStart.decode(p)]
|
|
268
|
+
yield* [CallStart.decode(p)]
|
|
220
269
|
}
|
|
221
270
|
} else {
|
|
222
|
-
yield* [CallStart.decode(pkt)]
|
|
271
|
+
yield* [CallStart.decode(pkt)]
|
|
223
272
|
}
|
|
224
273
|
}
|
|
225
274
|
},
|
|
226
275
|
|
|
227
276
|
fromJSON(object: any): CallStart {
|
|
228
277
|
return {
|
|
229
|
-
rpcService: isSet(object.rpcService) ? String(object.rpcService) :
|
|
230
|
-
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) :
|
|
231
|
-
data: isSet(object.data)
|
|
278
|
+
rpcService: isSet(object.rpcService) ? String(object.rpcService) : '',
|
|
279
|
+
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) : '',
|
|
280
|
+
data: isSet(object.data)
|
|
281
|
+
? bytesFromBase64(object.data)
|
|
282
|
+
: new Uint8Array(),
|
|
232
283
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
233
|
-
}
|
|
284
|
+
}
|
|
234
285
|
},
|
|
235
286
|
|
|
236
287
|
toJSON(message: CallStart): unknown {
|
|
237
|
-
const obj: any = {}
|
|
238
|
-
message.rpcService !== undefined && (obj.rpcService = message.rpcService)
|
|
239
|
-
message.rpcMethod !== undefined && (obj.rpcMethod = message.rpcMethod)
|
|
288
|
+
const obj: any = {}
|
|
289
|
+
message.rpcService !== undefined && (obj.rpcService = message.rpcService)
|
|
290
|
+
message.rpcMethod !== undefined && (obj.rpcMethod = message.rpcMethod)
|
|
240
291
|
message.data !== undefined &&
|
|
241
|
-
(obj.data = base64FromBytes(
|
|
242
|
-
|
|
243
|
-
|
|
292
|
+
(obj.data = base64FromBytes(
|
|
293
|
+
message.data !== undefined ? message.data : new Uint8Array()
|
|
294
|
+
))
|
|
295
|
+
message.dataIsZero !== undefined && (obj.dataIsZero = message.dataIsZero)
|
|
296
|
+
return obj
|
|
244
297
|
},
|
|
245
298
|
|
|
246
|
-
fromPartial<I extends Exact<DeepPartial<CallStart>, I>>(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
message
|
|
250
|
-
message.
|
|
251
|
-
message.
|
|
252
|
-
|
|
299
|
+
fromPartial<I extends Exact<DeepPartial<CallStart>, I>>(
|
|
300
|
+
object: I
|
|
301
|
+
): CallStart {
|
|
302
|
+
const message = createBaseCallStart()
|
|
303
|
+
message.rpcService = object.rpcService ?? ''
|
|
304
|
+
message.rpcMethod = object.rpcMethod ?? ''
|
|
305
|
+
message.data = object.data ?? new Uint8Array()
|
|
306
|
+
message.dataIsZero = object.dataIsZero ?? false
|
|
307
|
+
return message
|
|
253
308
|
},
|
|
254
|
-
}
|
|
309
|
+
}
|
|
255
310
|
|
|
256
311
|
function createBaseCallData(): CallData {
|
|
257
|
-
return {
|
|
312
|
+
return {
|
|
313
|
+
data: new Uint8Array(),
|
|
314
|
+
dataIsZero: false,
|
|
315
|
+
complete: false,
|
|
316
|
+
error: '',
|
|
317
|
+
}
|
|
258
318
|
}
|
|
259
319
|
|
|
260
320
|
export const CallData = {
|
|
261
|
-
encode(
|
|
321
|
+
encode(
|
|
322
|
+
message: CallData,
|
|
323
|
+
writer: _m0.Writer = _m0.Writer.create()
|
|
324
|
+
): _m0.Writer {
|
|
262
325
|
if (message.data.length !== 0) {
|
|
263
|
-
writer.uint32(10).bytes(message.data)
|
|
326
|
+
writer.uint32(10).bytes(message.data)
|
|
264
327
|
}
|
|
265
328
|
if (message.dataIsZero === true) {
|
|
266
|
-
writer.uint32(16).bool(message.dataIsZero)
|
|
329
|
+
writer.uint32(16).bool(message.dataIsZero)
|
|
267
330
|
}
|
|
268
331
|
if (message.complete === true) {
|
|
269
|
-
writer.uint32(24).bool(message.complete)
|
|
332
|
+
writer.uint32(24).bool(message.complete)
|
|
270
333
|
}
|
|
271
|
-
if (message.error !==
|
|
272
|
-
writer.uint32(34).string(message.error)
|
|
334
|
+
if (message.error !== '') {
|
|
335
|
+
writer.uint32(34).string(message.error)
|
|
273
336
|
}
|
|
274
|
-
return writer
|
|
337
|
+
return writer
|
|
275
338
|
},
|
|
276
339
|
|
|
277
340
|
decode(input: _m0.Reader | Uint8Array, length?: number): CallData {
|
|
278
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
279
|
-
let end = length === undefined ? reader.len : reader.pos + length
|
|
280
|
-
const message = createBaseCallData()
|
|
341
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
342
|
+
let end = length === undefined ? reader.len : reader.pos + length
|
|
343
|
+
const message = createBaseCallData()
|
|
281
344
|
while (reader.pos < end) {
|
|
282
|
-
const tag = reader.uint32()
|
|
345
|
+
const tag = reader.uint32()
|
|
283
346
|
switch (tag >>> 3) {
|
|
284
347
|
case 1:
|
|
285
|
-
message.data = reader.bytes()
|
|
286
|
-
break
|
|
348
|
+
message.data = reader.bytes()
|
|
349
|
+
break
|
|
287
350
|
case 2:
|
|
288
|
-
message.dataIsZero = reader.bool()
|
|
289
|
-
break
|
|
351
|
+
message.dataIsZero = reader.bool()
|
|
352
|
+
break
|
|
290
353
|
case 3:
|
|
291
|
-
message.complete = reader.bool()
|
|
292
|
-
break
|
|
354
|
+
message.complete = reader.bool()
|
|
355
|
+
break
|
|
293
356
|
case 4:
|
|
294
|
-
message.error = reader.string()
|
|
295
|
-
break
|
|
357
|
+
message.error = reader.string()
|
|
358
|
+
break
|
|
296
359
|
default:
|
|
297
|
-
reader.skipType(tag & 7)
|
|
298
|
-
break
|
|
360
|
+
reader.skipType(tag & 7)
|
|
361
|
+
break
|
|
299
362
|
}
|
|
300
363
|
}
|
|
301
|
-
return message
|
|
364
|
+
return message
|
|
302
365
|
},
|
|
303
366
|
|
|
304
367
|
// encodeTransform encodes a source of message objects.
|
|
305
368
|
// Transform<CallData, Uint8Array>
|
|
306
369
|
async *encodeTransform(
|
|
307
|
-
source:
|
|
370
|
+
source:
|
|
371
|
+
| AsyncIterable<CallData | CallData[]>
|
|
372
|
+
| Iterable<CallData | CallData[]>
|
|
308
373
|
): AsyncIterable<Uint8Array> {
|
|
309
374
|
for await (const pkt of source) {
|
|
310
375
|
if (Array.isArray(pkt)) {
|
|
311
376
|
for (const p of pkt) {
|
|
312
|
-
yield* [CallData.encode(p).finish()]
|
|
377
|
+
yield* [CallData.encode(p).finish()]
|
|
313
378
|
}
|
|
314
379
|
} else {
|
|
315
|
-
yield* [CallData.encode(pkt).finish()]
|
|
380
|
+
yield* [CallData.encode(pkt).finish()]
|
|
316
381
|
}
|
|
317
382
|
}
|
|
318
383
|
},
|
|
@@ -320,110 +385,135 @@ export const CallData = {
|
|
|
320
385
|
// decodeTransform decodes a source of encoded messages.
|
|
321
386
|
// Transform<Uint8Array, CallData>
|
|
322
387
|
async *decodeTransform(
|
|
323
|
-
source:
|
|
388
|
+
source:
|
|
389
|
+
| AsyncIterable<Uint8Array | Uint8Array[]>
|
|
390
|
+
| Iterable<Uint8Array | Uint8Array[]>
|
|
324
391
|
): AsyncIterable<CallData> {
|
|
325
392
|
for await (const pkt of source) {
|
|
326
393
|
if (Array.isArray(pkt)) {
|
|
327
394
|
for (const p of pkt) {
|
|
328
|
-
yield* [CallData.decode(p)]
|
|
395
|
+
yield* [CallData.decode(p)]
|
|
329
396
|
}
|
|
330
397
|
} else {
|
|
331
|
-
yield* [CallData.decode(pkt)]
|
|
398
|
+
yield* [CallData.decode(pkt)]
|
|
332
399
|
}
|
|
333
400
|
}
|
|
334
401
|
},
|
|
335
402
|
|
|
336
403
|
fromJSON(object: any): CallData {
|
|
337
404
|
return {
|
|
338
|
-
data: isSet(object.data)
|
|
405
|
+
data: isSet(object.data)
|
|
406
|
+
? bytesFromBase64(object.data)
|
|
407
|
+
: new Uint8Array(),
|
|
339
408
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
340
409
|
complete: isSet(object.complete) ? Boolean(object.complete) : false,
|
|
341
|
-
error: isSet(object.error) ? String(object.error) :
|
|
342
|
-
}
|
|
410
|
+
error: isSet(object.error) ? String(object.error) : '',
|
|
411
|
+
}
|
|
343
412
|
},
|
|
344
413
|
|
|
345
414
|
toJSON(message: CallData): unknown {
|
|
346
|
-
const obj: any = {}
|
|
415
|
+
const obj: any = {}
|
|
347
416
|
message.data !== undefined &&
|
|
348
|
-
(obj.data = base64FromBytes(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
message.
|
|
352
|
-
|
|
417
|
+
(obj.data = base64FromBytes(
|
|
418
|
+
message.data !== undefined ? message.data : new Uint8Array()
|
|
419
|
+
))
|
|
420
|
+
message.dataIsZero !== undefined && (obj.dataIsZero = message.dataIsZero)
|
|
421
|
+
message.complete !== undefined && (obj.complete = message.complete)
|
|
422
|
+
message.error !== undefined && (obj.error = message.error)
|
|
423
|
+
return obj
|
|
353
424
|
},
|
|
354
425
|
|
|
355
426
|
fromPartial<I extends Exact<DeepPartial<CallData>, I>>(object: I): CallData {
|
|
356
|
-
const message = createBaseCallData()
|
|
357
|
-
message.data = object.data ?? new Uint8Array()
|
|
358
|
-
message.dataIsZero = object.dataIsZero ?? false
|
|
359
|
-
message.complete = object.complete ?? false
|
|
360
|
-
message.error = object.error ??
|
|
361
|
-
return message
|
|
427
|
+
const message = createBaseCallData()
|
|
428
|
+
message.data = object.data ?? new Uint8Array()
|
|
429
|
+
message.dataIsZero = object.dataIsZero ?? false
|
|
430
|
+
message.complete = object.complete ?? false
|
|
431
|
+
message.error = object.error ?? ''
|
|
432
|
+
return message
|
|
362
433
|
},
|
|
363
|
-
}
|
|
434
|
+
}
|
|
364
435
|
|
|
365
|
-
declare var self: any | undefined
|
|
366
|
-
declare var window: any | undefined
|
|
367
|
-
declare var global: any | undefined
|
|
436
|
+
declare var self: any | undefined
|
|
437
|
+
declare var window: any | undefined
|
|
438
|
+
declare var global: any | undefined
|
|
368
439
|
var globalThis: any = (() => {
|
|
369
|
-
if (typeof globalThis !==
|
|
370
|
-
return globalThis
|
|
440
|
+
if (typeof globalThis !== 'undefined') {
|
|
441
|
+
return globalThis
|
|
371
442
|
}
|
|
372
|
-
if (typeof self !==
|
|
373
|
-
return self
|
|
443
|
+
if (typeof self !== 'undefined') {
|
|
444
|
+
return self
|
|
374
445
|
}
|
|
375
|
-
if (typeof window !==
|
|
376
|
-
return window
|
|
446
|
+
if (typeof window !== 'undefined') {
|
|
447
|
+
return window
|
|
377
448
|
}
|
|
378
|
-
if (typeof global !==
|
|
379
|
-
return global
|
|
449
|
+
if (typeof global !== 'undefined') {
|
|
450
|
+
return global
|
|
380
451
|
}
|
|
381
|
-
throw
|
|
382
|
-
})()
|
|
452
|
+
throw 'Unable to locate global object'
|
|
453
|
+
})()
|
|
383
454
|
|
|
384
455
|
function bytesFromBase64(b64: string): Uint8Array {
|
|
385
456
|
if (globalThis.Buffer) {
|
|
386
|
-
return Uint8Array.from(globalThis.Buffer.from(b64,
|
|
457
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'))
|
|
387
458
|
} else {
|
|
388
|
-
const bin = globalThis.atob(b64)
|
|
389
|
-
const arr = new Uint8Array(bin.length)
|
|
459
|
+
const bin = globalThis.atob(b64)
|
|
460
|
+
const arr = new Uint8Array(bin.length)
|
|
390
461
|
for (let i = 0; i < bin.length; ++i) {
|
|
391
|
-
arr[i] = bin.charCodeAt(i)
|
|
462
|
+
arr[i] = bin.charCodeAt(i)
|
|
392
463
|
}
|
|
393
|
-
return arr
|
|
464
|
+
return arr
|
|
394
465
|
}
|
|
395
466
|
}
|
|
396
467
|
|
|
397
468
|
function base64FromBytes(arr: Uint8Array): string {
|
|
398
469
|
if (globalThis.Buffer) {
|
|
399
|
-
return globalThis.Buffer.from(arr).toString(
|
|
470
|
+
return globalThis.Buffer.from(arr).toString('base64')
|
|
400
471
|
} else {
|
|
401
|
-
const bin: string[] = []
|
|
472
|
+
const bin: string[] = []
|
|
402
473
|
arr.forEach((byte) => {
|
|
403
|
-
bin.push(String.fromCharCode(byte))
|
|
404
|
-
})
|
|
405
|
-
return globalThis.btoa(bin.join(
|
|
474
|
+
bin.push(String.fromCharCode(byte))
|
|
475
|
+
})
|
|
476
|
+
return globalThis.btoa(bin.join(''))
|
|
406
477
|
}
|
|
407
478
|
}
|
|
408
479
|
|
|
409
|
-
type Builtin =
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
type
|
|
419
|
-
|
|
420
|
-
:
|
|
480
|
+
type Builtin =
|
|
481
|
+
| Date
|
|
482
|
+
| Function
|
|
483
|
+
| Uint8Array
|
|
484
|
+
| string
|
|
485
|
+
| number
|
|
486
|
+
| boolean
|
|
487
|
+
| undefined
|
|
488
|
+
|
|
489
|
+
export type DeepPartial<T> = T extends Builtin
|
|
490
|
+
? T
|
|
491
|
+
: T extends Long
|
|
492
|
+
? string | number | Long
|
|
493
|
+
: T extends Array<infer U>
|
|
494
|
+
? Array<DeepPartial<U>>
|
|
495
|
+
: T extends ReadonlyArray<infer U>
|
|
496
|
+
? ReadonlyArray<DeepPartial<U>>
|
|
497
|
+
: T extends { $case: string }
|
|
498
|
+
? { [K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]> } & {
|
|
499
|
+
$case: T['$case']
|
|
500
|
+
}
|
|
501
|
+
: T extends {}
|
|
502
|
+
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
503
|
+
: Partial<T>
|
|
504
|
+
|
|
505
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never
|
|
506
|
+
export type Exact<P, I extends P> = P extends Builtin
|
|
507
|
+
? P
|
|
508
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
|
|
509
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never
|
|
510
|
+
}
|
|
421
511
|
|
|
422
512
|
if (_m0.util.Long !== Long) {
|
|
423
|
-
_m0.util.Long = Long as any
|
|
424
|
-
_m0.configure()
|
|
513
|
+
_m0.util.Long = Long as any
|
|
514
|
+
_m0.configure()
|
|
425
515
|
}
|
|
426
516
|
|
|
427
517
|
function isSet(value: any): boolean {
|
|
428
|
-
return value !== null && value !== undefined
|
|
518
|
+
return value !== null && value !== undefined
|
|
429
519
|
}
|