starpc 0.9.1 → 0.10.1
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/Makefile +1 -1
- package/dist/echo/echo.pb.d.ts +29 -27
- package/dist/echo/echo.pb.js +20 -22
- package/dist/rpcstream/rpcstream.d.ts +4 -3
- package/dist/rpcstream/rpcstream.js +15 -5
- package/dist/rpcstream/rpcstream.pb.d.ts +18 -16
- package/dist/rpcstream/rpcstream.pb.js +60 -77
- package/dist/srpc/conn.d.ts +2 -1
- package/dist/srpc/packet.d.ts +1 -1
- package/dist/srpc/rpcproto.pb.d.ts +16 -14
- package/dist/srpc/rpcproto.pb.js +59 -86
- package/dist/srpc/server-rpc.js +3 -0
- package/dist/srpc/server.d.ts +2 -1
- package/dist/srpc/stream.d.ts +2 -1
- package/echo/echo.pb.go +1 -1
- package/echo/echo.pb.ts +88 -147
- package/echo/echo_srpc.pb.go +1 -1
- package/echo/echo_vtproto.pb.go +3 -3
- package/go.mod +19 -22
- package/go.sum +43 -47
- package/package.json +15 -15
- package/patches/ts-poet+6.1.0.patch +43 -0
- package/srpc/conn.ts +2 -1
- package/srpc/muxed-conn.go +1 -1
- package/srpc/packet.ts +1 -1
- package/srpc/rpcproto.pb.go +2 -1
- package/srpc/rpcproto.pb.ts +196 -277
- package/srpc/rpcproto_vtproto.pb.go +59 -12
- package/srpc/server-rpc.ts +3 -0
- package/srpc/server.go +1 -1
- package/srpc/server.ts +2 -1
- package/srpc/stream.ts +2 -1
- package/srpc/websocket.go +1 -1
- package/patches/ts-poet+4.15.0.patch +0 -45
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import Long from
|
|
3
|
-
import _m0 from
|
|
4
|
-
export const protobufPackage =
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import _m0 from "protobufjs/minimal.js";
|
|
4
|
+
export const protobufPackage = "rpcstream";
|
|
5
5
|
function createBaseRpcStreamPacket() {
|
|
6
6
|
return { body: undefined };
|
|
7
7
|
}
|
|
8
8
|
export const RpcStreamPacket = {
|
|
9
9
|
encode(message, writer = _m0.Writer.create()) {
|
|
10
|
-
if (message.body?.$case ===
|
|
10
|
+
if (message.body?.$case === "init") {
|
|
11
11
|
RpcStreamInit.encode(message.body.init, writer.uint32(10).fork()).ldelim();
|
|
12
12
|
}
|
|
13
|
-
if (message.body?.$case ===
|
|
13
|
+
if (message.body?.$case === "ack") {
|
|
14
14
|
RpcAck.encode(message.body.ack, writer.uint32(18).fork()).ldelim();
|
|
15
15
|
}
|
|
16
|
-
if (message.body?.$case ===
|
|
16
|
+
if (message.body?.$case === "data") {
|
|
17
17
|
writer.uint32(26).bytes(message.body.data);
|
|
18
18
|
}
|
|
19
19
|
return writer;
|
|
@@ -26,19 +26,13 @@ export const RpcStreamPacket = {
|
|
|
26
26
|
const tag = reader.uint32();
|
|
27
27
|
switch (tag >>> 3) {
|
|
28
28
|
case 1:
|
|
29
|
-
message.body = {
|
|
30
|
-
$case: 'init',
|
|
31
|
-
init: RpcStreamInit.decode(reader, reader.uint32()),
|
|
32
|
-
};
|
|
29
|
+
message.body = { $case: "init", init: RpcStreamInit.decode(reader, reader.uint32()) };
|
|
33
30
|
break;
|
|
34
31
|
case 2:
|
|
35
|
-
message.body = {
|
|
36
|
-
$case: 'ack',
|
|
37
|
-
ack: RpcAck.decode(reader, reader.uint32()),
|
|
38
|
-
};
|
|
32
|
+
message.body = { $case: "ack", ack: RpcAck.decode(reader, reader.uint32()) };
|
|
39
33
|
break;
|
|
40
34
|
case 3:
|
|
41
|
-
message.body = { $case:
|
|
35
|
+
message.body = { $case: "data", data: reader.bytes() };
|
|
42
36
|
break;
|
|
43
37
|
default:
|
|
44
38
|
reader.skipType(tag & 7);
|
|
@@ -78,60 +72,43 @@ export const RpcStreamPacket = {
|
|
|
78
72
|
fromJSON(object) {
|
|
79
73
|
return {
|
|
80
74
|
body: isSet(object.init)
|
|
81
|
-
? { $case:
|
|
75
|
+
? { $case: "init", init: RpcStreamInit.fromJSON(object.init) }
|
|
82
76
|
: isSet(object.ack)
|
|
83
|
-
? { $case:
|
|
77
|
+
? { $case: "ack", ack: RpcAck.fromJSON(object.ack) }
|
|
84
78
|
: isSet(object.data)
|
|
85
|
-
? { $case:
|
|
79
|
+
? { $case: "data", data: bytesFromBase64(object.data) }
|
|
86
80
|
: undefined,
|
|
87
81
|
};
|
|
88
82
|
},
|
|
89
83
|
toJSON(message) {
|
|
90
84
|
const obj = {};
|
|
91
|
-
message.body?.$case ===
|
|
92
|
-
(obj.init = message.body?.init
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
(obj.ack = message.body?.ack
|
|
97
|
-
? RpcAck.toJSON(message.body?.ack)
|
|
98
|
-
: undefined);
|
|
99
|
-
message.body?.$case === 'data' &&
|
|
100
|
-
(obj.data =
|
|
101
|
-
message.body?.data !== undefined
|
|
102
|
-
? base64FromBytes(message.body?.data)
|
|
103
|
-
: undefined);
|
|
85
|
+
message.body?.$case === "init" &&
|
|
86
|
+
(obj.init = message.body?.init ? RpcStreamInit.toJSON(message.body?.init) : undefined);
|
|
87
|
+
message.body?.$case === "ack" && (obj.ack = message.body?.ack ? RpcAck.toJSON(message.body?.ack) : undefined);
|
|
88
|
+
message.body?.$case === "data" &&
|
|
89
|
+
(obj.data = message.body?.data !== undefined ? base64FromBytes(message.body?.data) : undefined);
|
|
104
90
|
return obj;
|
|
105
91
|
},
|
|
106
92
|
fromPartial(object) {
|
|
107
93
|
const message = createBaseRpcStreamPacket();
|
|
108
|
-
if (object.body?.$case ===
|
|
109
|
-
|
|
110
|
-
object.body?.init !== null) {
|
|
111
|
-
message.body = {
|
|
112
|
-
$case: 'init',
|
|
113
|
-
init: RpcStreamInit.fromPartial(object.body.init),
|
|
114
|
-
};
|
|
94
|
+
if (object.body?.$case === "init" && object.body?.init !== undefined && object.body?.init !== null) {
|
|
95
|
+
message.body = { $case: "init", init: RpcStreamInit.fromPartial(object.body.init) };
|
|
115
96
|
}
|
|
116
|
-
if (object.body?.$case ===
|
|
117
|
-
|
|
118
|
-
object.body?.ack !== null) {
|
|
119
|
-
message.body = { $case: 'ack', ack: RpcAck.fromPartial(object.body.ack) };
|
|
97
|
+
if (object.body?.$case === "ack" && object.body?.ack !== undefined && object.body?.ack !== null) {
|
|
98
|
+
message.body = { $case: "ack", ack: RpcAck.fromPartial(object.body.ack) };
|
|
120
99
|
}
|
|
121
|
-
if (object.body?.$case ===
|
|
122
|
-
|
|
123
|
-
object.body?.data !== null) {
|
|
124
|
-
message.body = { $case: 'data', data: object.body.data };
|
|
100
|
+
if (object.body?.$case === "data" && object.body?.data !== undefined && object.body?.data !== null) {
|
|
101
|
+
message.body = { $case: "data", data: object.body.data };
|
|
125
102
|
}
|
|
126
103
|
return message;
|
|
127
104
|
},
|
|
128
105
|
};
|
|
129
106
|
function createBaseRpcStreamInit() {
|
|
130
|
-
return { componentId:
|
|
107
|
+
return { componentId: "" };
|
|
131
108
|
}
|
|
132
109
|
export const RpcStreamInit = {
|
|
133
110
|
encode(message, writer = _m0.Writer.create()) {
|
|
134
|
-
if (message.componentId !==
|
|
111
|
+
if (message.componentId !== "") {
|
|
135
112
|
writer.uint32(10).string(message.componentId);
|
|
136
113
|
}
|
|
137
114
|
return writer;
|
|
@@ -182,9 +159,7 @@ export const RpcStreamInit = {
|
|
|
182
159
|
}
|
|
183
160
|
},
|
|
184
161
|
fromJSON(object) {
|
|
185
|
-
return {
|
|
186
|
-
componentId: isSet(object.componentId) ? String(object.componentId) : '',
|
|
187
|
-
};
|
|
162
|
+
return { componentId: isSet(object.componentId) ? String(object.componentId) : "" };
|
|
188
163
|
},
|
|
189
164
|
toJSON(message) {
|
|
190
165
|
const obj = {};
|
|
@@ -193,16 +168,16 @@ export const RpcStreamInit = {
|
|
|
193
168
|
},
|
|
194
169
|
fromPartial(object) {
|
|
195
170
|
const message = createBaseRpcStreamInit();
|
|
196
|
-
message.componentId = object.componentId ??
|
|
171
|
+
message.componentId = object.componentId ?? "";
|
|
197
172
|
return message;
|
|
198
173
|
},
|
|
199
174
|
};
|
|
200
175
|
function createBaseRpcAck() {
|
|
201
|
-
return { error:
|
|
176
|
+
return { error: "" };
|
|
202
177
|
}
|
|
203
178
|
export const RpcAck = {
|
|
204
179
|
encode(message, writer = _m0.Writer.create()) {
|
|
205
|
-
if (message.error !==
|
|
180
|
+
if (message.error !== "") {
|
|
206
181
|
writer.uint32(10).string(message.error);
|
|
207
182
|
}
|
|
208
183
|
return writer;
|
|
@@ -253,9 +228,7 @@ export const RpcAck = {
|
|
|
253
228
|
}
|
|
254
229
|
},
|
|
255
230
|
fromJSON(object) {
|
|
256
|
-
return {
|
|
257
|
-
error: isSet(object.error) ? String(object.error) : '',
|
|
258
|
-
};
|
|
231
|
+
return { error: isSet(object.error) ? String(object.error) : "" };
|
|
259
232
|
},
|
|
260
233
|
toJSON(message) {
|
|
261
234
|
const obj = {};
|
|
@@ -264,39 +237,49 @@ export const RpcAck = {
|
|
|
264
237
|
},
|
|
265
238
|
fromPartial(object) {
|
|
266
239
|
const message = createBaseRpcAck();
|
|
267
|
-
message.error = object.error ??
|
|
240
|
+
message.error = object.error ?? "";
|
|
268
241
|
return message;
|
|
269
242
|
},
|
|
270
243
|
};
|
|
271
244
|
var globalThis = (() => {
|
|
272
|
-
if (typeof globalThis !==
|
|
245
|
+
if (typeof globalThis !== "undefined") {
|
|
273
246
|
return globalThis;
|
|
274
|
-
|
|
247
|
+
}
|
|
248
|
+
if (typeof self !== "undefined") {
|
|
275
249
|
return self;
|
|
276
|
-
|
|
250
|
+
}
|
|
251
|
+
if (typeof window !== "undefined") {
|
|
277
252
|
return window;
|
|
278
|
-
|
|
253
|
+
}
|
|
254
|
+
if (typeof global !== "undefined") {
|
|
279
255
|
return global;
|
|
280
|
-
|
|
256
|
+
}
|
|
257
|
+
throw "Unable to locate global object";
|
|
281
258
|
})();
|
|
282
|
-
const atob = globalThis.atob ||
|
|
283
|
-
((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
|
|
284
259
|
function bytesFromBase64(b64) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
260
|
+
if (globalThis.Buffer) {
|
|
261
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
const bin = globalThis.atob(b64);
|
|
265
|
+
const arr = new Uint8Array(bin.length);
|
|
266
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
267
|
+
arr[i] = bin.charCodeAt(i);
|
|
268
|
+
}
|
|
269
|
+
return arr;
|
|
289
270
|
}
|
|
290
|
-
return arr;
|
|
291
271
|
}
|
|
292
|
-
const btoa = globalThis.btoa ||
|
|
293
|
-
((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
|
|
294
272
|
function base64FromBytes(arr) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
273
|
+
if (globalThis.Buffer) {
|
|
274
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
const bin = [];
|
|
278
|
+
arr.forEach((byte) => {
|
|
279
|
+
bin.push(String.fromCharCode(byte));
|
|
280
|
+
});
|
|
281
|
+
return globalThis.btoa(bin.join(""));
|
|
282
|
+
}
|
|
300
283
|
}
|
|
301
284
|
if (_m0.util.Long !== Long) {
|
|
302
285
|
_m0.util.Long = Long;
|
package/dist/srpc/conn.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Direction, Stream } from '@libp2p/interface-connection';
|
|
2
2
|
import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer';
|
|
3
3
|
import type { Duplex } from 'it-stream-types';
|
|
4
|
+
import { Uint8ArrayList } from 'uint8arraylist';
|
|
4
5
|
import type { OpenStreamFunc, Stream as SRPCStream } from './stream.js';
|
|
5
6
|
import { Client } from './client.js';
|
|
6
7
|
export interface ConnParams {
|
|
@@ -8,7 +9,7 @@ export interface ConnParams {
|
|
|
8
9
|
direction?: Direction;
|
|
9
10
|
}
|
|
10
11
|
export interface StreamHandler {
|
|
11
|
-
handleStream(strm: Duplex<Uint8Array>): void;
|
|
12
|
+
handleStream(strm: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>): void;
|
|
12
13
|
}
|
|
13
14
|
export declare class Conn implements Duplex<Uint8Array> {
|
|
14
15
|
private muxer;
|
package/dist/srpc/packet.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Uint8ArrayList } from 'uint8arraylist';
|
|
|
3
3
|
import { Transform } from 'it-pipe';
|
|
4
4
|
export declare const decodePacketSource: (source: import("it-stream-types").Source<Uint8Array | Uint8Array[]>) => AsyncIterable<Packet>;
|
|
5
5
|
export declare const encodePacketSource: (source: import("it-stream-types").Source<Packet | Packet[]>) => AsyncIterable<Uint8Array>;
|
|
6
|
-
export declare function prependLengthPrefixTransform(): Transform<Uint8Array | Uint8ArrayList,
|
|
6
|
+
export declare function prependLengthPrefixTransform(): Transform<Uint8Array | Uint8ArrayList, Uint8Array>;
|
|
7
7
|
export declare function parseLengthPrefixTransform(): Transform<Uint8Array | Uint8ArrayList, Uint8ArrayList>;
|
|
8
8
|
export declare function encodeUint32Le(value: number): Uint8Array;
|
|
9
9
|
export declare function decodeUint32Le(data: Uint8Array): number;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Long from
|
|
2
|
-
import _m0 from
|
|
1
|
+
import Long from "long";
|
|
2
|
+
import _m0 from "protobufjs/minimal.js";
|
|
3
3
|
export declare const protobufPackage = "srpc";
|
|
4
4
|
/** Packet is a message sent over a srpc packet connection. */
|
|
5
5
|
export interface Packet {
|
|
6
6
|
body?: {
|
|
7
|
-
$case:
|
|
7
|
+
$case: "callStart";
|
|
8
8
|
callStart: CallStart;
|
|
9
9
|
} | {
|
|
10
|
-
$case:
|
|
10
|
+
$case: "callData";
|
|
11
11
|
callData: CallData;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -93,9 +93,9 @@ export declare const Packet: {
|
|
|
93
93
|
rpcMethod?: string | undefined;
|
|
94
94
|
data?: Uint8Array | undefined;
|
|
95
95
|
dataIsZero?: boolean | undefined;
|
|
96
|
-
} &
|
|
96
|
+
} & { [K in Exclude<keyof I["body"]["callStart"], keyof CallStart>]: never; }) | undefined;
|
|
97
97
|
$case: "callStart";
|
|
98
|
-
} &
|
|
98
|
+
} & { [K_1 in Exclude<keyof I["body"], "callStart" | "$case">]: never; }) | ({
|
|
99
99
|
callData?: {
|
|
100
100
|
data?: Uint8Array | undefined;
|
|
101
101
|
dataIsZero?: boolean | undefined;
|
|
@@ -115,10 +115,10 @@ export declare const Packet: {
|
|
|
115
115
|
dataIsZero?: boolean | undefined;
|
|
116
116
|
complete?: boolean | undefined;
|
|
117
117
|
error?: string | undefined;
|
|
118
|
-
} &
|
|
118
|
+
} & { [K_2 in Exclude<keyof I["body"]["callData"], keyof CallData>]: never; }) | undefined;
|
|
119
119
|
$case: "callData";
|
|
120
|
-
} &
|
|
121
|
-
} &
|
|
120
|
+
} & { [K_3 in Exclude<keyof I["body"], "callData" | "$case">]: never; }) | undefined;
|
|
121
|
+
} & { [K_4 in Exclude<keyof I, "body">]: never; }>(object: I): Packet;
|
|
122
122
|
};
|
|
123
123
|
export declare const CallStart: {
|
|
124
124
|
encode(message: CallStart, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -137,7 +137,7 @@ export declare const CallStart: {
|
|
|
137
137
|
rpcMethod?: string | undefined;
|
|
138
138
|
data?: Uint8Array | undefined;
|
|
139
139
|
dataIsZero?: boolean | undefined;
|
|
140
|
-
} &
|
|
140
|
+
} & { [K in Exclude<keyof I, keyof CallStart>]: never; }>(object: I): CallStart;
|
|
141
141
|
};
|
|
142
142
|
export declare const CallData: {
|
|
143
143
|
encode(message: CallData, writer?: _m0.Writer): _m0.Writer;
|
|
@@ -156,20 +156,22 @@ export declare const CallData: {
|
|
|
156
156
|
dataIsZero?: boolean | undefined;
|
|
157
157
|
complete?: boolean | undefined;
|
|
158
158
|
error?: string | undefined;
|
|
159
|
-
} &
|
|
159
|
+
} & { [K in Exclude<keyof I, keyof CallData>]: never; }>(object: I): CallData;
|
|
160
160
|
};
|
|
161
161
|
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
162
162
|
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
163
163
|
$case: string;
|
|
164
164
|
} ? {
|
|
165
|
-
[K in keyof Omit<T,
|
|
165
|
+
[K in keyof Omit<T, "$case">]?: DeepPartial<T[K]>;
|
|
166
166
|
} & {
|
|
167
|
-
$case: T[
|
|
167
|
+
$case: T["$case"];
|
|
168
168
|
} : T extends {} ? {
|
|
169
169
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
170
170
|
} : Partial<T>;
|
|
171
171
|
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
172
172
|
export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
173
173
|
[K in keyof P]: Exact<P[K], I[K]>;
|
|
174
|
-
} &
|
|
174
|
+
} & {
|
|
175
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
176
|
+
};
|
|
175
177
|
export {};
|
package/dist/srpc/rpcproto.pb.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import Long from
|
|
3
|
-
import _m0 from
|
|
4
|
-
export const protobufPackage =
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import _m0 from "protobufjs/minimal.js";
|
|
4
|
+
export const protobufPackage = "srpc";
|
|
5
5
|
function createBasePacket() {
|
|
6
6
|
return { body: undefined };
|
|
7
7
|
}
|
|
8
8
|
export const Packet = {
|
|
9
9
|
encode(message, writer = _m0.Writer.create()) {
|
|
10
|
-
if (message.body?.$case ===
|
|
10
|
+
if (message.body?.$case === "callStart") {
|
|
11
11
|
CallStart.encode(message.body.callStart, writer.uint32(10).fork()).ldelim();
|
|
12
12
|
}
|
|
13
|
-
if (message.body?.$case ===
|
|
13
|
+
if (message.body?.$case === "callData") {
|
|
14
14
|
CallData.encode(message.body.callData, writer.uint32(18).fork()).ldelim();
|
|
15
15
|
}
|
|
16
16
|
return writer;
|
|
@@ -23,16 +23,10 @@ export const Packet = {
|
|
|
23
23
|
const tag = reader.uint32();
|
|
24
24
|
switch (tag >>> 3) {
|
|
25
25
|
case 1:
|
|
26
|
-
message.body = {
|
|
27
|
-
$case: 'callStart',
|
|
28
|
-
callStart: CallStart.decode(reader, reader.uint32()),
|
|
29
|
-
};
|
|
26
|
+
message.body = { $case: "callStart", callStart: CallStart.decode(reader, reader.uint32()) };
|
|
30
27
|
break;
|
|
31
28
|
case 2:
|
|
32
|
-
message.body = {
|
|
33
|
-
$case: 'callData',
|
|
34
|
-
callData: CallData.decode(reader, reader.uint32()),
|
|
35
|
-
};
|
|
29
|
+
message.body = { $case: "callData", callData: CallData.decode(reader, reader.uint32()) };
|
|
36
30
|
break;
|
|
37
31
|
default:
|
|
38
32
|
reader.skipType(tag & 7);
|
|
@@ -72,62 +66,40 @@ export const Packet = {
|
|
|
72
66
|
fromJSON(object) {
|
|
73
67
|
return {
|
|
74
68
|
body: isSet(object.callStart)
|
|
75
|
-
? {
|
|
76
|
-
$case: 'callStart',
|
|
77
|
-
callStart: CallStart.fromJSON(object.callStart),
|
|
78
|
-
}
|
|
69
|
+
? { $case: "callStart", callStart: CallStart.fromJSON(object.callStart) }
|
|
79
70
|
: isSet(object.callData)
|
|
80
|
-
? { $case:
|
|
71
|
+
? { $case: "callData", callData: CallData.fromJSON(object.callData) }
|
|
81
72
|
: undefined,
|
|
82
73
|
};
|
|
83
74
|
},
|
|
84
75
|
toJSON(message) {
|
|
85
76
|
const obj = {};
|
|
86
|
-
message.body?.$case ===
|
|
87
|
-
(obj.callStart = message.body?.callStart
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
message.body?.$case === 'callData' &&
|
|
91
|
-
(obj.callData = message.body?.callData
|
|
92
|
-
? CallData.toJSON(message.body?.callData)
|
|
93
|
-
: undefined);
|
|
77
|
+
message.body?.$case === "callStart" &&
|
|
78
|
+
(obj.callStart = message.body?.callStart ? CallStart.toJSON(message.body?.callStart) : undefined);
|
|
79
|
+
message.body?.$case === "callData" &&
|
|
80
|
+
(obj.callData = message.body?.callData ? CallData.toJSON(message.body?.callData) : undefined);
|
|
94
81
|
return obj;
|
|
95
82
|
},
|
|
96
83
|
fromPartial(object) {
|
|
97
84
|
const message = createBasePacket();
|
|
98
|
-
if (object.body?.$case ===
|
|
99
|
-
|
|
100
|
-
object.body?.callStart !== null) {
|
|
101
|
-
message.body = {
|
|
102
|
-
$case: 'callStart',
|
|
103
|
-
callStart: CallStart.fromPartial(object.body.callStart),
|
|
104
|
-
};
|
|
85
|
+
if (object.body?.$case === "callStart" && object.body?.callStart !== undefined && object.body?.callStart !== null) {
|
|
86
|
+
message.body = { $case: "callStart", callStart: CallStart.fromPartial(object.body.callStart) };
|
|
105
87
|
}
|
|
106
|
-
if (object.body?.$case ===
|
|
107
|
-
|
|
108
|
-
object.body?.callData !== null) {
|
|
109
|
-
message.body = {
|
|
110
|
-
$case: 'callData',
|
|
111
|
-
callData: CallData.fromPartial(object.body.callData),
|
|
112
|
-
};
|
|
88
|
+
if (object.body?.$case === "callData" && object.body?.callData !== undefined && object.body?.callData !== null) {
|
|
89
|
+
message.body = { $case: "callData", callData: CallData.fromPartial(object.body.callData) };
|
|
113
90
|
}
|
|
114
91
|
return message;
|
|
115
92
|
},
|
|
116
93
|
};
|
|
117
94
|
function createBaseCallStart() {
|
|
118
|
-
return {
|
|
119
|
-
rpcService: '',
|
|
120
|
-
rpcMethod: '',
|
|
121
|
-
data: new Uint8Array(),
|
|
122
|
-
dataIsZero: false,
|
|
123
|
-
};
|
|
95
|
+
return { rpcService: "", rpcMethod: "", data: new Uint8Array(), dataIsZero: false };
|
|
124
96
|
}
|
|
125
97
|
export const CallStart = {
|
|
126
98
|
encode(message, writer = _m0.Writer.create()) {
|
|
127
|
-
if (message.rpcService !==
|
|
99
|
+
if (message.rpcService !== "") {
|
|
128
100
|
writer.uint32(10).string(message.rpcService);
|
|
129
101
|
}
|
|
130
|
-
if (message.rpcMethod !==
|
|
102
|
+
if (message.rpcMethod !== "") {
|
|
131
103
|
writer.uint32(18).string(message.rpcMethod);
|
|
132
104
|
}
|
|
133
105
|
if (message.data.length !== 0) {
|
|
@@ -194,11 +166,9 @@ export const CallStart = {
|
|
|
194
166
|
},
|
|
195
167
|
fromJSON(object) {
|
|
196
168
|
return {
|
|
197
|
-
rpcService: isSet(object.rpcService) ? String(object.rpcService) :
|
|
198
|
-
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) :
|
|
199
|
-
data: isSet(object.data)
|
|
200
|
-
? bytesFromBase64(object.data)
|
|
201
|
-
: new Uint8Array(),
|
|
169
|
+
rpcService: isSet(object.rpcService) ? String(object.rpcService) : "",
|
|
170
|
+
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) : "",
|
|
171
|
+
data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
|
|
202
172
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
203
173
|
};
|
|
204
174
|
},
|
|
@@ -213,20 +183,15 @@ export const CallStart = {
|
|
|
213
183
|
},
|
|
214
184
|
fromPartial(object) {
|
|
215
185
|
const message = createBaseCallStart();
|
|
216
|
-
message.rpcService = object.rpcService ??
|
|
217
|
-
message.rpcMethod = object.rpcMethod ??
|
|
186
|
+
message.rpcService = object.rpcService ?? "";
|
|
187
|
+
message.rpcMethod = object.rpcMethod ?? "";
|
|
218
188
|
message.data = object.data ?? new Uint8Array();
|
|
219
189
|
message.dataIsZero = object.dataIsZero ?? false;
|
|
220
190
|
return message;
|
|
221
191
|
},
|
|
222
192
|
};
|
|
223
193
|
function createBaseCallData() {
|
|
224
|
-
return {
|
|
225
|
-
data: new Uint8Array(),
|
|
226
|
-
dataIsZero: false,
|
|
227
|
-
complete: false,
|
|
228
|
-
error: '',
|
|
229
|
-
};
|
|
194
|
+
return { data: new Uint8Array(), dataIsZero: false, complete: false, error: "" };
|
|
230
195
|
}
|
|
231
196
|
export const CallData = {
|
|
232
197
|
encode(message, writer = _m0.Writer.create()) {
|
|
@@ -239,7 +204,7 @@ export const CallData = {
|
|
|
239
204
|
if (message.complete === true) {
|
|
240
205
|
writer.uint32(24).bool(message.complete);
|
|
241
206
|
}
|
|
242
|
-
if (message.error !==
|
|
207
|
+
if (message.error !== "") {
|
|
243
208
|
writer.uint32(34).string(message.error);
|
|
244
209
|
}
|
|
245
210
|
return writer;
|
|
@@ -300,12 +265,10 @@ export const CallData = {
|
|
|
300
265
|
},
|
|
301
266
|
fromJSON(object) {
|
|
302
267
|
return {
|
|
303
|
-
data: isSet(object.data)
|
|
304
|
-
? bytesFromBase64(object.data)
|
|
305
|
-
: new Uint8Array(),
|
|
268
|
+
data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
|
|
306
269
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
307
270
|
complete: isSet(object.complete) ? Boolean(object.complete) : false,
|
|
308
|
-
error: isSet(object.error) ? String(object.error) :
|
|
271
|
+
error: isSet(object.error) ? String(object.error) : "",
|
|
309
272
|
};
|
|
310
273
|
},
|
|
311
274
|
toJSON(message) {
|
|
@@ -322,39 +285,49 @@ export const CallData = {
|
|
|
322
285
|
message.data = object.data ?? new Uint8Array();
|
|
323
286
|
message.dataIsZero = object.dataIsZero ?? false;
|
|
324
287
|
message.complete = object.complete ?? false;
|
|
325
|
-
message.error = object.error ??
|
|
288
|
+
message.error = object.error ?? "";
|
|
326
289
|
return message;
|
|
327
290
|
},
|
|
328
291
|
};
|
|
329
292
|
var globalThis = (() => {
|
|
330
|
-
if (typeof globalThis !==
|
|
293
|
+
if (typeof globalThis !== "undefined") {
|
|
331
294
|
return globalThis;
|
|
332
|
-
|
|
295
|
+
}
|
|
296
|
+
if (typeof self !== "undefined") {
|
|
333
297
|
return self;
|
|
334
|
-
|
|
298
|
+
}
|
|
299
|
+
if (typeof window !== "undefined") {
|
|
335
300
|
return window;
|
|
336
|
-
|
|
301
|
+
}
|
|
302
|
+
if (typeof global !== "undefined") {
|
|
337
303
|
return global;
|
|
338
|
-
|
|
304
|
+
}
|
|
305
|
+
throw "Unable to locate global object";
|
|
339
306
|
})();
|
|
340
|
-
const atob = globalThis.atob ||
|
|
341
|
-
((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
|
|
342
307
|
function bytesFromBase64(b64) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
308
|
+
if (globalThis.Buffer) {
|
|
309
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
const bin = globalThis.atob(b64);
|
|
313
|
+
const arr = new Uint8Array(bin.length);
|
|
314
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
315
|
+
arr[i] = bin.charCodeAt(i);
|
|
316
|
+
}
|
|
317
|
+
return arr;
|
|
347
318
|
}
|
|
348
|
-
return arr;
|
|
349
319
|
}
|
|
350
|
-
const btoa = globalThis.btoa ||
|
|
351
|
-
((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
|
|
352
320
|
function base64FromBytes(arr) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
321
|
+
if (globalThis.Buffer) {
|
|
322
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
const bin = [];
|
|
326
|
+
arr.forEach((byte) => {
|
|
327
|
+
bin.push(String.fromCharCode(byte));
|
|
328
|
+
});
|
|
329
|
+
return globalThis.btoa(bin.join(""));
|
|
330
|
+
}
|
|
358
331
|
}
|
|
359
332
|
if (_m0.util.Long !== Long) {
|
|
360
333
|
_m0.util.Long = Long;
|
package/dist/srpc/server-rpc.js
CHANGED
|
@@ -15,6 +15,9 @@ export class ServerRPC extends CommonRPC {
|
|
|
15
15
|
if (!this.service || !this.method) {
|
|
16
16
|
throw new Error('rpcService and rpcMethod cannot be empty');
|
|
17
17
|
}
|
|
18
|
+
if (!this.lookupMethod) {
|
|
19
|
+
throw new Error('LookupMethod is not defined');
|
|
20
|
+
}
|
|
18
21
|
const methodDef = await this.lookupMethod(this.service, this.method);
|
|
19
22
|
if (!methodDef) {
|
|
20
23
|
throw new Error(`not found: ${this.service}/${this.method}`);
|
package/dist/srpc/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Stream } from '@libp2p/interface-connection';
|
|
2
2
|
import { Duplex } from 'it-stream-types';
|
|
3
|
+
import { Uint8ArrayList } from 'uint8arraylist';
|
|
3
4
|
import { LookupMethod } from './mux.js';
|
|
4
5
|
import { ServerRPC } from './server-rpc.js';
|
|
5
6
|
import { Packet } from './rpcproto.pb.js';
|
|
@@ -11,7 +12,7 @@ export declare class Server implements StreamHandler {
|
|
|
11
12
|
get rpcStreamHandler(): RpcStreamHandler;
|
|
12
13
|
startRpc(): ServerRPC;
|
|
13
14
|
handleStream(stream: Stream): ServerRPC;
|
|
14
|
-
handleDuplex(stream: Duplex<Uint8Array>): ServerRPC;
|
|
15
|
+
handleDuplex(stream: Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>): ServerRPC;
|
|
15
16
|
handlePacketDuplex(stream: Duplex<Uint8Array>): ServerRPC;
|
|
16
17
|
handlePacketStream(stream: Duplex<Packet>): ServerRPC;
|
|
17
18
|
}
|
package/dist/srpc/stream.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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
|
export declare type PacketHandler = (packet: Packet) => Promise<void>;
|
|
4
|
-
export declare type Stream = Duplex<Uint8Array>;
|
|
5
|
+
export declare type Stream = Duplex<Uint8ArrayList, Uint8ArrayList | Uint8Array>;
|
|
5
6
|
export declare type OpenStreamFunc = () => Promise<Stream>;
|