@@ -68,6 +68,7 @@ function parseKDL(kdlText: string): DeepPartial<WebIdl> {
68
68
const nodes = output ! ;
69
69
const enums : Record < string , Enum > = { } ;
70
70
const mixin : Record < string , DeepPartial < Interface > > = { } ;
71
+ const interfaces : Record < string , DeepPartial < Interface > > = { } ;
71
72
72
73
for ( const node of nodes ) {
73
74
const name = string ( node . values [ 0 ] ) ;
@@ -76,14 +77,21 @@ function parseKDL(kdlText: string): DeepPartial<WebIdl> {
76
77
enums [ name ] = handleEnum ( node ) ;
77
78
break ;
78
79
case "interface-mixin" :
79
- mixin [ name ] = handleMixin ( node ) ;
80
+ mixin [ name ] = handleMixinandInterfaces ( node , "mixin" ) ;
81
+ break ;
82
+ case "interface" :
83
+ interfaces [ name ] = handleMixinandInterfaces ( node , "interface" ) ;
80
84
break ;
81
85
default :
82
86
throw new Error ( `Unknown node name: ${ node . name } ` ) ;
83
87
}
84
88
}
85
89
86
- return { enums : { enum : enums } , mixins : { mixin } } ;
90
+ return {
91
+ enums : { enum : enums } ,
92
+ mixins : { mixin } ,
93
+ interfaces : { interface : interfaces } ,
94
+ } ;
87
95
}
88
96
89
97
/**
@@ -118,7 +126,10 @@ function handleEnum(node: Node): Enum {
118
126
* @param node The mixin node to handle.
119
127
* @param mixins The record of mixins to update.
120
128
*/
121
- function handleMixin ( node : Node ) : DeepPartial < Interface > {
129
+ function handleMixinandInterfaces (
130
+ node : Node ,
131
+ type : "mixin" | "interface" ,
132
+ ) : DeepPartial < Interface > {
122
133
const name = node . values [ 0 ] ;
123
134
124
135
const event : Event [ ] = [ ] ;
@@ -145,12 +156,22 @@ function handleMixin(node: Node): DeepPartial<Interface> {
145
156
}
146
157
}
147
158
159
+ const interfaceObject = type === "interface" && {
160
+ ...optionalMember ( "exposed" , "string" , node . properties ?. exposed ) ,
161
+ ...optionalMember ( "deprecated" , "string" , node . properties ?. deprecated ) ,
162
+ ...optionalMember (
163
+ "noInterfaceObject" ,
164
+ "boolean" ,
165
+ node . properties ?. noInterfaceObject ,
166
+ ) ,
167
+ } ;
148
168
return {
149
169
name,
150
170
events : { event } ,
151
171
properties : { property } ,
152
172
methods : { method } ,
153
173
...optionalMember ( "extends" , "string" , node . properties ?. extends ) ,
174
+ ...interfaceObject ,
154
175
} as DeepPartial < Interface > ;
155
176
}
156
177
0 commit comments