starpc 0.21.4 → 0.21.6
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 -0
- package/README.md +19 -0
- package/dist/e2e/mock/mock.pb.d.ts +2 -1
- package/dist/e2e/mock/mock.pb.js +10 -7
- package/dist/echo/echo.pb.d.ts +2 -1
- package/dist/echo/echo.pb.js +10 -7
- package/dist/rpcstream/rpcstream.pb.d.ts +2 -2
- package/dist/rpcstream/rpcstream.pb.js +40 -53
- package/dist/srpc/conn.d.ts +1 -1
- package/dist/srpc/conn.js +1 -1
- package/dist/srpc/log.d.ts +3 -0
- package/dist/srpc/log.js +21 -0
- package/dist/srpc/rpcproto.pb.d.ts +2 -2
- package/dist/srpc/rpcproto.pb.js +86 -75
- package/e2e/mock/mock.pb.go +2 -2
- package/e2e/mock/mock.pb.ts +27 -25
- package/e2e/mock/mock_srpc.pb.go +1 -1
- package/echo/echo.pb.go +2 -2
- package/echo/echo.pb.ts +27 -25
- package/echo/echo_srpc.pb.go +1 -1
- package/go.mod +2 -2
- package/go.sum +4 -4
- package/package.json +9 -9
- package/srpc/conn.ts +2 -7
- package/srpc/log.ts +25 -0
- package/srpc/rpcproto.pb.go +2 -2
- package/srpc/rpcproto.pb.ts +117 -116
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -195,6 +195,25 @@ Uses [vtprotobuf] to generate Protobuf marshal / unmarshal code.
|
|
|
195
195
|
|
|
196
196
|
[vtprotobuf]: https://github.com/planetscale/vtprotobuf
|
|
197
197
|
|
|
198
|
+
## Developing on MacOS
|
|
199
|
+
|
|
200
|
+
On MacOS, some homebrew packages are required for `yarn gen`:
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
brew install bash make coreutils gnu-sed findutils protobuf
|
|
204
|
+
brew link --overwrite protobuf
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Add to your .bashrc or .zshrc:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
|
|
211
|
+
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
|
|
212
|
+
export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
|
|
213
|
+
export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
|
|
198
217
|
## Support
|
|
199
218
|
|
|
200
219
|
Please file a [GitHub issue] and/or [Join Discord] with any questions.
|
|
@@ -28,6 +28,7 @@ export interface Mock {
|
|
|
28
28
|
/** MockRequest runs a mock unary request. */
|
|
29
29
|
MockRequest(request: MockMsg, abortSignal?: AbortSignal): Promise<MockMsg>;
|
|
30
30
|
}
|
|
31
|
+
export declare const MockServiceName = "e2e.mock.Mock";
|
|
31
32
|
export declare class MockClientImpl implements Mock {
|
|
32
33
|
private readonly rpc;
|
|
33
34
|
private readonly service;
|
|
@@ -91,7 +92,7 @@ interface Rpc {
|
|
|
91
92
|
request(service: string, method: string, data: Uint8Array, abortSignal?: AbortSignal): Promise<Uint8Array>;
|
|
92
93
|
}
|
|
93
94
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
94
|
-
export 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 {
|
|
95
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
95
96
|
$case: string;
|
|
96
97
|
} ? {
|
|
97
98
|
[K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>;
|
package/dist/e2e/mock/mock.pb.js
CHANGED
|
@@ -20,13 +20,13 @@ export const MockMsg = {
|
|
|
20
20
|
const tag = reader.uint32();
|
|
21
21
|
switch (tag >>> 3) {
|
|
22
22
|
case 1:
|
|
23
|
-
if (tag
|
|
23
|
+
if (tag !== 10) {
|
|
24
24
|
break;
|
|
25
25
|
}
|
|
26
26
|
message.body = reader.string();
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
|
-
if ((tag & 7)
|
|
29
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
30
30
|
break;
|
|
31
31
|
}
|
|
32
32
|
reader.skipType(tag & 7);
|
|
@@ -37,7 +37,7 @@ export const MockMsg = {
|
|
|
37
37
|
// Transform<MockMsg, Uint8Array>
|
|
38
38
|
async *encodeTransform(source) {
|
|
39
39
|
for await (const pkt of source) {
|
|
40
|
-
if (Array.isArray(pkt)) {
|
|
40
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
41
41
|
for (const p of pkt) {
|
|
42
42
|
yield* [MockMsg.encode(p).finish()];
|
|
43
43
|
}
|
|
@@ -51,7 +51,7 @@ export const MockMsg = {
|
|
|
51
51
|
// Transform<Uint8Array, MockMsg>
|
|
52
52
|
async *decodeTransform(source) {
|
|
53
53
|
for await (const pkt of source) {
|
|
54
|
-
if (Array.isArray(pkt)) {
|
|
54
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
55
55
|
for (const p of pkt) {
|
|
56
56
|
yield* [MockMsg.decode(p)];
|
|
57
57
|
}
|
|
@@ -62,11 +62,13 @@ export const MockMsg = {
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
fromJSON(object) {
|
|
65
|
-
return { body: isSet(object.body) ? String(object.body) : '' };
|
|
65
|
+
return { body: isSet(object.body) ? globalThis.String(object.body) : '' };
|
|
66
66
|
},
|
|
67
67
|
toJSON(message) {
|
|
68
68
|
const obj = {};
|
|
69
|
-
message.body !==
|
|
69
|
+
if (message.body !== '') {
|
|
70
|
+
obj.body = message.body;
|
|
71
|
+
}
|
|
70
72
|
return obj;
|
|
71
73
|
},
|
|
72
74
|
create(base) {
|
|
@@ -78,9 +80,10 @@ export const MockMsg = {
|
|
|
78
80
|
return message;
|
|
79
81
|
},
|
|
80
82
|
};
|
|
83
|
+
export const MockServiceName = 'e2e.mock.Mock';
|
|
81
84
|
export class MockClientImpl {
|
|
82
85
|
constructor(rpc, opts) {
|
|
83
|
-
this.service = opts?.service ||
|
|
86
|
+
this.service = opts?.service || MockServiceName;
|
|
84
87
|
this.rpc = rpc;
|
|
85
88
|
this.MockRequest = this.MockRequest.bind(this);
|
|
86
89
|
}
|
package/dist/echo/echo.pb.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface Echoer {
|
|
|
37
37
|
/** RpcStream opens a nested rpc call stream. */
|
|
38
38
|
RpcStream(request: AsyncIterable<RpcStreamPacket>, abortSignal?: AbortSignal): AsyncIterable<RpcStreamPacket>;
|
|
39
39
|
}
|
|
40
|
+
export declare const EchoerServiceName = "echo.Echoer";
|
|
40
41
|
export declare class EchoerClientImpl implements Echoer {
|
|
41
42
|
private readonly rpc;
|
|
42
43
|
private readonly service;
|
|
@@ -475,7 +476,7 @@ interface Rpc {
|
|
|
475
476
|
bidirectionalStreamingRequest(service: string, method: string, data: AsyncIterable<Uint8Array>, abortSignal?: AbortSignal): AsyncIterable<Uint8Array>;
|
|
476
477
|
}
|
|
477
478
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
478
|
-
export 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 {
|
|
479
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
479
480
|
$case: string;
|
|
480
481
|
} ? {
|
|
481
482
|
[K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>;
|
package/dist/echo/echo.pb.js
CHANGED
|
@@ -21,13 +21,13 @@ export const EchoMsg = {
|
|
|
21
21
|
const tag = reader.uint32();
|
|
22
22
|
switch (tag >>> 3) {
|
|
23
23
|
case 1:
|
|
24
|
-
if (tag
|
|
24
|
+
if (tag !== 10) {
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
27
|
message.body = reader.string();
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
if ((tag & 7)
|
|
30
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
reader.skipType(tag & 7);
|
|
@@ -38,7 +38,7 @@ export const EchoMsg = {
|
|
|
38
38
|
// Transform<EchoMsg, Uint8Array>
|
|
39
39
|
async *encodeTransform(source) {
|
|
40
40
|
for await (const pkt of source) {
|
|
41
|
-
if (Array.isArray(pkt)) {
|
|
41
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
42
42
|
for (const p of pkt) {
|
|
43
43
|
yield* [EchoMsg.encode(p).finish()];
|
|
44
44
|
}
|
|
@@ -52,7 +52,7 @@ export const EchoMsg = {
|
|
|
52
52
|
// Transform<Uint8Array, EchoMsg>
|
|
53
53
|
async *decodeTransform(source) {
|
|
54
54
|
for await (const pkt of source) {
|
|
55
|
-
if (Array.isArray(pkt)) {
|
|
55
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
56
56
|
for (const p of pkt) {
|
|
57
57
|
yield* [EchoMsg.decode(p)];
|
|
58
58
|
}
|
|
@@ -63,11 +63,13 @@ export const EchoMsg = {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
fromJSON(object) {
|
|
66
|
-
return { body: isSet(object.body) ? String(object.body) : '' };
|
|
66
|
+
return { body: isSet(object.body) ? globalThis.String(object.body) : '' };
|
|
67
67
|
},
|
|
68
68
|
toJSON(message) {
|
|
69
69
|
const obj = {};
|
|
70
|
-
message.body !==
|
|
70
|
+
if (message.body !== '') {
|
|
71
|
+
obj.body = message.body;
|
|
72
|
+
}
|
|
71
73
|
return obj;
|
|
72
74
|
},
|
|
73
75
|
create(base) {
|
|
@@ -79,9 +81,10 @@ export const EchoMsg = {
|
|
|
79
81
|
return message;
|
|
80
82
|
},
|
|
81
83
|
};
|
|
84
|
+
export const EchoerServiceName = 'echo.Echoer';
|
|
82
85
|
export class EchoerClientImpl {
|
|
83
86
|
constructor(rpc, opts) {
|
|
84
|
-
this.service = opts?.service ||
|
|
87
|
+
this.service = opts?.service || EchoerServiceName;
|
|
85
88
|
this.rpc = rpc;
|
|
86
89
|
this.Echo = this.Echo.bind(this);
|
|
87
90
|
this.EchoServerStream = this.EchoServerStream.bind(this);
|
|
@@ -12,7 +12,7 @@ export interface RpcStreamPacket {
|
|
|
12
12
|
} | {
|
|
13
13
|
$case: 'data';
|
|
14
14
|
data: Uint8Array;
|
|
15
|
-
};
|
|
15
|
+
} | undefined;
|
|
16
16
|
}
|
|
17
17
|
/** RpcStreamInit is the first message in a RPC stream. */
|
|
18
18
|
export interface RpcStreamInit {
|
|
@@ -177,7 +177,7 @@ export declare const RpcAck: {
|
|
|
177
177
|
} & { [K_1 in Exclude<keyof I_1, "error">]: never; }>(object: I_1): RpcAck;
|
|
178
178
|
};
|
|
179
179
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
180
|
-
export 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 {
|
|
180
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
181
181
|
$case: string;
|
|
182
182
|
} ? {
|
|
183
183
|
[K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>;
|
|
@@ -28,7 +28,7 @@ export const RpcStreamPacket = {
|
|
|
28
28
|
const tag = reader.uint32();
|
|
29
29
|
switch (tag >>> 3) {
|
|
30
30
|
case 1:
|
|
31
|
-
if (tag
|
|
31
|
+
if (tag !== 10) {
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
message.body = {
|
|
@@ -37,7 +37,7 @@ export const RpcStreamPacket = {
|
|
|
37
37
|
};
|
|
38
38
|
continue;
|
|
39
39
|
case 2:
|
|
40
|
-
if (tag
|
|
40
|
+
if (tag !== 18) {
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
message.body = {
|
|
@@ -46,13 +46,13 @@ export const RpcStreamPacket = {
|
|
|
46
46
|
};
|
|
47
47
|
continue;
|
|
48
48
|
case 3:
|
|
49
|
-
if (tag
|
|
49
|
+
if (tag !== 26) {
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
message.body = { $case: 'data', data: reader.bytes() };
|
|
53
53
|
continue;
|
|
54
54
|
}
|
|
55
|
-
if ((tag & 7)
|
|
55
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
56
56
|
break;
|
|
57
57
|
}
|
|
58
58
|
reader.skipType(tag & 7);
|
|
@@ -63,7 +63,7 @@ export const RpcStreamPacket = {
|
|
|
63
63
|
// Transform<RpcStreamPacket, Uint8Array>
|
|
64
64
|
async *encodeTransform(source) {
|
|
65
65
|
for await (const pkt of source) {
|
|
66
|
-
if (Array.isArray(pkt)) {
|
|
66
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
67
67
|
for (const p of pkt) {
|
|
68
68
|
yield* [RpcStreamPacket.encode(p).finish()];
|
|
69
69
|
}
|
|
@@ -77,7 +77,7 @@ export const RpcStreamPacket = {
|
|
|
77
77
|
// Transform<Uint8Array, RpcStreamPacket>
|
|
78
78
|
async *decodeTransform(source) {
|
|
79
79
|
for await (const pkt of source) {
|
|
80
|
-
if (Array.isArray(pkt)) {
|
|
80
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
81
81
|
for (const p of pkt) {
|
|
82
82
|
yield* [RpcStreamPacket.decode(p)];
|
|
83
83
|
}
|
|
@@ -100,19 +100,15 @@ export const RpcStreamPacket = {
|
|
|
100
100
|
},
|
|
101
101
|
toJSON(message) {
|
|
102
102
|
const obj = {};
|
|
103
|
-
message.body?.$case === 'init'
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
(obj.data =
|
|
113
|
-
message.body?.data !== undefined
|
|
114
|
-
? base64FromBytes(message.body?.data)
|
|
115
|
-
: undefined);
|
|
103
|
+
if (message.body?.$case === 'init') {
|
|
104
|
+
obj.init = RpcStreamInit.toJSON(message.body.init);
|
|
105
|
+
}
|
|
106
|
+
if (message.body?.$case === 'ack') {
|
|
107
|
+
obj.ack = RpcAck.toJSON(message.body.ack);
|
|
108
|
+
}
|
|
109
|
+
if (message.body?.$case === 'data') {
|
|
110
|
+
obj.data = base64FromBytes(message.body.data);
|
|
111
|
+
}
|
|
116
112
|
return obj;
|
|
117
113
|
},
|
|
118
114
|
create(base) {
|
|
@@ -159,13 +155,13 @@ export const RpcStreamInit = {
|
|
|
159
155
|
const tag = reader.uint32();
|
|
160
156
|
switch (tag >>> 3) {
|
|
161
157
|
case 1:
|
|
162
|
-
if (tag
|
|
158
|
+
if (tag !== 10) {
|
|
163
159
|
break;
|
|
164
160
|
}
|
|
165
161
|
message.componentId = reader.string();
|
|
166
162
|
continue;
|
|
167
163
|
}
|
|
168
|
-
if ((tag & 7)
|
|
164
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
169
165
|
break;
|
|
170
166
|
}
|
|
171
167
|
reader.skipType(tag & 7);
|
|
@@ -176,7 +172,7 @@ export const RpcStreamInit = {
|
|
|
176
172
|
// Transform<RpcStreamInit, Uint8Array>
|
|
177
173
|
async *encodeTransform(source) {
|
|
178
174
|
for await (const pkt of source) {
|
|
179
|
-
if (Array.isArray(pkt)) {
|
|
175
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
180
176
|
for (const p of pkt) {
|
|
181
177
|
yield* [RpcStreamInit.encode(p).finish()];
|
|
182
178
|
}
|
|
@@ -190,7 +186,7 @@ export const RpcStreamInit = {
|
|
|
190
186
|
// Transform<Uint8Array, RpcStreamInit>
|
|
191
187
|
async *decodeTransform(source) {
|
|
192
188
|
for await (const pkt of source) {
|
|
193
|
-
if (Array.isArray(pkt)) {
|
|
189
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
194
190
|
for (const p of pkt) {
|
|
195
191
|
yield* [RpcStreamInit.decode(p)];
|
|
196
192
|
}
|
|
@@ -202,12 +198,16 @@ export const RpcStreamInit = {
|
|
|
202
198
|
},
|
|
203
199
|
fromJSON(object) {
|
|
204
200
|
return {
|
|
205
|
-
componentId: isSet(object.componentId)
|
|
201
|
+
componentId: isSet(object.componentId)
|
|
202
|
+
? globalThis.String(object.componentId)
|
|
203
|
+
: '',
|
|
206
204
|
};
|
|
207
205
|
},
|
|
208
206
|
toJSON(message) {
|
|
209
207
|
const obj = {};
|
|
210
|
-
message.componentId !==
|
|
208
|
+
if (message.componentId !== '') {
|
|
209
|
+
obj.componentId = message.componentId;
|
|
210
|
+
}
|
|
211
211
|
return obj;
|
|
212
212
|
},
|
|
213
213
|
create(base) {
|
|
@@ -237,13 +237,13 @@ export const RpcAck = {
|
|
|
237
237
|
const tag = reader.uint32();
|
|
238
238
|
switch (tag >>> 3) {
|
|
239
239
|
case 1:
|
|
240
|
-
if (tag
|
|
240
|
+
if (tag !== 10) {
|
|
241
241
|
break;
|
|
242
242
|
}
|
|
243
243
|
message.error = reader.string();
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
|
-
if ((tag & 7)
|
|
246
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
249
|
reader.skipType(tag & 7);
|
|
@@ -254,7 +254,7 @@ export const RpcAck = {
|
|
|
254
254
|
// Transform<RpcAck, Uint8Array>
|
|
255
255
|
async *encodeTransform(source) {
|
|
256
256
|
for await (const pkt of source) {
|
|
257
|
-
if (Array.isArray(pkt)) {
|
|
257
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
258
258
|
for (const p of pkt) {
|
|
259
259
|
yield* [RpcAck.encode(p).finish()];
|
|
260
260
|
}
|
|
@@ -268,7 +268,7 @@ export const RpcAck = {
|
|
|
268
268
|
// Transform<Uint8Array, RpcAck>
|
|
269
269
|
async *decodeTransform(source) {
|
|
270
270
|
for await (const pkt of source) {
|
|
271
|
-
if (Array.isArray(pkt)) {
|
|
271
|
+
if (globalThis.Array.isArray(pkt)) {
|
|
272
272
|
for (const p of pkt) {
|
|
273
273
|
yield* [RpcAck.decode(p)];
|
|
274
274
|
}
|
|
@@ -279,11 +279,13 @@ export const RpcAck = {
|
|
|
279
279
|
}
|
|
280
280
|
},
|
|
281
281
|
fromJSON(object) {
|
|
282
|
-
return { error: isSet(object.error) ? String(object.error) : '' };
|
|
282
|
+
return { error: isSet(object.error) ? globalThis.String(object.error) : '' };
|
|
283
283
|
},
|
|
284
284
|
toJSON(message) {
|
|
285
285
|
const obj = {};
|
|
286
|
-
message.error !==
|
|
286
|
+
if (message.error !== '') {
|
|
287
|
+
obj.error = message.error;
|
|
288
|
+
}
|
|
287
289
|
return obj;
|
|
288
290
|
},
|
|
289
291
|
create(base) {
|
|
@@ -295,27 +297,12 @@ export const RpcAck = {
|
|
|
295
297
|
return message;
|
|
296
298
|
},
|
|
297
299
|
};
|
|
298
|
-
var tsProtoGlobalThis = (() => {
|
|
299
|
-
if (typeof globalThis !== 'undefined') {
|
|
300
|
-
return globalThis;
|
|
301
|
-
}
|
|
302
|
-
if (typeof self !== 'undefined') {
|
|
303
|
-
return self;
|
|
304
|
-
}
|
|
305
|
-
if (typeof window !== 'undefined') {
|
|
306
|
-
return window;
|
|
307
|
-
}
|
|
308
|
-
if (typeof global !== 'undefined') {
|
|
309
|
-
return global;
|
|
310
|
-
}
|
|
311
|
-
throw 'Unable to locate global object';
|
|
312
|
-
})();
|
|
313
300
|
function bytesFromBase64(b64) {
|
|
314
|
-
if (
|
|
315
|
-
return Uint8Array.from(
|
|
301
|
+
if (globalThis.Buffer) {
|
|
302
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'));
|
|
316
303
|
}
|
|
317
304
|
else {
|
|
318
|
-
const bin =
|
|
305
|
+
const bin = globalThis.atob(b64);
|
|
319
306
|
const arr = new Uint8Array(bin.length);
|
|
320
307
|
for (let i = 0; i < bin.length; ++i) {
|
|
321
308
|
arr[i] = bin.charCodeAt(i);
|
|
@@ -324,15 +311,15 @@ function bytesFromBase64(b64) {
|
|
|
324
311
|
}
|
|
325
312
|
}
|
|
326
313
|
function base64FromBytes(arr) {
|
|
327
|
-
if (
|
|
328
|
-
return
|
|
314
|
+
if (globalThis.Buffer) {
|
|
315
|
+
return globalThis.Buffer.from(arr).toString('base64');
|
|
329
316
|
}
|
|
330
317
|
else {
|
|
331
318
|
const bin = [];
|
|
332
319
|
arr.forEach((byte) => {
|
|
333
|
-
bin.push(String.fromCharCode(byte));
|
|
320
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
334
321
|
});
|
|
335
|
-
return
|
|
322
|
+
return globalThis.btoa(bin.join(''));
|
|
336
323
|
}
|
|
337
324
|
}
|
|
338
325
|
if (_m0.util.Long !== Long) {
|
package/dist/srpc/conn.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface StreamHandler {
|
|
|
12
12
|
handlePacketStream(strm: SRPCStream): void;
|
|
13
13
|
}
|
|
14
14
|
export declare function streamToSRPCStream(stream: Duplex<AsyncIterable<Uint8ArrayList>, Source<Uint8ArrayList | Uint8Array>, Promise<void>>): SRPCStream;
|
|
15
|
-
export declare class Conn implements Duplex<AsyncGenerator<Uint8Array
|
|
15
|
+
export declare class Conn implements Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
|
|
16
16
|
private muxer;
|
|
17
17
|
private server?;
|
|
18
18
|
constructor(server?: StreamHandler, connParams?: ConnParams);
|
package/dist/srpc/conn.js
CHANGED
package/dist/srpc/log.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// https://github.com/libp2p/js-libp2p/issues/2276
|
|
2
|
+
// https://github.com/libp2p/js-libp2p/blob/bca8d6e689b47d85dda74082ed72e671139391de/packages/logger/src/index.ts#L86
|
|
3
|
+
// https://github.com/libp2p/js-libp2p/issues/2275
|
|
4
|
+
// https://github.com/ChainSafe/js-libp2p-yamux/issues/69
|
|
5
|
+
export function createDisabledLogger(namespace) {
|
|
6
|
+
const logger = () => { };
|
|
7
|
+
logger.enabled = false;
|
|
8
|
+
logger.color = '';
|
|
9
|
+
logger.diff = 0;
|
|
10
|
+
logger.log = () => { };
|
|
11
|
+
logger.namespace = namespace;
|
|
12
|
+
logger.destroy = () => true;
|
|
13
|
+
logger.extend = () => logger;
|
|
14
|
+
logger.debug = logger;
|
|
15
|
+
logger.error = logger;
|
|
16
|
+
logger.trace = logger;
|
|
17
|
+
return logger;
|
|
18
|
+
}
|
|
19
|
+
export function createDisabledComponentLogger() {
|
|
20
|
+
return { forComponent: createDisabledLogger };
|
|
21
|
+
}
|
|
@@ -12,7 +12,7 @@ export interface Packet {
|
|
|
12
12
|
} | {
|
|
13
13
|
$case: 'callCancel';
|
|
14
14
|
callCancel: boolean;
|
|
15
|
-
};
|
|
15
|
+
} | undefined;
|
|
16
16
|
}
|
|
17
17
|
/** CallStart requests starting a new RPC call. */
|
|
18
18
|
export interface CallStart {
|
|
@@ -273,7 +273,7 @@ export declare const CallData: {
|
|
|
273
273
|
} & { [K_1 in Exclude<keyof I_1, keyof CallData>]: never; }>(object: I_1): CallData;
|
|
274
274
|
};
|
|
275
275
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
276
|
-
export 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 {
|
|
276
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {
|
|
277
277
|
$case: string;
|
|
278
278
|
} ? {
|
|
279
279
|
[K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]>;
|