1
- import _ from 'lodash' ;
2
- import * as utils from './utils' ;
3
- import d from 'debug' ;
4
1
import {
5
2
EventParameterDocumentation ,
6
3
DetailedObjectType ,
@@ -9,6 +6,11 @@ import {
9
6
DocumentationTag ,
10
7
} from '@electron/docs-parser' ;
11
8
import chalk from 'chalk' ;
9
+ import d from 'debug' ;
10
+ import _ from 'lodash' ;
11
+
12
+ import * as utils from './utils.js' ;
13
+
12
14
const debug = d ( 'dynamic-param' ) ;
13
15
14
16
type ParamInterface = EventParameterDocumentation &
@@ -37,7 +39,7 @@ const polite = (s: string): string => {
37
39
const ignoreDescriptions = < T extends EventParameterDocumentation > (
38
40
props : T [ ] ,
39
41
) : Pick < T , Exclude < keyof T , 'description' > > [ ] =>
40
- _ . map ( props , p => {
42
+ _ . map ( props , ( p ) => {
41
43
const { description, ...toReturn } = p ;
42
44
43
45
return toReturn ;
@@ -48,7 +50,7 @@ const unsetDescriptions = (o: any): any => {
48
50
if ( noDescriptionCache . has ( o ) ) return noDescriptionCache . get ( o ) ;
49
51
if ( typeof o !== 'object' || ! o ) return o ;
50
52
const val = Array . isArray ( o )
51
- ? o . map ( item => unsetDescriptions ( item ) )
53
+ ? o . map ( ( item ) => unsetDescriptions ( item ) )
52
54
: Object . keys ( o ) . reduce ( ( accum : any , key : string ) => {
53
55
if ( key === 'description' ) return accum ;
54
56
accum [ key ] = unsetDescriptions ( o [ key ] ) ;
@@ -149,7 +151,7 @@ const flushParamInterfaces = (
149
151
. sort ( ( a , b ) =>
150
152
paramInterfacesToDeclare [ a ] . tName ! . localeCompare ( paramInterfacesToDeclare [ b ] . tName ! ) ,
151
153
)
152
- . forEach ( paramKey => {
154
+ . forEach ( ( paramKey ) => {
153
155
if ( paramKey === 'Event' ) {
154
156
throw 'Unexpected dynamic Event type, should be routed through the Event handler' ;
155
157
}
@@ -181,7 +183,7 @@ const flushParamInterfaces = (
181
183
) ;
182
184
183
185
param . properties = param . properties || [ ] ;
184
- param . properties . forEach ( paramProperty => {
186
+ param . properties . forEach ( ( paramProperty ) => {
185
187
if ( paramProperty . description ) {
186
188
utils . extendArray (
187
189
paramAPI ,
@@ -192,7 +194,7 @@ const flushParamInterfaces = (
192
194
if ( ! Array . isArray ( paramProperty . type ) && paramProperty . type . toLowerCase ( ) === 'object' ) {
193
195
let argType =
194
196
( paramProperty as any ) . __type || _ . upperFirst ( _ . camelCase ( paramProperty . name ) ) ;
195
- if ( API . some ( a => a . name === argType ) ) {
197
+ if ( API . some ( ( a ) => a . name === argType ) ) {
196
198
paramProperty . type = argType ;
197
199
debug (
198
200
chalk . red (
@@ -210,7 +212,7 @@ const flushParamInterfaces = (
210
212
}
211
213
212
214
if ( Array . isArray ( paramProperty . type ) ) {
213
- paramProperty . type = paramProperty . type . map ( paramPropertyType => {
215
+ paramProperty . type = paramProperty . type . map ( ( paramPropertyType ) => {
214
216
const functionProp = paramPropertyType as DetailedFunctionType ;
215
217
if ( paramPropertyType . type === 'Function' && functionProp . parameters ) {
216
218
return {
@@ -229,7 +231,7 @@ const flushParamInterfaces = (
229
231
) {
230
232
let argType =
231
233
( paramProperty as any ) . __type || _ . upperFirst ( _ . camelCase ( paramProperty . name ) ) ;
232
- if ( API . some ( a => a . name === argType ) ) {
234
+ if ( API . some ( ( a ) => a . name === argType ) ) {
233
235
paramPropertyType . type = argType ;
234
236
debug (
235
237
chalk . red (
@@ -293,3 +295,5 @@ export class DynamicParamInterfaces {
293
295
static createParamInterface = createParamInterface ;
294
296
static flushParamInterfaces = flushParamInterfaces ;
295
297
}
298
+
299
+ utils . setParamInterfaces ( DynamicParamInterfaces ) ;
0 commit comments