From 2c20d0b4fac9a44305fee85e349642be5951a328 Mon Sep 17 00:00:00 2001 From: Mint de Wit Date: Tue, 9 Jan 2024 07:42:01 +0100 Subject: [PATCH] chore: update lib + move enum --- .../__snapshots__/index.spec.ts.snap | 1 - .../src/integrations/obs.ts | 17 --------------- packages/timeline-state-resolver/package.json | 2 +- .../__snapshots__/index.spec.ts.snap | 1 - .../timeline-state-resolver/src/conductor.ts | 2 -- .../integrations/obs/__tests__/obs.spec.ts | 16 +++++++------- .../src/integrations/obs/diff.ts | 21 ++++++++++++++++++- yarn.lock | 10 ++++----- 8 files changed, 34 insertions(+), 36 deletions(-) diff --git a/packages/timeline-state-resolver-types/src/__tests__/__snapshots__/index.spec.ts.snap b/packages/timeline-state-resolver-types/src/__tests__/__snapshots__/index.spec.ts.snap index 518078a2b..c0ed1f5dd 100644 --- a/packages/timeline-state-resolver-types/src/__tests__/__snapshots__/index.spec.ts.snap +++ b/packages/timeline-state-resolver-types/src/__tests__/__snapshots__/index.spec.ts.snap @@ -37,7 +37,6 @@ exports[`index imports 1`] = ` "MappingVmixType", "MediaSourceType", "MultiOSCDeviceType", - "OBSRequest", "OSCDeviceType", "OSCValueType", "QuantelActions", diff --git a/packages/timeline-state-resolver-types/src/integrations/obs.ts b/packages/timeline-state-resolver-types/src/integrations/obs.ts index df9771e28..c6b54b1fa 100644 --- a/packages/timeline-state-resolver-types/src/integrations/obs.ts +++ b/packages/timeline-state-resolver-types/src/integrations/obs.ts @@ -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 diff --git a/packages/timeline-state-resolver/package.json b/packages/timeline-state-resolver/package.json index 2d6ffad61..6c0b70322 100644 --- a/packages/timeline-state-resolver/package.json +++ b/packages/timeline-state-resolver/package.json @@ -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", diff --git a/packages/timeline-state-resolver/src/__tests__/__snapshots__/index.spec.ts.snap b/packages/timeline-state-resolver/src/__tests__/__snapshots__/index.spec.ts.snap index bec6d592a..598994a32 100644 --- a/packages/timeline-state-resolver/src/__tests__/__snapshots__/index.spec.ts.snap +++ b/packages/timeline-state-resolver/src/__tests__/__snapshots__/index.spec.ts.snap @@ -47,7 +47,6 @@ exports[`index imports 1`] = ` "MappingVmixType", "MediaSourceType", "MultiOSCDeviceType", - "OBSRequest", "OSCDeviceType", "OSCValueType", "PREPARETIME", diff --git a/packages/timeline-state-resolver/src/conductor.ts b/packages/timeline-state-resolver/src/conductor.ts index 6441577d5..30fb4fa00 100644 --- a/packages/timeline-state-resolver/src/conductor.ts +++ b/packages/timeline-state-resolver/src/conductor.ts @@ -1575,13 +1575,11 @@ async function makeImmediatelyAbortable( const abortPromise = new Promise((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]) diff --git a/packages/timeline-state-resolver/src/integrations/obs/__tests__/obs.spec.ts b/packages/timeline-state-resolver/src/integrations/obs/__tests__/obs.spec.ts index 3c997f6ac..1d3fc9a4d 100644 --- a/packages/timeline-state-resolver/src/integrations/obs/__tests__/obs.spec.ts +++ b/packages/timeline-state-resolver/src/integrations/obs/__tests__/obs.spec.ts @@ -3,7 +3,6 @@ import { DeviceType, MappingObsType, Mappings, - OBSRequest, SomeMappingObs, Timeline, TimelineContentOBSAny, @@ -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() { @@ -186,7 +186,7 @@ describe('OBS Device', () => { [ { command: { - requestName: OBSRequest.SET_CURRENT_SCENE, + requestName: OBSRequestName.SET_CURRENT_SCENE, args: { sceneName: 'scene1', }, @@ -208,7 +208,7 @@ describe('OBS Device', () => { [ { command: { - requestName: OBSRequest.SET_CURRENT_TRANSITION, + requestName: OBSRequestName.SET_CURRENT_TRANSITION, args: { transitionName: 'transition1', }, @@ -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, @@ -275,7 +275,7 @@ describe('OBS Device', () => { [ { command: { - requestName: OBSRequest.SET_SOURCE_SETTINGS, + requestName: OBSRequestName.SET_SOURCE_SETTINGS, args: { inputName: 'input1', inputSettings: { @@ -306,7 +306,7 @@ describe('OBS Device', () => { [ { command: { - requestName: OBSRequest.SET_INPUT_VOLUME, + requestName: OBSRequestName.SET_INPUT_VOLUME, args: { inputName: 'input1', inputVolumeDb: 3, @@ -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', @@ -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, diff --git a/packages/timeline-state-resolver/src/integrations/obs/diff.ts b/packages/timeline-state-resolver/src/integrations/obs/diff.ts index c8fcd2895..bb4de5b40 100644 --- a/packages/timeline-state-resolver/src/integrations/obs/diff.ts +++ b/packages/timeline-state-resolver/src/integrations/obs/diff.ts @@ -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( @@ -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', +} diff --git a/yarn.lock b/yarn.lock index 961a5cf06..775088dc4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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 @@ -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