Skip to content

Commit

Permalink
feat: Text preset type (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedist authored Apr 26, 2024
1 parent ceb04eb commit 34c03db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/host-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { OSCSomeArguments } from '../common/osc.js'
import type { SomeCompanionConfigField } from '../module-api/config.js'
import type { LogLevel, InstanceStatus } from '../module-api/enums.js'
import type { InputValue, CompanionOptionValues, CompanionInputFieldBase } from '../module-api/input.js'
import type { CompanionButtonPresetDefinition } from '../module-api/preset.js'
import type { CompanionButtonPresetDefinition, CompanionTextPresetDefinition } from '../module-api/preset.js'
import type { CompanionHTTPRequest, CompanionHTTPResponse } from '../module-api/http.js'
import type { SomeCompanionActionInputField } from '../module-api/action.js'
import type { CompanionVariableValue } from '../module-api/variable.js'
Expand Down Expand Up @@ -147,7 +147,7 @@ export interface SetVariableDefinitionsMessage {
}

export interface SetPresetDefinitionsMessage {
presets: Array<CompanionButtonPresetDefinition & { id: string }>
presets: Array<(CompanionButtonPresetDefinition | CompanionTextPresetDefinition) & { id: string }>
}

export interface SetVariableValuesMessage {
Expand Down
18 changes: 17 additions & 1 deletion src/module-api/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export interface CompanionPresetAction {
options: CompanionOptionValues
}

export type CompanionPresetDefinition = CompanionButtonPresetDefinition | CompanionTextPresetDefinition

/**
* The definition of a press button preset
*/
Expand All @@ -65,6 +67,20 @@ export interface CompanionButtonPresetDefinition {
steps: CompanionButtonStepActions[]
}

/**
* The definition of a text preset
*/
export interface CompanionTextPresetDefinition {
/** The type of this preset */
type: 'text'
/** The category of this preset, for grouping */
category: string
/** The name of this preset */
name: string
/** The text to display */
text: string
}

export interface CompanionPresetActionsWithOptions {
options?: CompanionActionSetOptions
actions: CompanionPresetAction[]
Expand All @@ -88,5 +104,5 @@ export interface CompanionButtonStepActions {
* The definitions of a group of feedbacks
*/
export interface CompanionPresetDefinitions {
[id: string]: CompanionButtonPresetDefinition | undefined
[id: string]: CompanionButtonPresetDefinition | CompanionTextPresetDefinition | undefined
}

0 comments on commit 34c03db

Please sign in to comment.