@@ -5,11 +5,13 @@ import path from "path";
55interface PluginConfigSource {
66 name : string ;
77 module : string ;
8- file : string ;
98 uri : string ;
109 config : string ;
11- interfaces ?: string [ ] ;
12- types ?: string [ ] ;
10+ files : {
11+ name : string ;
12+ interfaces ?: string [ ] ;
13+ types ?: string [ ] ;
14+ } [ ] ;
1315 externals ?: {
1416 type : string ;
1517 module : string ;
@@ -20,19 +22,29 @@ const plugins: PluginConfigSource[] = [
2022 {
2123 name : "Ipfs" ,
2224 module : "@web3api/ipfs-plugin-js" ,
23- file : "build/index.d.ts" ,
2425 uri : "w3://ens/ipfs.web3api.eth" ,
2526 config : "IpfsConfig" ,
26- interfaces : [ "IpfsConfig" ]
27+ files : [ {
28+ name : "build/index.d.ts" ,
29+ interfaces : [ "IpfsConfig" ]
30+ } ]
2731 } ,
2832 {
2933 name : "Ethereum" ,
3034 module : "@web3api/ethereum-plugin-js" ,
31- file : "build/index.d.ts" ,
3235 uri : "w3://ens/ethereum.web3api.eth" ,
3336 config : "EthereumConfig" ,
34- interfaces : [ "ConnectionConfig" , "ConnectionConfigs" ] ,
35- types : [ "EthereumConfig" , "EthereumProvider" , "EthereumSigner" , "AccountIndex" , "Address" ] ,
37+ files : [
38+ {
39+ name : "build/index.d.ts" ,
40+ types : [ "EthereumConfig" ] ,
41+ } ,
42+ {
43+ name : "build/Connection.d.ts" ,
44+ interfaces : [ "ConnectionConfig" , "ConnectionConfigs" ] ,
45+ types : [ "EthereumProvider" , "EthereumSigner" , "AccountIndex" , "Address" ] ,
46+ } ,
47+ ] ,
3648 externals : [
3749 {
3850 type : "Signer" ,
@@ -51,11 +63,13 @@ const plugins: PluginConfigSource[] = [
5163 {
5264 name : "Ens" ,
5365 module : "@web3api/ens-plugin-js" ,
54- file : "build/index.d.ts" ,
5566 uri : "w3://ens/ens.web3api.eth" ,
5667 config : "EnsConfig" ,
57- interfaces : [ "EnsConfig" , "Addresses" ] ,
58- types : [ "Address" ]
68+ files : [ {
69+ name : "build/index.d.ts" ,
70+ interfaces : [ "EnsConfig" , "Addresses" ] ,
71+ types : [ "Address" ]
72+ } ]
5973 }
6074] ;
6175
@@ -71,20 +85,25 @@ function main(): void {
7185 for ( const plugin of plugins ) {
7286 let output = header ;
7387
74- output += `\n\n/// Types generated from ${ plugin . file } `
88+ output += `\n\n/// Types generated from ${ plugin . module } build files:\n/// ${
89+ plugin . files . map ( ( { name } ) => name ) . join ( ', ' )
90+ } `
7591
7692 const project = new TsProject ( ) ;
77- const filePath = require . resolve ( path . join ( plugin . module , plugin . file ) ) ;
78- const sourceFile = project . addSourceFileAtPath ( filePath ) ;
7993
80- for ( const pluginInterface of plugin . interfaces || [ ] ) {
81- const int = sourceFile . getInterfaceOrThrow ( pluginInterface ) ;
82- output += `\n\n${ int . print ( ) . replace ( / / g, " " ) } ` ;
83- }
94+ for ( const file of plugin . files ) {
95+ const filePath = require . resolve ( path . join ( plugin . module , file . name ) ) ;
96+ const sourceFile = project . addSourceFileAtPath ( filePath ) ;
97+
98+ for ( const pluginInterface of file . interfaces || [ ] ) {
99+ const int = sourceFile . getInterfaceOrThrow ( pluginInterface ) ;
100+ output += `\n\n${ int . print ( ) . replace ( / / g, " " ) } ` ;
101+ }
84102
85- for ( const pluginType of plugin . types || [ ] ) {
86- const typ = sourceFile . getTypeAliasOrThrow ( pluginType ) ;
87- output += `\n\n${ typ . print ( ) . replace ( "declare " , "" ) } ` ;
103+ for ( const pluginType of file . types || [ ] ) {
104+ const typ = sourceFile . getTypeAliasOrThrow ( pluginType ) ;
105+ output += `\n\n${ typ . print ( ) . replace ( "declare " , "" ) } ` ;
106+ }
88107 }
89108
90109 for ( const pluginExternal of plugin . externals || [ ] ) {
0 commit comments