UNPKG

@elgato/streamdeck

Version:

The official Node.js SDK for creating Stream Deck plugins.

95 lines (94 loc) 3.83 kB
import type { ActionInfo, ConnectElgatoStreamDeckSocketFn, RegistrationInfo, UICommand, UIEventMap } from "../api"; import { EventEmitter } from "../common/event-emitter"; declare global { interface Window { /** * Connects to the Stream Deck, enabling the UI to interact with the plugin, and access the Stream Deck API. * @param port Port to be used when connecting to Stream Deck. * @param uuid Identifies the UI; this must be provided when establishing the connection with Stream Deck. * @param event Name of the event that identifies the registration procedure; this must be provided when establishing the connection with Stream Deck. * @param info Information about the Stream Deck application and operating system. * @param actionInfo Information about the action the UI is associated with. */ connectElgatoStreamDeckSocket: ConnectElgatoStreamDeckSocketFn; } } /** * Connection used by the UI to communicate with the plugin, and Stream Deck. */ declare class Connection extends EventEmitter<ExtendedUIEventMap> { /** * Determines whether the connection can connect; */ private canConnect; /** * Underlying web socket connection. */ private readonly connection; /** * Underlying connection information provided to the plugin to establish a connection with Stream Deck. */ private readonly info; /** * Initializes a new instance of the {@link Connection} class. */ constructor(); /** * Gets the connection's information. * @returns The information used to establish the connection. */ getInfo(): Promise<ConnectionInfo>; /** * Sends the commands to the Stream Deck, once the connection has been established and registered. * @param command Command being sent. * @returns `Promise` resolved when the command is sent to Stream Deck. */ send(command: UICommand): Promise<void>; /** * Establishes a connection with Stream Deck, allowing for the UI to send and receive messages. * @param port Port to be used when connecting to Stream Deck. * @param uuid Identifies the UI; this must be provided when establishing the connection with Stream Deck. * @param event Name of the event that identifies the registration procedure; this must be provided when establishing the connection with Stream Deck. * @param info Information about the Stream Deck application, the plugin, the user's operating system, user's Stream Deck devices, etc. * @param actionInfo Information for the action associated with the UI. * @returns A promise that is resolved when a connection has been established. */ private connect; /** * Attempts to emit the {@link ev} that was received from the {@link Connection.connection}. * @param ev Event message data received from Stream Deck. */ private tryEmit; } /** * Information about the connection with Stream Deck. */ export type ConnectionInfo = { /** * Unique identifier of the UI. */ uuid: string; /** * Information about the Stream Deck application, the plugin, the user's operating system, user's Stream Deck devices, etc. */ info: RegistrationInfo; /** * Information about the action associated with the UI. */ actionInfo: ActionInfo; }; /** * An extended event map that includes connection events. */ type ExtendedUIEventMap = UIEventMap & { /** * Occurs when a connecting is being established. */ connecting: [info: RegistrationInfo, actionInfo: ActionInfo]; /** * Occurs when a connection is established. */ connected: [info: RegistrationInfo, actionInfo: ActionInfo]; }; export declare const connection: Connection; export {};