50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
/**
|
|
* All available commands that can be sent to the WebComponent.
|
|
*/
|
|
export enum WebComponentCommand {
|
|
/**
|
|
* Initializes the WebComponent with the given configuration.
|
|
* @private
|
|
*/
|
|
INITIALIZE = 'INITIALIZE',
|
|
|
|
/**
|
|
* Ends the current meeting for all participants.
|
|
* This command is only available for the moderator.
|
|
*/
|
|
END_MEETING = 'END_MEETING',
|
|
/**
|
|
* Disconnects the local participant from the current room.
|
|
*/
|
|
LEAVE_ROOM = 'LEAVE_ROOM'
|
|
// TOGGLE_CHAT = 'TOGGLE_CHAT'
|
|
}
|
|
|
|
/**
|
|
* Type definitions for command payloads.
|
|
* Each property corresponds to a command in {@link WebComponentCommand}.
|
|
* @category Communication
|
|
*/
|
|
export interface CommandPayloads {
|
|
/**
|
|
* Payload for the INITIALIZE command.
|
|
* @private
|
|
*/
|
|
[WebComponentCommand.INITIALIZE]: {
|
|
domain: string;
|
|
};
|
|
[WebComponentCommand.END_MEETING]: void;
|
|
[WebComponentCommand.LEAVE_ROOM]: void;
|
|
// [WebComponentCommand.TOGGLE_CHAT]: void;
|
|
}
|
|
|
|
/**
|
|
* Gets the type-safe payload for a specific command.
|
|
* This type allows TypeScript to infer the correct payload type based on the command.
|
|
* @category Type Helpers
|
|
* @private
|
|
*/
|
|
export type CommandPayloadFor<T extends WebComponentCommand> = T extends keyof CommandPayloads
|
|
? CommandPayloads[T]
|
|
: never;
|