Skip to content

Commit

Permalink
feat: add isInMultiAction to PI action info (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: Richard Herman <[email protected]>
  • Loading branch information
GeekyEggo and GeekyEggo authored Jul 23, 2024
1 parent 2a276a7 commit 2a6c357
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Add `streamDeck.settings` namespace for interacting with settings.
- Add `streamDeck.system` namespace for system-related operations.
- Add `streamDeck.plugin` namespace for bi-direction communication with the plugin and the UI.
- Add `isInMultiAction` to the property inspector's action information.

### 🐞 Fix

Expand Down
4 changes: 4 additions & 0 deletions src/api/events/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export type SingleActionPayload<TSettings extends JsonObject, TController extend

/**
* Determines whether the action is part of a multi-action.
*
* NB. Requires Stream Deck 6.7 when accessed from the property inspector.
*/
readonly isInMultiAction: false;
};
Expand All @@ -139,6 +141,8 @@ export type MultiActionPayload<TSettings extends JsonObject> = ActionPayload<TSe

/**
* Determines whether the action is part of a multi-action.
*
* NB. Requires Stream Deck 6.7 when accessed from the property inspector.
*/
readonly isInMultiAction: true;
};
Expand Down
1 change: 1 addition & 0 deletions src/api/registration/__mocks__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const actionInfo: ActionInfo = {
device: "dev123",
payload: {
controller: "Keypad",
isInMultiAction: false,
coordinates: {
column: 1,
row: 2
Expand Down
27 changes: 6 additions & 21 deletions src/api/registration/ui.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { ActionIdentifier, Coordinates, DeviceIdentifier } from "../events";
import type { JsonObject } from "../../common/json";
import type { ActionIdentifier, DeviceIdentifier } from "../events";
import type { MultiActionPayload, SingleActionPayload } from "../events/action";

/**
* Connects to the Stream Deck, enabling the UI to interact with the plugin, and access the Stream Deck API.
Expand All @@ -12,29 +14,12 @@ export type ConnectElgatoStreamDeckSocketFn = (port: string, uuid: string, event

/**
* Information about the action associated with the UI.
* @template TSettings Settings associated with the action.
*/
export type ActionInfo<T = unknown> = ActionIdentifier &
export type ActionInfo<TSettings extends JsonObject = JsonObject> = ActionIdentifier &
DeviceIdentifier & {
/**
* Additional information about the action and event that occurred.
*/
readonly payload: {
/**
* Defines the controller type the action is applicable to. **Keypad** refers to a standard action on a Stream Deck device, e.g. 1 of the 15 buttons on the Stream Deck MK.2,
* or a pedal on the Stream Deck Pedal, etc., whereas an **Encoder** refers to a dial / touchscreen on the Stream Deck +.
*
* NB: Requires Stream Deck 6.5 for `WillAppear` and `WillDisappear` events.
*/
readonly controller: T;

/**
* Coordinates that identify the location of an action.
*/
readonly coordinates: Coordinates;

/**
* Settings associated with the action instance.
*/
settings: T;
};
readonly payload: MultiActionPayload<TSettings> | SingleActionPayload<TSettings>;
};
3 changes: 2 additions & 1 deletion src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type ActionInfo, type RegistrationInfo } from "../api";
import type { IDisposable } from "../common/disposable";
import type { JsonObject } from "../common/json";
import { connection } from "./connection";
import { i18n } from "./i18n";
import { logger } from "./logging";
Expand Down Expand Up @@ -46,7 +47,7 @@ const streamDeck = {
* @param listener Event handler function.
* @returns A disposable that removes the listener when disposed.
*/
onDidConnect: (listener: (info: RegistrationInfo, actionInfo: ActionInfo) => void): IDisposable => {
onDidConnect: <TSettings extends JsonObject = JsonObject>(listener: (info: RegistrationInfo, actionInfo: ActionInfo<TSettings>) => void): IDisposable => {
return connection.disposableOn("connected", listener);
}
};
Expand Down

0 comments on commit 2a6c357

Please sign in to comment.