Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bonjour discovery config fields #57

Merged
merged 3 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions assets/manifest.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"type": "object",
"title": "ModuleManifest",
"properties": {
"$schema": {
"type": "string"
},
"id": {
"type": "string",
"description": "Unique identifier for the module"
Expand Down Expand Up @@ -104,8 +107,42 @@
"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",
"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": false
}
},
"additionalProperties": false
}
},
"additionalProperties": false,
"required": [
"id",
"name",
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'
}