forked from bitfocus/companion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance_skel_types.d.ts
321 lines (284 loc) · 8.38 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/// <reference types="node" />
import { EventEmitter } from 'events'
export interface CompanionSystem extends EventEmitter {}
export type InputValue = number | string | boolean | Array<string | number>
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 CompanionOptionValues {
[key: string]: InputValue | undefined
}
export interface CompanionAction {
label: string
description?: string
options: SomeCompanionInputField[]
callback?: (action: CompanionActionEvent, info: CompanionActionEventInfo | null) => void
subscribe?: (action: CompanionActionEvent) => void
unsubscribe?: (action: CompanionActionEvent) => void
/**
* The user requested to 'learn' the values for this action.
*/
learn?: (
action: CompanionActionEvent
) => CompanionOptionValues | undefined | Promise<CompanionOptionValues | undefined>
}
export interface CompanionActionEvent {
id: string
action: string
options: CompanionOptionValues
}
export interface CompanionActionEventInfo {
deviceId: string | undefined
page: number
bank: number
}
export interface CompanionFeedbackEventInfo {
page: number
bank: number
width: number
height: number
}
export interface CompanionFeedbackEvent {
id: string
type: string
options: CompanionOptionValues
}
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
isVisible?: (options: any /*CompanionActionEvent | CompanionFeedbackEvent*/) => boolean // TODO - this varies based on where it is used, and in this current structure is not possible to type without breaking every module
}
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 */
maxSelection?: 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
/**
* The user requested to 'learn' the values for this feedback.
*/
learn?: (
feedback: CompanionFeedbackEvent
) => CompanionOptionValues | undefined | Promise<CompanionOptionValues | undefined>
}
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: CompanionOptionValues
style?: Partial<CompanionBankRequiredProps & CompanionBankAdditionalStyleProps>
}>
actions: Array<{
action: string
options: CompanionOptionValues
}>
release_actions?: Array<{
action: string
options: CompanionOptionValues
}>
}
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: CompanionOptionValues
}
export interface CompanionMigrationFeedback {
readonly id: string
readonly instance_id: string
type: string
options: CompanionOptionValues
}
export type OSCArgument = number | string | Uint8Array
export type OSCMetaArgument =
| { type: 'i' | 'f'; value: number }
| { type: 's'; value: string }
| { type: 'b'; value: Uint8Array }
export type OSCSomeArguments = OSCArgument | Array<OSCArgument> | OSCMetaArgument | Array<OSCMetaArgument>
export interface CompanionInstanceHTTPRequest {
baseUrl: string
body?: string
headers: Record<string, string>
hostname: string
ip: string
method: string
originalUrl: string
path: string
query: Record<string, string>
}
export interface CompanionInstanceHTTPResponse {
status?: number
headers?: Record<string, any>
body?: string
}