1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | export interface EventSource {
|
7 | addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
|
8 | removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: {}): void;
|
9 | }
|
10 | export interface PostMessageWithOrigin {
|
11 | postMessage(message: any, targetOrigin: string, transfer?: Transferable[]): void;
|
12 | }
|
13 | export interface Endpoint extends EventSource {
|
14 | postMessage(message: any, transfer?: Transferable[]): void;
|
15 | start?: () => void;
|
16 | }
|
17 | export declare const enum WireValueType {
|
18 | RAW = "RAW",
|
19 | PROXY = "PROXY",
|
20 | THROW = "THROW",
|
21 | HANDLER = "HANDLER"
|
22 | }
|
23 | export interface RawWireValue {
|
24 | id?: string;
|
25 | type: WireValueType.RAW;
|
26 | value: {};
|
27 | }
|
28 | export interface HandlerWireValue {
|
29 | id?: string;
|
30 | type: WireValueType.HANDLER;
|
31 | name: string;
|
32 | value: unknown;
|
33 | }
|
34 | export type WireValue = RawWireValue | HandlerWireValue;
|
35 | export type MessageID = string;
|
36 | export declare const enum MessageType {
|
37 | GET = "GET",
|
38 | SET = "SET",
|
39 | APPLY = "APPLY",
|
40 | CONSTRUCT = "CONSTRUCT",
|
41 | ENDPOINT = "ENDPOINT",
|
42 | RELEASE = "RELEASE"
|
43 | }
|
44 | export interface GetMessage {
|
45 | id?: MessageID;
|
46 | type: MessageType.GET;
|
47 | path: string[];
|
48 | }
|
49 | export interface SetMessage {
|
50 | id?: MessageID;
|
51 | type: MessageType.SET;
|
52 | path: string[];
|
53 | value: WireValue;
|
54 | }
|
55 | export interface ApplyMessage {
|
56 | id?: MessageID;
|
57 | type: MessageType.APPLY;
|
58 | path: string[];
|
59 | argumentList: WireValue[];
|
60 | }
|
61 | export interface ConstructMessage {
|
62 | id?: MessageID;
|
63 | type: MessageType.CONSTRUCT;
|
64 | path: string[];
|
65 | argumentList: WireValue[];
|
66 | }
|
67 | export interface EndpointMessage {
|
68 | id?: MessageID;
|
69 | type: MessageType.ENDPOINT;
|
70 | }
|
71 | export interface ReleaseMessage {
|
72 | id?: MessageID;
|
73 | type: MessageType.RELEASE;
|
74 | }
|
75 | export type Message = GetMessage | SetMessage | ApplyMessage | ConstructMessage | EndpointMessage | ReleaseMessage;
|