Skip to content

Commit

Permalink
Merge branch '2.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
6XGate committed Oct 27, 2024
2 parents 17ebc35 + df3eb22 commit 2f87e1d
Show file tree
Hide file tree
Showing 79 changed files with 1,411 additions and 1,349 deletions.
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# In case we update to Yarn v4
nmHoistingLimits: dependencies
nodeLinker: node-modules
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bridgecmdr",
"productName": "BridgeCmdr",
"version": "2.0.0",
"version": "2.0.1",
"description": "Controller for professional A/V monitors and switches",
"packageManager": "[email protected]",
"type": "module",
Expand Down Expand Up @@ -74,7 +74,7 @@
"@types/ini": "^4.1.1",
"@types/level": "^6.0.3",
"@types/levelup": "^5.1.5",
"@types/node": "^20.16.10",
"@types/node": "^20.16.15",
"@types/pouchdb-core": "^7.0.15",
"@types/pouchdb-find": "^7.3.3",
"@types/setimmediate": "^1.0.4",
Expand All @@ -83,7 +83,7 @@
"@typescript-eslint/parser": "^8.7.0",
"@vitejs/plugin-vue": "^5.1.4",
"@vitejs/plugin-vue-jsx": "^4.0.1",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/coverage-v8": "^2.1.3",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/tsconfig": "^0.5.1",
Expand All @@ -100,7 +100,7 @@
"electron": "^31.6.0",
"electron-builder": "^24.13.3",
"electron-unhandled": "^5.0.0",
"electron-updater": "^6.3.8",
"electron-updater": "^6.3.9",
"electron-vite": "^2.3.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -112,40 +112,40 @@
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-vue": "^9.28.0",
"events": "^3.3.0",
"execa": "^9.4.0",
"execa": "^9.4.1",
"husky": "^9.1.6",
"ini": "^4.1.3",
"levelup": "^5.1.1",
"mime": "^4.0.4",
"multileveldown": "^5.0.1",
"npm-check-updates": "^17.1.3",
"npm-run-all2": "^6.2.3",
"pinia": "^2.2.2",
"npm-check-updates": "^17.1.6",
"npm-run-all2": "^6.2.6",
"pinia": "^2.2.4",
"pouchdb-adapter-leveldb-core": "^9.0.0",
"pouchdb-core": "^9.0.0",
"pouchdb-find": "^9.0.0",
"prettier": "^3.3.3",
"radash": "^12.1.0",
"sass": "^1.79.4",
"sass": "^1.79.6",
"setimmediate": "^1.0.5",
"stream-browserify": "^3.0.0",
"tslib": "^2.7.0",
"type-fest": "^4.26.1",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"typescript-eslint-parser-for-extra-files": "^0.7.0",
"util": "^0.12.5",
"uuid": "^10.0.0",
"vite": "^5.4.8",
"vite": "^5.4.10",
"vite-plugin-vue-devtools": "^7.4.6",
"vite-plugin-vuetify": "^2.0.4",
"vite-tsconfig-paths": "^5.0.1",
"vitest": "^2.1.1",
"vue": "^3.5.10",
"vitest": "^2.1.3",
"vue": "^3.5.12",
"vue-eslint-parser": "^9.4.3",
"vue-i18n": "^9.14.1",
"vue-router": "^4.4.5",
"vue-tsc": "^2.1.6",
"vuetify": "^3.7.2",
"vue-tsc": "^2.1.8",
"vuetify": "^3.7.3",
"xdg-basedir": "^5.1.0",
"zod": "^3.23.8"
},
Expand Down
13 changes: 13 additions & 0 deletions src/core/basics.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
/** Provides a means to define a tuple via satisfies. */
export type Fixed<T = unknown> = [T, ...T[]]

/** Could be a promise. */
export type MaybePromise<T> = Promise<T> | T

/** Guards and filter to not nullish */
export const isNotNullish = <T>(value: T | null | undefined): value is T => value != null

/** Wraps a non-array value in an array, or simply passes an array through. */
export function toArray<T>(value: T): T extends unknown[] ? T : T[] {
if (value == null) {
return [] as never
}

return (Array.isArray(value) ? value : [value]) as never
}

/**
* Wait a specified amount of time.
* @param timeout - The amount of time to wait in milliseconds.
*/
export async function waitTill(timeout: number) {
await new Promise<void>((resolve) => {
setTimeout(resolve, timeout)
})
}
6 changes: 5 additions & 1 deletion src/core/delegates.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export type Action<Result = void> = () => Result
/** The type of functions. */
export type Func<Result, Args extends unknown[] = []> = (...args: Args) => Result

