Skip to content

Commit 1a20a48

Browse files
committed
Update typings for obs-websocket 5.0
1 parent 3340572 commit 1a20a48

File tree

2 files changed

+53
-18
lines changed

2 files changed

+53
-18
lines changed

scripts/build-types.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {writeFileSync} from 'node:fs';
44
import {join} from 'node:path';
55
import got from 'got';
66
import {ESLint} from 'eslint';
7+
import {JsonObject} from 'type-fest';
78

89
// protoco.json typing
910
interface GeneratedProtocol {
@@ -76,14 +77,11 @@ const headers = {
7677
Authorization: process.env.GH_TOKEN ? `token ${process.env.GH_TOKEN}` : undefined,
7778
};
7879

79-
/* Uncomment once released
8080
const {body: release} = await got('https://api.github.com/repos/obsproject/obs-websocket/releases/latest', {
8181
headers,
82-
responseType: 'json'
82+
responseType: 'json',
8383
});
84-
const commit = release.tag_name;
85-
*/
86-
const commit = 'master';
84+
const commit = (release as JsonObject).tag_name as string;
8785

8886
const {body: protocol} = await got<GeneratedProtocol>(`https://raw.githubusercontent.com/obsproject/obs-websocket/${commit}/docs/generated/protocol.json`, {
8987
headers,
@@ -254,7 +252,7 @@ const linted = await linter.lintText(source, {
254252

255253
if (linted[0].messages.length > 0) {
256254
const formatter = await linter.loadFormatter('stylish');
257-
process.stderr.write(formatter.format(linted));
255+
process.stderr.write(await formatter.format(linted));
258256
process.exitCode = 1;
259257
}
260258

@@ -548,7 +546,7 @@ function stringifyTypes(inputTypes: AnyType): string {
548546
const subtype = stringifyTypes(inputTypes.items);
549547

550548
if (subtype === 'JsonObject') {
551-
return 'JsonArray';
549+
return 'JsonObject[]';
552550
}
553551

554552
return `Array<${subtype}>`;

src/types.ts

+48-11
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export interface OBSEventTypes {
355355
/**
356356
* Array of filter objects
357357
*/
358-
filters: JsonArray;
358+
filters: JsonObject[];
359359
};
360360
SourceFilterCreated: {
361361
/**
@@ -548,7 +548,7 @@ export interface OBSEventTypes {
548548
/**
549549
* Array of active inputs with their associated volume levels
550550
*/
551-
inputs: JsonArray;
551+
inputs: JsonObject[];
552552
};
553553
MediaInputPlaybackStarted: {
554554
/**
@@ -658,7 +658,7 @@ export interface OBSEventTypes {
658658
/**
659659
* Array of scene item objects
660660
*/
661-
sceneItems: JsonArray;
661+
sceneItems: JsonObject[];
662662
};
663663
SceneItemEnableStateChanged: {
664664
/**
@@ -758,7 +758,7 @@ export interface OBSEventTypes {
758758
/**
759759
* Updated array of scenes
760760
*/
761-
scenes: JsonArray;
761+
scenes: JsonObject[];
762762
};
763763
CurrentSceneTransitionChanged: {
764764
/**
@@ -1053,6 +1053,20 @@ export interface OBSRequestTypes {
10531053
*/
10541054
overlay?: boolean;
10551055
};
1056+
SetSourceFilterEnabled: {
1057+
/**
1058+
* Name of the source the filter is on
1059+
*/
1060+
sourceName: string;
1061+
/**
1062+
* Name of the filter
1063+
*/
1064+
filterName: string;
1065+
/**
1066+
* New enable state of the filter
1067+
*/
1068+
filterEnabled: boolean;
1069+
};
10561070
GetVersion: never;
10571071
GetStats: never;
10581072
BroadcastCustomEvent: {
@@ -1436,6 +1450,13 @@ export interface OBSRequestTypes {
14361450
* Name of the source to find
14371451
*/
14381452
sourceName: string;
1453+
/**
1454+
* Number of matches to skip during search. >= 0 means first forward. -1 means last (top) item
1455+
*
1456+
* @restrictions >= -1
1457+
* @defaultValue 0
1458+
*/
1459+
searchOffset?: number;
14391460
};
14401461
CreateSceneItem: {
14411462
/**
@@ -1840,6 +1861,7 @@ export interface OBSRequestTypes {
18401861
*/
18411862
inputName: string;
18421863
};
1864+
GetMonitorList: never;
18431865
}
18441866

18451867
export interface OBSResponseTypes {
@@ -1934,7 +1956,7 @@ export interface OBSResponseTypes {
19341956
/**
19351957
* Array of filters
19361958
*/
1937-
filters: JsonArray;
1959+
filters: JsonObject[];
19381960
};
19391961
GetSourceFilterDefaultSettings: {
19401962
/**
@@ -1965,6 +1987,7 @@ export interface OBSResponseTypes {
19651987
};
19661988
SetSourceFilterIndex: undefined;
19671989
SetSourceFilterSettings: undefined;
1990+
SetSourceFilterEnabled: undefined;
19681991
GetVersion: {
19691992
/**
19701993
* Current OBS Studio version
@@ -1986,6 +2009,14 @@ export interface OBSResponseTypes {
19862009
* Image formats available in `GetSourceScreenshot` and `SaveSourceScreenshot` requests.
19872010
*/
19882011
supportedImageFormats: string[];
2012+
/**
2013+
* Name of the platform. Usually `windows`, `macos`, or `ubuntu` (linux flavor). Not guaranteed to be any of those
2014+
*/
2015+
platform: string;
2016+
/**
2017+
* Description of the platform, like `Windows 10 (10.0)`
2018+
*/
2019+
platformDescription: string;
19892020
};
19902021
GetStats: {
19912022
/**
@@ -2053,7 +2084,7 @@ export interface OBSResponseTypes {
20532084
/**
20542085
* Array of inputs
20552086
*/
2056-
inputs: JsonArray;
2087+
inputs: JsonObject[];
20572088
};
20582089
GetInputKindList: {
20592090
/**
@@ -2168,7 +2199,7 @@ export interface OBSResponseTypes {
21682199
/**
21692200
* Array of items in the list property
21702201
*/
2171-
propertyItems: JsonArray;
2202+
propertyItems: JsonObject[];
21722203
};
21732204
PressInputPropertiesButton: undefined;
21742205
GetMediaInputStatus: {
@@ -2255,13 +2286,13 @@ export interface OBSResponseTypes {
22552286
/**
22562287
* Array of scene items in the scene
22572288
*/
2258-
sceneItems: JsonArray;
2289+
sceneItems: JsonObject[];
22592290
};
22602291
GetGroupItemList: {
22612292
/**
22622293
* Array of scene items in the group
22632294
*/
2264-
sceneItems: JsonArray;
2295+
sceneItems: JsonObject[];
22652296
};
22662297
GetSceneItemId: {
22672298
/**
@@ -2329,7 +2360,7 @@ export interface OBSResponseTypes {
23292360
/**
23302361
* Array of scenes
23312362
*/
2332-
scenes: JsonArray;
2363+
scenes: JsonObject[];
23332364
};
23342365
GetGroupList: {
23352366
/**
@@ -2444,7 +2475,7 @@ export interface OBSResponseTypes {
24442475
/**
24452476
* Array of transitions
24462477
*/
2447-
transitions: JsonArray;
2478+
transitions: JsonObject[];
24482479
};
24492480
GetCurrentSceneTransition: {
24502481
/**
@@ -2493,4 +2524,10 @@ export interface OBSResponseTypes {
24932524
OpenInputPropertiesDialog: undefined;
24942525
OpenInputFiltersDialog: undefined;
24952526
OpenInputInteractDialog: undefined;
2527+
GetMonitorList: {
2528+
/**
2529+
* a list of detected monitors with some information
2530+
*/
2531+
monitors: JsonObject[];
2532+
};
24962533
}

0 commit comments

Comments
 (0)