Skip to content

Commit c781523

Browse files
committed
Migrate Crypto and handle property typed
1 parent 2cea3f6 commit c781523

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

inputfiles/overridingTypes.jsonc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -327,21 +327,6 @@
327327
},
328328
"interfaces": {
329329
"interface": {
330-
"CryptoKey": {
331-
"properties": {
332-
"property": {
333-
"algorithm": {
334-
"type": "KeyAlgorithm"
335-
},
336-
"usages": {
337-
"type": "sequence",
338-
"subtype": {
339-
"type": "KeyUsage"
340-
}
341-
}
342-
}
343-
}
344-
},
345330
"GPUPipelineError": {
346331
// Web IDL optional argument can be followed by a required argument, but not in TS
347332
// TODO: Maybe do this in the emitter?

inputfiles/patches/crypto.kdl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@ dictionary CryptoKeyPair {
33
member privateKey required=#true
44
member publicKey required=#true
55
}
6+
7+
interface CryptoKey {
8+
property algorithm type=KeyAlgorithm
9+
property usages {
10+
type sequence {
11+
type KeyUsage
12+
}
13+
}
14+
}

src/build/patches.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,22 @@ function handleEvent(child: Node): Event {
232232
* @param child The child node to handle.
233233
*/
234234
function handleProperty(child: Node): Partial<Property> {
235+
let typeNode: Node | undefined;
236+
for (const c of child.children) {
237+
if (c.name === "type") {
238+
typeNode = c;
239+
break;
240+
}
241+
}
242+
235243
return {
236244
name: string(child.values[0]),
237245
...optionalMember("exposed", "string", child.properties?.exposed),
238246
...optionalMember("optional", "boolean", child.properties?.optional),
239247
...optionalMember("overrideType", "string", child.properties?.overrideType),
240-
...optionalMember("type", "string", child.properties?.type),
248+
...(typeNode
249+
? handleTyped(typeNode)
250+
: optionalMember("type", "string", child.properties?.type)),
241251
...optionalMember("readonly", "boolean", child.properties?.readonly),
242252
...optionalMember("deprecated", "boolean", child.properties?.deprecated),
243253
};

0 commit comments

Comments
 (0)