forked from bitfocus/companion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance_skel_types.d.ts
275 lines (244 loc) · 7.15 KB
/
instance_skel_types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/// <reference types="node" />
import { EventEmitter } from 'events'
export interface CompanionSystem extends EventEmitter {}
export type InputValue = number | string | boolean
export type CompanionBank = CompanionBankPage | CompanionBankPNG | CompanionBankPreset
export interface CompanionBankPage {
style: 'pageup' | 'pagedown' | 'pagenum'
}
export type CompanionAlignment =
| 'left:top'
| 'center:top'
| 'right:top'
| 'left:center'
| 'center:center'
| 'right:center'
| 'left:bottom'
| 'center:bottom'
| 'right:bottom'
export type CompanionTextSize = 'auto' | '7' | '14' | '18' | '24' | '30' | '44'
export interface CompanionBankRequiredProps {
text: string
size: CompanionTextSize
color: number
bgcolor: number
}
export interface CompanionBankAdditionalStyleProps {
alignment: CompanionAlignment
pngalignment: CompanionAlignment
png64?: string
}
export interface CompanionBankAdditionalCoreProps {
latch: boolean
relative_delay: boolean
}
export interface CompanionBankPNG
extends CompanionBankRequiredProps,
CompanionBankAdditionalStyleProps,
CompanionBankAdditionalCoreProps {
style: 'png'
}
export interface CompanionBankPreset
extends CompanionBankRequiredProps,
Partial<CompanionBankAdditionalStyleProps>,
Partial<CompanionBankAdditionalCoreProps> {
style: 'png' | 'text' // 'text' for backwards compatability
}
export interface CompanionAction {
label: string
description?: string
options: SomeCompanionInputField[]
callback?: (action: CompanionActionEvent, info: CompanionActionEventInfo | null) => void
subscribe?: (action: CompanionActionEvent) => void
unsubscribe?: (action: CompanionActionEvent) => void
}
export interface CompanionActionEvent {
id: string
action: string
options: { [key: string]: InputValue | undefined }
}
export interface CompanionActionEventInfo {
deviceId: string | undefined
page: number
bank: number
}
export interface CompanionFeedbackEventInfo {
page: number
bank: number
}
export interface CompanionFeedbackEvent {
id: string
type: string
options: { [key: string]: InputValue | undefined }
}
export interface CompanionFeedbackResult {
color?: number
bgcolor?: number
}
export type ConfigValue = string | number
export interface DropdownChoice {
id: ConfigValue
label: string
}
export type SomeCompanionInputField =
| CompanionInputFieldText
| CompanionInputFieldColor
| CompanionInputFieldTextInput
| CompanionInputFieldTextWithVariablesInput
| CompanionInputFieldDropdown
| CompanionInputFieldMultiDropdown
| CompanionInputFieldNumber
| CompanionInputFieldCheckbox
export interface CompanionInputField {
id: string
type: 'text' | 'textinput' | 'textwithvariables' | 'dropdown' | 'colorpicker' | 'number' | 'checkbox'
label: string
tooltip?: string
}
export interface CompanionInputFieldText extends CompanionInputField {
type: 'text'
value: string
}
export interface CompanionInputFieldColor extends CompanionInputField {
type: 'colorpicker'
default: number
}
export interface CompanionInputFieldTextInput extends CompanionInputField {
type: 'textinput'
regex?: string
default?: string
required?: boolean
}
export interface CompanionInputFieldTextWithVariablesInput extends CompanionInputField {
type: 'textwithvariables'
default?: string
}
export interface CompanionInputFieldDropdown extends CompanionInputFieldDropdownBase {
multiple?: false
default: ConfigValue
/** Allow custom values to be defined */
allowCustom?: boolean
/** Check custom value against refex */
regex?: string
}
export interface CompanionInputFieldMultiDropdown extends CompanionInputFieldDropdownBase {
multiple: true
default: ConfigValue[]
required?: boolean
/** The minimum number of selected values */
minSelection?: number
/** The maximum number of selected values */
maximumSelectionLength?: number
}
export interface CompanionInputFieldDropdownBase extends CompanionInputField {
type: 'dropdown'
// default: ConfigValue
choices: DropdownChoice[]
multiple?: boolean
/** The minimum number of entries the dropdown must have before it allows searching */
minChoicesForSearch?: number
}
export interface CompanionInputFieldCheckbox extends CompanionInputField {
type: 'checkbox'
default: boolean
}
export interface CompanionInputFieldNumber extends CompanionInputField {
type: 'number'
min: number
max: number
step?: number
range?: boolean
required?: boolean
default: number
}
export interface CompanionConfigField extends CompanionInputField {
width: number
}
export type SomeCompanionConfigField = SomeCompanionInputField & CompanionConfigField
export interface CompanionVariable {
label: string
name: string
}
export interface CompanionFeedbackBase<TRes> {
type?: 'boolean' | 'advanced'
label: string
description?: string
options: SomeCompanionInputField[]
callback?: (
feedback: CompanionFeedbackEvent,
bank: CompanionBankPNG | null,
info: CompanionFeedbackEventInfo | null
) => TRes
subscribe?: (feedback: CompanionFeedbackEvent) => void
unsubscribe?: (feedback: CompanionFeedbackEvent) => void
}
export interface CompanionFeedbackBoolean extends CompanionFeedbackBase<boolean> {
type: 'boolean'
style: Partial<CompanionBankRequiredProps & CompanionBankAdditionalStyleProps>
}
export interface CompanionFeedbackAdvanced extends CompanionFeedbackBase<CompanionFeedbackResult> {
type?: 'advanced'
}
export type CompanionFeedback = CompanionFeedbackBoolean | CompanionFeedbackAdvanced
export interface CompanionPreset {
category: string
label: string
bank: CompanionBankPreset
feedbacks: Array<{
type: string
options: { [key: string]: InputValue | undefined }
style?: Partial<CompanionBankRequiredProps & CompanionBankAdditionalStyleProps>
}>
actions: Array<{
action: string
options: { [key: string]: InputValue | undefined }
}>
release_actions?: Array<{
action: string
options: { [key: string]: InputValue | undefined }
}>
}
export interface CompanionFeedbacks {
[id: string]: CompanionFeedback | undefined
}
export interface CompanionActions {
[id: string]: CompanionAction | undefined
}
export interface CompanionUpgradeContext {
/** Translate a key index from the old 15 key layout (5x3 grid) to the 32 key layout (8x4 grid) */
convert15to32(key: number): number
rgb(red: number, green: number, blue: number): number
rgbRev(color: number): { r: number; g: number; b: number }
}
export type CompanionStaticUpgradeScript = (
context: CompanionUpgradeContext,
config: CompanionCoreInstanceconfig & Record<string, any>,
affected_actions: CompanionMigrationAction[],
affected_feedbacks: CompanionMigrationFeedback[]
) => boolean
export interface CompanionUpgradeToBooleanFeedbackMap {
[feedback_id: string]:
| true
| {
// Option name to style property
[option_key: string]: 'text' | 'size' | 'color' | 'bgcolor' | 'alignment' | 'pngalignment' | 'png64'
}
| undefined
}
export interface CompanionCoreInstanceconfig {
instance_type: string
label: string
}
export interface CompanionMigrationAction {
readonly id: string
readonly instance: string
label: string
action: string
options: { [key: string]: InputValue | undefined }
}
export interface CompanionMigrationFeedback {
readonly id: string
readonly instance_id: string
type: string
options: { [key: string]: InputValue | undefined }
}