1 | import type { Disposable } from './disposable';
|
2 | import type { ContentTypeEncoder, ContentTypeDecoder } from './encoding';
|
3 | interface _MessageBuffer {
|
4 | readonly encoding: RAL.MessageBufferEncoding;
|
5 | |
6 |
|
7 |
|
8 |
|
9 |
|
10 | append(chunk: Uint8Array | string): void;
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | tryReadHeaders(lowerCaseKeys?: boolean): Map<string, string> | undefined;
|
20 | |
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | tryReadBody(length: number): Uint8Array | undefined;
|
27 | }
|
28 | type _MessageBufferEncoding = 'ascii' | 'utf-8';
|
29 | interface _ReadableStream {
|
30 | onData(listener: (data: Uint8Array) => void): Disposable;
|
31 | onClose(listener: () => void): Disposable;
|
32 | onError(listener: (error: any) => void): Disposable;
|
33 | onEnd(listener: () => void): Disposable;
|
34 | }
|
35 | interface _WritableStream {
|
36 | onClose(listener: () => void): Disposable;
|
37 | onError(listener: (error: any) => void): Disposable;
|
38 | onEnd(listener: () => void): Disposable;
|
39 | write(data: Uint8Array): Promise<void>;
|
40 | write(data: string, encoding: _MessageBufferEncoding): Promise<void>;
|
41 | end(): void;
|
42 | }
|
43 | interface _DuplexStream extends _ReadableStream, _WritableStream {
|
44 | }
|
45 | interface RAL {
|
46 | readonly applicationJson: {
|
47 | readonly encoder: ContentTypeEncoder;
|
48 | readonly decoder: ContentTypeDecoder;
|
49 | };
|
50 | readonly messageBuffer: {
|
51 | create(encoding: RAL.MessageBufferEncoding): RAL.MessageBuffer;
|
52 | };
|
53 | readonly console: {
|
54 | info(message?: any, ...optionalParams: any[]): void;
|
55 | log(message?: any, ...optionalParams: any[]): void;
|
56 | warn(message?: any, ...optionalParams: any[]): void;
|
57 | error(message?: any, ...optionalParams: any[]): void;
|
58 | };
|
59 | readonly timer: {
|
60 | setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
|
61 | setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable;
|
62 | setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
|
63 | };
|
64 | }
|
65 | declare function RAL(): RAL;
|
66 | declare namespace RAL {
|
67 | type MessageBuffer = _MessageBuffer;
|
68 | type MessageBufferEncoding = _MessageBufferEncoding;
|
69 | type ReadableStream = _ReadableStream;
|
70 | type WritableStream = _WritableStream;
|
71 | type DuplexStream = _DuplexStream;
|
72 | function install(ral: RAL): void;
|
73 | }
|
74 | export default RAL;
|