starpc 0.49.3 → 0.49.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/dist/srpc/conn.d.ts +4 -4
- package/dist/srpc/conn.js +1 -1
- package/dist/srpc/index.d.ts +1 -0
- package/dist/srpc/log.d.ts +1 -1
- package/dist/srpc/stream-muxer.d.ts +38 -0
- package/dist/srpc/stream-muxer.js +1 -0
- package/dist/srpc/stream.d.ts +1 -1
- package/dist/srpc/websocket.d.ts +1 -1
- package/go.mod +7 -8
- package/go.sum +10 -6
- package/package.json +16 -17
- package/srpc/aptre-yamux.d.ts +21 -0
- package/srpc/conn.ts +5 -5
- package/srpc/index.ts +10 -0
- package/srpc/log.ts +1 -1
- package/srpc/stream-muxer.ts +58 -0
- package/srpc/stream.ts +1 -1
- package/srpc/websocket.ts +1 -1
package/dist/srpc/conn.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { YamuxMuxerInit } from '@
|
|
2
|
-
import type { ComponentLogger, Direction, Stream, StreamMuxer, StreamMuxerFactory } from '@libp2p/interface';
|
|
1
|
+
import { YamuxMuxerInit } from '@aptre/yamux';
|
|
3
2
|
import type { Duplex } from 'it-stream-types';
|
|
4
3
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
4
|
+
import type { ComponentLogger, Direction, Stream, StreamMuxer, StreamMuxerFactory } from './stream-muxer.js';
|
|
5
5
|
import { type OpenStreamFunc, type PacketStream } from './stream.js';
|
|
6
6
|
import { Client } from './client.js';
|
|
7
7
|
export interface StreamConnParams {
|
|
@@ -17,8 +17,8 @@ export declare class StreamConn implements Duplex<AsyncGenerator<Uint8Array | Ui
|
|
|
17
17
|
private _muxer;
|
|
18
18
|
private _server?;
|
|
19
19
|
constructor(server?: StreamHandler, connParams?: StreamConnParams);
|
|
20
|
-
get sink(): import("it-stream-types").Sink<AsyncGenerator<
|
|
21
|
-
get source(): AsyncGenerator<
|
|
20
|
+
get sink(): import("it-stream-types").Sink<AsyncGenerator<any, any, any>, unknown>;
|
|
21
|
+
get source(): AsyncGenerator<any, any, any>;
|
|
22
22
|
get streams(): Stream[];
|
|
23
23
|
get muxer(): StreamMuxer;
|
|
24
24
|
get server(): StreamHandler | undefined;
|
package/dist/srpc/conn.js
CHANGED
package/dist/srpc/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { Client } from './client.js';
|
|
|
3
3
|
export { Server } from './server.js';
|
|
4
4
|
export { StreamConn } from './conn.js';
|
|
5
5
|
export type { StreamConnParams, StreamHandler } from './conn.js';
|
|
6
|
+
export type { AbortOptions, ComponentLogger, Direction, Logger, Stream, StreamMuxer, StreamMuxerFactory, StreamMuxerInit, } from './stream-muxer.js';
|
|
6
7
|
export { WebSocketConn } from './websocket.js';
|
|
7
8
|
export type { PacketHandler, OpenStreamFunc, HandleStreamFunc, PacketStream, streamToPacketStream, } from './stream.js';
|
|
8
9
|
export { StaticHandler, createHandler } from './handler.js';
|
package/dist/srpc/log.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ComponentLogger, Logger } from '
|
|
1
|
+
import type { ComponentLogger, Logger } from './stream-muxer.js';
|
|
2
2
|
export declare function createDisabledLogger(namespace: string): Logger;
|
|
3
3
|
export declare function createDisabledComponentLogger(): ComponentLogger;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Duplex, Source } from 'it-stream-types';
|
|
2
|
+
export type Direction = 'inbound' | 'outbound';
|
|
3
|
+
export interface AbortOptions {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
export interface Logger {
|
|
7
|
+
(formatter: any, ...args: any[]): void;
|
|
8
|
+
error(formatter: any, ...args: any[]): void;
|
|
9
|
+
trace(formatter: any, ...args: any[]): void;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
newScope(name: string): Logger;
|
|
12
|
+
}
|
|
13
|
+
export interface ComponentLogger {
|
|
14
|
+
forComponent(name: string): Logger;
|
|
15
|
+
}
|
|
16
|
+
export interface Stream extends Duplex<AsyncGenerator<any>, Source<any>, Promise<void>> {
|
|
17
|
+
close(options?: AbortOptions): Promise<void>;
|
|
18
|
+
closeRead(options?: AbortOptions): Promise<void>;
|
|
19
|
+
closeWrite(options?: AbortOptions): Promise<void>;
|
|
20
|
+
abort(err: Error): void;
|
|
21
|
+
}
|
|
22
|
+
export interface StreamMuxerInit {
|
|
23
|
+
onIncomingStream?(stream: Stream): void;
|
|
24
|
+
onStreamEnd?(stream: Stream): void;
|
|
25
|
+
direction?: Direction;
|
|
26
|
+
log?: Logger;
|
|
27
|
+
}
|
|
28
|
+
export interface StreamMuxerFactory {
|
|
29
|
+
protocol: string;
|
|
30
|
+
createStreamMuxer(init?: StreamMuxerInit): StreamMuxer;
|
|
31
|
+
}
|
|
32
|
+
export interface StreamMuxer extends Duplex<AsyncGenerator<any>> {
|
|
33
|
+
protocol: string;
|
|
34
|
+
readonly streams: Stream[];
|
|
35
|
+
newStream(name?: string): Stream | Promise<Stream>;
|
|
36
|
+
close(options?: AbortOptions): Promise<void>;
|
|
37
|
+
abort(err: Error): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/srpc/stream.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Duplex, Source } from 'it-stream-types';
|
|
2
|
-
import { Stream } from '
|
|
2
|
+
import type { Stream } from './stream-muxer.js';
|
|
3
3
|
import type { Packet } from './rpcproto.pb.js';
|
|
4
4
|
export type PacketHandler = (packet: Packet) => Promise<void>;
|
|
5
5
|
export type PacketStream = Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>;
|
package/dist/srpc/websocket.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Direction } from '@libp2p/interface';
|
|
2
1
|
import type WebSocket from '@aptre/it-ws/web-socket';
|
|
2
|
+
import type { Direction } from './stream-muxer.js';
|
|
3
3
|
import { StreamConn } from './conn.js';
|
|
4
4
|
import { Server } from './server.js';
|
|
5
5
|
export declare class WebSocketConn extends StreamConn {
|
package/go.mod
CHANGED
|
@@ -3,32 +3,31 @@ module github.com/aperturerobotics/starpc
|
|
|
3
3
|
go 1.25.0
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
|
-
github.com/aperturerobotics/common v0.32.
|
|
7
|
-
github.com/aperturerobotics/protobuf-go-lite v0.
|
|
8
|
-
github.com/aperturerobotics/util v1.
|
|
6
|
+
github.com/aperturerobotics/common v0.32.7 // latest
|
|
7
|
+
github.com/aperturerobotics/protobuf-go-lite v0.13.0 // latest
|
|
8
|
+
github.com/aperturerobotics/util v1.34.3 // latest
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
12
|
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 // aperture-2
|
|
13
13
|
github.com/aperturerobotics/cli v1.1.0 // indirect
|
|
14
|
+
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0 // indirect
|
|
14
15
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260329113540-600516012db3 // indirect
|
|
16
|
+
github.com/aperturerobotics/go-websocket v1.8.15-0.20260329113544-74dbfb8f11c6 // master
|
|
15
17
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726 // indirect
|
|
16
18
|
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 // wasi
|
|
17
19
|
)
|
|
18
20
|
|
|
19
21
|
require (
|
|
20
|
-
github.com/aperturerobotics/go-websocket v1.8.15-0.20260329113544-74dbfb8f11c6 // master
|
|
21
22
|
github.com/libp2p/go-yamux/v4 v4.0.2 // latest
|
|
22
23
|
github.com/pkg/errors v0.9.1 // latest
|
|
23
24
|
github.com/sirupsen/logrus v1.9.5-0.20260309202648-9f0600962f75 // latest
|
|
24
|
-
google.golang.org/protobuf v1.36.11 // latest
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
require (
|
|
28
|
-
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0 // indirect
|
|
29
28
|
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
|
30
29
|
github.com/tetratelabs/wazero v1.11.0 // indirect
|
|
31
30
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 // indirect
|
|
32
|
-
golang.org/x/mod v0.
|
|
33
|
-
golang.org/x/sys v0.
|
|
31
|
+
golang.org/x/mod v0.35.0 // indirect
|
|
32
|
+
golang.org/x/sys v0.43.0 // indirect
|
|
34
33
|
)
|
package/go.sum
CHANGED
|
@@ -2,8 +2,8 @@ github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017 h1:3U7
|
|
|
2
2
|
github.com/aperturerobotics/abseil-cpp v0.0.0-20260131110040-4bb56e2f9017/go.mod h1:lNSJTKECIUFAnfeSqy01kXYTYe1BHubW7198jNX3nEw=
|
|
3
3
|
github.com/aperturerobotics/cli v1.1.0 h1:7a+YRC+EY3npAnTzhHV5gLCiw91KS0Ts3XwLILGOsT8=
|
|
4
4
|
github.com/aperturerobotics/cli v1.1.0/go.mod h1:M7BFP9wow5ytTzMyJQOOO991fGfsUqdTI7gGEsHfTQ8=
|
|
5
|
-
github.com/aperturerobotics/common v0.32.
|
|
6
|
-
github.com/aperturerobotics/common v0.32.
|
|
5
|
+
github.com/aperturerobotics/common v0.32.7 h1:gmiFtqEpJm9kMMj3ZaWcu/JJtbLL4z9vInnp1mY4QVo=
|
|
6
|
+
github.com/aperturerobotics/common v0.32.7/go.mod h1:2ShBlwKiYj6LbKUQCEHvMBt70wJ5v+Wkwtoe4hCRsnA=
|
|
7
7
|
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0 h1:6/3RSSlPEQ6LeidslB1ZCJkxW+MnfYDkvdWMDklDXw4=
|
|
8
8
|
github.com/aperturerobotics/go-protoc-gen-prost v0.0.0-20260329113538-218ccd8f20e0/go.mod h1:OBb/beWmr/pDIZAUfi86j/4tBh2v5ctTxKMqSnh9c/4=
|
|
9
9
|
github.com/aperturerobotics/go-protoc-wasi v0.0.0-20260329113540-600516012db3 h1:lp+V8RYcBwTX1p81swkpZn5fhw1wn2xLorzETIxRyZQ=
|
|
@@ -14,10 +14,12 @@ github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f
|
|
|
14
14
|
github.com/aperturerobotics/json-iterator-lite v1.0.1-0.20251104042408-0c9eb8a3f726/go.mod h1:SvGGBv3OVxUyqO0ZxA/nvs6z3cg7NIbZ64TnbV2OISo=
|
|
15
15
|
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4 h1:4Dy3BAHh2kgVdHAqtlwcFsgY0kAwUe2m3rfFcaGwGQg=
|
|
16
16
|
github.com/aperturerobotics/protobuf v0.0.0-20260203024654-8201686529c4/go.mod h1:tMgO7y6SJo/d9ZcvrpNqIQtdYT9de+QmYaHOZ4KnhOg=
|
|
17
|
-
github.com/aperturerobotics/protobuf-go-lite v0.
|
|
18
|
-
github.com/aperturerobotics/protobuf-go-lite v0.
|
|
17
|
+
github.com/aperturerobotics/protobuf-go-lite v0.13.0 h1:jEvCJhHaJEikDY/va2AUnS0DOb/0n82aISLAqxSh4Sk=
|
|
18
|
+
github.com/aperturerobotics/protobuf-go-lite v0.13.0/go.mod h1:lGH3s5ArCTXKI4wJdlNpaybUtwSjfAG0vdWjxOfMcF8=
|
|
19
19
|
github.com/aperturerobotics/util v1.33.0 h1:l7Aql7rlFZaGPRS+lzFC7h0zuLE0WyR3nPVXgCYMW88=
|
|
20
20
|
github.com/aperturerobotics/util v1.33.0/go.mod h1:FOKm51ZpgLsRszA4e7mjvqrt6J6Pju5GjSJg1Qz4Ouo=
|
|
21
|
+
github.com/aperturerobotics/util v1.34.3 h1:9lFYJovGlAHYX66aWKVzfoVzYox13P054d/Dy8T/GRg=
|
|
22
|
+
github.com/aperturerobotics/util v1.34.3/go.mod h1:xtE2hwpgKGaW0TLx01+9xLsG+rYvhygQ+JCuQeAbvME=
|
|
21
23
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
22
24
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
23
25
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
|
@@ -38,10 +40,12 @@ github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbw
|
|
|
38
40
|
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
|
|
39
41
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342 h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
|
|
40
42
|
github.com/xrash/smetrics v0.0.0-20250705151800-55b8f293f342/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
|
41
|
-
golang.org/x/mod v0.
|
|
42
|
-
golang.org/x/mod v0.
|
|
43
|
+
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
|
44
|
+
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
|
43
45
|
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
|
|
44
46
|
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
47
|
+
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
|
48
|
+
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|
45
49
|
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
|
46
50
|
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
|
47
51
|
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.49.
|
|
3
|
+
"version": "0.49.6",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"gen:force": "bun run go:aptre -- generate --force && bun run format",
|
|
77
77
|
"test": "bun run test:js && bun run test:go",
|
|
78
78
|
"test:go": "bun run go:aptre -- test",
|
|
79
|
-
"test:cpp": "mkdir -p build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build . --parallel && ctest --output-on-failure",
|
|
79
|
+
"test:cpp": "mkdir -p build && cd build && cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release && cmake --build . --parallel && ctest --output-on-failure",
|
|
80
80
|
"build:e2e": "bun run build && cd e2e && esbuild e2e.ts --sourcemap --outfile=e2e.cjs --bundle --platform=node",
|
|
81
81
|
"test:js": "vitest run",
|
|
82
82
|
"test:js:watch": "vitest",
|
|
@@ -109,36 +109,35 @@
|
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@eslint/js": "^10.0.0",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
113
|
-
"@typescript-eslint/parser": "^8.
|
|
112
|
+
"@typescript-eslint/eslint-plugin": "^8.59.0",
|
|
113
|
+
"@typescript-eslint/parser": "^8.59.0",
|
|
114
114
|
"depcheck": "^1.4.6",
|
|
115
|
-
"esbuild": "^0.
|
|
116
|
-
"eslint": "^10.1
|
|
115
|
+
"esbuild": "^0.28.0",
|
|
116
|
+
"eslint": "^10.2.1",
|
|
117
117
|
"eslint-config-prettier": "^10.0.0",
|
|
118
118
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
119
|
-
"globals": "^17.
|
|
120
|
-
"happy-dom": "^20.
|
|
119
|
+
"globals": "^17.5.0",
|
|
120
|
+
"happy-dom": "^20.9.0",
|
|
121
121
|
"husky": "^9.1.7",
|
|
122
122
|
"lint-staged": "^16.4.0",
|
|
123
|
-
"prettier": "^3.8.
|
|
123
|
+
"prettier": "^3.8.3",
|
|
124
124
|
"rimraf": "^6.1.3",
|
|
125
125
|
"tsx": "^4.20.4",
|
|
126
|
-
"typescript": "^6.0.
|
|
127
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
128
|
-
"vitest": "^4.1.
|
|
126
|
+
"typescript": "^6.0.3",
|
|
127
|
+
"@typescript/native-preview": "^7.0.0-dev.20260422.1",
|
|
128
|
+
"vitest": "^4.1.5"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
+
"@aptre/yamux": "^1.0.3",
|
|
131
132
|
"@aptre/it-ws": "^1.1.2",
|
|
132
133
|
"@aptre/protobuf-es-lite": "^1.0.1",
|
|
133
|
-
"@chainsafe/libp2p-yamux": "^7.0.1",
|
|
134
|
-
"@libp2p/interface": "^2.6.1",
|
|
135
134
|
"event-iterator": "^2.0.0",
|
|
136
135
|
"isomorphic-ws": "^5.0.0",
|
|
137
|
-
"it-first": "^3.0.
|
|
136
|
+
"it-first": "^3.0.11",
|
|
138
137
|
"it-pipe": "^3.0.1",
|
|
139
138
|
"it-pushable": "^3.2.3",
|
|
140
|
-
"it-stream-types": "^2.0.
|
|
141
|
-
"uint8arraylist": "^2.4.
|
|
139
|
+
"it-stream-types": "^2.0.4",
|
|
140
|
+
"uint8arraylist": "^2.4.9",
|
|
142
141
|
"ws": "^8.20.0"
|
|
143
142
|
}
|
|
144
143
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ComponentLogger, StreamMuxerFactory } from './stream-muxer.js'
|
|
2
|
+
|
|
3
|
+
declare module '@aptre/yamux' {
|
|
4
|
+
export interface YamuxMuxerInit {
|
|
5
|
+
enableKeepAlive?: boolean
|
|
6
|
+
keepAliveInterval?: number
|
|
7
|
+
maxInboundStreams?: number
|
|
8
|
+
maxOutboundStreams?: number
|
|
9
|
+
initialStreamWindowSize?: number
|
|
10
|
+
maxStreamWindowSize?: number
|
|
11
|
+
maxMessageSize?: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface YamuxMuxerComponents {
|
|
15
|
+
logger: ComponentLogger
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function yamux(
|
|
19
|
+
init?: YamuxMuxerInit,
|
|
20
|
+
): (components: YamuxMuxerComponents) => StreamMuxerFactory
|
|
21
|
+
}
|
package/srpc/conn.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { YamuxMuxerInit, yamux } from '@
|
|
1
|
+
import { YamuxMuxerInit, yamux } from '@aptre/yamux'
|
|
2
|
+
import type { Duplex } from 'it-stream-types'
|
|
3
|
+
import { Uint8ArrayList } from 'uint8arraylist'
|
|
4
|
+
|
|
2
5
|
import type {
|
|
3
6
|
ComponentLogger,
|
|
4
7
|
Direction,
|
|
5
8
|
Stream,
|
|
6
9
|
StreamMuxer,
|
|
7
10
|
StreamMuxerFactory,
|
|
8
|
-
} from '
|
|
9
|
-
import type { Duplex } from 'it-stream-types'
|
|
10
|
-
import { Uint8ArrayList } from 'uint8arraylist'
|
|
11
|
-
|
|
11
|
+
} from './stream-muxer.js'
|
|
12
12
|
import {
|
|
13
13
|
streamToPacketStream,
|
|
14
14
|
type OpenStreamFunc,
|
package/srpc/index.ts
CHANGED
|
@@ -9,6 +9,16 @@ export { Client } from './client.js'
|
|
|
9
9
|
export { Server } from './server.js'
|
|
10
10
|
export { StreamConn } from './conn.js'
|
|
11
11
|
export type { StreamConnParams, StreamHandler } from './conn.js'
|
|
12
|
+
export type {
|
|
13
|
+
AbortOptions,
|
|
14
|
+
ComponentLogger,
|
|
15
|
+
Direction,
|
|
16
|
+
Logger,
|
|
17
|
+
Stream,
|
|
18
|
+
StreamMuxer,
|
|
19
|
+
StreamMuxerFactory,
|
|
20
|
+
StreamMuxerInit,
|
|
21
|
+
} from './stream-muxer.js'
|
|
12
22
|
export { WebSocketConn } from './websocket.js'
|
|
13
23
|
export type {
|
|
14
24
|
PacketHandler,
|
package/srpc/log.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentLogger, Logger } from '
|
|
1
|
+
import type { ComponentLogger, Logger } from './stream-muxer.js'
|
|
2
2
|
|
|
3
3
|
// https://github.com/libp2p/js-libp2p/issues/2276
|
|
4
4
|
// https://github.com/libp2p/js-libp2p/blob/bca8d6e689b47d85dda74082ed72e671139391de/packages/logger/src/index.ts#L86
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Duplex, Source } from 'it-stream-types'
|
|
2
|
+
|
|
3
|
+
// Direction describes which side initiated a muxed connection or stream.
|
|
4
|
+
export type Direction = 'inbound' | 'outbound'
|
|
5
|
+
|
|
6
|
+
// AbortOptions carries an optional abort signal.
|
|
7
|
+
export interface AbortOptions {
|
|
8
|
+
signal?: AbortSignal
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Logger is the minimal callable logger surface used by the muxer stack.
|
|
12
|
+
export interface Logger {
|
|
13
|
+
(formatter: any, ...args: any[]): void
|
|
14
|
+
error(formatter: any, ...args: any[]): void
|
|
15
|
+
trace(formatter: any, ...args: any[]): void
|
|
16
|
+
enabled: boolean
|
|
17
|
+
newScope(name: string): Logger
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ComponentLogger builds per-component loggers.
|
|
21
|
+
export interface ComponentLogger {
|
|
22
|
+
forComponent(name: string): Logger
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Stream is the supported duplex stream shape accepted by StreamConn.
|
|
26
|
+
export interface Stream extends Duplex<
|
|
27
|
+
AsyncGenerator<any>,
|
|
28
|
+
Source<any>,
|
|
29
|
+
Promise<void>
|
|
30
|
+
> {
|
|
31
|
+
close(options?: AbortOptions): Promise<void>
|
|
32
|
+
closeRead(options?: AbortOptions): Promise<void>
|
|
33
|
+
closeWrite(options?: AbortOptions): Promise<void>
|
|
34
|
+
abort(err: Error): void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// StreamMuxerInit configures an individual muxer instance.
|
|
38
|
+
export interface StreamMuxerInit {
|
|
39
|
+
onIncomingStream?(stream: Stream): void
|
|
40
|
+
onStreamEnd?(stream: Stream): void
|
|
41
|
+
direction?: Direction
|
|
42
|
+
log?: Logger
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// StreamMuxerFactory constructs stream muxers over a duplex transport.
|
|
46
|
+
export interface StreamMuxerFactory {
|
|
47
|
+
protocol: string
|
|
48
|
+
createStreamMuxer(init?: StreamMuxerInit): StreamMuxer
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// StreamMuxer is the supported multiplexed transport surface.
|
|
52
|
+
export interface StreamMuxer extends Duplex<AsyncGenerator<any>> {
|
|
53
|
+
protocol: string
|
|
54
|
+
readonly streams: Stream[]
|
|
55
|
+
newStream(name?: string): Stream | Promise<Stream>
|
|
56
|
+
close(options?: AbortOptions): Promise<void>
|
|
57
|
+
abort(err: Error): void
|
|
58
|
+
}
|
package/srpc/stream.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Duplex, Source } from 'it-stream-types'
|
|
2
2
|
import { pipe } from 'it-pipe'
|
|
3
|
-
import { Stream } from '@libp2p/interface'
|
|
4
3
|
|
|
4
|
+
import type { Stream } from './stream-muxer.js'
|
|
5
5
|
import type { Packet } from './rpcproto.pb.js'
|
|
6
6
|
import { combineUint8ArrayListTransform } from './array-list.js'
|
|
7
7
|
import {
|
package/srpc/websocket.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { pipe } from 'it-pipe'
|
|
2
|
-
import { Direction } from '@libp2p/interface'
|
|
3
2
|
|
|
4
3
|
import duplex from '@aptre/it-ws/duplex'
|
|
5
4
|
import type WebSocket from '@aptre/it-ws/web-socket'
|
|
6
5
|
|
|
6
|
+
import type { Direction } from './stream-muxer.js'
|
|
7
7
|
import { StreamConn } from './conn.js'
|
|
8
8
|
import { Server } from './server.js'
|
|
9
9
|
import { combineUint8ArrayListTransform } from './array-list.js'
|