@@ -8,7 +8,8 @@ module.exports = (API, addToOutput) => {
8
8
const CommonInterface = [ 'interface CommonInterface {' ]
9
9
const MainInterface = [ 'interface MainInterface extends CommonInterface {' ]
10
10
const RendererInterface = [ 'interface RendererInterface extends CommonInterface {' ]
11
- const ElectronMainAndRendererInterface = [ 'interface AllElectron {' ]
11
+ const ElectronMainAndRendererInterface = [ 'interface AllElectron extends MainInterface, RendererInterface {}' ]
12
+ const constDeclarations = [ ]
12
13
const EMRI = { }
13
14
14
15
const classify = ( moduleName ) => {
@@ -28,11 +29,20 @@ module.exports = (API, addToOutput) => {
28
29
if ( module . name === 'process' ) return
29
30
let TargetInterface
30
31
const isClass = module . type === 'Class' || API . some ( ( tModule , tIndex ) => index !== tIndex && tModule . name . toLowerCase ( ) === module . name . toLowerCase ( ) )
31
- const moduleString = ` ${ classify ( module . name ) } : ${ isClass ? 'typeof ' : '' } Electron. ${ _ . upperFirst ( module . name ) } `
32
+ const moduleString = ` ${ classify ( module . name ) } : ${ isClass ? 'typeof ' : '' } ${ _ . upperFirst ( module . name ) } `
32
33
if ( ! module . process ) {
33
34
// We must be a structure or something
34
35
return
35
36
}
37
+ if ( ! isClass || module . name != classify ( module . name ) ) {
38
+ if ( isClass ) {
39
+ constDeclarations . push (
40
+ `type ${ classify ( module . name ) } = ${ _ . upperFirst ( module . name ) } ;` ,
41
+ `const ${ classify ( module . name ) } : typeof ${ _ . upperFirst ( module . name ) } ;` )
42
+ } else {
43
+ constDeclarations . push ( `const ${ classify ( module . name ) } : ${ _ . upperFirst ( module . name ) } ;` )
44
+ }
45
+ }
36
46
if ( module . process . main && module . process . renderer ) {
37
47
TargetInterface = CommonInterface
38
48
} else if ( module . process . main ) {
@@ -46,7 +56,6 @@ module.exports = (API, addToOutput) => {
46
56
if ( TargetInterface ) {
47
57
debug ( classify ( module . name ) . toLowerCase ( ) , EMRI [ classify ( module . name ) . toLowerCase ( ) ] )
48
58
if ( ! EMRI [ classify ( module . name ) . toLowerCase ( ) ] ) {
49
- ElectronMainAndRendererInterface . push ( moduleString )
50
59
TargetInterface . push ( moduleString )
51
60
}
52
61
EMRI [ classify ( module . name ) . toLowerCase ( ) ] = true
@@ -56,11 +65,11 @@ module.exports = (API, addToOutput) => {
56
65
CommonInterface . push ( '}' )
57
66
MainInterface . push ( '}' )
58
67
RendererInterface . push ( '}' )
59
- ElectronMainAndRendererInterface . push ( '}' )
60
68
61
69
addToOutput ( [ '' ] )
62
70
addToOutput ( CommonInterface , ';' )
63
71
addToOutput ( MainInterface , ';' )
64
72
addToOutput ( RendererInterface , ';' )
65
73
addToOutput ( ElectronMainAndRendererInterface , ';' )
74
+ addToOutput ( constDeclarations )
66
75
}
0 commit comments