Skip to content

Commit 8815771

Browse files
committed
update types
1 parent 72017a2 commit 8815771

File tree

12 files changed

+358
-342
lines changed

12 files changed

+358
-342
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default tseslint.config(
2525
"prefer-const": "off",
2626
"prefer-spread": "off",
2727
"no-dupe-class-members": "off",
28+
"no-extra-boolean-cast": "off",
2829
"space-before-function-paren": "off",
2930
"@typescript-eslint/no-duplicate-enum-values": "warn",
3031
"@typescript-eslint/no-explicit-any": "off",

src/actions/channels.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import type { CompanionActionDefinition, CompanionActionDefinitions, DropdownChoice } from "@companion-module/base"
3-
import { ChannelSelector } from "presonus-studiolive-api"
3+
import type { ChannelSelector } from "presonus-studiolive-api"
44
import type Instance from ".."
55
import { generateTransitionPeriodOption } from "../util/actionsUtils"
66
import { extractChannelSelector, generateChannelSelectOption, generateMixSelectOption } from "../util/channelUtils"
@@ -19,11 +19,12 @@ const withChannelSelector = function (fn: (
1919
}) satisfies CompanionActionDefinition['callback']
2020
}
2121

22+
export type GeneratedChannelActions = ReturnType<typeof generateActions_channels>
2223
export default function generateActions_channels(this: Instance, channels: DropdownChoice[], mixes: DropdownChoice[]) {
2324
const channelSelectOptions = generateChannelSelectOption(channels)
2425
const mixSelectOptions = generateMixSelectOption(mixes, "Mix Target")
2526

26-
const map = {
27+
const actions = {
2728
mute: {
2829
name: 'Mute channel',
2930
options: [
@@ -61,7 +62,7 @@ export default function generateActions_channels(this: Instance, channels: Dropd
6162
mixSelectOptions,
6263
generateTransitionPeriodOption(200)
6364
], callback: withChannelSelector((action, context, channel) => {
64-
let currentLevel = this.client.getLevel(channel)
65+
const currentLevel = this.client.getLevel(channel)
6566
this.client.setChannelVolumeLinear(channel, 0, <number>action.options.transition).then(() => {
6667
this.client.mute(channel)
6768
this.client.setChannelVolumeLinear(channel, currentLevel)
@@ -76,7 +77,7 @@ export default function generateActions_channels(this: Instance, channels: Dropd
7677
mixSelectOptions,
7778
generateTransitionPeriodOption(200)
7879
], callback: withChannelSelector((action, context, channel) => {
79-
let currentLevel = this.client.getLevel(channel)
80+
const currentLevel = this.client.getLevel(channel)
8081

8182
this.client.setChannelVolumeLinear(channel, 0, 0).then(() => {
8283
this.client.unmute(channel)
@@ -92,11 +93,11 @@ export default function generateActions_channels(this: Instance, channels: Dropd
9293
mixSelectOptions,
9394
generateTransitionPeriodOption(200)
9495
], callback: withChannelSelector((action, context, channel) => {
95-
const fn = this.client.getMute(channel) ? map.unmute_smooth : map.mute_smooth
96+
const fn = this.client.getMute(channel) ? actions.unmute_smooth : actions.mute_smooth
9697
fn.callback(action, context)
9798
}),
9899
}
99100
} satisfies CompanionActionDefinitions
100101

101-
return map
102+
return actions
102103
}

src/actions/projectScenes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CompanionActionDefinitions, DropdownChoice } from "@companion-module/base";
2-
import Instance from "..";
1+
import type { CompanionActionDefinitions, DropdownChoice } from "@companion-module/base";
2+
import type Instance from "../";
33
import { ValueSeparator } from "../util/Constants";
44

55
export default function generateActions_projectScenes(this: Instance, project_scenes: DropdownChoice[]) {
@@ -18,7 +18,7 @@ export default function generateActions_projectScenes(this: Instance, project_sc
1818
}
1919
],
2020
callback: (action, context) => {
21-
let [project, scene] = (<string>action.options[key]).split(ValueSeparator)
21+
const [project, scene] = (<string>action.options[key]).split(ValueSeparator)
2222
if (!project) return
2323

2424
if (scene) {

src/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CompanionVariableDefinition } from '@companion-module/base'
1+
import type { CompanionVariableDefinition } from '@companion-module/base'
22
import generateMixes from './mixes'
33
import generateChannelSelectEntries from './util/channelUtils'
44

src/feedbacks.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const withChannelSelector = function <T>(fn: (
1818

1919
}
2020

21+
export type FeedbackDefinitions = ReturnType<typeof generateFeedback>
2122
export default function generateFeedback(this: Instance, channels: DropdownChoice[], mixes: DropdownChoice[]) {
2223
const channelSelectOptions = generateChannelSelectOption(channels)
2324
const mixSelectOptions = generateMixSelectOption(mixes, "Mix Source")
@@ -53,8 +54,11 @@ export default function generateFeedback(this: Instance, channels: DropdownChoic
5354
let colour: string = this.client.getColour(channel)
5455
if (!colour) return {};
5556

56-
const [R, G, B, A] = Buffer.from(colour, 'hex')
57-
if (R + G + B == 0) return {};
57+
const [R, G, B] = Buffer.from(colour, 'hex')
58+
59+
// Black, set to empty
60+
// perhaps we should set to black though?
61+
if (R + G + B === 0) return {};
5862

5963
return {
6064
bgcolor: combineRgb(R, G, B)

0 commit comments

Comments
 (0)