Skip to content

Commit

Permalink
Merge pull request #9 from phillipivan/main
Browse files Browse the repository at this point in the history
fix socket checks, update dev dependencies, update yarn, lint
  • Loading branch information
phillipivan authored Sep 24, 2024
2 parents b9578af + 76045dc commit 9c08e8e
Show file tree
Hide file tree
Showing 14 changed files with 2,587 additions and 2,162 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.yarn/
node_modules/
package-lock.json
/pkg
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { generateEslintConfig } from '@companion-module/tools/eslint/config.mjs'

const baseConfig = await generateEslintConfig({})

const customConfig = [
...baseConfig,
{
languageOptions: {
sourceType: 'module',
},
},
]

export default customConfig
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "sennheiser-digital6000",
"version": "1.0.4",
"version": "1.0.5",
"main": "src/main.js",
"type": "module",
"scripts": {
"format": "prettier -w .",
"package": "companion-module-build"
"package": "companion-module-build",
"lint:raw": "eslint",
"lint": "yarn lint:raw ."
},
"license": "MIT",
"repository": {
Expand All @@ -17,7 +19,10 @@
"companion-module-utils": "~0.5.0"
},
"devDependencies": {
"@companion-module/tools": "^1.5.1"
"@companion-module/tools": "^2.0.4",
"eslint": "^9.11.0",
"prettier": "~3.3.3"
},
"prettier": "@companion-module/tools/.prettierrc.json"
"prettier": "@companion-module/tools/.prettierrc.json",
"packageManager": "yarn@4.5.0"
}
7 changes: 3 additions & 4 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function (self) {
}
self.addCmdtoQueue(msg)
},
subscribe: ({ options }) => {
subscribe: () => {
const msg = {
sys: {
booster: query,
Expand Down Expand Up @@ -61,7 +61,7 @@ export default function (self) {
}
self.addCmdtoQueue(msg)
},
subscribe: ({ options }) => {
subscribe: () => {
const msg = {
sys: {
brightness: query,
Expand Down Expand Up @@ -239,8 +239,7 @@ export default function (self) {
callback: async ({ options }) => {
const channel = parseInt(await self.parseVariablesInString(options.channel))
if (isNaN(channel) || channel > limits.active_bank_channel.max || channel < limits.active_bank_channel.min) {
const channel = parseInt(await self.parseVariablesInString(options.channel))
self.log('warn', `rxActiveBankChannel passed an invalid variable ${carrier}. `)
self.log('warn', `rxActiveBankChannel passed an invalid variable ${options.channel}:${channel}. `)
return undefined
}
const msg = {
Expand Down
45 changes: 23 additions & 22 deletions src/buildEM6000icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,59 +80,60 @@ async function buildIcons(orientation, image, meters, iconOptions) {
iconOptions.includes('mute') && iconOptions.includes('encryption')
? iconDims.mute.x + iconDims.encrypt.x + 2 * bar.space
: iconOptions.includes('mute')
? iconDims.mute.x + bar.space
: iconOptions.includes('encryption')
? iconDims.encrypt.x + bar.space
: 0
? iconDims.mute.x + bar.space
: iconOptions.includes('encryption')
? iconDims.encrypt.x + bar.space
: 0
const xOffsetEncrypt = iconOptions.includes('mute') ? iconDims.mute.x + bar.space : 0
const iconOffset = {
battery: {
x:
orientation === 'left'
? mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetBat
: orientation === 'top'
? image.width - (bar.lengthOffset - bar.offsetBase + xOffsetBat + iconDims.battery.x)
: orientation === 'bottom'
? bar.offsetBase + xOffsetBat
: image.width - (mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetBat + iconDims.battery.x),
? image.width - (bar.lengthOffset - bar.offsetBase + xOffsetBat + iconDims.battery.x)
: orientation === 'bottom'
? bar.offsetBase + xOffsetBat
: image.width - (mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetBat + iconDims.battery.x),
y:
orientation === 'top'
? mtrCount * (bar.width + bar.space) + bar.offsetSide
: orientation === 'bottom'
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.battery.y)
: image.height - (bar.offsetBase + iconDims.battery.y),
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.battery.y)
: image.height - (bar.offsetBase + iconDims.battery.y),
},
mute: {
x:
orientation === 'left'
? mtrCount * (bar.width + bar.space) + bar.offsetSide
: orientation === 'top'
? image.width - (bar.lengthOffset - bar.offsetBase + iconDims.mute.x)
: orientation === 'bottom'
? bar.offsetBase
: image.width - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.mute.x),
? image.width - (bar.lengthOffset - bar.offsetBase + iconDims.mute.x)
: orientation === 'bottom'
? bar.offsetBase
: image.width - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.mute.x),
y:
orientation === 'top'
? mtrCount * (bar.width + bar.space) + bar.offsetSide
: orientation === 'bottom'
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.mute.y)
: image.height - (bar.offsetBase + iconDims.mute.y),
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.mute.y)
: image.height - (bar.offsetBase + iconDims.mute.y),
},
encrypt: {
x:
orientation === 'left'
? mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetEncrypt
: orientation === 'top'
? image.width - (bar.lengthOffset - bar.offsetBase + xOffsetEncrypt + iconDims.encrypt.x)
: orientation === 'bottom'
? bar.offsetBase + xOffsetEncrypt
: image.width - (mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetEncrypt + iconDims.encrypt.x),
? image.width - (bar.lengthOffset - bar.offsetBase + xOffsetEncrypt + iconDims.encrypt.x)
: orientation === 'bottom'
? bar.offsetBase + xOffsetEncrypt
: image.width -
(mtrCount * (bar.width + bar.space) + bar.offsetSide + xOffsetEncrypt + iconDims.encrypt.x),
y:
orientation === 'top'
? mtrCount * (bar.width + bar.space) + bar.offsetSide
: orientation === 'bottom'
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.encrypt.y)
: image.height - (bar.offsetBase + iconDims.encrypt.y),
? image.height - (mtrCount * (bar.width + bar.space) + bar.offsetSide + iconDims.encrypt.y)
: image.height - (bar.offsetBase + iconDims.encrypt.y),
},
}
const commonIconProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/feedbackChecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function startFeedbackChecks(interval) {
this.statusCheck(InstanceStatus.ConnectionFailure, `No data`)
this.log(
'warn',
`UDP Socket listening. No data recieved for at least ${this.quietPeriod * this.config.interval} ms`
`UDP Socket listening. No data recieved for at least ${this.quietPeriod * this.config.interval} ms`,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/feedbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default async function (self) {
feedback.image,
options.meters,
options.icons,
options.orientation
options.orientation,
)

if (iBuffer !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/parseResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function parseResponse(msg) {
} else if (data.osc.xid !== undefined) {
this.log(
'warn',
`Message recieved with unexpected xid. Expected ${this.id} Recieved ${data.osc.xid}\nFrom ${msg.toString()}`
`Message recieved with unexpected xid. Expected ${this.id} Recieved ${data.osc.xid}\nFrom ${msg.toString()}`,
)
return
}
Expand Down
9 changes: 6 additions & 3 deletions src/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ export function setupInitialSubscriptions(device, interval) {
},
}
this.addCmdtoQueue(sub)
this.subscriptionTimer = setTimeout(() => {
this.setupInitialSubscriptions(device, interval)
}, (subscriptions.lifetime - 1) * 1000)
this.subscriptionTimer = setTimeout(
() => {
this.setupInitialSubscriptions(device, interval)
},
(subscriptions.lifetime - 1) * 1000,
)
}

export async function cancelSubscriptions(device) {
Expand Down
2 changes: 1 addition & 1 deletion src/udp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function sendCommand(msg) {
if (msg.osc === undefined) {
msg.osc = { xid: this.id }
}
if (this.socket !== undefined && !this.socket.isDestoryed) {
if (this.socket !== undefined && !this.socket.isDestroyed) {
await this.socket
.send(JSON.stringify(msg))
.then(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export function convert_LQI_to_percent(lqi) {
}

export function safeName(dirtyName) {
const regexpName = new RegExp(/[()[\]{}~`!@%&_\\\^:'".?]/g)
const regexpName = new RegExp(/[()[\]{}~`!@%&_\\^:'".?]/g)
return dirtyName.trim().replaceAll(regexpName, '').slice(0, 8)
}
8 changes: 4 additions & 4 deletions src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export default async function (self) {
{ variableId: `skx${i}_gain`, name: `SKX${i} Gain (dB)` },
{ variableId: `skx${i}_capsule`, name: `SKX${i} Capsule` },
{ variableId: `skx${i}_battery_percent`, name: `SKX${i} Battery (%)` },
{ variableId: `skx${i}_battery_time`, name: `SKX${i} Battery Time` }
{ variableId: `skx${i}_battery_time`, name: `SKX${i} Battery Time` },
)
}
variableDefinitions.push(
{ variableId: 'device_version', name: 'Device Version' },
{ variableId: 'device_name', name: 'Device Name' },
{ variableId: 'sys_brightness', name: 'System Brightness' },
{ variableId: 'sys_clock', name: 'System Clock' },
{ variableId: 'sys_clock_frequency', name: 'System Clock Frequency' }
{ variableId: 'sys_clock_frequency', name: 'System Clock Frequency' },
)
} else if (self.config.device === choices.devices[2].id) {
//set L6000 variables
Expand All @@ -56,13 +56,13 @@ export default async function (self) {
{ variableId: `slot${i}_${j}_battery_cycle_count`, name: `Slot ${i}/${j} Battery Cycle Count` },
{ variableId: `slot${i}_${j}_battery_state_of_health`, name: `Slot ${i}/${j} State Of Health (%)` },
{ variableId: `slot${i}_${j}_battery_time_to_full_h`, name: `Slot ${i}/${j} Time to Full (H)` },
{ variableId: `slot${i}_${j}_battery_time_to_full_min`, name: `Slot ${i}/${j} Time to Full (Min)` }
{ variableId: `slot${i}_${j}_battery_time_to_full_min`, name: `Slot ${i}/${j} Time to Full (Min)` },
)
}
}
variableDefinitions.push(
{ variableId: 'device_version', name: 'Device Version' },
{ variableId: 'device_name', name: 'Device Name' }
{ variableId: 'device_name', name: 'Device Name' },
)
}

Expand Down
Loading

0 comments on commit 9c08e8e

Please sign in to comment.