Skip to content

Commit

Permalink
chore: update lib + move enum
Browse files Browse the repository at this point in the history
  • Loading branch information
mint-dewit committed Jan 9, 2024
1 parent bcd87a6 commit 2c20d0b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ exports[`index imports 1`] = `
"MappingVmixType",
"MediaSourceType",
"MultiOSCDeviceType",
"OBSRequest",
"OSCDeviceType",
"OSCValueType",
"QuantelActions",
Expand Down
17 changes: 0 additions & 17 deletions packages/timeline-state-resolver-types/src/integrations/obs.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
import { DeviceType } from '..'

export enum OBSRequest {
SET_CURRENT_SCENE = 'SetCurrentProgramScene',
SET_PREVIEW_SCENE = 'SetCurrentPreviewScene',
SET_CURRENT_TRANSITION = 'SetCurrentSceneTransition',
START_RECORDING = 'StartRecord',
STOP_RECORDING = 'StopRecord',
START_STREAMING = 'StartStream',
STOP_STREAMING = 'StopStream',
SET_SCENE_ITEM_ENABLED = 'SetSceneItemEnabled',
SET_SCENE_ITEM_TRANSFORM = 'SetSceneItemTransform',
SET_MUTE = 'SetInputMute',
SET_SOURCE_SETTINGS = 'SetInputSettings',
SET_INPUT_VOLUME = 'SetInputVolume',
TRIGGER_MEDIA_INPUT_ACTION = 'TriggerMediaInputAction',
SET_MEDIA_INPUT_CURSOR = 'SetMediaInputCursor',
}

export type TimelineContentOBSAny =
| TimelineContentOBSCurrentScene
| TimelineContentOBSCurrentTransition
Expand Down
2 changes: 1 addition & 1 deletion packages/timeline-state-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"hpagent": "^1.2.0",
"hyperdeck-connection": "2.0.0-nightly-master-20231205-105655-157a483.0",
"klona": "^2.0.6",
"obs-websocket-js": "git+https://github.com/mint-dewit/obs-websocket-js.git#dd214862314df7f1617a50aaf97ac2e30c1d45f4",
"obs-websocket-js": "^5.0.4",
"osc": "^2.4.4",
"p-all": "^3.0.0",
"p-queue": "^6.6.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ exports[`index imports 1`] = `
"MappingVmixType",
"MediaSourceType",
"MultiOSCDeviceType",
"OBSRequest",
"OSCDeviceType",
"OSCValueType",
"PREPARETIME",
Expand Down
2 changes: 0 additions & 2 deletions packages/timeline-state-resolver/src/conductor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,13 +1575,11 @@ async function makeImmediatelyAbortable<T>(
const abortPromise = new Promise<void>((resolve, reject) => {
resolveAbortPromise = () => {
resolve()
// @ts-expect-error removeEventListener is missing in @types/node until 16.x
abortSignal.removeEventListener('abort', rejectPromise)
}
const rejectPromise = () => {
reject(new AbortError())
}
// @ts-expect-error addEventListener is missing in @types/node until 16.x
abortSignal.addEventListener('abort', rejectPromise, { once: true })
})
return Promise.race([mainPromise, abortPromise])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
DeviceType,
MappingObsType,
Mappings,
OBSRequest,
SomeMappingObs,
Timeline,
TimelineContentOBSAny,
Expand All @@ -13,6 +12,7 @@ import {
import { OBSCommandWithContext, OBSDevice } from '..'
import { getDeviceContext } from '../../__tests__/testlib'
import { getDefaultState, OBSDeviceState } from '../state'
import { OBSRequestName } from '../diff'
import '../../../__mocks__/ws'

async function getInitialisedObsDevice() {
Expand Down Expand Up @@ -186,7 +186,7 @@ describe('OBS Device', () => {
[
{
command: {
requestName: OBSRequest.SET_CURRENT_SCENE,
requestName: OBSRequestName.SET_CURRENT_SCENE,
args: {
sceneName: 'scene1',
},
Expand All @@ -208,7 +208,7 @@ describe('OBS Device', () => {
[
{
command: {
requestName: OBSRequest.SET_CURRENT_TRANSITION,
requestName: OBSRequestName.SET_CURRENT_TRANSITION,
args: {
transitionName: 'transition1',
},
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('OBS Device', () => {
[
// {
// command: {
// requestName: OBSRequest.SET_SCENE_ITEM_TRANSFORM,
// requestName: OBSRequestName.SET_SCENE_ITEM_TRANSFORM,
// args: {
// sceneName: 'scene1',
// sceneItemId: 1,
Expand Down Expand Up @@ -275,7 +275,7 @@ describe('OBS Device', () => {
[
{
command: {
requestName: OBSRequest.SET_SOURCE_SETTINGS,
requestName: OBSRequestName.SET_SOURCE_SETTINGS,
args: {
inputName: 'input1',
inputSettings: {
Expand Down Expand Up @@ -306,7 +306,7 @@ describe('OBS Device', () => {
[
{
command: {
requestName: OBSRequest.SET_INPUT_VOLUME,
requestName: OBSRequestName.SET_INPUT_VOLUME,
args: {
inputName: 'input1',
inputVolumeDb: 3,
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('OBS Device', () => {
[
{
command: {
requestName: OBSRequest.TRIGGER_MEDIA_INPUT_ACTION,
requestName: OBSRequestName.TRIGGER_MEDIA_INPUT_ACTION,
args: {
inputName: 'input1',
mediaAction: 'OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PLAY',
Expand All @@ -349,7 +349,7 @@ describe('OBS Device', () => {
},
{
command: {
requestName: OBSRequest.SET_MEDIA_INPUT_CURSOR,
requestName: OBSRequestName.SET_MEDIA_INPUT_CURSOR,
args: {
inputName: 'input1',
mediaCursor: 1000 - 200 + 80,
Expand Down
21 changes: 20 additions & 1 deletion packages/timeline-state-resolver/src/integrations/obs/diff.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _ = require('underscore')
import { OBSCommandWithContext, OBSCommandWithContextTyped } from '.'
import { OBSDeviceState, OBSScene, OBSSceneItem, OBSInputState } from './state'
import { OBSRequest as OBSRequestName } from 'timeline-state-resolver-types'
import { literal } from '../../lib'

export function diffStates(
Expand Down Expand Up @@ -357,3 +356,23 @@ function resolveInputSettings(oldState: OBSDeviceState, newState: OBSDeviceState

return commands
}

/**
* Enum derived from keyof OBSRequestTypes in obs-websocket-js
*/
export enum OBSRequestName {
SET_CURRENT_SCENE = 'SetCurrentProgramScene',
SET_PREVIEW_SCENE = 'SetCurrentPreviewScene',
SET_CURRENT_TRANSITION = 'SetCurrentSceneTransition',
START_RECORDING = 'StartRecord',
STOP_RECORDING = 'StopRecord',
START_STREAMING = 'StartStream',
STOP_STREAMING = 'StopStream',
SET_SCENE_ITEM_ENABLED = 'SetSceneItemEnabled',
SET_SCENE_ITEM_TRANSFORM = 'SetSceneItemTransform',
SET_MUTE = 'SetInputMute',
SET_SOURCE_SETTINGS = 'SetInputSettings',
SET_INPUT_VOLUME = 'SetInputVolume',
TRIGGER_MEDIA_INPUT_ACTION = 'TriggerMediaInputAction',
SET_MEDIA_INPUT_CURSOR = 'SetMediaInputCursor',
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8706,9 +8706,9 @@ asn1@evs-broadcast/node-asn1:
languageName: node
linkType: hard

"obs-websocket-js@git+https://github.com/mint-dewit/obs-websocket-js.git#dd214862314df7f1617a50aaf97ac2e30c1d45f4":
version: 5.0.3
resolution: "obs-websocket-js@https://github.com/mint-dewit/obs-websocket-js.git#commit=dd214862314df7f1617a50aaf97ac2e30c1d45f4"
"obs-websocket-js@npm:^5.0.4":
version: 5.0.4
resolution: "obs-websocket-js@npm:5.0.4"
dependencies:
"@msgpack/msgpack": ^2.7.1
crypto-js: ^4.1.1
Expand All @@ -8717,7 +8717,7 @@ asn1@evs-broadcast/node-asn1:
isomorphic-ws: ^5.0.0
type-fest: ^3.11.0
ws: ^8.13.0
checksum: 4756ad48c1e666bf05f07a68a9068ce9cf35cb7499af9dfb148f4f0d012cf6fd42b2ded7207edd6a92139965de223273ef23615b9cc1f4b1baecded93a4a1344
checksum: 5fab50747624abebe18a186f1cacd3f2ba72fe2a642f43a05babcc4b8da6342f4bcce31e8aacd7a895debf17a88eaff2222e423c9c55d2ba6b116ebb05cc4c2e
languageName: node
linkType: hard

Expand Down Expand Up @@ -11101,7 +11101,7 @@ asn1@evs-broadcast/node-asn1:
json-schema-ref-parser: ^9.0.9
json-schema-to-typescript: ^10.1.5
klona: ^2.0.6
obs-websocket-js: "git+https://github.com/mint-dewit/obs-websocket-js.git#dd214862314df7f1617a50aaf97ac2e30c1d45f4"
obs-websocket-js: ^5.0.4
osc: ^2.4.4
p-all: ^3.0.0
p-queue: ^6.6.2
Expand Down

0 comments on commit 2c20d0b

Please sign in to comment.