@@ -48,7 +48,7 @@ interface ObjectType {
48
48
}
49
49
50
50
interface OutputType {
51
- type : 'object ' ;
51
+ type : 'ObsWebSocket.Output ' ;
52
52
properties : Tree ;
53
53
optional : boolean ;
54
54
}
@@ -138,7 +138,7 @@ function parseApi(raw: RawComments): void {
138
138
if ( request . params ) {
139
139
const foo = unflattenAndResolveTypes ( request . params ) ;
140
140
argsString += '{' ;
141
- argsString += stringifyTypes ( foo , { terminator : ',' , finalTerminator : false } ) ;
141
+ argsString += stringifyTypes ( foo , { terminator : ',' , finalTerminator : false , name : request . name } ) ;
142
142
argsString += '}' ;
143
143
} else {
144
144
argsString += 'void' ;
@@ -147,7 +147,7 @@ function parseApi(raw: RawComments): void {
147
147
let returnTypeString = 'void' ;
148
148
if ( request . returns ) {
149
149
const foo = unflattenAndResolveTypes ( request . returns ) ;
150
- returnTypeString = `{messageId: string;status: "ok";${ stringifyTypes ( foo , { terminator : ';' , finalTerminator : false } ) } }` ;
150
+ returnTypeString = `{messageId: string;status: "ok";${ stringifyTypes ( foo , { terminator : ';' , finalTerminator : false , name : request . name } ) } }` ;
151
151
}
152
152
responseString += `${ returnTypeString } ;` ;
153
153
@@ -205,6 +205,13 @@ declare module 'obs-websocket-js' {
205
205
"ConnectionClosed": void;
206
206
"AuthenticationSuccess": void;
207
207
"AuthenticationFailure": void;
208
+ "error": {
209
+ error: any;
210
+ message: string;
211
+ type: string;
212
+ // This would require importing all of the WebSocket types so leaving out for now.
213
+ // target: WebSocket;
214
+ };
208
215
${ eventOverloads . join ( '\n\n ' ) }
209
216
}
210
217
@@ -314,11 +321,14 @@ function unflattenAndResolveTypes(inputItems: RawType[]): Tree {
314
321
315
322
const firstIntermediate = ( currentNode as any ) [ nodeName ] ;
316
323
if ( firstIntermediate . type === 'array' ) {
317
- firstIntermediate . items = {
318
- type : 'object' ,
319
- properties : { } ,
320
- optional : false
321
- } ;
324
+ // Not sure if needed at all, but was here before and causing issues, so added a check.
325
+ if ( ! firstIntermediate . items . properties ) {
326
+ firstIntermediate . items = {
327
+ type : 'object' ,
328
+ properties : { } ,
329
+ optional : true // Matches the "array<object>" case in "resolveType".
330
+ } ;
331
+ }
322
332
currentNode = firstIntermediate . items . properties ;
323
333
} else {
324
334
currentNode = firstIntermediate . properties ;
@@ -395,7 +405,7 @@ function resolveType(inType: string): AnyType {
395
405
return {
396
406
type : 'array' ,
397
407
items : {
398
- type : 'object ' ,
408
+ type : 'ObsWebSocket.Output ' ,
399
409
properties : { } ,
400
410
optional : true
401
411
} ,
@@ -452,14 +462,14 @@ function resolveType(inType: string): AnyType {
452
462
type : 'ObsWebSocket.OBSStats' ,
453
463
optional : isOptional
454
464
} ;
455
- case 'string | object' :
456
- case 'object' :
465
+ case 'output' :
457
466
return {
458
- type : 'object ' ,
467
+ type : 'ObsWebSocket.Output ' ,
459
468
properties : { } ,
460
469
optional : isOptional
461
470
} ;
462
- case 'output' :
471
+ case 'string | object' :
472
+ case 'object' :
463
473
return {
464
474
type : 'object' ,
465
475
properties : { } ,
@@ -470,7 +480,7 @@ function resolveType(inType: string): AnyType {
470
480
}
471
481
}
472
482
473
- function stringifyTypes ( inputTypes : Tree , { terminator = ';' , finalTerminator = true , includePrefix = true } = { } ) : string {
483
+ function stringifyTypes ( inputTypes : Tree , { terminator = ';' , finalTerminator = true , includePrefix = true , name = '' } = { } ) : string {
474
484
let returnString = '' ;
475
485
Object . entries ( inputTypes ) . forEach ( ( [ key , typeDef ] ) => {
476
486
if ( includePrefix ) {
@@ -485,7 +495,12 @@ function stringifyTypes(inputTypes: Tree, {terminator = ';', finalTerminator = t
485
495
if ( typeDef . items ) {
486
496
if ( typeDef . items . type === 'object' ) {
487
497
if ( Object . keys ( typeDef . items . properties ) . length > 0 ) {
488
- returnString += `${ stringifyTypes ( typeDef . items . properties , { includePrefix : false , terminator : '' } ) } []` ;
498
+ returnString += `{${ stringifyTypes ( typeDef . items . properties , { name} ) } ` ;
499
+ // Allows other arbitrary properties inside of "ExecuteBatch".
500
+ if ( name === 'ExecuteBatch' ) {
501
+ returnString += '[k: string]: any;' ;
502
+ }
503
+ returnString += '}[]' ;
489
504
} else {
490
505
returnString += 'Array<{[k: string]: any}>' ;
491
506
}
0 commit comments