Created
July 7, 2020 12:04
-
-
Save Johnz86/30fda2b8a995b070a66a0a7910160905 to your computer and use it in GitHub Desktop.
Typings for Browser Presentation API https://developer.mozilla.org/en-US/docs/Web/API/Presentation_API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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