Skip to content

Commit 1ed0913

Browse files
Julusianjstarpl
andauthored
feat: support ip streamdecks (#26)
Co-authored-by: Jan Starzak <[email protected]>
1 parent d71e374 commit 1ed0913

File tree

16 files changed

+717
-597
lines changed

16 files changed

+717
-597
lines changed

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.19
1+
22.15.1

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18.19
1+
22.15.1

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"devDependencies": {
4747
"@sofie-automation/code-standard-preset": "~2.5.2",
4848
"@types/jest": "^29.5.12",
49-
"@types/node": "^18.19.33",
49+
"@types/node": "^22.15.21",
5050
"@types/sprintf-js": "^1.1.4",
5151
"@types/underscore": "^1.11.15",
5252
"concurrently": "^8.2.2",
@@ -64,11 +64,8 @@
6464
"zip-a-folder": "^3.1.6"
6565
},
6666
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
67-
"packageManager": "yarn@4.2.2",
67+
"packageManager": "yarn@4.9.1",
6868
"dependencies": {
69-
"@yao-pkg/pkg": "6.2.0"
70-
},
71-
"resolutions": {
72-
"node-hid": "npm:@julusian/[email protected]"
69+
"@yao-pkg/pkg": "^6.5.1"
7370
}
7471
}

