@orpc/client 2.0.0-beta.49 → 2.0.0-beta.50
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/adapters/fetch/index.d.ts +3 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/rpc-link.d.ts +8 -8
- package/dist/adapters/fetch/rpc-link.js +16 -13
- package/dist/adapters/fetch/transport.d.ts +29 -31
- package/dist/adapters/fetch/transport.js +49 -63
- package/dist/adapters/message-port/index.d.ts +4 -3
- package/dist/adapters/message-port/index.js +3 -3
- package/dist/adapters/message-port/message-port.d.ts +13 -13
- package/dist/adapters/message-port/message-port.js +35 -53
- package/dist/adapters/message-port/rpc-link.d.ts +8 -8
- package/dist/adapters/message-port/rpc-link.js +17 -14
- package/dist/adapters/message-port/transport.d.ts +31 -34
- package/dist/adapters/message-port/transport.js +38 -52
- package/dist/adapters/standard/codec.d.ts +10 -10
- package/dist/adapters/standard/index.d.ts +6 -5
- package/dist/adapters/standard/index.js +2 -4
- package/dist/adapters/standard/link.d.ts +31 -31
- package/dist/adapters/standard/link.js +101 -85
- package/dist/adapters/standard/plugin.d.ts +25 -31
- package/dist/adapters/standard/plugin.js +14 -16
- package/dist/adapters/standard/rpc-link-codec.d.ts +53 -60
- package/dist/adapters/standard/rpc-link-codec.js +98 -102
- package/dist/adapters/standard/transport.d.ts +7 -7
- package/dist/adapters/websocket/index.d.ts +3 -2
- package/dist/adapters/websocket/index.js +2 -2
- package/dist/adapters/websocket/rpc-link.d.ts +8 -8
- package/dist/adapters/websocket/rpc-link.js +16 -13
- package/dist/adapters/websocket/transport.d.ts +101 -100
- package/dist/adapters/websocket/transport.js +102 -130
- package/dist/async-iterator-object.d.ts +2 -2
- package/dist/async-iterator-object.js +27 -28
- package/dist/client-safe.d.ts +4 -6
- package/dist/client-safe.js +29 -34
- package/dist/client.d.ts +24 -26
- package/dist/client.js +35 -37
- package/dist/consts.d.ts +1 -1
- package/dist/consts.js +18 -41
- package/dist/dynamic-link.d.ts +6 -6
- package/dist/dynamic-link.js +16 -16
- package/dist/error-utils.d.ts +3 -4
- package/dist/error-utils.js +47 -51
- package/dist/error.d.ts +79 -79
- package/dist/error.js +154 -166
- package/dist/index.d.ts +14 -53
- package/dist/index.js +12 -40
- package/dist/plugins/batch.d.ts +122 -155
- package/dist/plugins/batch.js +320 -391
- package/dist/plugins/cookie-jar.d.ts +64 -61
- package/dist/plugins/cookie-jar.js +208 -245
- package/dist/plugins/dedupe.d.ts +49 -53
- package/dist/plugins/dedupe.js +168 -211
- package/dist/plugins/index.d.ts +9 -28
- package/dist/plugins/index.js +8 -23
- package/dist/plugins/request-compression.d.ts +38 -35
- package/dist/plugins/request-compression.js +131 -177
- package/dist/plugins/response-compression.d.ts +21 -18
- package/dist/plugins/response-compression.js +64 -88
- package/dist/plugins/retry-after.d.ts +31 -38
- package/dist/plugins/retry-after.js +60 -85
- package/dist/plugins/retry.d.ts +55 -55
- package/dist/plugins/retry.js +118 -137
- package/dist/plugins/timeout.d.ts +19 -17
- package/dist/plugins/timeout.js +41 -36
- package/dist/rpc-json-serializer.d.ts +84 -84
- package/dist/rpc-json-serializer.js +338 -383
- package/dist/rpc-serializer.d.ts +20 -21
- package/dist/rpc-serializer.js +97 -125
- package/dist/types.d.ts +19 -31
- package/dist/utils.d.ts +18 -29
- package/dist/utils.js +63 -47
- package/package.json +5 -5
- package/dist/adapters/standard/codec.js +0 -1
- package/dist/adapters/standard/transport.js +0 -1
- package/dist/types.js +0 -1
|
@@ -1,104 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return { kind: 'output', output: deserialized };
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
import { MalformedResponseError, ResponseError } from "../../error.js";
|
|
2
|
+
import { createORPCErrorFromJson, isORPCErrorJson } from "../../error-utils.js";
|
|
3
|
+
import { RPCSerializer } from "../../rpc-serializer.js";
|
|
4
|
+
import { isAsyncIteratorObject, mergeHttpPath, pathToHttpPath, stringifyJSON, value } from "@orpc/shared";
|
|
5
|
+
import { mergeStandardHeaders, parseStandardUrl } from "@standard-server/core";
|
|
6
|
+
import { toStandardHeaders } from "@standard-server/fetch";
|
|
7
|
+
// src/adapters/standard/rpc-link-codec.ts
|
|
8
|
+
var RPCLinkCodec = class {
|
|
9
|
+
baseUrl;
|
|
10
|
+
maxUrlLength;
|
|
11
|
+
fallbackMethod;
|
|
12
|
+
expectedMethod;
|
|
13
|
+
headers;
|
|
14
|
+
serializer;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.baseUrl = options.url ?? "/";
|
|
17
|
+
this.maxUrlLength = options.maxUrlLength ?? 2083;
|
|
18
|
+
this.fallbackMethod = options.fallbackMethod ?? "POST";
|
|
19
|
+
this.expectedMethod = options.method ?? this.fallbackMethod;
|
|
20
|
+
this.headers = options.headers ?? {};
|
|
21
|
+
this.serializer = options.serializer ?? new RPCSerializer();
|
|
22
|
+
}
|
|
23
|
+
async encodeInput(input, path, options) {
|
|
24
|
+
let headers = toResolvedStandardHeaders(await value(this.headers, options, path, input));
|
|
25
|
+
if (options.lastEventId !== void 0) headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
|
|
26
|
+
const expectedMethod = await value(this.expectedMethod, options, path, input);
|
|
27
|
+
const baseUrl = await value(this.baseUrl, options, path, input);
|
|
28
|
+
const [pathname, search, hash] = parseStandardUrl(baseUrl);
|
|
29
|
+
const newPathname = mergeHttpPath(pathname, pathToHttpPath(path));
|
|
30
|
+
const serialized = this.serializer.serialize(input);
|
|
31
|
+
if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
|
|
32
|
+
const maxUrlLength = await value(this.maxUrlLength, options, path, input);
|
|
33
|
+
const mergedSearch = new URLSearchParams(search);
|
|
34
|
+
mergedSearch.append("data", stringifyJSON(serialized) ?? "");
|
|
35
|
+
const url = `${newPathname}?${mergedSearch}${hash ?? ""}`;
|
|
36
|
+
if (url.length <= maxUrlLength) return {
|
|
37
|
+
body: void 0,
|
|
38
|
+
method: expectedMethod,
|
|
39
|
+
headers,
|
|
40
|
+
url,
|
|
41
|
+
signal: options.signal
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
url: `${newPathname}${search ?? ""}${hash ?? ""}`,
|
|
46
|
+
method: expectedMethod === "GET" ? this.fallbackMethod : expectedMethod,
|
|
47
|
+
headers,
|
|
48
|
+
body: serialized,
|
|
49
|
+
signal: options.signal
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async decodeResponse(response) {
|
|
53
|
+
const isOk = response.status < 400;
|
|
54
|
+
const body = await response.resolveBody();
|
|
55
|
+
const deserialized = await (async () => {
|
|
56
|
+
try {
|
|
57
|
+
return this.serializer.deserialize(body);
|
|
58
|
+
} catch (cause) {
|
|
59
|
+
throw new MalformedResponseError({
|
|
60
|
+
message: isOk ? "Invalid RPC response format." : void 0,
|
|
61
|
+
response: {
|
|
62
|
+
status: response.status,
|
|
63
|
+
headers: response.headers,
|
|
64
|
+
body
|
|
65
|
+
},
|
|
66
|
+
cause
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
if (!isOk) {
|
|
71
|
+
if (isORPCErrorJson(deserialized)) return {
|
|
72
|
+
kind: "error",
|
|
73
|
+
error: createORPCErrorFromJson(deserialized, { cause: new ResponseError({ response: {
|
|
74
|
+
status: response.status,
|
|
75
|
+
headers: response.headers,
|
|
76
|
+
body
|
|
77
|
+
} }) })
|
|
78
|
+
};
|
|
79
|
+
throw new MalformedResponseError({ response: {
|
|
80
|
+
headers: response.headers,
|
|
81
|
+
status: response.status,
|
|
82
|
+
body
|
|
83
|
+
} });
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
kind: "output",
|
|
87
|
+
output: deserialized
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
};
|
|
94
91
|
function toResolvedStandardHeaders(headers) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
return headers;
|
|
92
|
+
/**
|
|
93
|
+
* Headers class might not be available in some environments,
|
|
94
|
+
* so we check for the existence of `forEach` and `get`
|
|
95
|
+
* methods to determine if it's a Headers instance.
|
|
96
|
+
*/
|
|
97
|
+
if (typeof headers.forEach === "function") return toStandardHeaders(headers);
|
|
98
|
+
return headers;
|
|
104
99
|
}
|
|
100
|
+
export { RPCLinkCodec };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ClientContext, ClientOptions } from "../../types.js";
|
|
2
|
+
import { StandardLazyResponse, StandardRequest } from "@standard-server/core";
|
|
3
3
|
/**
|
|
4
4
|
* Handles the transport layer for sending requests and receiving responses.
|
|
5
5
|
*
|
|
@@ -7,8 +7,8 @@ import type { ClientContext, ClientOptions } from '../../types.ts';
|
|
|
7
7
|
* such as HTTP fetch, WebSocket, or other transport mechanisms.
|
|
8
8
|
*/
|
|
9
9
|
export interface StandardLinkTransport<T extends ClientContext> {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* @throws Transport-level errors (network failures, timeouts, etc.)
|
|
12
|
+
*/
|
|
13
|
+
send(request: StandardRequest, path: string[], options: ClientOptions<T>): Promise<StandardLazyResponse>;
|
|
14
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { RPCLink, RPCLinkOptions } from "./rpc-link.js";
|
|
2
|
+
import { WebSocketLike, WebSocketLinkTransport, WebSocketLinkTransportAttemptInfo, WebSocketLinkTransportOptions, WebSocketLinkTransportReconnectOnCloseOptions, WebSocketLinkTransportReconnectOptions } from "./transport.js";
|
|
3
|
+
export { RPCLink, RPCLinkOptions, WebSocketLike, WebSocketLinkTransport, WebSocketLinkTransportAttemptInfo, WebSocketLinkTransportOptions, WebSocketLinkTransportReconnectOnCloseOptions, WebSocketLinkTransportReconnectOptions };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { RPCLink } from "./rpc-link.js";
|
|
2
|
+
export { WebSocketLinkTransport } from "./transport.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import { ClientContext } from "../../types.js";
|
|
2
|
+
import { StandardLink, StandardLinkOptions } from "../standard/link.js";
|
|
3
|
+
import { RPCLinkCodecOptions } from "../standard/rpc-link-codec.js";
|
|
4
|
+
import "../standard/index.js";
|
|
5
|
+
import { WebSocketLinkTransportOptions } from "./transport.js";
|
|
6
|
+
export interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, WebSocketLinkTransportOptions<T>, RPCLinkCodecOptions<T> {}
|
|
7
7
|
/**
|
|
8
8
|
* Client link that communicates with an RPC Handler over a WebSocket connection.
|
|
9
9
|
*
|
|
10
10
|
* @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
|
|
11
11
|
*/
|
|
12
12
|
export declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
13
|
-
|
|
14
|
-
}
|
|
13
|
+
constructor(options: RPCLinkOptions<T>);
|
|
14
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { RPCLinkCodec
|
|
2
|
-
import {
|
|
1
|
+
import { RPCLinkCodec } from "../standard/rpc-link-codec.js";
|
|
2
|
+
import { StandardLink } from "../standard/link.js";
|
|
3
|
+
import { WebSocketLinkTransport } from "./transport.js";
|
|
4
|
+
// src/adapters/websocket/rpc-link.ts
|
|
3
5
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
6
|
+
* Client link that communicates with an RPC Handler over a WebSocket connection.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
|
|
9
|
+
*/
|
|
10
|
+
var RPCLink = class extends StandardLink {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
const codec = new RPCLinkCodec(options);
|
|
13
|
+
const transport = new WebSocketLinkTransport(options);
|
|
14
|
+
super(codec, transport, options);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export { RPCLink };
|
|
@@ -1,115 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { ClientContext, ClientOptions } from "../../types.js";
|
|
2
|
+
import { StandardLinkTransport } from "../standard/transport.js";
|
|
3
|
+
import "../standard/index.js";
|
|
4
|
+
import { Promisable } from "@orpc/shared";
|
|
5
|
+
import { StandardLazyResponse, StandardRequest } from "@standard-server/core";
|
|
6
|
+
import { DecodePeerMessageOptions, EncodePeerMessageOptions } from "@standard-server/peer";
|
|
7
|
+
export type WebSocketLike = Pick<WebSocket, "addEventListener" | "removeEventListener" | "send" | "readyState">;
|
|
7
8
|
export interface WebSocketLinkTransportAttemptInfo {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Total number of connection attempts for this transport's lifetime.
|
|
11
|
+
* Starts at 1 on the first attempt, increments on every subsequent
|
|
12
|
+
* attempt, and never resets.
|
|
13
|
+
*/
|
|
14
|
+
totalAttempt: number;
|
|
15
|
+
/**
|
|
16
|
+
* Attempt number within the current (re)connect cycle.
|
|
17
|
+
* Starts at 1, increments on each consecutive failure, and resets to 1
|
|
18
|
+
* once a connection succeeds or the cycle gives up. Use this for backoff calculations.
|
|
19
|
+
*/
|
|
20
|
+
attempt: number;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
23
|
* Reconnection behavior when the connection is lost. Passing it enables reconnection.
|
|
23
24
|
*/
|
|
24
25
|
export interface WebSocketLinkTransportReconnectOptions {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Delay before a (re)connect attempt, in milliseconds.
|
|
28
|
+
*
|
|
29
|
+
* @default info => info.attempt === 1 ? 0 : 2_000
|
|
30
|
+
*/
|
|
31
|
+
delay?: ((info: WebSocketLinkTransportAttemptInfo) => number) | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Maximum number of consecutive failed attempts before giving up.
|
|
34
|
+
* When reached, calls waiting for the connection fail, and the next
|
|
35
|
+
* call starts a new reconnect cycle.
|
|
36
|
+
* Should greater than 1
|
|
37
|
+
*
|
|
38
|
+
* @default Infinity
|
|
39
|
+
*/
|
|
40
|
+
maxAttempt?: number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Maximum number of connection attempts over the transport's lifetime,
|
|
43
|
+
* successful ones included (see `totalAttempt`).
|
|
44
|
+
* When reached, calls that need a new connection fail instead of connecting.
|
|
45
|
+
*
|
|
46
|
+
* @default Infinity
|
|
47
|
+
*/
|
|
48
|
+
maxTotalAttempt?: number | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Whether to proactively reconnect right after the socket closes,
|
|
51
|
+
* rather than waiting for the next call to trigger reconnection.
|
|
52
|
+
* Reduces latency for the next request.
|
|
53
|
+
*
|
|
54
|
+
* `true` enables it, {@link WebSocketLinkTransportReconnectOnCloseOptions} enables and customizes it.
|
|
55
|
+
*
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
onClose?: boolean | WebSocketLinkTransportReconnectOnCloseOptions | undefined;
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Proactive reconnection right after the socket closes. Passing it enables it.
|
|
61
62
|
*/
|
|
62
63
|
export interface WebSocketLinkTransportReconnectOnCloseOptions {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Delay before reconnecting after the socket closes, in milliseconds.
|
|
66
|
+
*
|
|
67
|
+
* @default 0
|
|
68
|
+
*/
|
|
69
|
+
delay?: number | undefined;
|
|
69
70
|
}
|
|
70
71
|
export interface WebSocketLinkTransportOptions<_T extends ClientContext> {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Returns a WebSocket instance for peer communication.
|
|
74
|
+
* Can be async for lazy resolution.
|
|
75
|
+
*/
|
|
76
|
+
connect: (info: WebSocketLinkTransportAttemptInfo) => Promisable<WebSocketLike>;
|
|
77
|
+
/**
|
|
78
|
+
* Whether to connect immediately on initialization, instead of waiting
|
|
79
|
+
* for the first call. Reduces latency for the first request.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
connectOnInit?: boolean | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Reconnection when the connection is lost. `true` enables it,
|
|
86
|
+
* {@link WebSocketLinkTransportReconnectOptions} enables and customizes it.
|
|
87
|
+
*
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
reconnect?: boolean | WebSocketLinkTransportReconnectOptions | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Options for encoding peer messages. such as `prefix` for distinguishing messages on the same channel..
|
|
93
|
+
*/
|
|
94
|
+
encodePeerMessage?: EncodePeerMessageOptions | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Options for decoding peer messages. such as `prefix` for distinguishing messages on the same channel..
|
|
97
|
+
*/
|
|
98
|
+
decodePeerMessage?: DecodePeerMessageOptions | undefined;
|
|
98
99
|
}
|
|
99
100
|
export declare class WebSocketLinkTransport<T extends ClientContext> implements StandardLinkTransport<T> {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
101
|
+
private readonly connect;
|
|
102
|
+
private readonly reconnectEnabled;
|
|
103
|
+
private readonly reconnectDelay;
|
|
104
|
+
private readonly reconnectMaxAttempt;
|
|
105
|
+
private readonly reconnectMaxTotalAttempt;
|
|
106
|
+
private readonly reconnectOnCloseEnabled;
|
|
107
|
+
private readonly reconnectOnCloseDelay;
|
|
108
|
+
private readonly encodePeerMessageOptions;
|
|
109
|
+
private readonly decodePeerMessageOptions;
|
|
110
|
+
constructor(options: WebSocketLinkTransportOptions<T>);
|
|
111
|
+
send(standardRequest: StandardRequest, _path: string[], _options: ClientOptions<T>): Promise<StandardLazyResponse>;
|
|
112
|
+
private totalAttempt;
|
|
113
|
+
private attempt;
|
|
114
|
+
private current;
|
|
115
|
+
private getConnectedPeer;
|
|
116
|
+
}
|