Skip to content

Instantly share code, notes, and snippets.

@Johnz86
Created July 7, 2020 12:04
Show Gist options
  • Save Johnz86/30fda2b8a995b070a66a0a7910160905 to your computer and use it in GitHub Desktop.
Save Johnz86/30fda2b8a995b070a66a0a7910160905 to your computer and use it in GitHub Desktop.
interface Presentation {
defaultRequest: PresentationRequest;
receiver: PresentationReceiver;
}
interface PresentationReceiver {
connectionList: Promise<PresentationConnectionList>;
}
interface PresentationConnection {
binaryType: ArrayBuffer | Blob;
readonly id: string;
readonly state: string;
readonly url: string;
onclose: ((this: PresentationConnection, ev: Event) => any) | null;
onconnect: ((this: PresentationConnection, ev: Event) => any) | null;
onmessage: ((this: PresentationConnection, ev: Event) => any) | null;
onterminated: ((this: PresentationConnection, ev: Event) => any) | null;
close(): void;
terminate(): void;
send(data: string | Blob | Array<any>): void;
}
interface PresentationConnectionAvailableEvent extends Event {
readonly connection: PresentationConnection
}
interface PresentationConnectionList {
connections: PresentationConnection[];
onconnectionavailable: ((this: PresentationConnectionList, event: PresentationConnectionAvailableEvent) => any) | null;
}
interface PresentationConnectionCloseEvent {
readonly message: string;
readonly reason: 'error' | 'closed' | 'wentaway';
}
interface PresentationAvailability {
readonly value: boolean;
onchange: ((this: PresentationAvailability, ev: Event) => any) | null;
}
interface PresentationRequest {
onconnectionavailable: ((this: PresentationRequest, event: PresentationConnectionAvailableEvent) => any) | null;
start(): Promise<PresentationConnection>;
reconnect(presentationId: string): Promise<PresentationConnection>;
getAvailability(): Promise<PresentationAvailability>;
}
declare var PresentationRequest: {
prototype: PresentationRequest;
new(urls: string[] | string): PresentationRequest;
};
declare module global {
interface Navigator {
presentation: Presentation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment