1 | import { Message, RequestMessage, RequestType, RequestType0, RequestType1, RequestType2, RequestType3, RequestType4, RequestType5, RequestType6, RequestType7, RequestType8, RequestType9, ResponseMessage, ResponseError, NotificationMessage, NotificationType, NotificationType0, NotificationType1, NotificationType2, NotificationType3, NotificationType4, NotificationType5, NotificationType6, NotificationType7, NotificationType8, NotificationType9, _EM, ParameterStructures } from './messages';
|
2 | import type { Disposable } from './disposable';
|
3 | import { Event } from './events';
|
4 | import { CancellationToken, AbstractCancellationTokenSource } from './cancellation';
|
5 | import { MessageReader } from './messageReader';
|
6 | import { MessageWriter } from './messageWriter';
|
7 | export type ProgressToken = number | string;
|
8 | export declare namespace ProgressToken {
|
9 | function is(value: any): value is number | string;
|
10 | }
|
11 | interface ProgressParams<T> {
|
12 | |
13 |
|
14 |
|
15 | token: ProgressToken;
|
16 | |
17 |
|
18 |
|
19 | value: T;
|
20 | }
|
21 | export declare class ProgressType<PR> {
|
22 | |
23 |
|
24 |
|
25 |
|
26 | readonly __: [PR, _EM] | undefined;
|
27 | readonly _pr: PR | undefined;
|
28 | constructor();
|
29 | }
|
30 | export type HandlerResult<R, E> = R | ResponseError<E> | Thenable<R> | Thenable<ResponseError<E>> | Thenable<R | ResponseError<E>>;
|
31 | export interface StarRequestHandler {
|
32 | (method: string, params: any[] | object | undefined, token: CancellationToken): HandlerResult<any, any>;
|
33 | }
|
34 | export interface GenericRequestHandler<R, E> {
|
35 | (...params: any[]): HandlerResult<R, E>;
|
36 | }
|
37 | export interface RequestHandler0<R, E> {
|
38 | (token: CancellationToken): HandlerResult<R, E>;
|
39 | }
|
40 | export interface RequestHandler<P, R, E> {
|
41 | (params: P, token: CancellationToken): HandlerResult<R, E>;
|
42 | }
|
43 | export interface RequestHandler1<P1, R, E> {
|
44 | (p1: P1, token: CancellationToken): HandlerResult<R, E>;
|
45 | }
|
46 | export interface RequestHandler2<P1, P2, R, E> {
|
47 | (p1: P1, p2: P2, token: CancellationToken): HandlerResult<R, E>;
|
48 | }
|
49 | export interface RequestHandler3<P1, P2, P3, R, E> {
|
50 | (p1: P1, p2: P2, p3: P3, token: CancellationToken): HandlerResult<R, E>;
|
51 | }
|
52 | export interface RequestHandler4<P1, P2, P3, P4, R, E> {
|
53 | (p1: P1, p2: P2, p3: P3, p4: P4, token: CancellationToken): HandlerResult<R, E>;
|
54 | }
|
55 | export interface RequestHandler5<P1, P2, P3, P4, P5, R, E> {
|
56 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token: CancellationToken): HandlerResult<R, E>;
|
57 | }
|
58 | export interface RequestHandler6<P1, P2, P3, P4, P5, P6, R, E> {
|
59 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token: CancellationToken): HandlerResult<R, E>;
|
60 | }
|
61 | export interface RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E> {
|
62 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token: CancellationToken): HandlerResult<R, E>;
|
63 | }
|
64 | export interface RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E> {
|
65 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token: CancellationToken): HandlerResult<R, E>;
|
66 | }
|
67 | export interface RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E> {
|
68 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token: CancellationToken): HandlerResult<R, E>;
|
69 | }
|
70 | export interface StarNotificationHandler {
|
71 | (method: string, params: any[] | object | undefined): void;
|
72 | }
|
73 | export interface GenericNotificationHandler {
|
74 | (...params: any[]): void;
|
75 | }
|
76 | export interface NotificationHandler0 {
|
77 | (): void;
|
78 | }
|
79 | export interface NotificationHandler<P> {
|
80 | (params: P): void;
|
81 | }
|
82 | export interface NotificationHandler1<P1> {
|
83 | (p1: P1): void;
|
84 | }
|
85 | export interface NotificationHandler2<P1, P2> {
|
86 | (p1: P1, p2: P2): void;
|
87 | }
|
88 | export interface NotificationHandler3<P1, P2, P3> {
|
89 | (p1: P1, p2: P2, p3: P3): void;
|
90 | }
|
91 | export interface NotificationHandler4<P1, P2, P3, P4> {
|
92 | (p1: P1, p2: P2, p3: P3, p4: P4): void;
|
93 | }
|
94 | export interface NotificationHandler5<P1, P2, P3, P4, P5> {
|
95 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): void;
|
96 | }
|
97 | export interface NotificationHandler6<P1, P2, P3, P4, P5, P6> {
|
98 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): void;
|
99 | }
|
100 | export interface NotificationHandler7<P1, P2, P3, P4, P5, P6, P7> {
|
101 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): void;
|
102 | }
|
103 | export interface NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8> {
|
104 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): void;
|
105 | }
|
106 | export interface NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9> {
|
107 | (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): void;
|
108 | }
|
109 | export interface Logger {
|
110 | error(message: string): void;
|
111 | warn(message: string): void;
|
112 | info(message: string): void;
|
113 | log(message: string): void;
|
114 | }
|
115 | export declare const NullLogger: Logger;
|
116 | export declare enum Trace {
|
117 | Off = 0,
|
118 | Messages = 1,
|
119 | Compact = 2,
|
120 | Verbose = 3
|
121 | }
|
122 | export declare namespace TraceValues {
|
123 | |
124 |
|
125 |
|
126 | const Off: 'off';
|
127 | |
128 |
|
129 |
|
130 | const Messages: 'messages';
|
131 | |
132 |
|
133 |
|
134 | const Compact: 'compact';
|
135 | |
136 |
|
137 |
|
138 | const Verbose: 'verbose';
|
139 | }
|
140 | export type TraceValues = 'off' | 'messages' | 'compact' | 'verbose';
|
141 | export declare namespace Trace {
|
142 | function fromString(value: string): Trace;
|
143 | function toString(value: Trace): TraceValues;
|
144 | }
|
145 | export declare enum TraceFormat {
|
146 | Text = "text",
|
147 | JSON = "json"
|
148 | }
|
149 | export declare namespace TraceFormat {
|
150 | function fromString(value: string): TraceFormat;
|
151 | }
|
152 | export interface TraceOptions {
|
153 | sendNotification?: boolean;
|
154 | traceFormat?: TraceFormat;
|
155 | }
|
156 | export interface SetTraceParams {
|
157 | value: TraceValues;
|
158 | }
|
159 | export declare namespace SetTraceNotification {
|
160 | const type: NotificationType<SetTraceParams>;
|
161 | }
|
162 | export interface LogTraceParams {
|
163 | message: string;
|
164 | verbose?: string;
|
165 | }
|
166 | export declare namespace LogTraceNotification {
|
167 | const type: NotificationType<LogTraceParams>;
|
168 | }
|
169 | export interface Tracer {
|
170 | log(dataObject: any): void;
|
171 | log(message: string, data?: string): void;
|
172 | }
|
173 | export declare enum ConnectionErrors {
|
174 | |
175 |
|
176 |
|
177 | Closed = 1,
|
178 | |
179 |
|
180 |
|
181 | Disposed = 2,
|
182 | |
183 |
|
184 |
|
185 | AlreadyListening = 3
|
186 | }
|
187 | export declare class ConnectionError extends Error {
|
188 | readonly code: ConnectionErrors;
|
189 | constructor(code: ConnectionErrors, message: string);
|
190 | }
|
191 | export type ConnectionStrategy = {
|
192 | cancelUndispatched?: (message: Message, next: (message: Message) => ResponseMessage | undefined) => ResponseMessage | undefined;
|
193 | };
|
194 | export declare namespace ConnectionStrategy {
|
195 | function is(value: any): value is ConnectionStrategy;
|
196 | }
|
197 | export type CancellationId = number | string;
|
198 | export interface IdCancellationReceiverStrategy {
|
199 | kind?: 'id';
|
200 | |
201 |
|
202 |
|
203 |
|
204 |
|
205 | createCancellationTokenSource(id: CancellationId): AbstractCancellationTokenSource;
|
206 | |
207 |
|
208 |
|
209 | dispose?(): void;
|
210 | }
|
211 | export declare namespace IdCancellationReceiverStrategy {
|
212 | function is(value: any): value is IdCancellationReceiverStrategy;
|
213 | }
|
214 | export interface RequestCancellationReceiverStrategy {
|
215 | kind: 'request';
|
216 | |
217 |
|
218 |
|
219 |
|
220 |
|
221 | createCancellationTokenSource(requestMessage: RequestMessage): AbstractCancellationTokenSource;
|
222 | |
223 |
|
224 |
|
225 | dispose?(): void;
|
226 | }
|
227 | export declare namespace RequestCancellationReceiverStrategy {
|
228 | function is(value: any): value is RequestCancellationReceiverStrategy;
|
229 | }
|
230 |
|
231 |
|
232 |
|
233 |
|
234 | export type CancellationReceiverStrategy = IdCancellationReceiverStrategy;
|
235 | export declare namespace CancellationReceiverStrategy {
|
236 | const Message: CancellationReceiverStrategy;
|
237 | function is(value: any): value is CancellationReceiverStrategy;
|
238 | }
|
239 | export interface CancellationSenderStrategy {
|
240 | |
241 |
|
242 |
|
243 |
|
244 |
|
245 | enableCancellation?(request: RequestMessage): void;
|
246 | |
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | sendCancellation(conn: MessageConnection, id: CancellationId): Promise<void>;
|
253 | |
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | cleanup(id: CancellationId): void;
|
260 | |
261 |
|
262 |
|
263 | dispose?(): void;
|
264 | }
|
265 | export declare namespace CancellationSenderStrategy {
|
266 | const Message: CancellationSenderStrategy;
|
267 | function is(value: any): value is CancellationSenderStrategy;
|
268 | }
|
269 | export interface CancellationStrategy {
|
270 | receiver: CancellationReceiverStrategy | RequestCancellationReceiverStrategy;
|
271 | sender: CancellationSenderStrategy;
|
272 | }
|
273 | export declare namespace CancellationStrategy {
|
274 | const Message: CancellationStrategy;
|
275 | function is(value: any): value is CancellationStrategy;
|
276 | }
|
277 | export interface MessageStrategy {
|
278 | handleMessage(message: Message, next: (message: Message) => void): void;
|
279 | }
|
280 | export declare namespace MessageStrategy {
|
281 | function is(value: any): value is MessageStrategy;
|
282 | }
|
283 | export interface ConnectionOptions {
|
284 | cancellationStrategy?: CancellationStrategy;
|
285 | connectionStrategy?: ConnectionStrategy;
|
286 | messageStrategy?: MessageStrategy;
|
287 | }
|
288 | export declare namespace ConnectionOptions {
|
289 | function is(value: any): value is ConnectionOptions;
|
290 | }
|
291 | export interface MessageConnection {
|
292 | sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
|
293 | sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
|
294 | sendRequest<P1, R, E>(type: RequestType1<P1, R, E>, p1: P1, token?: CancellationToken): Promise<R>;
|
295 | sendRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, p1: P1, p2: P2, token?: CancellationToken): Promise<R>;
|
296 | sendRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, p1: P1, p2: P2, p3: P3, token?: CancellationToken): Promise<R>;
|
297 | sendRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, token?: CancellationToken): Promise<R>;
|
298 | sendRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, token?: CancellationToken): Promise<R>;
|
299 | sendRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, token?: CancellationToken): Promise<R>;
|
300 | sendRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, token?: CancellationToken): Promise<R>;
|
301 | sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, token?: CancellationToken): Promise<R>;
|
302 | sendRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, token?: CancellationToken): Promise<R>;
|
303 | sendRequest<R>(method: string, r0?: ParameterStructures | any, ...rest: any[]): Promise<R>;
|
304 | onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable;
|
305 | onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable;
|
306 | onRequest<P1, R, E>(type: RequestType1<P1, R, E>, handler: RequestHandler1<P1, R, E>): Disposable;
|
307 | onRequest<P1, P2, R, E>(type: RequestType2<P1, P2, R, E>, handler: RequestHandler2<P1, P2, R, E>): Disposable;
|
308 | onRequest<P1, P2, P3, R, E>(type: RequestType3<P1, P2, P3, R, E>, handler: RequestHandler3<P1, P2, P3, R, E>): Disposable;
|
309 | onRequest<P1, P2, P3, P4, R, E>(type: RequestType4<P1, P2, P3, P4, R, E>, handler: RequestHandler4<P1, P2, P3, P4, R, E>): Disposable;
|
310 | onRequest<P1, P2, P3, P4, P5, R, E>(type: RequestType5<P1, P2, P3, P4, P5, R, E>, handler: RequestHandler5<P1, P2, P3, P4, P5, R, E>): Disposable;
|
311 | onRequest<P1, P2, P3, P4, P5, P6, R, E>(type: RequestType6<P1, P2, P3, P4, P5, P6, R, E>, handler: RequestHandler6<P1, P2, P3, P4, P5, P6, R, E>): Disposable;
|
312 | onRequest<P1, P2, P3, P4, P5, P6, P7, R, E>(type: RequestType7<P1, P2, P3, P4, P5, P6, P7, R, E>, handler: RequestHandler7<P1, P2, P3, P4, P5, P6, P7, R, E>): Disposable;
|
313 | onRequest<P1, P2, P3, P4, P5, P6, P7, P8, R, E>(type: RequestType8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>, handler: RequestHandler8<P1, P2, P3, P4, P5, P6, P7, P8, R, E>): Disposable;
|
314 | onRequest<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>(type: RequestType9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>, handler: RequestHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9, R, E>): Disposable;
|
315 | onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): Disposable;
|
316 | onRequest(handler: StarRequestHandler): Disposable;
|
317 | hasPendingResponse(): boolean;
|
318 | sendNotification(type: NotificationType0): Promise<void>;
|
319 | sendNotification<P>(type: NotificationType<P>, params?: P): Promise<void>;
|
320 | sendNotification<P1>(type: NotificationType1<P1>, p1: P1): Promise<void>;
|
321 | sendNotification<P1, P2>(type: NotificationType2<P1, P2>, p1: P1, p2: P2): Promise<void>;
|
322 | sendNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, p1: P1, p2: P2, p3: P3): Promise<void>;
|
323 | sendNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, p1: P1, p2: P2, p3: P3, p4: P4): Promise<void>;
|
324 | sendNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): Promise<void>;
|
325 | sendNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): Promise<void>;
|
326 | sendNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): Promise<void>;
|
327 | sendNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): Promise<void>;
|
328 | sendNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): Promise<void>;
|
329 | sendNotification(method: string, r0?: ParameterStructures | any, ...rest: any[]): Promise<void>;
|
330 | onNotification(type: NotificationType0, handler: NotificationHandler0): Disposable;
|
331 | onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): Disposable;
|
332 | onNotification<P1>(type: NotificationType1<P1>, handler: NotificationHandler1<P1>): Disposable;
|
333 | onNotification<P1, P2>(type: NotificationType2<P1, P2>, handler: NotificationHandler2<P1, P2>): Disposable;
|
334 | onNotification<P1, P2, P3>(type: NotificationType3<P1, P2, P3>, handler: NotificationHandler3<P1, P2, P3>): Disposable;
|
335 | onNotification<P1, P2, P3, P4>(type: NotificationType4<P1, P2, P3, P4>, handler: NotificationHandler4<P1, P2, P3, P4>): Disposable;
|
336 | onNotification<P1, P2, P3, P4, P5>(type: NotificationType5<P1, P2, P3, P4, P5>, handler: NotificationHandler5<P1, P2, P3, P4, P5>): Disposable;
|
337 | onNotification<P1, P2, P3, P4, P5, P6>(type: NotificationType6<P1, P2, P3, P4, P5, P6>, handler: NotificationHandler6<P1, P2, P3, P4, P5, P6>): Disposable;
|
338 | onNotification<P1, P2, P3, P4, P5, P6, P7>(type: NotificationType7<P1, P2, P3, P4, P5, P6, P7>, handler: NotificationHandler7<P1, P2, P3, P4, P5, P6, P7>): Disposable;
|
339 | onNotification<P1, P2, P3, P4, P5, P6, P7, P8>(type: NotificationType8<P1, P2, P3, P4, P5, P6, P7, P8>, handler: NotificationHandler8<P1, P2, P3, P4, P5, P6, P7, P8>): Disposable;
|
340 | onNotification<P1, P2, P3, P4, P5, P6, P7, P8, P9>(type: NotificationType9<P1, P2, P3, P4, P5, P6, P7, P8, P9>, handler: NotificationHandler9<P1, P2, P3, P4, P5, P6, P7, P8, P9>): Disposable;
|
341 | onNotification(method: string, handler: GenericNotificationHandler): Disposable;
|
342 | onNotification(handler: StarNotificationHandler): Disposable;
|
343 | onUnhandledNotification: Event<NotificationMessage>;
|
344 | onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
|
345 | sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): Promise<void>;
|
346 | onUnhandledProgress: Event<ProgressParams<any>>;
|
347 | trace(value: Trace, tracer: Tracer, sendNotification?: boolean): Promise<void>;
|
348 | trace(value: Trace, tracer: Tracer, traceOptions?: TraceOptions): Promise<void>;
|
349 | onError: Event<[Error, Message | undefined, number | undefined]>;
|
350 | onClose: Event<void>;
|
351 | listen(): void;
|
352 | end(): void;
|
353 | onDispose: Event<void>;
|
354 | dispose(): void;
|
355 | inspect(): void;
|
356 | }
|
357 | export declare function createMessageConnection(messageReader: MessageReader, messageWriter: MessageWriter, _logger?: Logger, options?: ConnectionOptions): MessageConnection;
|
358 | export {};
|