packages/input-gateway/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
]
5353
},
5454
"engines": {
55-
"node": "^18.19"
55+
"node": "^22.15"
5656
},
5757
"files": [
5858
"/dist",
@@ -74,8 +74,8 @@
7474
"dependencies": {
7575
"@esm2cjs/p-queue": "7.3.0",
7676
"@sofie-automation/input-manager": "0.3.1-alpha.3",
77-
"@sofie-automation/server-core-integration": "1.51.6",
78-
"@sofie-automation/shared-lib": "1.51.6",
77+
"@sofie-automation/server-core-integration": "1.52.0-nightly-release52-20250507-090800-3f13e1f.0",
78+
"@sofie-automation/shared-lib": "1.52.0-nightly-release52-20250507-090800-3f13e1f.0",
7979
"debug": "^4.3.4",
8080
"eventemitter3": "5.0.1",
8181
"p-all": "5.0.0",

packages/input-gateway/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { protectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
1+
import { protectString } from '@sofie-automation/server-core-integration'
22
import { Config } from './connector'
33

44
// CLI arguments / Environment variables --------------

packages/input-gateway/src/connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CoreHandler, CoreConfig } from './coreHandler'
22
import { Logger } from 'winston'
33
import { Process } from './process'
4-
import { PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
4+
import { PeripheralDeviceId } from '@sofie-automation/server-core-integration'
55

66
export interface Config {
77
process: ProcessConfig

packages/input-gateway/src/coreHandler.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@ import {
44
DDPConnectorOptions,
55
PeripheralDevicePubSub,
66
PeripheralDevicePubSubCollectionsNames,
7+
StatusCode,
8+
PeripheralDeviceId,
9+
PeripheralDeviceAPI,
10+
protectString,
11+
unprotectString,
12+
stringifyError,
13+
PeripheralDeviceCommand,
714
} from '@sofie-automation/server-core-integration'
8-
import { StatusCode } from '@sofie-automation/shared-lib/dist/lib/status'
15+
import { PeripheralDeviceCommandId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
916
import _ from 'underscore'
1017
import * as Winston from 'winston'
1118
import { DeviceConfig } from './inputManagerHandler'
1219
import fs from 'fs'
1320
import { INPUT_DEVICE_CONFIG } from './configManifest'
14-
import { PeripheralDeviceCommandId, PeripheralDeviceId } from '@sofie-automation/shared-lib/dist/core/model/Ids'
15-
import {
16-
PeripheralDeviceCategory,
17-
PeripheralDeviceSubType,
18-
PeripheralDeviceType,
19-
PERIPHERAL_SUBTYPE_PROCESS,
20-
} from '@sofie-automation/shared-lib/dist/peripheralDevice/peripheralDeviceAPI'
21-
import { protectString, unprotectString } from '@sofie-automation/shared-lib/dist/lib/protectedString'
22-
import { PeripheralDeviceCommand } from '@sofie-automation/shared-lib/dist/core/model/PeripheralDeviceCommand'
2321
import { Process } from './process'
24-
import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyError'
2522
import path from 'path'
2623

2724
export interface CoreConfig {
@@ -73,9 +70,7 @@ export class CoreHandler {
7370
this._coreConfig = config
7471
this._process = process
7572

76-
this.core = new CoreConnection(
77-
this.getCoreConnectionOptions('Input Gateway', 'InputGateway', PERIPHERAL_SUBTYPE_PROCESS)
78-
)
73+
this.core = new CoreConnection(this.getCoreConnectionOptions())
7974

8075
this.core.onConnected(() => {
8176
this.logger.info('Core Connected!')
@@ -104,10 +99,10 @@ export class CoreHandler {
10499
}
105100
await this.core.init(ddpConfig)
106101
this.logger.info('Core id: ' + this.core.deviceId)
107-
this._statusInitialized = true
108-
await this.updateCoreStatus()
109-
110102
await this.setupObserversAndSubscriptions()
103+
if (this._onConnected) this._onConnected()
104+
105+
this._statusInitialized = true
111106

112107
await this.updateCoreStatus()
113108
}
@@ -140,20 +135,20 @@ export class CoreHandler {
140135
await this.core.destroy()
141136
}
142137
}
143-
getCoreConnectionOptions(name: string, subDeviceId: string, subDeviceType?: PeripheralDeviceSubType): CoreOptions {
138+
private getCoreConnectionOptions(): CoreOptions {
144139
if (!this._deviceOptions.deviceId) {
145140
// this.logger.warn('DeviceId not set, using a temporary random id!')
146141
throw new Error('DeviceId is not set!')
147142
}
148143

149144
const options: CoreOptions = {
150-
deviceId: protectString(this._deviceOptions.deviceId + subDeviceId),
145+
deviceId: protectString(this._deviceOptions.deviceId + 'InputGateway'),
151146
deviceToken: this._deviceOptions.deviceToken,
152147

153-
deviceCategory: PeripheralDeviceCategory.TRIGGER_INPUT,
154-
deviceType: PeripheralDeviceType.INPUT,
148+
deviceCategory: PeripheralDeviceAPI.PeripheralDeviceCategory.TRIGGER_INPUT,
149+
deviceType: PeripheralDeviceAPI.PeripheralDeviceType.INPUT,
155150

156-
deviceName: name,
151+
deviceName: 'Input Gateway',
157152
watchDog: this._coreConfig ? this._coreConfig.watchdog : true,
158153

159154
configManifest: {
@@ -169,7 +164,6 @@ export class CoreHandler {
169164
options.deviceToken = 'unsecureToken'
170165
}
171166

172-
if (subDeviceType === PERIPHERAL_SUBTYPE_PROCESS) options.versions = this._getVersions()
173167
return options
174168
}
175169
onConnected(fcn: () => any): void {

packages/input-manager/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"generate-schema-types": "node ./scripts/schema-types.mjs"
6666
},
6767
"engines": {
68-
"node": "^18.19"
68+
"node": "^22.15"
6969
},
7070
"lint-staged": {
7171
"*.{css,json,md,scss}": [
@@ -91,7 +91,8 @@
9191
"production"
9292
],
9393
"dependencies": {
94-
"@elgato-stream-deck/node": "7.1.2",
94+
"@elgato-stream-deck/node": "7.3.0",
95+
"@elgato-stream-deck/tcp": "7.3.0",
9596
"@julusian/jpeg-turbo": "^2.1.0",
9697
"easymidi": "^3.1.0",
9798
"eventemitter3": "5.0.1",

packages/input-manager/src/devices/device.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface StatusChangeEventArgs {
3434
status: StatusCode
3535
}
3636

37-
type DeviceEvents = {
37+
export type DeviceEvents = {
3838
/** A notification that a trigger was triggered, call this.getNextTrigger() to get it when it's time to send it to Core. */
3939
trigger: []
4040
statusChange: [e: StatusChangeEventArgs]
@@ -60,11 +60,11 @@ export abstract class Device extends EventEmitter<DeviceEvents> {
6060
this.removeAllListeners()
6161
}
6262

63-
protected addTriggerEvent(triggerEvent: TriggerEvent): void {
63+
public addTriggerEvent(triggerEvent: TriggerEvent): void {
6464
this.#triggerEvents.push(triggerEvent)
6565
this.emit('trigger')
6666
}
67-
protected updateTriggerAnalog<T extends TriggerEventArguments>(
67+
public updateTriggerAnalog<T extends TriggerEventArguments>(
6868
triggerEvent: Omit<TriggerEvent, 'arguments'>,
6969
updateArgumnets: (triggerAnalog: T | undefined) => T
7070
): void {

packages/input-manager/src/generated/streamdeck.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface StreamDeckDeviceOptions {
99
path?: string
1010
serialNumber?: string
1111
index?: number
12+
ip?: string
13+
port?: number
1214
brightness?: number
1315
stylePresets?: {
1416
[k: string]: StreamdeckStylePreset

0 commit comments

Comments
 (0)