/** The type of action functions. */
export type Action<Args extends unknown[] = []> = (...args: Args) => void
16 changes: 16 additions & 0 deletions src/core/error-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ export function toError<Cause>(cause: Cause) {
export function raiseError(factory: () => Error): never {
throw factory()
}

export function warnPromiseFailures<T>(msg: string, results: PromiseSettledResult<T>[]) {
for (const result of results) {
if (result.status === 'rejected') {
console.warn(msg, result.reason)
}
}
}

export function logPromiseFailures<T>(msg: string, results: PromiseSettledResult<T>[]) {
for (const result of results) {
if (result.status === 'rejected') {
console.error(msg, result.reason)
}
}
}
4 changes: 1 addition & 3 deletions src/core/keys.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { Tagged } from 'type-fest'

export type BrandedBases = symbol | number | string

declare const KeyType: unique symbol

export type BrandedKey<Key extends BrandedBases, Kind extends PropertyKey, T> = Tagged<
export type BrandedKey<Key extends PropertyKey, Kind extends PropertyKey, T> = Tagged<
Key,
Kind,
{
Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/extron/sis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const extronSisDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs | kDeviceCanDecoupleAudioOutput,
setup: async (uri) => {
const sendCommand = async (command: string) => {
setup: async function setup(uri) {
async function sendCommand(command: string) {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
Expand All @@ -36,20 +36,20 @@ const extronSisDriver = defineDriver({
await connection.close()
}

const activate = async (inputChannel: number, videoOutputChannel: number, audioOutputChannel: number) => {
async function activate(inputChannel: number, videoOutputChannel: number, audioOutputChannel: number) {
Logger.log(`extronSisDriver.activate(${inputChannel}, ${videoOutputChannel}, ${audioOutputChannel})`)
const videoCommand = `${inputChannel}*${videoOutputChannel}%`
const audioCommand = `${inputChannel}*${audioOutputChannel}$`
await sendCommand(`${videoCommand}\r\n${audioCommand}\r\n`)
}

const powerOn = async () => {
async function powerOn() {
Logger.log('extronSisDriver.powerOn')
Logger.debug('extronSisDriver.powerOn is a no-op')
await Promise.resolve()
}

const powerOff = async () => {
async function powerOff() {
Logger.log('extronSisDriver.powerOff')
Logger.debug('extronSisDriver.powerOff is a no-op')
await Promise.resolve()
Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/sony/rs485.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const sonyRs485Driver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async (uri) => {
const sendCommand = async (command: Command, arg0?: CommandArg, arg1?: CommandArg) => {
setup: async function setup(uri) {
async function sendCommand(command: Command, arg0?: CommandArg, arg1?: CommandArg) {
const source = createAddress(kAddressAll, 0)
const destination = createAddress(kAddressAll, 0)
const packet = createCommand(destination, source, command, arg0, arg1)
Expand All @@ -42,17 +42,17 @@ const sonyRs485Driver = defineDriver({
await connection.close()
}

const activate = async (inputChannel: number) => {
async function activate(inputChannel: number) {
Logger.log(`sonyRs485Driver.activate(${inputChannel})`)
await sendCommand(kSetChannel, 1, inputChannel)
}

const powerOn = async () => {
async function powerOn() {
Logger.log('sonyRs485Driver.powerOn')
await sendCommand(kPowerOn)
}

const powerOff = async () => {
async function powerOff() {
Logger.log('sonyRs485Driver.powerOff')
await sendCommand(kPowerOff)
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/tesla-smart/kvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const teslaSmartKvmDriver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async (uri) => {
const sendCommand = async (command: Buffer) => {
setup: async function setup(uri) {
async function sendCommand(command: Buffer) {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
Expand All @@ -36,18 +36,18 @@ const teslaSmartKvmDriver = defineDriver({
await connection.close()
}

const activate = async (inputChannel: number) => {
async function activate(inputChannel: number) {
Logger.log(`teslaSmartKvmDriver.activate(${inputChannel})`)
await sendCommand(Buffer.of(0xaa, 0xbb, 0x03, 0x01, inputChannel, 0xee))
}

const powerOn = async () => {
async function powerOn() {
Logger.log('teslaSmartKvmDriver.powerOn')
Logger.debug('teslaSmartKvmDriver.powerOn is a no-op')
await Promise.resolve()
}

const powerOff = async () => {
async function powerOff() {
Logger.log('teslaSmartKvmDriver.powerOff')
Logger.debug('teslaSmartKvmDriver.powerOff is a no-op')
await Promise.resolve()
Expand Down
8 changes: 4 additions & 4 deletions src/main/drivers/tesla-smart/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const teslaSmartMatrixDriver = defineDriver({
}
},
capabilities: kDeviceSupportsMultipleOutputs,
setup: async (uri) => {
setup: async function setup(uri) {
const sendCommand = async (command: Buffer) => {
const connection = await createCommandStream(uri, {
baudRate: 9600,
Expand All @@ -38,21 +38,21 @@ const teslaSmartMatrixDriver = defineDriver({

const toChannel = (n: number) => String(n).padStart(2, '0')

const activate = async (inputChannel: number, outputChannel: number) => {
async function activate(inputChannel: number, outputChannel: number) {
Logger.log(`teslaSmartMatrixDriver.activate(${inputChannel}, ${outputChannel})`)
const command = `MT00SW${toChannel(inputChannel)}${toChannel(outputChannel)}NT`
await sendCommand(Buffer.from(command, 'ascii'))

await Promise.resolve()
}

const powerOn = async () => {
async function powerOn() {
Logger.log('teslaSmartMatrixDriver.powerOn')
Logger.debug('teslaSmartMatrixDriver.powerOn is a no-op')
await Promise.resolve()
}

const powerOff = async () => {
async function powerOff() {
Logger.log('teslaSmartMatrixDriver.powerOff')
Logger.debug('teslaSmartMatrixDriver.powerOff is a no-op')
await Promise.resolve()
Expand Down
10 changes: 5 additions & 5 deletions src/main/drivers/tesla-smart/sdi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const teslaSmartSdiDriver = defineDriver({
}
},
capabilities: kDeviceHasNoExtraCapabilities,
setup: async (uri) => {
const sendCommand = async (command: Buffer) => {
setup: async function setup(uri) {
async function sendCommand(command: Buffer) {
const connection = await createCommandStream(uri, {
baudRate: 9600,
dataBits: 8,
Expand All @@ -36,18 +36,18 @@ const teslaSmartSdiDriver = defineDriver({
await connection.close()
}

const activate = async (inputChannel: number) => {
async function activate(inputChannel: number) {
Logger.log(`teslaSmartSdiDriver.activate(${inputChannel})`)
await sendCommand(Buffer.of(0xaa, 0xcc, 0x01, inputChannel))
}

const powerOn = async () => {
async function powerOn() {
Logger.log('teslaSmartSdiDriver.powerOn')
Logger.debug('teslaSmartSdiDriver.powerOn is a no-op')
await Promise.resolve()
}

const powerOff = async () => {
async function powerOff() {
Logger.log('teslaSmartSdiDriver.powerOff')
Logger.debug('teslaSmartSdiDriver.powerOff is a no-op')
await Promise.resolve()
Expand Down
6 changes: 3 additions & 3 deletions src/main/helpers/dbus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface KeyMap {
objpath: string
}

const useDbus = memo(() => {
const useDbus = memo(function useDbus() {
/**
* Targets bus.
*/
Expand Down Expand Up @@ -227,7 +227,7 @@ const useDbus = memo(() => {

/** Encodes the parameters based on a binding schema. */
function encodeParams(schema: SchemaType[], args: unknown[]) {
return schema.map((type, index) => {
return schema.map(function encodeParam(type, index) {
// NOTE: All logic here depends on TypeScript type
// checking to ensure all strings and data are
// correct, only the nullish check is done.
Expand Down Expand Up @@ -282,7 +282,7 @@ const useDbus = memo(() => {
member: string,
schema: Schema
): (...args: ArgsFromSchame<Schema>) => Promise<string> {
return async (...args) => {
return async function dbusCall(...args) {
const params = encodeParams(schema, args)

return await dbusSend(target, dest, path, ifname, member, ...params)
Expand Down
4 changes: 2 additions & 2 deletions src/main/helpers/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function createStream(stream: Duplex, implementation: StreamImplementation) {
}

async function createSocketStream(options: NetConnectOpts) {
const socket = await new Promise<Socket>((resolve, reject) => {
const socket = await new Promise<Socket>(function createSocketStreamInner(resolve, reject) {
try {
const stream = createConnection(options, () => {
resolve(stream)
Expand Down Expand Up @@ -107,7 +107,7 @@ async function createNetStream(target: string, options: NetStreamOptions) {
}

async function createPortStream(path: string, options: PortStreamOptions) {
const port = await new Promise<SerialPort>((resolve, reject) => {
const port = await new Promise<SerialPort>(function createPortStreamInner(resolve, reject) {
const stream = new SerialPort({ path, ...options }, (e) => {
if (e != null) reject(e)
else resolve(stream)
Expand Down
Loading

0 comments on commit 2f87e1d

Please sign in to comment.