Skip to content

Commit

Permalink
feat: bonjour fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 12, 2023
1 parent 1250c0a commit 3f13b89
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 13 deletions.
37 changes: 37 additions & 0 deletions assets/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,43 @@
"items": {
"type": "string"
}
},
"bonjourQueries": {
"type": "object",
"description": "If the device or software for your module supports bonjour announcements, Companion will offer an easy way to watch for these announcements.\nEach query you define must have a matching config field of type 'bonjour-device' with the same name",
"uniqueItems": true,
"items": {
"type": "string"
},
"patternProperties": {
"": {
"type": "object",
"title": "ModuleBonjourQuery",
"description": "",
"properties": {
"type": {
"type": "string"
},
"protocol": {
"type": "string",
"enum": ["tcp", "udp"]
},
"txt": {
"type": "object",
"description": "Match on any txt values returned in the query. This is useful to filter out devices of the same 'type' that are not supported",
"patternProperties": {
"": {
"type": "string"
}
},
"additionalProperties": false
}
},
"required": ["type", "protocol"],
"additionalProperties": true
}
},
"additionalProperties": false
}
},
"required": [
Expand Down
2 changes: 2 additions & 0 deletions src/module-api/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
CompanionInputFieldBase,
CompanionInputFieldBonjourDevice,
CompanionInputFieldCheckbox,
CompanionInputFieldColor,
CompanionInputFieldDropdown,
Expand Down Expand Up @@ -27,5 +28,6 @@ export type SomeCompanionConfigField = (
| CompanionInputFieldMultiDropdown
| CompanionInputFieldNumber
| CompanionInputFieldCheckbox
| CompanionInputFieldBonjourDevice
) &
CompanionConfigField
48 changes: 35 additions & 13 deletions src/module-api/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface CompanionInputFieldBase {
| 'number'
| 'checkbox'
| 'custom-variable'
| 'bonjour-device'
/** The label of the field */
label: string
/** A hover tooltip for this field */
Expand Down Expand Up @@ -53,17 +54,17 @@ export interface CompanionInputFieldStaticText extends CompanionInputFieldBase {
value: string
}

export type CompanionColorPresetValue = string|{color: string, title: string}
export type CompanionColorPresetValue = string | { color: string; title: string }

/**
* A colour picker input
*
* Available for actions/feedbacks/config
* Has three optional configuration properties:
* Available for actions/feedbacks/config
* Has three optional configuration properties:
* - {boolean} `enableAlpha` will show the colour picker with an additional alpha entry
* - {'string'|'number'} `returnType` do you want to get the results as CSS string or Companion color number
* - {string[]} `presetColors` replace the default swatch with your own colors when set
*
*
* ### Example
* ```js
* {
Expand All @@ -73,7 +74,7 @@ export type CompanionColorPresetValue = string|{color: string, title: string}
* default: 'rgb(255, 0, 0)'
* }
* ```
*
*
* ```js
* {
* id: 'overlay',
Expand All @@ -89,11 +90,11 @@ export type CompanionColorPresetValue = string|{color: string, title: string}
export interface CompanionInputFieldColor extends CompanionInputFieldBase {
type: 'colorpicker'
/**
* The default color value to set when creating this action/feedback/instance
* Can be a color string or a color number
* Valid strings are CSS color strings in Hex, RGB, HSL or HSV notation with ot without alpha
* The default color value to set when creating this action/feedback/instance
* Can be a color string or a color number
* Valid strings are CSS color strings in Hex, RGB, HSL or HSV notation with ot without alpha
* Valid numbers are 0x0 - 0xffffffff, where the components are ttrrggbb, you can generate the number with combineRgb()
*
*
* ### Examples for red
* ```
* '#f00'
Expand All @@ -105,19 +106,19 @@ export interface CompanionInputFieldColor extends CompanionInputFieldBase {
* 'hsv(0, 100, 100)'
* 0xff0000
* ```
*/
default: string|number
*/
default: string | number
/**
* This will enable a alpha entry slider and input
*/
enableAlpha?: boolean
/**
* Specify if you want the colorpicker returning it's value as a CSS string or as a color number.
* Specify if you want the colorpicker returning it's value as a CSS string or as a color number.
* This will also be the format stored in the database for this value
*/
returnType?: 'string' | 'number'
/**
* If set, this will override the default colors shown in the swatch.
* If set, this will override the default colors shown in the swatch.
* Enter an array of either color strings or objects with color strings and titles
*/
presetColors?: CompanionColorPresetValue[]
Expand Down Expand Up @@ -331,3 +332,24 @@ export interface CompanionInputFieldNumber extends CompanionInputFieldBase {
export interface CompanionInputFieldCustomVariable extends CompanionInputFieldBase {
type: 'custom-variable'
}

/**
* An input field to list and select devices discovered with a bonjour query
*
* Available for config
*
* Note: Bonjour does not work in all environments, so the user is always able to select 'Manual' (null).
* You must make sure to handle this, we recommend using the `isVisible` function to hide the manual input fields when a bonjour device is selected.
*
* ### Example
* ```js
* {
* id: 'my-device',
* type: 'bonjour-device',
* label: 'Device'
* }
* ```
*/
export interface CompanionInputFieldBonjourDevice extends CompanionInputFieldBase {
type: 'bonjour-device'
}

0 comments on commit 3f13b89

Please sign in to comment.