1- import _ from 'lodash' ;
2- import * as utils from './utils' ;
3- import d from 'debug' ;
41import {
52 EventParameterDocumentation ,
63 DetailedObjectType ,
@@ -9,6 +6,11 @@ import {
96 DocumentationTag ,
107} from '@electron/docs-parser' ;
118import chalk from 'chalk' ;
9+ import d from 'debug' ;
10+ import _ from 'lodash' ;
11+
12+ import * as utils from './utils.js' ;
13+
1214const debug = d ( 'dynamic-param' ) ;
1315
1416type ParamInterface = EventParameterDocumentation &
@@ -37,7 +39,7 @@ const polite = (s: string): string => {
3739const ignoreDescriptions = < T extends EventParameterDocumentation > (
3840 props : T [ ] ,
3941) : Pick < T , Exclude < keyof T , 'description' > > [ ] =>
40- _ . map ( props , p => {
42+ _ . map ( props , ( p ) => {
4143 const { description, ...toReturn } = p ;
4244
4345 return toReturn ;
@@ -48,7 +50,7 @@ const unsetDescriptions = (o: any): any => {
4850 if ( noDescriptionCache . has ( o ) ) return noDescriptionCache . get ( o ) ;
4951 if ( typeof o !== 'object' || ! o ) return o ;
5052 const val = Array . isArray ( o )
51- ? o . map ( item => unsetDescriptions ( item ) )
53+ ? o . map ( ( item ) => unsetDescriptions ( item ) )
5254 : Object . keys ( o ) . reduce ( ( accum : any , key : string ) => {
5355 if ( key === 'description' ) return accum ;
5456 accum [ key ] = unsetDescriptions ( o [ key ] ) ;
@@ -149,7 +151,7 @@ const flushParamInterfaces = (
149151 . sort ( ( a , b ) =>
150152 paramInterfacesToDeclare [ a ] . tName ! . localeCompare ( paramInterfacesToDeclare [ b ] . tName ! ) ,
151153 )
152- . forEach ( paramKey => {
154+ . forEach ( ( paramKey ) => {
153155 if ( paramKey === 'Event' ) {
154156 throw 'Unexpected dynamic Event type, should be routed through the Event handler' ;
155157 }
@@ -181,7 +183,7 @@ const flushParamInterfaces = (
181183 ) ;
182184
183185 param . properties = param . properties || [ ] ;
184- param . properties . forEach ( paramProperty => {
186+ param . properties . forEach ( ( paramProperty ) => {
185187 if ( paramProperty . description ) {
186188 utils . extendArray (
187189 paramAPI ,
@@ -192,7 +194,7 @@ const flushParamInterfaces = (
192194 if ( ! Array . isArray ( paramProperty . type ) && paramProperty . type . toLowerCase ( ) === 'object' ) {
193195 let argType =
194196 ( paramProperty as any ) . __type || _ . upperFirst ( _ . camelCase ( paramProperty . name ) ) ;
195- if ( API . some ( a => a . name === argType ) ) {
197+ if ( API . some ( ( a ) => a . name === argType ) ) {
196198 paramProperty . type = argType ;
197199 debug (
198200 chalk . red (
@@ -210,7 +212,7 @@ const flushParamInterfaces = (
210212 }
211213
212214 if ( Array . isArray ( paramProperty . type ) ) {
213- paramProperty . type = paramProperty . type . map ( paramPropertyType => {
215+ paramProperty . type = paramProperty . type . map ( ( paramPropertyType ) => {
214216 const functionProp = paramPropertyType as DetailedFunctionType ;
215217 if ( paramPropertyType . type === 'Function' && functionProp . parameters ) {
216218 return {
@@ -229,7 +231,7 @@ const flushParamInterfaces = (
229231 ) {
230232 let argType =
231233 ( paramProperty as any ) . __type || _ . upperFirst ( _ . camelCase ( paramProperty . name ) ) ;
232- if ( API . some ( a => a . name === argType ) ) {
234+ if ( API . some ( ( a ) => a . name === argType ) ) {
233235 paramPropertyType . type = argType ;
234236 debug (
235237 chalk . red (
@@ -293,3 +295,5 @@ export class DynamicParamInterfaces {
293295 static createParamInterface = createParamInterface ;
294296 static flushParamInterfaces = flushParamInterfaces ;
295297}
298+
299+ utils . setParamInterfaces ( DynamicParamInterfaces ) ;
0 commit comments