Skip to content

Commit

Permalink
chore: convert remaining services to ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Sep 16, 2024
1 parent 3cbde95 commit 76014bb
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 588 deletions.
2 changes: 1 addition & 1 deletion companion/lib/Core/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { VariablesController } from '../Variables/Controller.js'
import type { InternalController } from '../Internal/Controller.js'
import type { DataUserConfig } from '../Data/UserConfig.js'
import type { SurfaceController } from '../Surface/Controller.js'
import type ServiceController from '../Service/Controller.js'
import type { ServiceController } from '../Service/Controller.js'
import type { UIHandler } from '../UI/Handler.js'
import type { InstanceController } from '../Instance/Controller.js'
import type { GraphicsController } from '../Graphics/Controller.js'
Expand Down
2 changes: 1 addition & 1 deletion companion/lib/Registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DataUserConfig } from './Data/UserConfig.js'
import { InstanceController } from './Instance/Controller.js'
import { InternalController } from './Internal/Controller.js'
import { PageController } from './Page/Controller.js'
import ServiceController from './Service/Controller.js'
import { ServiceController } from './Service/Controller.js'
import { SurfaceController } from './Surface/Controller.js'
import { UIController } from './UI/Controller.js'
import { UIHandler } from './UI/Handler.js'
Expand Down
4 changes: 2 additions & 2 deletions companion/lib/Resources/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { SurfaceRotation } from '../Surface/Util.js'
import type { Registry } from '../Registry.js'
import type { ButtonStyleProperties } from '@companion-app/shared/Model/StyleModel.js'
import type { CompanionInputFieldBaseExtended, EncodeIsVisible2 } from '@companion-app/shared/Model/Options.js'
import type { CompanionInputFieldBase } from '@companion-module/base'
import type { CompanionAlignment, CompanionInputFieldBase } from '@companion-module/base'

/** @deprecated remove this re-export */
export { ControlLocation } from '@companion-app/shared/Model/Common.js'
Expand Down Expand Up @@ -408,7 +408,7 @@ export type VerticalAlignment = 'top' | 'bottom' | 'center'
export function ParseAlignment(
alignment: string,
validate?: boolean
): [horizontal: HorizontalAlignment, vertical: VerticalAlignment, full: string] {
): [horizontal: HorizontalAlignment, vertical: VerticalAlignment, full: CompanionAlignment] {
const [halignRaw, valignRaw] = alignment.toLowerCase().split(':', 2)

let halign: 'left' | 'right' | 'center'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { ServiceArtnet } from './Artnet.js'
import { ServiceBonjourDiscovery } from './BonjourDiscovery.js'
import ServiceElgatoPlugin from './ElgatoPlugin.js'
import ServiceEmberPlus from './EmberPlus.js'
import { ServiceElgatoPlugin } from './ElgatoPlugin.js'
import { ServiceEmberPlus } from './EmberPlus.js'
import { ServiceHttpApi } from './HttpApi.js'
import ServiceHttps from './Https.js'
import { ServiceHttps } from './Https.js'
import { ServiceOscListener } from './OscListener.js'
import { ServiceOscSender } from './OscSender.js'
import { ServiceRosstalk } from './Rosstalk.js'
import ServiceSatellite from './Satellite.js'
import { ServiceSatellite } from './Satellite.js'
import { ServiceSharedUdpManager } from './SharedUdpManager.js'
import { ServiceSurfaceDiscovery } from './SurfaceDiscovery.js'
import { ServiceTcp } from './Tcp.js'
import { ServiceUdp } from './Udp.js'
import { ServiceVideohubPanel } from './VideohubPanel.js'
import type { Registry } from '../Registry.js'
import type { ClientSocket } from '../UI/Handler.js'

/**
* Class that manages all of the services.
Expand All @@ -34,11 +36,24 @@ import { ServiceVideohubPanel } from './VideohubPanel.js'
* develop commercial activities involving the Companion software without
* disclosing the source code of your own applications.
*/
class ServiceController {
/**
* @param {import('../Registry.js').Registry} registry - the application core
*/
constructor(registry) {
export class ServiceController {
readonly httpApi: ServiceHttpApi
readonly https: ServiceHttps
readonly oscSender: ServiceOscSender
readonly oscListener: ServiceOscListener
readonly tcp: ServiceTcp
readonly udp: ServiceUdp
readonly emberplus: ServiceEmberPlus
readonly artnet: ServiceArtnet
readonly rosstalk: ServiceRosstalk
readonly satellite: ServiceSatellite
readonly elgatoPlugin: ServiceElgatoPlugin
readonly videohubPanel: ServiceVideohubPanel
readonly bonjourDiscovery: ServiceBonjourDiscovery
readonly sharedUdpManager: ServiceSharedUdpManager
readonly surfaceDiscovery: ServiceSurfaceDiscovery

constructor(registry: Registry) {
this.httpApi = new ServiceHttpApi(registry, registry.ui.express)
this.https = new ServiceHttps(registry, registry.ui.express)
this.oscSender = new ServiceOscSender(registry)
Expand All @@ -58,11 +73,10 @@ class ServiceController {

/**
* Update a key/value pair from the user config
* @param {string} key - the key that changed
* @param {(boolean|number|string)} value - the new value
* @access public
* @param key - the key that changed
* @param value - the new value
*/
updateUserConfig(key, value) {
updateUserConfig(key: string, value: boolean | number | string): void {
this.artnet.updateUserConfig(key, value)
this.bonjourDiscovery.updateUserConfig(key, value)
this.elgatoPlugin.updateUserConfig(key, value)
Expand All @@ -80,13 +94,9 @@ class ServiceController {

/**
* Setup a new socket client's events
* @param {import('../UI/Handler.js').ClientSocket} client - the client socket
* @access public
*/
clientConnect(client) {
clientConnect(client: ClientSocket): void {
this.bonjourDiscovery.clientConnect(client)
this.surfaceDiscovery.clientConnect(client)
}
}

export default ServiceController
Loading

0 comments on commit 76014bb

Please sign in to comment.