"use strict"; import { Image, MediaStatus, ReceiverStatus, SenderApplication, SenderMessage, Volume } from "./components/cast/types"; import { ReceiverDevice } from "./types"; interface CastSessionUpdated { sessionId: string; statusText: string; namespaces: Array<{ name: string }>; volume: Volume; } interface CastSessionCreated extends CastSessionUpdated { appId: string; appImages: Image[]; displayName: string; receiverFriendlyName: string; senderApps: SenderApplication[]; transportId: string; } /** * Messages that cross the native messaging channel. MUST keep * in-sync with the extension's version at: * ext/src/messaging.ts > MessageDefinitions */ type MessageDefinitions = { "shim:castSessionCreated": CastSessionCreated; "shim:castSessionUpdated": CastSessionUpdated; "shim:castSessionStopped": { sessionId: string; }; "shim:receivedCastSessionMessage": { sessionId: string; namespace: string; messageData: string; }; "shim:impl_sendCastMessage": { sessionId: string; messageId: string; error?: string; }; "bridge:createCastSession": { appId: string; receiverDevice: ReceiverDevice; }; "bridge:sendCastReceiverMessage": { sessionId: string; messageData: SenderMessage; messageId: string; }; "bridge:sendCastSessionMessage": { sessionId: string; namespace: string; messageData: object | string; messageId: string; }; "bridge:stopCastApp": { receiverDevice: ReceiverDevice }; /** * getInfo uses the old :/ form for compat with old bridge * versions. */ "bridge:getInfo": string; "bridge:/getInfo": string; "bridge:startDiscovery": { shouldWatchStatus: boolean; }; "bridge:startMediaServer": { filePath: string; port: number; }; "bridge:stopMediaServer": {}; "mediaCast:mediaServerStarted": { mediaPath: string; subtitlePaths: string[]; localAddress: string; }; "mediaCast:mediaServerStopped": {}; "mediaCast:mediaServerError": {}; "main:receiverDeviceUp": { deviceId: string; deviceInfo: ReceiverDevice }; "main:receiverDeviceDown": { deviceId: string }; "main:receiverDeviceStatusUpdated": { deviceId: string; status: ReceiverStatus; }; "main:receiverDeviceMediaStatusUpdated": { deviceId: string; status: MediaStatus; }; }; interface MessageBase { subject: K; data: MessageDefinitions[K]; } type Messages = { [K in keyof MessageDefinitions]: MessageBase; }; /** * Make message data key optional if specified as blank or with * all-optional keys. */ type NarrowedMessage> = L extends any ? {} extends L["data"] ? Omit & Partial : L : never; export type Message = NarrowedMessage;